diff options
author | Oxore <oxore@protonmail.com> | 2023-05-08 12:37:54 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-05-08 12:37:54 +0300 |
commit | 19e313b5891dfaceead13df6dd3e828a9ce90592 (patch) | |
tree | 70310c67c3ae3a4b320d5b0c2b68d32b5b192ead | |
parent | 5c8aedf98c462387ad073698918d5cb7d9965a4b (diff) |
Impl ADDX
-rw-r--r-- | disasm.cpp | 19 | ||||
-rw-r--r-- | test.bash | 13 |
2 files changed, 27 insertions, 5 deletions
@@ -1368,10 +1368,23 @@ static void chunk_mf000_vc000(DisasmNode &n, uint16_t i, const DataBuffer &c, co } static inline void disasm_addx( - DisasmNode &node, const uint16_t instr, const DataBuffer &code, const Settings &s) + DisasmNode &node, const uint16_t instr, const DataBuffer &, const Settings &) { - // TODO - return disasm_verbatim(node, instr, code, s); + const OpSize opsize = static_cast<OpSize>((instr >> 6) & 3); + // Already handled by parent call of `disasm_add_addx_adda` + assert(opsize != OpSize::kInvalid); + const int m = (instr >> 3) & 1; + const int xn = instr & 7; + const int xi = (instr >> 9) & 7; + const auto src = m ? AddrModeArg::AnAddrDecr(xn) : AddrModeArg::Dn(xn); + const auto dst = m ? AddrModeArg::AnAddrDecr(xi) : AddrModeArg::Dn(xi); + char src_str[32]{}; + char dst_str[32]{}; + src.SNPrint(src_str, sizeof(src_str)); + dst.SNPrint(dst_str, sizeof(dst_str)); + snprintf(node.mnemonic, kMnemonicBufferSize, "addx%c", suffix_from_opsize(opsize)); + snprintf(node.arguments, kArgsBufferSize, "%s,%s", src_str, dst_str); + node.size = kInstructionSizeStepBytes + src.Size() + dst.Size(); } static inline void disasm_adda( @@ -93,7 +93,16 @@ run_test_iterative() { done } -# 4xxx adda +# dxxx addx +# +run_test_simple "addxb Dn, Dn" "\xd1\x00" +run_test_simple "addxw Dn, Dn" "\xd3\x47" +run_test_simple "addxl Dn, Dn" "\xd5\x86" +run_test_simple "addxb -(An), -(An)" "\xd1\x08" +run_test_simple "addxw -(An), -(An)" "\xd3\x4f" +run_test_simple "addxl -(An), -(An)" "\xd5\x8e" + +# dxxx adda # run_test_simple "addaw Dn, An" "\xd4\xc1" run_test_simple "addal An, An" "\xdb\xca" @@ -101,7 +110,7 @@ run_test_simple "addaw (An)+, An" "\xdb\xda" run_test_simple "addaw #imm, An" "\xda\xfc\x01\x00" run_test_simple "addal #imm, An" "\xdb\xfc\x80\x00\x00\x00" -# 4xxx add +# dxxx add # run_test_simple "addb Dn, Dn" "\xd4\x01" run_test_expect_short "addb An, Dn" "\xd4\x09" |