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



參考資訊:
https://tldp.org/HOWTO/Assembly-HOWTO/hello.html
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 $4, %eax
    mov $1, %ebx
    mov $msg, %ecx
    mov $len, %edx
    int $0x80
  
    mov $1, %eax
    mov $0, %ebx
    int $0x80

NRsyscall nameeaxarg0(ebx)arg1(ecx)arg2(edx)
1exit1int error_code
4write4unsigned int fdconst char *bufsize_t count

編譯、執行

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