程式語言 - Flat Assembler (FASM) - Assembly (x86) - Hello, world!(printf)



參考資訊:
https://board.flatassembler.net/index.php
https://tldp.org/HOWTO/Assembly-HOWTO/hello.html
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md

main.s

    format elf
    public main
    extrn 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

編譯、執行

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