-2

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!

Dan
  • 139
  • 1
  • 8
  • 1
    I updated the [AT&T tag wiki](https://stackoverflow.com/tags/att/info) with info like this on AT&T syntax, and a link to a good canonical duplicate. – Peter Cordes Nov 18 '17 at 18:05

1 Answers1

1

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.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299