Search in sources :

Example 51 with Program

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

the class Mos6502Test method testIRQ.

@Test
public void testIRQ() {
    Program program = new Program().with(LDA_I, 1, LDA_I, 2, LDA_I, 3);
    memory.setBlock(0, program.getProgramAsByteArray());
    // ->PCH
    memory.setByteAt(0xFFFE, 0x01);
    // ->PCL
    memory.setByteAt(0xFFFF, 0x10);
    Registers registers = processor.getRegisters();
    // Sample register values
    registers.setRegister(Registers.Register.STATUS_FLAGS, 0b00000000);
    processor.step(1);
    processor.irq();
    assertEquals(0xFC, registers.getRegister(Registers.Register.STACK_POINTER_HI));
    // PC (on Stack)
    assertEquals(0x02, memory.getByte(0x1FE));
    assertEquals(0x00, memory.getByte(0x1FF));
    // Status (on stack) with B set
    assertTrue((Registers.Flag.IRQ_DISABLE.getPlaceValue() & memory.getByte(0x1FD)) == Registers.Flag.IRQ_DISABLE.getPlaceValue());
    // PC is set to value of [FFFE:FFFF]
    assertEquals(memory.getByte(0xFFFE), registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
    assertEquals(memory.getByte(0xFFFF), registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 52 with Program

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

the class Mos6502Test method testLSR.

@Test
public void testLSR() {
    Program program = new Program().with(LDA_I, 0b01011010, LSR_A);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    processor.step(2);
    assertEquals(program.getLength(), registers.getPC());
    assertEquals("Expected 00101101, got " + Integer.toBinaryString(processor.getRegisters().getRegister(Registers.Register.ACCUMULATOR)), 0b00101101, processor.getRegisters().getRegister(Registers.Register.ACCUMULATOR));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 53 with Program

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

the class Mos6502Test method testNOP.

@Test
public void testNOP() {
    Program program = new Program().with(NOP, NOP, NOP);
    memory.setBlock(0, program.getProgramAsByteArray());
    Registers registers = processor.getRegisters();
    for (int i = 1; i <= program.getLength(); i++) {
        processor.step();
        assertEquals(i, registers.getPC());
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 54 with Program

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

the class Mos6502Test method testTXA.

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

Example 55 with Program

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

the class Mos6502Test method testZAtXIndexSTA.

@Test
public void testZAtXIndexSTA() {
    Program program = new Program().with(LDA_I, 0xAA, LDX_I, 0x1, STA_Z_IX, 0x20);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(3);
    Registers registers = processor.getRegisters();
    assertEquals(program.getLength(), registers.getPC());
    assertEquals(0xAA, memory.getByte(0x21));
}
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