use of com.rox.emu.mem.SimpleMemory in project emuRox by rossdrew.
the class Mos6502CompilerTest method testAbsoluteAddressing.
@Test
public void testAbsoluteAddressing() {
final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$1C STA $100 INC $100");
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);
assertEquals(0x1D, memory.getByte(0x100));
}
use of com.rox.emu.mem.SimpleMemory 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.mem.SimpleMemory in project emuRox by rossdrew.
the class Mos6502Test method setUp.
@Before
public void setUp() {
memory = new SimpleMemory();
memory.setByteAt(0xFFFC, 0);
memory.setByteAt(0xFFFD, 0);
processor = new Mos6502(memory);
processor.reset();
}
use of com.rox.emu.mem.SimpleMemory in project emuRox by rossdrew.
the class Mos6502Test method testStartup.
@Test
public void testStartup() {
memory = new SimpleMemory();
memory.setByteAt(0xFFFC, 0x1);
memory.setByteAt(0xFFFD, 0x1);
processor = new Mos6502(memory);
processor.reset();
Registers registers = processor.getRegisters();
// Status flags reset
assertEquals(0x34, registers.getRegister(Registers.Register.STATUS_FLAGS));
// PC Set to location pointed to by mem[FFFC:FFFD]
assertEquals(0x1, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
// ...
assertEquals(0x1, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
// Stack Pointer at top of stack
assertEquals(0xFF, registers.getRegister(Registers.Register.STACK_POINTER_HI));
// All cleared
assertEquals(0, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0, registers.getRegister(Registers.Register.Y_INDEX));
}
use of com.rox.emu.mem.SimpleMemory in project emuRox by rossdrew.
the class Mos6502Theories method setUp.
@Before
public void setUp() {
memory = new SimpleMemory();
memory.setByteAt(0x0, 0xFFFC);
memory.setByteAt(0x0, 0xFFFD);
processor = new Mos6502(memory);
processor.reset();
}
Aggregations