Search in sources :

Example 41 with Program

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

the class Mos6502Test method testPHA.

@Test
public void testPHA() {
    Program program = new Program().with(LDA_I, 0x99, PHA);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step();
    assert (processor.getRegisters().getRegister(Registers.Register.STACK_POINTER_HI) == 0xFF);
    processor.step();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xFE, processor.getRegisters().getRegister(Registers.Register.STACK_POINTER_HI));
    assertEquals(0x99, memory.getByte(0x01FF));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 42 with Program

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

the class Mos6502Test method testSTXAbsolute.

@Test
public void testSTXAbsolute() {
    Program program = new Program().with(LDX_I, 0xAA, STX_ABS, 0x02, 0x20);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(2);
    Registers registers = processor.getRegisters();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xAA, memory.getByte(0x220));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 43 with Program

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

the class Mos6502Test method testROR.

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

Example 44 with Program

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

the class Mos6502Test method testINY.

@Test
public void testINY() {
    Program program = new Program().with(LDY_I, 0x01, INY);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step();
    assert (processor.getRegisters().getRegister(Registers.Register.Y_INDEX) == 1);
    processor.step();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(2, processor.getRegisters().getRegister(Registers.Register.Y_INDEX));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 45 with Program

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

the class Mos6502Test method testEOR.

@Test
public void testEOR() {
    Program program = new Program().with(LDA_I, 0b00010101, EOR_I, 0b00000101);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(2);
    Registers registers = processor.getRegisters();
    assertEquals(0b00010000, 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