Search in sources :

Example 96 with Program

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

the class Mos6502CompilerTest method testDoubleDigitArgument.

@Test
public void testDoubleDigitArgument() {
    OpCode.streamOf(AddressingMode.ZERO_PAGE).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + "AB");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", new int[] { opcode.getByteValue(), 0xAB }, bytes);
    });
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 97 with Program

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

the class Mos6502CompilerTest method testQuadrupleDigitArgument.

@Test
public void testQuadrupleDigitArgument() {
    OpCode.streamOf(AddressingMode.ABSOLUTE).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + "ABCD");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", new int[] { opcode.getByteValue(), 0xAB, 0xCD }, bytes);
    });
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 98 with Program

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

the class Mos6502CompilerTest method testChainedTwoByteInstruction.

@Test
public void testChainedTwoByteInstruction() {
    final Mos6502Compiler compiler = new Mos6502Compiler("LDA " + IMMEDIATE_VALUE_PREFIX + "47 SEC");
    final Program program = compiler.compileProgram();
    int[] bytes = program.getProgramAsByteArray();
    int[] expected = new int[] { OpCode.LDA_I.getByteValue(), 0x47, OpCode.SEC.getByteValue() };
    assertArrayEquals("Expected: " + Arrays.toString(expected) + ", Got: " + Arrays.toString(bytes), expected, bytes);
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 99 with Program

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

the class Mos6502CompilerTest method testImpliedInstructions.

@Test
public void testImpliedInstructions() {
    OpCode.streamOf(AddressingMode.IMPLIED).forEach((opcode) -> {
        final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName());
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        assertEquals("Wrong byte value for " + opcode.getOpCodeName() + "(" + opcode.getByteValue() + ")", opcode.getByteValue(), bytes[0]);
    });
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 100 with Program

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

the class Mos6502CompilerTest method testRelativeNavigationForwards.

@Test
public void testRelativeNavigationForwards() {
    final Mos6502Compiler compiler = new Mos6502Compiler("SEC BCS MyLabel NOP MyLabel: SED");
    final int[] expectedResult = new int[] { OpCode.SEC.getByteValue(), OpCode.BCS.getByteValue(), 0b00000001, OpCode.NOP.getByteValue(), OpCode.SED.getByteValue() };
    final Program program = compiler.compileProgram();
    final int[] actualResult = program.getProgramAsByteArray();
    assertTrue("Expected " + Arrays.toString(expectedResult) + ", got " + Arrays.toString(actualResult), Arrays.equals(actualResult, expectedResult));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) 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