use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testIntegration.
@Test
public void testIntegration() {
final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$14 ADC #$5 STA $20");
Program program = compiler.compileProgram();
final int[] programByte = program.getProgramAsByteArray();
Memory memory = new SimpleMemory();
Mos6502 processor = new Mos6502(memory);
processor.reset();
memory.setBlock(0, programByte);
processor.step(3);
Registers registers = processor.getRegisters();
assertEquals(0x19, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0x19, memory.getByte(0x20));
assertEquals(programByte.length, registers.getPC());
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Properties method testInvalidImmediateADC.
@Property(trials = 100)
public void testInvalidImmediateADC(@When(satisfies = "#_ < 0 || #_ > 255") int value) {
Program program = new Program().with(LDA_I, value);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step();
Registers registers = processor.getRegisters();
assertNotEquals(value, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(program.getLength(), registers.getPC());
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testADC.
@Test
public void testADC() {
Program program = new Program().with(CLC, LDA_I, 0x1, ADC_I, 0x1);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step(3);
Registers registers = processor.getRegisters();
// Accumulator is 0x2 == (0x1 + 0x1) == (mem[0x1] + mem[0x3])
assertEquals(0x2, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(program.getLength(), registers.getPC());
assertEquals(0x0, 0);
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testBEQ.
@Test
public void testBEQ() {
Program program = new Program().with(LDA_I, 0x0, BEQ, 0x4, LDA_I, 0x99, LDX_I, 0x98, LDY_I, 0x97);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(3);
assertEquals(program.getLength(), registers.getPC());
assertEquals(0x0, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0x0, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0x97, registers.getRegister(Registers.Register.Y_INDEX));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testCPX.
@Test
public void testCPX() {
Program program = new Program().with(LDX_I, 0x10, CPX_I, 0x10);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(2);
assertEquals(program.getLength(), registers.getPC());
assertEquals(0x10, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(true, registers.getFlag(Registers.Flag.ZERO));
assertEquals(false, registers.getFlag(Registers.Flag.NEGATIVE));
assertEquals(true, registers.getFlag(Registers.Flag.CARRY));
}
Aggregations