AT&T syntax

Sections

Section definition starts with . symbol

symbol Main routine defines with .globl instead global as we do it in nasm

Operands order

mov destination, source

mov source, destination

Size of operands and operation syntax

b - 1 byte operands

w - 2 bytes operands

l - 4 bytes operands

q - 8 bytes operands

t - 10 bytes operands

o - 16 bytes operands

Memory access

Jumps

lcall $section, $offset

Far jump--A jump to an instruction located in a different segment than the current code segment but at the same privilege level, sometimes referred to as an intersegment jump.

Comments

# - single line comments

// - single line comments

/* */ - for multiline comments

Conclusion

It is sixth part ofand here we will look on AT&T assembler syntax. Previously we used nasm assembler in all parts, but there are some another assemblers with different syntax, fasm yasm and others. As i wrote above we will look on gas (GNU assembler) and difference between it's syntax and nasm. GCC uses GNU assembler, so if you see at assembler output for simple hello world:You will see following output:Looks different then nasm, let's look on some differences.I don't know how about you, but when I start to write assembler program, usually I'm starting from sections definition. Let's look on simple example:You can note two little differences here:Also gas uses another directives for data defintion:When we write assembler program with nasm, we have following general syntax for data manipulation:With GNU assembler we have back order i.e.:For example:Also you can not here that registers starts withsymbol. If you're using direct operands, need to usesymbol:Sometimes when we need to get part of memory, for example first byte of 64 register, we used following syntax:There is another way for such operations in gas. We don't define size in operands but in instruction:GNU assembler has 6 postfixes for operations:This rule is not onlyinstruction, but also for all another like addl, xorb, cmpw and etc...You can note that we usedbrackets in previous example insteadin nasm example. To dereference values in parentheses are used GAS:, for example:GNU assembler supports following operators for far functions call and jumps:GNU assembler supports 3 types of comments:It was a sixth part of series 'say hello to x64 assembly'. Of course here described not of all differences between Intel and AT&T syntax, but it's good start to not see at AT&T code as on foreign language if you already know nasm. if you will have a questions/suggestions write me a comment or ping me at twitter for discussing. If you're interesting in some additional themes about assembly and x86_64 programming write me a comment and I will try to write blog post about it in near time.All another parts you can find - here All source code you can find as every time - here English is not my first language, so you'll find mistakes in blog post please write me in comments or drop me email