syscall指令_linux汇编:如何调用syscall?

  • Post author:
  • Post category:linux


要在64位Linux中进行系统调用,请将系统调用号放在rax中,然后将其参数按顺序放在rdi,rsi,rdx,r10,r8和r9中,然后调用syscall.

这是一个例子

.global _start

.text

_start:

# write(1, message, 13)

mov $1, %rax # system call 1 is write

mov $1, %rdi # file handle 1 is stdout

mov $message, %rsi # address of string to output

mov $13, %rdx # number of bytes

syscall

# exit(0)

mov $60, %rax # system call 60 is exit

xor %rdi, %rdi # return code 0

syscall

message:

.ascii “Hello, World\n”



版权声明:本文为weixin_36468140原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。