diff options
author | Oxore <oxore@protonmail.com> | 2023-05-09 00:09:20 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-05-09 00:09:20 +0300 |
commit | 2f2c8dbc006ec03e9887ab7a91f7cf97bb6ce53d (patch) | |
tree | 11b32e6b75b9f162afa158b5edf6e9db82cbc242 | |
parent | b43a6b815d27e5fd846b50634af7b4a99b57c9ac (diff) |
Impl CMPM
-rw-r--r-- | disasm.cpp | 22 | ||||
-rw-r--r-- | test.bash | 7 |
2 files changed, 25 insertions, 4 deletions
@@ -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<OpSize>((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( @@ -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" |