程式語言 - Netwide Assembler (NASM) - Assembly (x86) - Hello, world!(printf)



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

main.s

    global main
    extern printf
 
    section .data
msg db "hello, world!", 10, 0
 
    section .text
main:
    push ebp
    mov ebp, esp
   
    push msg
    call printf 
    xor eax, eax

    mov esp, ebp
    pop ebp
    ret

編譯、執行

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