1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Complete the cmp set.

This commit is contained in:
Thomas Harte 2022-04-03 15:50:03 -04:00
parent 125d97cc41
commit 7f6a955a71
2 changed files with 64 additions and 2 deletions

View File

@ -355,12 +355,12 @@ enum class Operation: uint8_t {
/// Floating point compare ordered.
/// fcmpo
/// crfD(), frA(), feB()
/// crfD(), frA(), frB()
fcmpo,
/// Floating point compare unordered.
/// fcmpu
/// crfD(), frA(), feB()
/// crfD(), frA(), frB()
fcmpu,
/// Floating point convert to integer word.

View File

@ -310,6 +310,55 @@ NSString *offset(Instruction instruction) {
XCTAssertEqual([columns[4] intValue], instruction.imm());
break;
case Operation::cmp:
if([operation isEqualToString:@"cmpw"]) {
XCTAssertFalse(instruction.l());
XCTAssertFalse(instruction.crfD());
AssertEqualR(columns[3], instruction.rA());
AssertEqualR(columns[4], instruction.rB());
break;
}
if([operation isEqualToString:@"cmp"]) {
XCTAssertEqualObjects(columns[3], conditionreg(instruction.crfD()));
AssertEqualR(columns[4], instruction.rA());
AssertEqualR(columns[5], instruction.rB());
break;
}
NSAssert(FALSE, @"Didn't handle cmp %@", line);
break;
case Operation::cmpl:
if([operation isEqualToString:@"cmplw"]) {
XCTAssertFalse(instruction.l());
if(instruction.crfD()) {
XCTAssertEqualObjects(columns[3], conditionreg(instruction.crfD()));
AssertEqualR(columns[4], instruction.rA());
AssertEqualR(columns[5], instruction.rB());
} else {
AssertEqualR(columns[3], instruction.rA());
AssertEqualR(columns[4], instruction.rB());
}
break;
}
NSAssert(FALSE, @"Didn't handle cmpl %@", line);
break;
case Operation::cmpli:
case Operation::cmpi:
if([operation isEqualToString:@"cmpwi"] || [operation isEqualToString:@"cmplwi"]) {
XCTAssertFalse(instruction.l());
} else {
XCTAssertTrue(instruction.l());
}
XCTAssertEqualObjects(columns[3], conditionreg(instruction.crfD()));
AssertEqualR(columns[4], instruction.rA());
XCTAssertEqual([columns[5] hexInt], instruction.simm());
break;
#define NoArg(x) \
case Operation::x: \
AssertEqualOperationName(operation, @#x); \
@ -677,6 +726,19 @@ NSString *offset(Instruction instruction) {
#undef crfDS
#define crfDfAfB(x) \
case Operation::x: \
AssertEqualOperationName(operation, @#x, instruction); \
XCTAssertEqualObjects(columns[3], conditionreg(instruction.crfD())); \
AssertEqualFR(columns[4], instruction.frA()); \
AssertEqualFR(columns[5], instruction.frB()); \
break;
crfDfAfB(fcmpo);
crfDfAfB(fcmpu);
#undef crfDfAfB
case Operation::bcx:
case Operation::bclrx:
case Operation::bcctrx: {