1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-27 01:29:31 +00:00

Subsume MOVEQ into MOVE.l; add missing invalid_operands.

This commit is contained in:
Thomas Harte 2022-04-25 19:58:19 -04:00
parent 4e5a6c89b9
commit 8ff0b71b29
4 changed files with 37 additions and 12 deletions

View File

@ -131,8 +131,9 @@ constexpr Operation Predecoder<model>::operation(OpT op) {
case ORtoRw: case ORtoMw: return Operation::ORw;
case ORtoRl: case ORtoMl: return Operation::ORl;
case EXGRtoR: case EXGAtoA: case EXGRtoA:
return Operation::EXG;
case EXGRtoR: case EXGAtoA: case EXGRtoA: return Operation::EXG;
case MOVEQ: return Operation::MOVEl;
default: break;
}
@ -177,10 +178,12 @@ template <uint8_t op> uint32_t Predecoder<model>::invalid_operands() {
static constexpr auto ControlAddressingModes = Ind | d16An | d8AnXn | XXXw | XXXl | d16PC | d8PCXn;
switch(op) {
default: return NoOperandMask::value;
default: return ~NoOperandMask::value;
case OpT(Operation::ABCD):
case OpT(Operation::ADDXb): case OpT(Operation::ADDXw): case OpT(Operation::ADDXl):
case OpT(Operation::SBCD):
case OpT(Operation::SUBXb): case OpT(Operation::SUBXw): case OpT(Operation::SUBXl):
return ~TwoOperandMask<
Dn | PreDec,
Dn | PreDec
@ -243,6 +246,12 @@ template <uint8_t op> uint32_t Predecoder<model>::invalid_operands() {
AlterableAddressingModesNoAn
>::value;
case MOVEQ:
return ~TwoOperandMask<
Quick,
Dn
>::value;
case ADDQw: case ADDQl:
case SUBQw: case SUBQl:
return ~TwoOperandMask<
@ -449,6 +458,18 @@ template <uint8_t op> uint32_t Predecoder<model>::invalid_operands() {
Ind | PostInc | d16An | d8AnXn | XXXw | XXXl | d16PC | d8PCXn,
Imm
>::value;
case MOVEPtoRl: case MOVEPtoRw:
return ~TwoOperandMask<
d16An,
Dn
>::value;
case MOVEPtoMl: case MOVEPtoMw:
return ~TwoOperandMask<
Dn,
d16An
>::value;
}
}
@ -804,8 +825,7 @@ template <uint8_t op, bool validate> Preinstruction Predecoder<model>::decode(ui
// b9b11: a destination register;
// b0b7: a 'quick' value.
//
// TODO: does this need to be a separate instruction from MOVEl?
case OpT(Operation::MOVEq):
case MOVEQ:
return validated<op, validate>(
Preinstruction(operation,
AddressingMode::Quick, 0,
@ -1147,7 +1167,7 @@ Preinstruction Predecoder<model>::decode7(uint16_t instruction) {
// 4-134 (p238)
if(!(instruction & 0x100)) {
Decode(Op::MOVEq);
Decode(MOVEQ);
} else {
return Preinstruction();
}

View File

@ -62,6 +62,8 @@ template <Model model> class Predecoder {
MOVEPtoRl, MOVEPtoRw,
MOVEPtoMl, MOVEPtoMw,
MOVEQ,
ADDQb, ADDQw, ADDQl,
ADDQAw, ADDQAl,
SUBQb, SUBQw, SUBQl,

View File

@ -32,7 +32,6 @@ enum class Operation: uint8_t {
MOVEb, MOVEw, MOVEl,
MOVEAw, MOVEAl,
MOVEq,
LEA, PEA,
MOVEtoSR, MOVEfromSR,
@ -141,7 +140,7 @@ constexpr int8_t quick(uint16_t instruction) {
switch(op) {
case Operation::Bccb:
case Operation::BSRb:
case Operation::MOVEq: return int8_t(instruction);
case Operation::MOVEl: return int8_t(instruction);
case Operation::TRAP: return int8_t(instruction & 15);
default: {
int8_t value = (instruction >> 9) & 7;
@ -153,7 +152,7 @@ constexpr int8_t quick(uint16_t instruction) {
constexpr int8_t quick(Operation op, uint16_t instruction) {
switch(op) {
case Operation::MOVEq: return quick<Operation::MOVEq>(instruction);
case Operation::MOVEl: return quick<Operation::MOVEl>(instruction);
case Operation::Bccb: return quick<Operation::Bccb>(instruction);
case Operation::BSRb: return quick<Operation::BSRb>(instruction);
case Operation::TRAP: return quick<Operation::TRAP>(instruction);

View File

@ -113,13 +113,17 @@ template <int index> NSString *operand(Preinstruction instruction, uint16_t opco
case Operation::MOVEb: instruction = @"MOVE.b"; break;
case Operation::MOVEw: instruction = @"MOVE.w"; break;
case Operation::MOVEl: instruction = @"MOVE.l"; break;
case Operation::MOVEl:
if(found.mode<0>() == AddressingMode::Quick) {
instruction = @"MOVE.q";
} else {
instruction = @"MOVE.l";
}
break;
case Operation::MOVEAw: instruction = @"MOVEA.w"; break;
case Operation::MOVEAl: instruction = @"MOVEA.l"; break;
case Operation::MOVEq: instruction = @"MOVE.q"; break;
case Operation::LEA: instruction = @"LEA"; break;
case Operation::PEA: instruction = @"PEA"; break;