我正在尝试使用syscalls将单个字符打印到STDOUT,但这给我一个段错误。以下代码是一个较大程序的一部分,该程序也使用syscall和rdi打印常规字符串。它打印出“我是”,然后例如要打印17。原谅我,我是新来的。
movq $1, %rax #sysout
movq $1, %rdi #stdout
movq $'1', (%rsi) #move char 1 to rsi
movq $1, %rdx #move counter(length of string) to rdx (next argument of syscall)
syscall #syscall (print)
movq $1, %rax #sysout
movq $1, %rdi #stdout
movq $'9', (%rsi) #move char 9 to rsi
movq $1, %rdx #move counter(length of string) to rdx (next argument of syscall)
syscall #syscall (print)
movq $60, %rax # system call 60 is sys exit
movq $0, %rdx # normal exit: 0
syscall