summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-05-01 01:31:21 +0300
committerOxore <oxore@protonmail.com>2023-05-01 01:31:21 +0300
commitc04ca8aab1ad9811372738113cfb5365ec056516 (patch)
tree7ef70f38ddeaf26e6390a1b6064b4d9c23d44db2
parentd38bdcabf534e2c639299f3a8fff8b9e048bbaf4 (diff)
Impl MOVEQ
-rw-r--r--disasm.cpp19
-rw-r--r--disasm.h1
-rw-r--r--test.bash8
-rw-r--r--test_random.bash8
4 files changed, 28 insertions, 8 deletions
diff --git a/disasm.cpp b/disasm.cpp
index df7f16a..7dac5ff 100644
--- a/disasm.cpp
+++ b/disasm.cpp
@@ -796,10 +796,23 @@ static void chunk_mf000_v5000(DisasmNode& n, uint16_t instr, const DataBuffer &c
return disasm_addq_subq(n, instr, c, s, opsize);
}
-static void disasm_moveq(DisasmNode& n, uint16_t i, const DataBuffer &c, const Settings &s)
+static void disasm_moveq(DisasmNode& node, uint16_t instr, const DataBuffer &code, const Settings &s)
{
- // TODO
- return disasm_verbatim(n, i, c, s);
+ if (instr & 0x100) {
+ // Does not exist
+ return disasm_verbatim(node, instr, code, s);
+ }
+ const int m = 0;
+ const int xn = (instr >> 9) & 7;
+ const auto dst = AddrModeArg::Fetch(node.offset + kInstructionSizeStepBytes, code, m, xn, 'w');
+ assert(dst.mode == AddrMode::kDn);
+ char dst_str[32]{};
+ dst.SNPrint(dst_str, sizeof(dst_str));
+ snprintf(node.mnemonic, kMnemonicBufferSize, "moveq");
+ const int8_t data = instr & 0xff;
+ snprintf(node.arguments, kArgsBufferSize, "#%d,%s", data, dst_str);
+ node.size = kInstructionSizeStepBytes + dst.Size();
+
}
static void chunk_mf000_v8000(DisasmNode& n, uint16_t i, const DataBuffer &c, const Settings &s)
diff --git a/disasm.h b/disasm.h
index 017a8bc..5d2a9ae 100644
--- a/disasm.h
+++ b/disasm.h
@@ -15,7 +15,6 @@ constexpr size_t kRefsCountPerBuffer = 10;
constexpr size_t kMnemonicBufferSize = 8;
constexpr size_t kArgsBufferSize = 80;
-constexpr size_t kMarkBufferSize = 64;
enum class ReferenceType {
kUnknown = 0,
diff --git a/test.bash b/test.bash
index 5d282e8..c95d3ad 100644
--- a/test.bash
+++ b/test.bash
@@ -62,6 +62,14 @@ run_test_iterative() {
done
}
+# 70xx / 72xx/ 74xx / 76xx / 78xx / 7axx / 7cxx / 7exx
+#
+run_test_simple "moveq #0 to D0" "\x70\x00"
+run_test_simple "moveq #1 to D2" "\x74\x01"
+run_test_simple "moveq #127 to D7" "\x7e\x7f"
+run_test_simple "moveq #-1 to D5" "\x7a\xff"
+run_test_simple "moveq #-128 to D1" "\x72\x80"
+
# From random tests
#
run_test_simple "movel %pc@(-16,%a0:l),%a3@+ with nop" "\x26\xfb\x88\xf0\x4e\x71"
diff --git a/test_random.bash b/test_random.bash
index 07403fe..20de9cd 100644
--- a/test_random.bash
+++ b/test_random.bash
@@ -46,10 +46,10 @@ run_test_random() {
fi
}
-for i in `seq 1 10`; do
- run_test_random huge$i 1024
-done
-
for i in `seq 1 1000`; do
run_test_random tiny$i 1
done
+
+for i in `seq 1 10`; do
+ run_test_random huge$i 1024
+done