GNU >> Assembly (x86)

hello, world! (printf)


參考資訊:
1. syscall

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!


返回上一頁