summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-05-20 18:33:40 +0300
committerOxore <oxore@protonmail.com>2023-05-20 18:33:40 +0300
commit25bf809a867720399cf12f8c0efec86eaeec26c5 (patch)
tree18abcb06422e3605e40bb8eed9d9bb716f66592e
parent1a9089d41233b3b7b207e9a7e8553dc5b14e92ae (diff)
Impl marks referencing for PEA and NBCD
-rw-r--r--disasm.cpp8
-rw-r--r--test_marks_referencing.bash8
-rw-r--r--test_random.bash8
3 files changed, 22 insertions, 2 deletions
diff --git a/disasm.cpp b/disasm.cpp
index 4d965fd..8be3058 100644
--- a/disasm.cpp
+++ b/disasm.cpp
@@ -927,14 +927,22 @@ static size_t disasm_nbcd_swap_pea(DisasmNode &node, const uint16_t instr, const
break;
case AddrMode::kD16AnAddr:
case AddrMode::kD8AnXiAddr:
+ break;
case AddrMode::kWord:
case AddrMode::kLong:
+ node.ref1_addr = static_cast<uint32_t>(arg.lword);
+ node.ref_kinds = kRef1AbsMask | kRef1ReadMask;
break;
case AddrMode::kD16PCAddr:
case AddrMode::kD8PCXiAddr:
if (is_nbcd) {
return disasm_verbatim(node, instr);
}
+ if (arg.mode == AddrMode::kD16PCAddr) {
+ node.ref1_addr = node.offset + kInstructionSizeStepBytes +
+ static_cast<uint32_t>(arg.d16_pc.d16);
+ node.ref_kinds = kRef1RelMask | kRef1ReadMask;
+ }
break;
case AddrMode::kImmediate:
return disasm_verbatim(node, instr);
diff --git a/test_marks_referencing.bash b/test_marks_referencing.bash
index db5691d..f7dc40f 100644
--- a/test_marks_referencing.bash
+++ b/test_marks_referencing.bash
@@ -92,7 +92,11 @@ run_test_rdisp "braw .+2" "\x4e\x71\x60\x00\x00\x00"
run_test_rword "moveml 0x0:w,%d0" "\x4c\xf8\x00\x01\x00\x00"
run_test_rword "moveml 0x6:w,%a0" "\x4c\xf8\x01\x00\x00\x06\x4e\x71\x4e\x71"
run_test_rword "movemw 0x0:l,%a0" "\x4e\x71\x4e\x71\x4c\xb9\x01\x00\x00\x00\x00\x02"
+run_test_rpcrel "movemw (0,PC),%a0" "\x4e\x71\x4e\x71\x4c\xba\x01\x00\x00\x00"
run_test_rpcrel "lea (0,PC)" "\x47\xfa\x00\x00"
run_test_rpcrel "jmp (0,PC)" "\x4e\xfa\x00\x00"
-run_test_rpcrel "movemw (0,PC),%a0" "\x4e\x71\x4e\x71\x4c\xba\x01\x00\x00\x00"
-run_test_rword "movew 0x0:w,0x2:w" "\x4e\x75\x4e\x76\x31\xf8\x00\x00\x00\x02"
+run_test_rword "peal 0x0:w" "\x48\x78\x00\x00"
+run_test_rword "peal 0x0:l" "\x48\x79\x00\x00\x00\x00"
+run_test_rpcrel "peal (0,PC)" "\x48\x7a\x00\x00"
+run_test_rword "nbcd 0x0:w" "\x48\x38\x00\x00"
+run_test_rword "nbcd 0x6:l with nop" "\x48\x39\x00\x00\x00\x06\x4e\x71"
diff --git a/test_random.bash b/test_random.bash
index 094dad1..daf5a5b 100644
--- a/test_random.bash
+++ b/test_random.bash
@@ -46,10 +46,18 @@ run_test_random() {
fi
}
+# Tiny tests are mostly for ensuring that bounds checking is working properly,
+# because it is more likely to encounter something that looks like a truncated
+# instruction.
+#
+# If there is an obvious bug, then it will most likely be detected
+# here and it is easier to dissect tiny test blob than huge test trying to debug
+# single test case.
for i in `seq 1 1000`; do
run_test_random tiny$i 1
done
+# Huge tests are for the broad coverage. They catch a lot!
for i in `seq 1 10`; do
run_test_random huge$i 1024
done