diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp index b2a3392d1..105707d5c 100644 --- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp +++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp @@ -279,18 +279,28 @@ template < // Special case: the condition code is 1, which is ordinarily false. In that case this // is the trailing step of a BSR. case Operation::Bccb: - case Operation::Bccw: - case Operation::Bccl: { - // Test the conditional, treating 'false' as true. - const bool should_branch = status.evaluate_condition(instruction.condition()); - - // Schedule something appropriate, by rewriting the program for this instruction temporarily. - if(should_branch) { - flow_controller.add_pc(src.l); + if(status.evaluate_condition(instruction.condition())) { + flow_controller.add_pc(int8_t(src.b) - 2); } else { flow_controller.decline_branch(); } - } break; + break; + + case Operation::Bccw: + if(status.evaluate_condition(instruction.condition())) { + flow_controller.add_pc(int16_t(src.b) - 2); + } else { + flow_controller.decline_branch(); + } + break; + + case Operation::Bccl: + if(status.evaluate_condition(instruction.condition())) { + flow_controller.add_pc(src.l - 2); + } else { + flow_controller.decline_branch(); + } + break; case Operation::DBcc: // Decide what sort of DBcc this is. diff --git a/InstructionSets/M68k/Instruction.hpp b/InstructionSets/M68k/Instruction.hpp index 2ed4730d1..8868f01fc 100644 --- a/InstructionSets/M68k/Instruction.hpp +++ b/InstructionSets/M68k/Instruction.hpp @@ -272,6 +272,7 @@ template uint8_t ope case Operation::ORItoSR: case Operation::ORItoCCR: case Operation::ANDItoSR: case Operation::ANDItoCCR: case Operation::EORItoSR: case Operation::EORItoCCR: + case Operation::Bccb: case Operation::Bccw: case Operation::Bccl: return FetchOp1; // diff --git a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm index 067f70bff..eb0300ece 100644 --- a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm @@ -33,10 +33,12 @@ // add_sub // addi_subi_cmpi // eor_and_or +// addq_subq +// addx_subx - (void)setUp { // To limit tests run to a subset of files and/or of tests, uncomment and fill in below. - _fileSet = [NSSet setWithArray:@[@"addq_subq.json"]]; + _fileSet = [NSSet setWithArray:@[@"bcc.json"]]; // _testSet = [NSSet setWithArray:@[@"ADDQ 00d0"]]; // _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]]; // _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];