Search in sources :

Example 86 with Program

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

the class Mos6502CompilerTest method testLabelExtractionInCompilation.

@Test
public void testLabelExtractionInCompilation() {
    final Mos6502Compiler compiler = new Mos6502Compiler("MyLabel: SEC");
    final Program program = compiler.compileProgram();
    assertEquals(1, program.getLabels().size());
    assertEquals(0, program.getLocationOf("MyLabel"));
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 87 with Program

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

the class Mos6502CompilerTest method testInvalidArgument.

@Test
public void testInvalidArgument() {
    try {
        final Mos6502Compiler compiler = new Mos6502Compiler("INC $12345");
        Program program = compiler.compileProgram();
        program.getProgramAsByteArray();
        fail("The argument for INC is too long, should throw an error");
    } catch (UnknownOpCodeException e) {
        assertNotNull(e);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 88 with Program

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

the class Mos6502CompilerTest method testInlineCommentRemoval.

@Test
public void testInlineCommentRemoval() {
    final Mos6502Compiler compiler = new Mos6502Compiler("SEC ;this should not be parsed\nCLC");
    Program program = compiler.compileProgram();
    int[] bytes = program.getProgramAsByteArray();
    assertEquals(2, bytes.length);
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 89 with Program

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

the class Mos6502CompilerTest method testChainedInstruction.

@Test
public void testChainedInstruction() {
    final Mos6502Compiler compiler = new Mos6502Compiler("SEC LDA " + IMMEDIATE_VALUE_PREFIX + "47");
    final Program program = compiler.compileProgram();
    int[] bytes = program.getProgramAsByteArray();
    int[] expected = new int[] { OpCode.SEC.getByteValue(), OpCode.LDA_I.getByteValue(), 0x47 };
    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 90 with Program

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

the class Mos6502CompilerTest method testInvalidIndirectIndexingMode.

@Test
public void testInvalidIndirectIndexingMode() {
    try {
        final Mos6502Compiler compiler = new Mos6502Compiler("ADC " + INDIRECT_PREFIX + "10(");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        fail("Invalid prefix for an indirect value should throw an exception but was " + Arrays.toString(bytes));
    } catch (UnknownOpCodeException e) {
        assertFalse(e.getMessage().isEmpty());
        assertFalse(e.getOpCode() == null);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) 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