Search in sources :

Example 71 with Program

use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.

the class Mos6502Test method testINC.

@Test
public void testINC() {
    Program program = new Program().with(LDA_I, 1, STA_Z, 0x20, INC_Z, 0x20);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(3);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(2, memory.getByte(0x20));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 72 with Program

use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.

the class Mos6502Test method testTXS.

@Test
public void testTXS() {
    Program program = new Program().with(LDX_I, 0xAA, TXS);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(2);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xAA, registers.getRegister(Registers.Register.X_INDEX));
    assertEquals(0xAA, registers.getRegister(Registers.Register.STACK_POINTER_HI));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 73 with Program

use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.

the class Mos6502Test method testSBC.

@Test
public void testSBC() {
    Program program = new Program().with(SEC, LDA_I, 0xA, SBC_I, 0x5);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(3);
    Registers registers = processor.getRegisters();
    assertEquals(0x5, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(program.getLength(), registers.getPC());
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 74 with Program

use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.

the class Mos6502Test method testCLI.

@Test
public void testCLI() {
    Program program = new Program().with(CLI);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    // Load status, push to stack then clear it and pull it from stack
    registers.setRegister(Registers.Register.STATUS_FLAGS, 0b00000100);
    processor.step(1);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0b00000000, registers.getRegister(Registers.Register.STATUS_FLAGS));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 75 with Program

use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.

the class Mos6502Test method testAND.

@Test
public void testAND() {
    Program program = new Program().with(LDA_I, 0b00000101, AND_I, 0b00000101);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(2);
    Registers registers = processor.getRegisters();
    assertEquals(0b00000101, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0x0, 0);
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Aggregations

Program (com.rox.emu.processor.mos6502.util.Program)100 Test (org.junit.Test)86 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)32 Property (com.pholser.junit.quickcheck.Property)12 UnknownOpCodeException (com.rox.emu.UnknownOpCodeException)6 Memory (com.rox.emu.mem.Memory)2 SimpleMemory (com.rox.emu.mem.SimpleMemory)2 UnknownTokenException (com.rox.emu.UnknownTokenException)1 RoxWord (com.rox.emu.env.RoxWord)1 AddressingMode (com.rox.emu.processor.mos6502.op.AddressingMode)1 OpCode (com.rox.emu.processor.mos6502.op.OpCode)1 StringTokenizer (java.util.StringTokenizer)1