use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testAbsoluteAddressing.
@Test
public void testAbsoluteAddressing() {
final Mos6502Compiler compiler = new Mos6502Compiler("LDA #$1C STA $100 INC $100");
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);
assertEquals(0x1D, memory.getByte(0x100));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testImmediateInstructions.
@Property
public void testImmediateInstructions(@InRange(min = "0", max = "255") int byteValue) {
final String hexByte = Integer.toHexString(byteValue);
OpCode.streamOf(AddressingMode.IMMEDIATE).forEach((opcode) -> {
final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + IMMEDIATE_VALUE_PREFIX + hexByte);
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", new int[] { opcode.getByteValue(), byteValue }, bytes);
});
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testTripleDigitArgument.
@Test
public void testTripleDigitArgument() {
OpCode.streamOf(AddressingMode.ABSOLUTE).forEach((opcode) -> {
final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + "ABC");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", new int[] { opcode.getByteValue(), 0xA, 0xBC }, bytes);
});
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testZeroPageXInstructions.
@Property
public void testZeroPageXInstructions(@InRange(min = "0", max = "255") int byteValue) {
final String hexByte = Integer.toHexString(byteValue);
OpCode.streamOf(AddressingMode.ZERO_PAGE_X).forEach((opcode) -> {
final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " " + VALUE_PREFIX + hexByte + ",X");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertArrayEquals("Output for '" + opcode.toString() + "' was wrong.", new int[] { opcode.getByteValue(), byteValue }, bytes);
});
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502CompilerTest method testChainedTwoByteInstructionsWithLabel.
@Test
public void testChainedTwoByteInstructionsWithLabel() {
final Mos6502Compiler compiler = new Mos6502Compiler("LDA " + IMMEDIATE_VALUE_PREFIX + "47 LABELA: CLC LDA " + IMMEDIATE_VALUE_PREFIX + "10 SEC");
final Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
int[] expected = new int[] { OpCode.LDA_I.getByteValue(), 0x47, OpCode.CLC.getByteValue(), OpCode.LDA_I.getByteValue(), 0x10, OpCode.SEC.getByteValue() };
assertArrayEquals("Expected: " + Arrays.toString(expected) + ", Got: " + Arrays.toString(bytes), expected, bytes);
assertEquals(1, program.getLabels().size());
assertEquals(2, program.getLocationOf("LABELA"));
}
Aggregations