Search in sources :

Example 31 with Program

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

the class Mos6502Test method testADCWithCarry.

@Test
public void testADCWithCarry() {
    Program program = new Program().with(SEC, LDA_I, 0x1, ADC_I, 0x1);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step(3);
    Registers registers = processor.getRegisters();
    assertEquals(0x3, 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 32 with Program

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

the class Mos6502Test method testReset.

@Test
public void testReset() {
    Program program = new Program().with(LDA_I, 0xAA, LDX_I, 0xBB, LDX_I, 0xCC);
    memory.setBlock(0, program.getProgramAsByteArray());
    memory.setByteAt(0xFFFC, 0x0);
    memory.setByteAt(0xFFFD, 0x0);
    Registers registers = processor.getRegisters();
    registers.setRegister(Registers.Register.STATUS_FLAGS, 0x99);
    registers.setRegister(Registers.Register.PROGRAM_COUNTER_LOW, 0x99);
    registers.setRegister(Registers.Register.PROGRAM_COUNTER_HI, 0x99);
    registers.setRegister(Registers.Register.STACK_POINTER_HI, 0x99);
    registers.setRegister(Registers.Register.ACCUMULATOR, 0x99);
    registers.setRegister(Registers.Register.X_INDEX, 0x99);
    registers.setRegister(Registers.Register.Y_INDEX, 0x99);
    processor.step(3);
    processor.reset();
    assertEquals(0x34, registers.getRegister(Registers.Register.STATUS_FLAGS));
    assertEquals(0x0, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
    assertEquals(0x0, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
    assertEquals(0xFF, registers.getRegister(Registers.Register.STACK_POINTER_HI));
    assertEquals(0, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0, registers.getRegister(Registers.Register.X_INDEX));
    assertEquals(0, registers.getRegister(Registers.Register.Y_INDEX));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 33 with Program

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

the class Mos6502Test method testDEY.

@Test
public void testDEY() {
    Program program = new Program().with(LDY_I, 0x01, DEY);
    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(0, processor.getRegisters().getRegister(Registers.Register.Y_INDEX));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Test(org.junit.Test)

Example 34 with Program

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

the class Mos6502Test method testASL.

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

Example 35 with Program

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

the class Mos6502Test method testLDA.

@Test
public void testLDA() {
    Program program = new Program().with(LDA_I, 0xAA);
    memory.setBlock(0, program.getProgramAsByteArray());
    processor.step();
    Registers registers = processor.getRegisters();
    assertEquals(0xAA, registers.getRegister(Registers.Register.ACCUMULATOR));
    assertEquals(0x0, 0);
    assertEquals(program.getLength(), registers.getPC());
}
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