程式語言 - Netwide Assembler (NASM) - Assembly (x64) - Hello, world!(int 0x80)



參考資訊:
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md

System Call

NRsyscall nameraxarg0(rbx)arg1(rcx)arg2(rdx)
1write1unsigned int fdconst char *bufsize_t count
60exit60int error_code

main.s

    global _start

    section .data
msg db "hello, world!", 10
len equ $ - msg

    section .text
_start:
    mov rax, 1
    mov rbx, 1
    mov rcx, msg
    mov rdx, len
    int 0x80
     
    mov rax, 60
    mov rbx, 0
    int 0x80

編譯、執行

$ nasm -f elf64 main.s
$ x86_64-linux-gnu-gcc main.o -o main -nostdlib -static
$ qemu-x86_64 ./main
    hello, world!