diff --git a/InstructionSets/68k/Decoder.cpp b/InstructionSets/68k/Decoder.cpp index 87c3c15d3..0d3b5482b 100644 --- a/InstructionSets/68k/Decoder.cpp +++ b/InstructionSets/68k/Decoder.cpp @@ -131,8 +131,9 @@ constexpr Operation Predecoder::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 uint32_t Predecoder::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 uint32_t Predecoder::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 uint32_t Predecoder::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 Preinstruction Predecoder::decode(ui // b9–b11: a destination register; // b0–b7: a 'quick' value. // - // TODO: does this need to be a separate instruction from MOVEl? - case OpT(Operation::MOVEq): + case MOVEQ: return validated( Preinstruction(operation, AddressingMode::Quick, 0, @@ -1147,7 +1167,7 @@ Preinstruction Predecoder::decode7(uint16_t instruction) { // 4-134 (p238) if(!(instruction & 0x100)) { - Decode(Op::MOVEq); + Decode(MOVEQ); } else { return Preinstruction(); } diff --git a/InstructionSets/68k/Decoder.hpp b/InstructionSets/68k/Decoder.hpp index 3589e711f..fbd67d5d9 100644 --- a/InstructionSets/68k/Decoder.hpp +++ b/InstructionSets/68k/Decoder.hpp @@ -62,6 +62,8 @@ template class Predecoder { MOVEPtoRl, MOVEPtoRw, MOVEPtoMl, MOVEPtoMw, + MOVEQ, + ADDQb, ADDQw, ADDQl, ADDQAw, ADDQAl, SUBQb, SUBQw, SUBQl, diff --git a/InstructionSets/68k/Instruction.hpp b/InstructionSets/68k/Instruction.hpp index 57a5cff76..00f9b99b7 100644 --- a/InstructionSets/68k/Instruction.hpp +++ b/InstructionSets/68k/Instruction.hpp @@ -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(instruction); + case Operation::MOVEl: return quick(instruction); case Operation::Bccb: return quick(instruction); case Operation::BSRb: return quick(instruction); case Operation::TRAP: return quick(instruction); diff --git a/OSBindings/Mac/Clock SignalTests/m68kDecoderTests.mm b/OSBindings/Mac/Clock SignalTests/m68kDecoderTests.mm index 25fe27552..1b099908f 100644 --- a/OSBindings/Mac/Clock SignalTests/m68kDecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/m68kDecoderTests.mm @@ -113,13 +113,17 @@ template 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;