1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Handle the synonym test cases.

This commit is contained in:
Thomas Harte 2022-04-04 08:09:59 -04:00
parent 59a1fde2a1
commit ac524532e7

View File

@ -157,6 +157,37 @@ NSString *offset(Instruction instruction) {
const auto instruction = decoder.decode(opcode);
NSLog(@"%@", line);
// Deal with some of the simplified mnemonics as special cases;
// underlying observation: distinguishing special cases isn't that
// important to a mere decoder.
if([operation isEqualToString:@"nop"]) {
// These tests use ORI for NOP.
XCTAssertEqual(instruction.operation, Operation::ori);
XCTAssertEqual(instruction.rD(), instruction.rA());
XCTAssertEqual(instruction.simm(), 0);
continue;
}
if([operation isEqualToString:@"mr"] || [operation isEqualToString:@"mr."]) {
// OR is used to achieve MR (i.e. move register).
XCTAssertEqual(instruction.operation, Operation::orx);
XCTAssertEqual((instruction.rc() != 0), ([operation characterAtIndex:operation.length - 1] == '.'));
AssertEqualR(columns[3], instruction.rA());
AssertEqualR(columns[4], instruction.rS());
AssertEqualR(columns[4], instruction.rB());
continue;
}
if([operation isEqualToString:@"li"]) {
// ADDI is used to achieve LI (i.e. load immediate).
XCTAssertEqual(instruction.operation, Operation::addi);
AssertEqualR(columns[3], instruction.rD());
XCTAssertEqual(0, instruction.rA());
XCTAssertEqual([columns[4] hexInt], instruction.simm());
continue;
}
switch(instruction.operation) {
default:
NSAssert(FALSE, @"Didn't handle %@", line);