From 2f2c8dbc006ec03e9887ab7a91f7cf97bb6ce53d Mon Sep 17 00:00:00 2001 From: Oxore Date: Tue, 9 May 2023 00:09:20 +0300 Subject: Impl CMPM --- disasm.cpp | 22 +++++++++++++++++++--- test.bash | 7 ++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/disasm.cpp b/disasm.cpp index b50cb5f..6752717 100644 --- a/disasm.cpp +++ b/disasm.cpp @@ -1681,10 +1681,26 @@ static void disasm_add_sub_cmp( } static void disasm_cmpm( - DisasmNode &node, const uint16_t instr, const DataBuffer &code, const Settings &s) + DisasmNode &node, const uint16_t instr, const DataBuffer &, const Settings &) { - // TODO Implement - return disasm_verbatim(node, instr, code, s); + const OpSize opsize = static_cast((instr >> 6) & 3); + // Must be already handled by parent call + assert(opsize != OpSize::kInvalid); + const int m = (instr >> 3) & 3; + assert(m == 1); + (void) m; + const int xn = instr & 7; + const int xi = (instr >> 9) & 7; + const auto src = AddrModeArg::AnAddrIncr(xn); + const auto dst = AddrModeArg::AnAddrIncr(xi); + char src_str[32]{}; + char dst_str[32]{}; + src.SNPrint(src_str, sizeof(src_str)); + dst.SNPrint(dst_str, sizeof(dst_str)); + const char suffix = suffix_from_opsize(opsize); + snprintf(node.mnemonic, kMnemonicBufferSize, "cmpm%c", suffix); + snprintf(node.arguments, kArgsBufferSize, "%s,%s", src_str, dst_str); + node.size = kInstructionSizeStepBytes + src.Size() + dst.Size(); } static void disasm_eor( diff --git a/test.bash b/test.bash index 863e3c0..7de13cf 100644 --- a/test.bash +++ b/test.bash @@ -93,10 +93,15 @@ run_test_iterative() { done } +# bxxx cmpm +# +run_test_simple "cmpmb (An)+, (An)+" "\xb1\x08" +run_test_simple "cmpmw (An)+, (An)+" "\xb1\x48" +run_test_simple "cmpml (An)+, (An)+" "\xb1\x88" + # bxxx eor # run_test_simple "eorb Dn, Dn" "\xb5\x01" -run_test_expect_short "eorb Dn, An" "\xb5\x09" run_test_simple "eorb Dn, (An)" "\xb5\x11" run_test_simple "eorb Dn, (An)+" "\xb5\x19" run_test_simple "eorw Dn, -(An)" "\xb5\x61" -- cgit v1.2.3