When we have
add %rbx, %rax
Does this mean add the value of rbx to rax or add the value rax to rbx?
If for example rbx=3 and rax=6, after the add %rbx, %rax, what will be the values of %rax and %rbx?
GNU x64 assembler syntax please!
When we have
add %rbx, %rax
Does this mean add the value of rbx to rax or add the value rax to rbx?
If for example rbx=3 and rax=6, after the add %rbx, %rax, what will be the values of %rax and %rbx?
GNU x64 assembler syntax please!
x86 assembly comes in two major "flavors": Intel syntax and AT&T syntax (used mostly by default by GNU tools).
Your snippet is in AT&T syntax (where register names are prefixed with a %
); in AT&T syntax operands order is generally source, destination, so
add %rbx, %rax
means "add rbx to rax" (i.e., in C it would be rax += rbx
).
This is the opposite of Intel syntax, so if you were to see some snippet in Intel syntax, such as
add rbx, rax
(notice the absence of %
) it would mean "add rax to rbx" (i.e. rbx += rax
).
You can find a nice list of AT&T vs Intel syntax differences here.