From ccadf6963095d8c4815ba6247e0b95e01511b179 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 31 Oct 2022 15:15:05 -0400 Subject: [PATCH] Add test of `operand_flags` and `operand_size`; add entries for missing 68000 and 68010 instructions. --- .../M68k/Implementation/InstructionOperandFlags.hpp | 6 +++++- InstructionSets/M68k/Instruction.hpp | 11 +++++++---- .../Mac/Clock SignalTests/68000DecoderTests.mm | 12 ++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/InstructionSets/M68k/Implementation/InstructionOperandFlags.hpp b/InstructionSets/M68k/Implementation/InstructionOperandFlags.hpp index b4ade6adc..68a92fdfc 100644 --- a/InstructionSets/M68k/Implementation/InstructionOperandFlags.hpp +++ b/InstructionSets/M68k/Implementation/InstructionOperandFlags.hpp @@ -19,7 +19,9 @@ template constexpr uint8_t operand_flags(Op // // No operands are fetched or stored. - // (which means that source and destination will appear as their effective addresses) + // + // (which means that source and destination, if they exist, + // should be supplied as their effective addresses) // case Operation::PEA: case Operation::JMP: case Operation::JSR: @@ -27,6 +29,8 @@ template constexpr uint8_t operand_flags(Op case Operation::TAS: case Operation::RTR: case Operation::RTS: case Operation::RTE: case Operation::RTD: + case Operation::TRAP: case Operation::RESET: case Operation::NOP: + case Operation::STOP: case Operation::TRAPV: case Operation::BKPT: return 0; // diff --git a/InstructionSets/M68k/Instruction.hpp b/InstructionSets/M68k/Instruction.hpp index 6091cb425..b7b7ce0ac 100644 --- a/InstructionSets/M68k/Instruction.hpp +++ b/InstructionSets/M68k/Instruction.hpp @@ -151,9 +151,12 @@ enum class Operation: uint8_t { EXTbtol, - cpBcc, cpDBcc, cpGEN, - cpScc, cpTRAPcc, cpRESTORE, - cpSAVE, + // Coprocessor instructions are omitted for now, until I can + // determine by what mechanism the number of + // "OPTIONAL COPROCESSOR-DEFINED EXTENSION WORDS" is determined. +// cpBcc, cpDBcc, cpGEN, +// cpScc, cpTRAPcc, cpRESTORE, +// cpSAVE, // // 68030 additions. @@ -177,7 +180,7 @@ enum class Operation: uint8_t { // Max68000 = RESET, Max68010 = RTD, - Max68020 = cpSAVE, + Max68020 = EXTbtol, Max68030 = PTESTW, Max68040 = PTESTW, }; diff --git a/OSBindings/Mac/Clock SignalTests/68000DecoderTests.mm b/OSBindings/Mac/Clock SignalTests/68000DecoderTests.mm index f7525aeaf..917515c91 100644 --- a/OSBindings/Mac/Clock SignalTests/68000DecoderTests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000DecoderTests.mm @@ -53,6 +53,12 @@ template void test(NSString *filename, Class cls) { const auto found = decoder.decode(uint16_t(instr)); + // Test that all appropriate table entries are present for this operation. + if(found.operation != Operation::Undefined) { + operand_flags(found.operation); + operand_size(found.operation); + } + NSString *const instruction = [NSString stringWithUTF8String:found.to_string(instr).c_str()]; if(![instruction isEqualToString:expected]) { [failures addObject:[NSString stringWithFormat:@"%@ should decode as %@; got %@", instrName, expected, instruction]]; @@ -77,13 +83,7 @@ template void test(NSString *filename, Class cls) { test(@"68010ops", [self class]); } -/* - TODO: generate full new reference JSONs for tests below here. - For now these are here for manual verification of the diffs. -*/ - - (void)test68020 { -// generate(); test(@"68020ops", [self class]); }