What is the use of "%" in assembly? For example, sometimes an instruction is written as:
movl %eax, %ebx
and other times it's written as:
movl eax, ebx
(without the percent symbol) what is the difference?
For all assemblers, there's a problem when you need to refer to a symbol that happens to have the same name as a register. For example, if you've got some C code that has the function "int eax()" in it and you link it with some assembly code that does "mov ebx,eax", then the assembler needs to know if "eax" is the register or if it's the function.
To get around that different assemblers do different things. Some (e.g. NASM) would assume "eax" is the register and would require some sort of prefix for ambiguous symbols (e.g. "$eax" to refer to the symbol rather than the register). Others (e.g. GAS) do the opposite and add a prefix to the register name; sometimes even if there's no ambiguity at all (e.g. "%eax" to refer to the register and "eax" to refer to the symbol).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With