What does % mean on register names in assembly language?

Viewed 53

I tried to convert and interpret C language code into assembly language with GCC -S option. What is the difference between push %rbp and push rbp?

1 Answers

Both statements you gave do the same thing, the main difference is in the syntax.
There are 2 major syntax conventions for X86, the Intel convention and the AT&T convention.
See syntax comparison for details.

[UPD:] Just in case, duplicating the syntax information here:

AT&T Intel
Parameter order Source before the destination.
movl $5, %eax
Destination before source.
mov eax, 5
Parameter size Mnemonics are suffixed with a letter indicating the size of the operands: q for qword, l for long (dword), w for word, and b for byte.
addl $4, %esp
Derived from the name of the register that is used (e.g. rax, eax, ax, al imply q, l, w, b, respectively).
add esp, 4
Sigils Immediate values prefixed with a $, registers prefixed with a %. The assembler automatically detects the type of symbols; i.e., whether they are registers, constants or something else.
Effective addresses General syntax of DISP(BASE,INDEX,SCALE).
movl mem_addr(%ebx,%ecx,4), %eax
Arithmetic expressions in square brackets; additionally, size keywords like byte, word, or dword have to be used if the size cannot be determined from the operands.
mov eax, [ebx + ecx*4 + mem_addr]
Related