Lesson 2 of 13 · 22m
Reading x86-64 Without Panicking
Fifteen instructions plus the SysV calling convention cover most of real disassembly — the rest is recognizing compiler idioms like lea arithmetic, endbr64, and reciprocal division.
You do not need the 5,000-page Intel manual. Compiled x86-64 uses a small vocabulary obsessively — a dozen instructions cover ninety percent of what a disassembler shows you. The wrong mental model is "learn the ISA." The manual is a reference, not a teacher. What you need is the working vocabulary, the calling convention, and the shape of a stack frame — after that, pattern-matching carries the load.
The working vocabulary
mov rax, [rdi+0x18] ; load the value at address rdi+0x18
lea rax, [rdi+0x18] ; compute the address itself, no dereference
push rbp / pop rbp ; save / restore on the stack
call 0x401040 / ret ; call a function / return to caller
cmp eax, 0x2a ; set flags = eax - 0x2a, discard the result
test eax, eax ; flags from eax AND eax — the classic null check
jz / jnz / jl / jge ; conditional jumps on those flags
jmp 0x401050 ; unconditional jump
xor eax, eax ; idiom: zero a register
nop ; do nothing — alignment padding and patch spacelea shows up constantly doing arithmetic in disguise — lea eax, [rdi+rdi*4] is x*5 wearing a trench coat. Compilers love it because it's a one-instruction multiply-add that doesn't touch flags.
Two more that confuse people on sight. movzx/movsxd widen a byte or word into a register — movzx eax, byte [rsi] reads a char; movsxd rax, dword [rbp-0x4] sign-extends a 32-bit int for pointer math. And endbr64, the four-byte nothing that opens almost every function in a modern binary: it's a landing-pad marker for CET indirect-branch protection (-fcf-protection, default on Fedora and recent Debian/Ubuntu builds). As a reader you ignore it; as a patcher you remember it's there.
The System V calling convention
On Linux x86-64, integer arguments go rdi, rsi, rdx, rcx, r8, r9 in order; the return value lands in rax. rbx, rbp, and r12–r15 are callee-saved — when a prologue pushes them, the function intends to use them and will restore them on the way out. This one fact lets you read any call site instantly: the register loads immediately before it are the arguments. One alignment fact worth internalizing now: rsp stays 16-byte aligned at every call. The ABI demands it, and SSE spills like movaps [rsp+0x20], xmm0 fault on a misaligned stack — which is why hand-written assembly that calls printf on a sloppily-aligned stack crashes inside libc, not in your code.
Anatomy of a function
push rbp
mov rbp, rsp ; establish frame pointer
sub rsp, 0x30 ; reserve 48 bytes of locals
mov [rbp-0x14], edi ; first arg stored into a local
mov [rbp-0x20], rsi ; second arg (looks like a pointer)
...
mov eax, [rbp-0x14] ; compute return value into rax
leave ; = mov rsp,rbp ; pop rbp
ret[rbp-0x14] is a local variable — Ghidra will name it local_14. Count the locals, watch which get written versus only read, and the function's working memory maps itself.
A leaf function — one that calls nothing — often skips sub rsp entirely and spills locals into the red zone: the 128 bytes below rsp the System V ABI guarantees signal handlers won't clobber. Writes to [rsp-8] and [rsp-0x10] with no frame setup in sight aren't disassembler noise; they're a leaf function's locals.
Idioms the compiler won't stop using
- Division by constant becomes multiplication.
x / 10at-O2compiles toimulby0xCCCCCCCDfollowed by a shift right — the reciprocal magic number. When you see a bizarre multiply-and-shift where you expecteddiv, that's division, recovered. rep movs/rep stos—memcpyandmemsetinlined in place.cdqe— sign-extendeaxintorax; usually means anintis about to index a pointer.- The magic XOR.
xor eax, eaxis the canonical zero: two bytes againstmov eax, 0's five, and the CPU recognizesxor r,rat the register renamer as a zeroing idiom — no execution unit, and no dependency on the register's old value, so the chain can't stall. It sets flags (ZF goes to 1, CF and OF clear);mov eax, 0survives as the encoding chosen precisely when the previous compare's flags must live on.
Two syntaxes, one machine
GDB defaults to AT&T order (mov %rdi,%rax — source first); Ghidra, IDA, and x64dbg show Intel order (mov rax,rdi — destination first). One-time fix: set disassembly-flavor intel, preferably in ~/.gdbinit so you never see AT&T again.
Field notes
test eax,eax+jzis a zero/null check;cmpfollowed byjae/jbmeans the source compared unsigned,jge/jlmeans signed — the jump mnemonic preserves type information the decompiler will guess at.- Windows x64 uses a different convention:
rcx, rdx, r8, r9, plus 32 bytes of caller-reserved shadow space below the return address. Know which world your binary lives in. - At
-O2, frame pointers are usually omitted — locals become[rsp+...]and their offsets shift asrspmoves through the function. Same concept, harder to track by eye; this is where the decompiler earns its keep.
Keep reading
Related articles from the SudoSecurity blog.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
Hacktivism, 2021 to Today: From Steel Mills to Power Grids
Part 1 ended on a 70-gigabyte breach in 2021. Since then, hacktivists derailed trains, dumped molten steel on camera, and reached grids in three countries.
What is an Infostealer?
Infostealers are commodity malware that silently harvest credentials, session tokens, and crypto wallets from infected machines. The Lumma Stealer infection that triggered the Vercel breach started with one. Here is how they work and why they are so effective.