程式語言 - GNU - Assembly (x86) - Hello, world!(printf)



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

main.s

    .global main
    .extern printf
 
    .data
msg: .asciz "hello, world!\n"
 
    .text
main:
    push %ebp
    mov %esp, %ebp
   
    push $msg
    call printf 
    xor %eax, %eax

    mov %ebp, %esp
    pop %ebp
    ret

編譯、執行

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