Skip to content
Assembly

Linux 시스콜로 Hello World

커널 시스콜만 사용해 출력하고 종료하는 독립형 x86-64 프로그램.

#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