From 7f6a955a717c6acc0983133a0cfce1add6343e3b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 3 Apr 2022 15:50:03 -0400 Subject: [PATCH] Complete the cmp set. --- InstructionSets/PowerPC/Instruction.hpp | 4 +- .../DingusdevPowerPCTests.mm | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/InstructionSets/PowerPC/Instruction.hpp b/InstructionSets/PowerPC/Instruction.hpp index ddd0dc410..f88aa3ee1 100644 --- a/InstructionSets/PowerPC/Instruction.hpp +++ b/InstructionSets/PowerPC/Instruction.hpp @@ -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. diff --git a/OSBindings/Mac/Clock SignalTests/DingusdevPowerPCTests.mm b/OSBindings/Mac/Clock SignalTests/DingusdevPowerPCTests.mm index f0e03e9ea..d6ba709a8 100644 --- a/OSBindings/Mac/Clock SignalTests/DingusdevPowerPCTests.mm +++ b/OSBindings/Mac/Clock SignalTests/DingusdevPowerPCTests.mm @@ -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: {