x86-64 FASM Assembly Documentation#

Welcome to the documentation for my x86-64 assembly projects written in FASM (Flat Assembler).

Documentation:

Quick Start#

For new users:

  1. Setup: Follow X to install FASM

  2. Basics: Clearing registers X

About FASM & x86-64#

FASM (Flat Assembler) is a fast, self-hosting assembler for x86 and x86-64 architectures.

Key Features: - Pure assembly - no linker needed - Multi-pass optimization - Powerful macro system - Direct output to binary/executable formats - Cross-platform (Windows, Linux, macOS)

x86-64 Specifics: - 64-bit registers (RAX, RBX, RCX, RDX, RSI, RDI, RBP, RSP, R8-R15) - 64-bit memory addressing - SSE/AVX extensions available

Example: Hello World in FASM#

 1format ELF64 executable 3
 2entry start
 3
 4segment readable executable
 5
 6start:
 7    mov     rax, 1          ; sys_write
 8    mov     rdi, 1          ; stdout
 9    lea     rsi, [msg]      ; message pointer
10    mov     rdx, msg_len    ; message length
11    syscall
12
13    mov     rax, 60         ; sys_exit
14    xor     rdi, rdi        ; exit code 0
15    syscall
16
17segment readable writeable
18
19msg db 'Hello, x86-64 World!', 0xA
20msg_len = $ - msg

Building with FASM#

Basic compilation:

fasm source.asm output.bin

Basic compilation and linking with nasm 64bit

nasm -f elf64 source.s
ld source.o -o output

For Linux ELF64 executables:

format ELF64 executable 3
; ... your code ...

For Windows PE64 executables:

format PE64 GUI 5.0
; ... your code ...

Resources#

Tips for FASM Development#

Note

FASM uses case-sensitive labels and symbols (unlike MASM).

Warning

Remember that x86-64 uses different calling conventions on Linux (System V ABI) and Windows (x64 calling convention).

Tip

Use FASM’s macro system to create reusable components and simplify complex code.

Indices and Tables#

nah