From 0b4ce1210eb90aa370d286390c8566f2bee133bd Mon Sep 17 00:00:00 2001 From: Grond Date: Wed, 24 Jun 2026 14:58:13 -0700 Subject: Do not add an 's' when outputing opcodes that always set flags --- src/armv7/display.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/armv7/display.rs b/src/armv7/display.rs index 29d3ed6..0e909f6 100644 --- a/src/armv7/display.rs +++ b/src/armv7/display.rs @@ -55,8 +55,18 @@ impl Instruction { unsafe { f.write_lt_8(opc.name())?; } + // test/compare instructions always set flags and are consequently encoded with bit 20 set + // as most other instructions that sets flags are. because these instructions + // unconditionally set flags, though, their mnemonic skips the `s` suffix. if self.s() { - f.write_char('s')?; + let always_sets_flags = + *opc == Opcode::CMP || + *opc == Opcode::CMN || + *opc == Opcode::TST || + *opc == Opcode::TEQ; + if !always_sets_flags { + f.write_char('s')?; + } } if self.w() { f.write_fixed_size(".w")?; -- cgit v1.1