use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testIndirectXInstructions.
@Property
public void testIndirectXInstructions(@InRange(min = "0", max = "255") int byteValue) {
final String hexByte = Integer.toHexString(byteValue);
OpCode.streamOf(AddressingMode.INDIRECT_X).forEach((opcode) -> {
final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " (" + VALUE_PREFIX + hexByte + ",X)");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertArrayEquals(new int[] { opcode.getByteValue(), byteValue }, bytes);
});
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method testIntegration.
@Test
public void testIntegration() {
final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$14 ADC #$5 STA $20");
Program program = compiler.compileProgram();
final int[] programByte = program.getProgramAsByteArray();
Memory memory = new SimpleMemory();
Mos6502 processor = new Mos6502(memory);
processor.reset();
memory.setBlock(0, programByte);
processor.step(3);
Registers registers = processor.getRegisters();
assertEquals(0x19, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0x19, memory.getByte(0x20));
assertEquals(programByte.length, registers.getPC());
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class Mos6502CompilerTest method opCode2JaCoCoCoverage.
@Test
public void opCode2JaCoCoCoverage() {
final Mos6502Compiler compiler = new Mos6502Compiler("\0BRK");
try {
compiler.compileProgram();
fail("Exception expected. This should not pass a String switch statement");
} catch (UnknownTokenException e) {
assertTrue(e.getMessage().contains("\0BRK"));
assertNotNull(e);
}
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler in project emuRox by rossdrew.
the class DebuggerWindow method compile.
public void compile(String programText) {
final Mos6502Compiler compiler = new Mos6502Compiler(programText);
try {
final Program program = compiler.compileProgram();
final int[] programAsByteArray = program.getProgramAsByteArray();
loadProgram(programAsByteArray);
} catch (UnknownOpCodeException e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
use of com.rox.emu.processor.mos6502.util.Mos6502Compiler 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"));
}
Aggregations