1

I am trying to print single characters to STDOUT using syscalls, however it is giving me a segfault. The following code is part of a larger program which also uses syscall and rdi to print out regular strings. It prints out "I am" and then I want to print 17 for example. Forgive me, I am very new to assembly.

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

0 Answers0