Assembly Language Codex

Low-level programming patterns for x86-64 Linux systems.

Topics

Topic Description

Fundamentals

Registers, memory, addressing modes, basic instructions

Arithmetic & Logic

Math operations, bitwise, comparisons, flags

Stack & Functions

Call conventions, stack frames, local variables

Linux Syscalls

System call interface, common syscalls, error handling

Reverse Engineering

Disassembly patterns, common constructs, analysis

Why Assembly?

Use Case Value

Kernel Development

Understanding kernel code, writing optimized paths

Security Research

Exploit development, malware analysis, CTF challenges

Performance

Identifying bottlenecks, understanding compiler output

Debugging

Reading crash dumps, understanding segfaults

Tools

Tool Purpose

objdump -d

Disassemble binaries

gdb

Debug at instruction level

strace

Trace syscalls

ltrace

Trace library calls

nasm

Netwide Assembler

gcc -S

Generate assembly from C

Quick Reference

Registers (x86-64)

RAX, RBX, RCX, RDX    - General purpose (64-bit)
RSI, RDI              - Source/Destination index
RSP, RBP              - Stack/Base pointer
R8-R15                - Additional general purpose
RIP                   - Instruction pointer
RFLAGS                - Status flags

Calling Convention (System V AMD64)

Arguments: RDI, RSI, RDX, RCX, R8, R9 (then stack)
Return:    RAX (and RDX for 128-bit)
Callee-saved: RBX, RBP, R12-R15
Caller-saved: RAX, RCX, RDX, RSI, RDI, R8-R11