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"));
}
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);
}
}
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);
}
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);
}
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);
}
}
Aggregations