5
votes

GNU assembler appears to have some means of controlling the alternative forms of the opcode being emitted for some instructions. E.g.

.intel_syntax noprefix
mov   eax, ecx
mov.s eax, ecx

Processing the above code with as test.s -o test.o && objdump -d test.o -M intel gives the following disassembly:

0:   89 c8                   mov    eax,ecx
2:   8b c1                   mov    eax,ecx

We can see that .s suffix appears to switch 89 opcode to the 8b version (and appropriately change the ModRM byte).

How does this syntax work in GAS? I can't find any relevant documentation.

1
As worded, this is technically off topic because you're asking for a link to docs instead of directly asking for more details about how they work. (Which you could do in a way that would make a summary + link to docs a good answer). Anyway, good question, it should stay open even though it bends the rules, IMO.Peter Cordes
@Mogsdad: rephrased it to be on-topic, and voted to reopen.Peter Cordes

1 Answers

3
votes

As of Binutils 2.29 the instruction suffixes are now deprecated in favor of pseudo-prefixes. You can find the older suffixes documented in the GNU Assembler (pre-2.29) info pages. Earlier info as pages say this:

9.15.4.1 Instruction Naming

[snip]

Different encoding options can be specified via optional mnemonic suffix. .s suffix swaps 2 register operands in encoding when moving from one register to another. .d8 or .d32 suffix prefers 8bit or 32bit displacement in encoding.

Documenting the new pseudo prefixes, Binutils 2.29 (and later) info as pages were revised to read:

Different encoding options can be specified via pseudo prefixes:

  • {disp8} – prefer 8-bit displacement.
  • {disp32} – prefer 32-bit displacement.
  • {load} – prefer load-form instruction.
  • {store} – prefer store-form instruction.
  • {vex2} – prefer 2-byte VEX prefix for VEX instruction.
  • {vex3} – prefer 3-byte VEX prefix for VEX instruction.
  • {evex} – encode with EVEX prefix.