Search in sources :

Example 76 with Program

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

the class Mos6502Test method testCLV.

@Test
public void testCLV() {
    Program program = new Program().with(LDA_I, 0x50, ADC_I, 0x50, CLV);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(2);
    assert (registers.getFlag(Registers.Flag.OVERFLOW));
    processor.step();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(false, registers.getFlag(Registers.Flag.OVERFLOW));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 77 with Program

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

the class Mos6502Test method testAccumulatorSTA.

@Test
public void testAccumulatorSTA() {
    Program program = new Program().with(LDA_I, 0xAA, STA_ABS, 0xFF, 0x01);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(2);
    Registers registers = processor.getRegisters();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xAA, memory.getByte(0xFF01));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 78 with Program

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

the class Mos6502Test method testSEC.

@Test
public void testSEC() {
    Program program = new Program().with(SEC);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(true, registers.getFlag(Registers.Flag.CARRY));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 79 with Program

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

the class Mos6502Test method testBNE.

@Test
public void testBNE() {
    Program program = new Program().with(LDA_I, 0x1, BNE, 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(0x1, 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)

Example 80 with Program

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

the class Mos6502Test method testCMP.

@Test
public void testCMP() {
    Program program = new Program().with(LDA_I, 0x10, CMP_I, 0x10);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(2);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0x10, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(true, registers.getFlag(Registers.Flag.ZERO));
    assertEquals(false, registers.getFlag(Registers.Flag.NEGATIVE));
    assertEquals(true, registers.getFlag(Registers.Flag.CARRY));
}
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