Skip to content

x86: Add has_address_size_prefix to Instruction#802

Open
mattst88 wants to merge 3 commits into
icedland:masterfrom
mattst88:has-address-size-prefix
Open

x86: Add has_address_size_prefix to Instruction#802
mattst88 wants to merge 3 commits into
icedland:masterfrom
mattst88:has-address-size-prefix

Conversation

@mattst88

@mattst88 mattst88 commented Jun 12, 2026

Copy link
Copy Markdown

Summary

  • Add has_address_size_prefix bit (bit 20 of flags1) to Instruction with getter/setter
  • Set it in the decoder when a 0x67 prefix appears on an instruction with no memory operand
  • Emit 0x67 in write_prefixes() when the bit is set

Before this change, 0x67 on a non-memory instruction was silently discarded by the decoder, breaking round-trip encode/decode. NASM can reproduce the byte (a32 nop67 90), so this fix enables NASM-text round-tripping for such instructions.

Test plan

  • cargo test -p iced-x86 passes
  • Encoder round-trip: decode 67 90 (32-bit), re-encode → 67 90

mattst88 added 3 commits June 12, 2026 09:34
Track whether the original encoding contained a 0x67 address-size prefix
that had no semantic effect (i.e. the instruction has no memory
operand). Backed by a free bit (bit 20) in InstrFlags1::flags1,
following the same pattern as has_lock_prefix.
…0x67

OpCodeHandler_Prefix67 flips the address size and delegates to the real
opcode handler. If the decoded instruction has no memory operand of any
kind (OpKind >= MemorySegSI), the 0x67 byte had no semantic effect and
was previously silently discarded. Record it via has_address_size_prefix
so the encoder and formatters can reproduce the original bytes.
Extend write_prefixes() to emit the address-size prefix byte when
instruction.has_address_size_prefix() is true, in addition to the
existing EncoderFlags::P67 path that handles memory operands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant