at&t syntax

Programming, for all ages and all languages.
Post Reply
jinksys

at&t syntax

Post by jinksys »

I learned assembly with nasm using intel syntax, but I like using at&t's
syntax, but something is confusing me...

I know immediate values must be preceded by $, but what is the
difference between

mov   $label,%eax
mov   label,%eax

Also, nasm uses square brackets to return a value from a memory address like:

mov eax,[label]

What is the at&t equivalent of the square brackets?
Schol-R-LEA

Re:at&t syntax

Post by Schol-R-LEA »

For direct addressing, you would use the label with no prefix:

movl label, %eax

BTW, remember to use the size postfixes consistently; unlike in NASM, they are mandatory in GAS (AFAIK).

I've just added a page on AT&T syntax to the OS Developement FAQ, based on a posting I wrote several months ago. HTH.
Post Reply