GNU >> Assembly (x64)

hello, world! (syscall)


參考資訊:
1. syscall
2. how-to-use-sysenter-under-linux

main.s

    .global _start

    .data
msg: .ascii "hello, world!\n"
len = . - msg

    .text
_start:
    mov $1, %rax
    mov $1, %rdi
    mov $msg, %rsi
    mov $len, %rdx
    syscall

    mov $60, %rax
    xor %rdi, %rdi
    syscall

NRsyscall nameraxarg0(rdi)arg1(rsi)arg2(rdx)
1write1unsigned int fdconst char *bufsize_t count
60exit60int error_code

編譯、執行

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


返回上一頁