Search in sources :

Example 21 with Program

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

the class Mos6502Test method testTYA.

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

Example 22 with Program

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

the class Mos6502Test method testTAX.

@Test
public void testTAX() {
    Program program = new Program().with(LDA_I, 0x0F, TAX);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(2);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0x0F, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0x0F, registers.getRegister(Registers.Register.X_INDEX));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 23 with Program

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

the class Mos6502Test method testLDY.

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

Example 24 with Program

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

the class Mos6502Test method testPLA.

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

Example 25 with Program

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

the class Mos6502Test method testBCC.

@Test
public void testBCC() {
    Program program = new Program().with(CLC, BCC, 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));
}
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