1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-30 22:29:56 +00:00

Correct decoding of Bcc.b, satisfying Bcc and BSR tests.

This commit is contained in:
Thomas Harte 2022-05-03 15:32:54 -04:00
parent 5a87506f3d
commit af973138df
6 changed files with 28 additions and 3 deletions

View File

@ -812,10 +812,15 @@ template <uint8_t op, bool validate> Preinstruction Predecoder<model>::decode(ui
// No further operands decoded, but note that one is somewhere in the opcode.
//
case OpT(Operation::TRAP):
case OpT(Operation::Bccb):
case OpT(Operation::BSRb):
return validated<op, validate>(AddressingMode::Quick);
case OpT(Operation::Bccb):
return validated<op, validate>(
AddressingMode::Quick, 0,
AddressingMode::None, 0,
Condition((instruction >> 8) & 0xf));
//
// MARK: LINKw
//

View File

@ -45,6 +45,7 @@ template <Model model, typename BusHandler> class Executor {
void add_pc(uint32_t);
void decline_branch() {}
void did_update_status();
void bsr(uint32_t offset);
// TODO: ownership of this shouldn't be here.
struct Registers {

View File

@ -364,6 +364,13 @@ void Executor<model, BusHandler>::add_pc(uint32_t offset) {
program_counter_.l = instruction_address_ + offset;
}
template <Model model, typename BusHandler>
void Executor<model, BusHandler>::bsr(uint32_t offset) {
address_[7].l -= 4;
bus_handler_.template write<uint32_t>(address_[7].l, program_counter_.l);
program_counter_.l = instruction_address_ + offset;
}
}
}

View File

@ -302,6 +302,16 @@ template <
}
break;
case Operation::BSRb:
flow_controller.bsr(int8_t(src.b) + 2);
break;
case Operation::BSRw:
flow_controller.bsr(int16_t(src.w) + 2);
break;
case Operation::BSRl:
flow_controller.bsr(src.l + 2);
break;
case Operation::DBcc:
// Decide what sort of DBcc this is.
if(!status.evaluate_condition(instruction.condition())) {

View File

@ -273,6 +273,7 @@ template <Model model, Operation t_operation = Operation::Undefined> uint8_t ope
case Operation::ANDItoSR: case Operation::ANDItoCCR:
case Operation::EORItoSR: case Operation::EORItoCCR:
case Operation::Bccb: case Operation::Bccw: case Operation::Bccl:
case Operation::BSRb: case Operation::BSRw: case Operation::BSRl:
return FetchOp1;
//

View File

@ -35,11 +35,12 @@
// eor_and_or
// addq_subq
// addx_subx
// bcc
- (void)setUp {
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
_fileSet = [NSSet setWithArray:@[@"bcc.json"]];
// _testSet = [NSSet setWithArray:@[@"Bcc 6000 [0]"]];
_fileSet = [NSSet setWithArray:@[@"btst_bchg_bclr_bset.json"]];
// _testSet = [NSSet setWithArray:@[@"Bcc 6206"]];
// _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]];
// _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];
}