Jan Helbling's Site

x86_64 Assembly Linux

Introduction

Hi! This is a small and practical introduction to x86_64 assembly on Linux. The focus is on understanding how syscalls work at a low level – no C runtime, no main, direct kernel interaction.


x86_64 Assembly Basics

On x86_64 Linux, system calls use CPU registers such as:

Syscalls are executed using the syscall instruction.


Hello World in x86_64 Assembly

section .data
msg db 'Hello World', 0x0a
msglen equ $ - msg

section .text
global _start

_start:
    mov rax, 1      ; write syscall
    mov rdi, 1      ; stdout
    mov rsi, msg    ; buffer
    mov rdx, msglen ; length
    syscall

    mov rax, 60     ; exit syscall
    mov rdi, 0      ; status
    syscall

Build & Run

nasm -f elf64 hello.asm -o hello.o
ld hello.o -o hello
./hello

References