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



參考資訊:
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
https://teaching.basilico.di.unimi.it/lib/exe/fetch.php/pub/debian-mips-tutorial.pdf

main.s

    .global main
    .extern printf

    .data
msg: .asciz "hello, world!\n"

    .text
main:
    subu $sp, $sp, 4
    sw $ra, 0($sp)

    la $a0, msg
    jal printf

    lw $ra, 0($sp)
    addiu $sp, $sp, 4
    jr $ra

編譯、執行

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