From a421dc4262d602728c562876e67129cb2fc3a741 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 26 Jul 2026 08:30:08 +0000 Subject: capstone prints thumb add/sub sp+immediate as two operands --- differential-tests/tests/differential-v7-thumb.rs | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/differential-tests/tests/differential-v7-thumb.rs b/differential-tests/tests/differential-v7-thumb.rs index aff45cb..835604e 100644 --- a/differential-tests/tests/differential-v7-thumb.rs +++ b/differential-tests/tests/differential-v7-thumb.rs @@ -528,6 +528,31 @@ fn capstone_differential_thumb() { return true; } } + + // capstone prints the T2 encoding of `ADD (SP plus immediate)` with + // two operands instead of the three from the manual. + if word & 0xff80 == 0xb000 && + parsed_yax.opcode == "add" && + parsed_cs.opcode == "add" && + parsed_yax.operands[0] == parsed_cs.operands[0] && + parsed_yax.operands[0] == parsed_yax.operands[1] && + parsed_cs.operands[1] == parsed_yax.operands[2] { + return true; + } + } + + if (parsed_yax.opcode == "sub" && + parsed_cs.opcode == "sub") { + // capstone prints the T1 encoding of `SUB (SP minus immediate)` with + // two operands instead of the three from the manual. + if word & 0xff80 == 0xb080 && + parsed_yax.opcode == "sub" && + parsed_cs.opcode == "sub" && + parsed_yax.operands[0] == parsed_cs.operands[0] && + parsed_yax.operands[0] == parsed_yax.operands[1] && + parsed_cs.operands[1] == parsed_yax.operands[2] { + return true; + } } // TODO: yaxpeax-arm doesn't know about armv8-m yet, which gets `bxns` to -- cgit v1.1