Search in sources :

Example 36 with Program

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

the class Mos6502Test method testInvalidOpCode.

@Test
public void testInvalidOpCode() {
    Program program = new Program().with(231);
    memory.setBlock(0, program.getProgramAsByteArray());
    try {
        processor.step();
        fail("Invalid opCode exception expected!");
    } catch (UnknownOpCodeException e) {
        assertEquals("231", e.getOpCode());
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Test(org.junit.Test)

Example 37 with Program

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

the class Mos6502Test method testOR.

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

Example 38 with Program

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

the class Mos6502Test method testBVS.

@Test
public void testBVS() {
    Program program = new Program().with(LDA_I, 0x50, ADC_I, 0x50, BVS, 0x4, LDA_I, 0x99, LDX_I, 0x98, LDY_I, 0x97);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(4);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xA0, 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 39 with Program

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

the class Mos6502Test method testTSX.

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

Example 40 with Program

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

the class Mos6502Test method testJSR.

@Test
public void testJSR() {
    Program program = new Program().with(JSR, 0x02, 0x0F);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(1);
    assertEquals(0x020F, registers.getPC());
    // Jump address
    assertEquals(0x02, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
    assertEquals(0x0F, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
    // Return address
    assertEquals(0x00, memory.getByte(0x1FF));
    assertEquals(0x03, memory.getByte(0x1FE));
}
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