Netwide Assembler (NASM) >> Assembly (x64)

hello, world! (printf)


參考資訊:
1. syscall

main.s

    global main
    extern printf
  
    section .data
msg db "hello, world!", 10, 0
  
    section .text
main:
    push rbp
    mov rbp, rsp
    
    mov rdi, msg
    call printf
    xor rdi, rdi
 
    mov rsp, rbp
    pop rbp
    ret

編譯、執行

$ nasm -f elf64 main.s
$ x86_64-linux-gnu-gcc main.o -o main -static
$ qemu-x86_64 ./main
    hello, world!


返回上一頁