use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.
the class Mos6502CompilerTest method testOversizedValue.
@Test
public void testOversizedValue() {
try {
final Mos6502Compiler compiler = new Mos6502Compiler("ADC " + VALUE_PREFIX + "12345");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
fail("Argument size over " + 0xFFFF + " should throw an exception but was " + Arrays.toString(bytes));
} catch (UnknownOpCodeException e) {
assertFalse(e.getMessage().isEmpty());
assertFalse(e.getOpCode() == null);
}
}
use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.
the class OpCodeConverter method getAddressingMode.
/**
* Extract the {@link Mos6502} {@link AddressingMode} from the {@link String} representation of an {@link OpCode}.
*
* @param internalOpCodeName the {@link String} representation of an {@link OpCode}
* @return An {@link AddressingMode} object that represents the intended addressing mode of the {@link OpCode} in question
*/
public static AddressingMode getAddressingMode(String internalOpCodeName) {
final String[] tokens = internalOpCodeName.split(OpCode.TOKEN_SEPARATOR);
if (tokens.length <= OpCode.ADDR_I) {
// XXX Write this less ugly
if (EnumSet.of(Operation.JSR, Operation.BPL, Operation.BMI, Operation.BVC, Operation.BVS, Operation.BCC, Operation.BCS, Operation.BNE, Operation.BEQ).contains(getOperation(internalOpCodeName)))
return AddressingMode.RELATIVE;
return AddressingMode.IMPLIED;
}
final String addressingModeDescriptor = tokens[OpCode.ADDR_I];
// XXX Not pretty but necessary for proper test coverage - update if JaCoCo ever learns to deal with it
final String indexToken = (tokens.length <= OpCode.INDX_I) ? "" : tokens[OpCode.INDX_I];
if ("I".equals(addressingModeDescriptor))
return AddressingMode.IMMEDIATE;
else if ("A".equals(addressingModeDescriptor))
return AddressingMode.ACCUMULATOR;
else if ("Z".equals(addressingModeDescriptor))
return withIndexing(AddressingMode.ZERO_PAGE, indexToken);
else if ("ABS".equals(addressingModeDescriptor))
return withIndexing(AddressingMode.ABSOLUTE, indexToken);
else if ("IND".equals(addressingModeDescriptor))
return withIndexing(AddressingMode.INDIRECT, indexToken);
else
throw new UnknownOpCodeException("Unrecognised addressing mode " + addressingModeDescriptor, internalOpCodeName);
}
Aggregations