Search in sources :

Example 1 with SimpleMemory

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));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 2 with SimpleMemory

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());
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) SimpleMemory(com.rox.emu.mem.SimpleMemory) Memory(com.rox.emu.mem.Memory) SimpleMemory(com.rox.emu.mem.SimpleMemory) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 3 with SimpleMemory

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();
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Before(org.junit.Before)

Example 4 with SimpleMemory

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));
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Test(org.junit.Test)

Example 5 with SimpleMemory

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();
}
Also used : SimpleMemory(com.rox.emu.mem.SimpleMemory) Before(org.junit.Before)

Aggregations

SimpleMemory (com.rox.emu.mem.SimpleMemory)13 Memory (com.rox.emu.mem.Memory)5 Test (org.junit.Test)4 Property (com.pholser.junit.quickcheck.Property)3 Before (org.junit.Before)3 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)2 Program (com.rox.emu.processor.mos6502.util.Program)2 Mos6502 (com.rox.emu.processor.mos6502.Mos6502)1 Registers6502 (com.rox.emu.processor.mos6502.dbg.ui.component.Registers6502)1 Theory (org.junit.experimental.theories.Theory)1