diff options
-rw-r--r-- | disasm.cpp | 26 | ||||
-rw-r--r-- | test.bash | 9 |
2 files changed, 33 insertions, 2 deletions
@@ -549,7 +549,31 @@ static inline const char *mnemonic_for_bitops(unsigned opcode) static inline void disasm_movep( DisasmNode &node, const uint16_t instr, const DataBuffer &code, const Settings &s) { - return disasm_verbatim(node, instr, code, s); + const unsigned dn = ((instr >> 9) & 7); + const unsigned an = instr & 7; + const char suffix = ((instr >> 6) & 1) ? 'l' : 'w'; + const auto dir = static_cast<MoveDirection>(!((instr >> 7) & 1)); + const auto addr = AddrModeArg::Fetch( + node.offset + kInstructionSizeStepBytes, code, 5, an, suffix); + if (addr.mode == AddrMode::kInvalid) { + // Boundary check failed, most likely + return disasm_verbatim(node, instr, code, s); + } + assert(addr.mode == AddrMode::kD16AnAddr); + const auto reg = AddrModeArg::Fetch( + node.offset + kInstructionSizeStepBytes, code, 0, dn, suffix); + assert(reg.mode == AddrMode::kDn); + char addr_str[32]{}; + char reg_str[32]{}; + addr.SNPrint(addr_str, sizeof(addr_str)); + reg.SNPrint(reg_str, sizeof(reg_str)); + snprintf(node.mnemonic, kMnemonicBufferSize, "movep%c", suffix); + if (dir == MoveDirection::kRegisterToMemory) { + snprintf(node.arguments, kArgsBufferSize, "%s,%s", reg_str, addr_str); + } else { + snprintf(node.arguments, kArgsBufferSize, "%s,%s", addr_str, reg_str); + } + node.size = kInstructionSizeStepBytes + addr.Size() + reg.Size(); } static void disasm_src_arg_bitops_movep( @@ -76,7 +76,7 @@ run_test_simple() { cat ${file_asm} else echo -e "${CGREEN}OK${CRST}" - cat ${file_asm} + #cat ${file_asm} fi } @@ -93,6 +93,13 @@ run_test_iterative() { done } +# 0xxx movep +# +run_test_simple "movepw Dn to (An)" "\x01\x0b\x00\xa0" +run_test_simple "movepl Dn to (An)" "\x03\x4a\x00\xa0" +run_test_simple "movepw (An) to Dn" "\x05\x89\x00\xa0" +run_test_simple "movepl (An) to Dn" "\x07\xc8\x00\xa0" + # 0xxx bitwise ops # run_test_simple "btstl immediate in Dn" "\x08\x07\x00\x06" |