From Zero to Hello World: My First Steps into x86 Assembly Language (64-bit)

64-bit Version

RegisterPurpose in Our ProgramWhy this specific register?
RAXHolds the syscall numberConvention: First argument for syscalls
RDIHolds file descriptor (stdout=1)Syscall argument #1
RSIHolds address of the stringSyscall argument #2
RDXHolds length of the stringSyscall argument #3
RDIHolds exit code (used again)Syscall argument #1 for exit

These are part of the System V ABI (the standard calling convention on Linux 64-bit).


32-bit Version (The First One)

RegisterPurposeWhy?
EAXSyscall numberOld convention
EBXFile descriptor / Exit codeOld convention
ECXAddress of stringOld convention
EDXLength of stringOld convention

Quick Summary: Why These Registers?

  • In 32-bit (old way): Linux used EAX, EBX, ECX, EDX in that order for system calls.
  • In 64-bit (new way): Linux uses RAX, RDI, RSI, RDX, R10, R8, R9 in that order.

This is not random — it’s a standard agreement between the kernel and programs so the operating system knows where to find the parameters.


General Purpose Registers (64-bit)

You will see these often:

  • RAX, RBX, RCX, RDX → General workhorses
  • RDI, RSI → Often used for strings / function arguments
  • RBP, RSP → Base pointer and Stack pointer
  • R8–R15 → Extra general registers