Skip to content
Assembly

Hello World via syscall Linux

Un programme x86-64 autonome qui affiche et quitte en n'utilisant que les appels système du noyau.

#syscall#linux#hello-world

Code

assembly
; nasm -f elf64 hello.asm && ld hello.o -o hello && ./hello
section .rodata
    msg:     db "Hello, x86-64!", 10
    msg_len: equ $ - msg

section .text
    global _start

_start:
    ; write(1, msg, msg_len)   syscall #1
    mov     rax, 1          ; write
    mov     rdi, 1          ; fd = stdout
    lea     rsi, [rel msg]  ; buffer (RIP-relative)
    mov     rdx, msg_len
    syscall

    ; exit(0)   syscall #60
    mov     rax, 60
    xor     edi, edi
    syscall