Before you write a single instruction you have to pick a dialect. The same machine code can be written two ways — Intel syntax and AT&T syntax — and they look different enough that reading one when you expect the other is genuinely confusing. This course writes Intel, but you will see AT&T constantly, so you need to recognize both.
They describe the exact same instructions; they just disagree on how to spell them. Three differences account for almost everything you will notice:
mov dest, src). AT&T puts it last (mov src, dest). This one trips people up the most — the same line means opposite things depending on dialect.% (%rax) and immediate values get a $ ($1). Intel writes them bare (rax, 1).movq (quad, 8 bytes), movl (long, 4 bytes). Intel infers the size from the registers involved, or you state it with a keyword like qword.Memory operands differ too: Intel brackets them ([rax]), AT&T parenthesizes ((%rax)), and a scaled index like [rbx + rcx*4] becomes (%rbx, %rcx, 4).
Intel syntax is what NASM assembles, what the Intel manuals use, and — in most people's experience — the easier of the two to read: destination-first matches how we say it out loud ("move 1 into rax"), and the lack of sigils keeps lines short. Every snippet we write in this course is Intel.
The catch: the default tools emit AT&T. gdb and objdump both disassemble to AT&T unless you tell them otherwise, and plenty of tutorials and references are written in it. You do not have to write AT&T, but you must be able to read it, because the moment you debug or disassemble something you will be staring at it.
This is not academic. Take the hello.asm we assemble in the next lesson and disassemble it. Ask objdump for Intel and you get back what we wrote:
objdump -d -M intel hello0000000000401000 <_start>: 401000: b8 01 00 00 00 mov eax,0x1 401005: bf 01 00 00 00 mov edi,0x1 40100a: 48 be 00 20 40 00 00 movabs rsi,0x402000 401011: 00 00 00 401014: ba 0e 00 00 00 mov edx,0xe 401019: 0f 05 syscall 40101b: b8 3c 00 00 00 mov eax,0x3c 401020: bf 00 00 00 00 mov edi,0x0 401025: 0f 05 syscallDrop the -M intel and the exact same bytes come back in AT&T — operands reversed, registers and immediates wearing their sigils:
objdump -d hello0000000000401000 <_start>: 401000: b8 01 00 00 00 mov $0x1,%eax 401005: bf 01 00 00 00 mov $0x1,%edi 40100a: 48 be 00 20 40 00 00 movabs $0x402000,%rsi 401011: 00 00 00 401014: ba 0e 00 00 00 mov $0xe,%edx 401019: 0f 05 syscall 40101b: b8 3c 00 00 00 mov $0x3c,%eax 401020: bf 00 00 00 00 mov $0x0,%edi 401025: 0f 05 syscallSame program, same machine code, two spellings. Being able to glance at either and know what it does is the baseline skill for everything that follows.
For quick reference, here is one instruction in both syntaxes. This is also the tab convention the rest of the course uses for assembly snippets:
1mov rax, 1
2mov rdi, [rbx + rcx*8]Read them against the three rules above: the order flips, the % and $ sigils appear, and the q suffix spells out the size that Intel left implicit.
set disassembly-flavor intel (put it in your ~/.gdbinit to make it permanent). The Debugging Assembly lesson assumes you have.