4

I am trying to match a specific sequence of bytes with GNU assembler. Objdump disassembles these bytes as:

81 e2 66 00 00 00       and    edx,0x66

However, GAS "helpfully" assembles this instruction more efficiently:

83 e2 66                and    edx,0x66

How can I force GAS to use the less efficient 32-bit immediate operand form? I know if I was using NASM, I could use the strict keyword. Is there an equivalent keyword for GNU assembler?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
rtburns
  • 41
  • 2
  • Section [9.16.4](https://sourceware.org/binutils/docs/as/i386_002dMnemonics.html) of the manual might be of help. – fuz Jul 23 '22 at 20:03
  • [This](https://stackoverflow.com/questions/48046814/what-methods-can-be-used-to-efficiently-extend-instruction-length-on-modern-x86) might also be of some help. – sj95126 Jul 23 '22 at 20:03
  • 4
    I tried the {disp32} and {nooptimize} prefixes but they didn't have any effect. They also mention `strict`, which is NASM-specific, and the `b`/`w`/`l`/`q` mnemonic suffixes, which are ATT-specific. Were there other suggestions in those links I've overlooked? – rtburns Jul 23 '22 at 20:29
  • 2
    Probably GAS doesn't have an override for that. Even NASM syntax doesn't AFAIK have a way to round-trip `add al, 1` that uses the 3-byte `add r/m8, imm8` encoding (with modrm) instead of the shorter `add al, imm8` special-case encoding. I seem to recall someone commenting on a previous SO question that they were thinking of developing an asm syntax for x86 that could represent every encoding choice, allowing round-tripping binary to asm and back without change, unless you edit the asm. But I don't remember which post that was on, and IDK if that project ever went anywhere. – Peter Cordes Jul 23 '22 at 22:02

0 Answers0