Netwide Assembler (NASM) >> Assembly (x86)

hello, world! (printf)


參考資訊:
1. syscall

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!


返回上一頁