use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testIRQ.
@Test
public void testIRQ() {
Program program = new Program().with(LDA_I, 1, LDA_I, 2, LDA_I, 3);
memory.setBlock(0, program.getProgramAsByteArray());
// ->PCH
memory.setByteAt(0xFFFE, 0x01);
// ->PCL
memory.setByteAt(0xFFFF, 0x10);
Registers registers = processor.getRegisters();
// Sample register values
registers.setRegister(Registers.Register.STATUS_FLAGS, 0b00000000);
processor.step(1);
processor.irq();
assertEquals(0xFC, registers.getRegister(Registers.Register.STACK_POINTER_HI));
// PC (on Stack)
assertEquals(0x02, memory.getByte(0x1FE));
assertEquals(0x00, memory.getByte(0x1FF));
// Status (on stack) with B set
assertTrue((Registers.Flag.IRQ_DISABLE.getPlaceValue() & memory.getByte(0x1FD)) == Registers.Flag.IRQ_DISABLE.getPlaceValue());
// PC is set to value of [FFFE:FFFF]
assertEquals(memory.getByte(0xFFFE), registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
assertEquals(memory.getByte(0xFFFF), registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testLSR.
@Test
public void testLSR() {
Program program = new Program().with(LDA_I, 0b01011010, LSR_A);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(2);
assertEquals(program.getLength(), registers.getPC());
assertEquals("Expected 00101101, got " + Integer.toBinaryString(processor.getRegisters().getRegister(Registers.Register.ACCUMULATOR)), 0b00101101, processor.getRegisters().getRegister(Registers.Register.ACCUMULATOR));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testNOP.
@Test
public void testNOP() {
Program program = new Program().with(NOP, NOP, NOP);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
for (int i = 1; i <= program.getLength(); i++) {
processor.step();
assertEquals(i, registers.getPC());
}
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testTXA.
@Test
public void testTXA() {
Program program = new Program().with(LDX_I, 0x0D, TXA);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(2);
assertEquals(program.getLength(), registers.getPC());
assertEquals(0x0D, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0x0D, registers.getRegister(Registers.Register.ACCUMULATOR));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testZAtXIndexSTA.
@Test
public void testZAtXIndexSTA() {
Program program = new Program().with(LDA_I, 0xAA, LDX_I, 0x1, STA_Z_IX, 0x20);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step(3);
Registers registers = processor.getRegisters();
assertEquals(program.getLength(), registers.getPC());
assertEquals(0xAA, memory.getByte(0x21));
}
Aggregations