What do the dollar ($) and percentage (%) signs represent in x86 assembly?

juliensaad picture juliensaad · Feb 8, 2012 · Viewed 25.2k times · Source

I am trying to understand how the assembly language works for a micro-computer architecture class, and I keep facing different syntaxes in examples:

sub $48, %esp
mov %eax, 32(%esp)

What do these codes mean? What is the 32 operand an addition to the esp register?

Answer

Necrolis picture Necrolis · Feb 8, 2012

Thats not Intel syntax, its AT&T syntax, also called GAS syntax.

the $ prefix is for immediates (constants), and the % prefix is for registers (they are required1).

For more about AT&T syntax, see also the [att] tag wiki.


1 Unless the noprefix option is specified, see here & here. But usually noprefix is only used with .intel_syntax noprefix, to get MASM-like syntax.