In this code the user is asked to supply a number.
Once they do so the number should be incremented by 1.
This code works when you hard code the value of the number on line 11 (movq $number , %rsi
).
If I replace "$Number" with an actual digit like "$5" for example the code will print out the value +1 so in this case '6', but it doesn't seem to work, can someone advise what i am doing wrong? /////////////////////////////////////////////////////////////////// updated code //////////////////////////////////////////////////////////// now works if user input is between 0-9 however errors start if input value > 10
.data
number: .skip 8
.text
mystring: .asciz "Your number +1 is = %d"
.global main
main:
call _getNumber
movq $0 , %rax
movq number, %rsi
sub $2608, %rsi
inc %rsi
movq $mystring, %rdi
call printf
ret
_getNumber: #sub routine to take number from the user
movq $0, %rax #set to 0 for input
movq $0, %rdi
movq $number, %rsi
movq $8, %rdx
syscall
ret