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



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

main.s

    .global _start
    
    .data
msg: .ascii "hello, world!\n"
len = . - msg
 
    .text
_start:
    mov $1, %rax
    mov $1, %rbx
    mov $msg, %rcx
    mov $len, %rdx
    int $0x80

    mov $60, %rax
    mov $0, %rbx
    int $0x80

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

編譯、執行

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