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



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

System Call

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

main.s

    format elf executable 3
    entry start

    segment readable writeable
msg db "hello, world!", 10
len = $ - msg

    segment readable executable
start:
    mov eax, 4
    mov ebx, 1
    mov ecx, msg
    mov edx, len
    int 0x80
 
    mov eax, 1
    xor ebx, ebx
    int 0x80

編譯、執行

$ qemu-i386 /usr/local/bin/fasm main.s 
$ qemu-i386 ./main
    hello, world!