Let's say we got the number "98" stored in %r11, using movzbq i store the first digit "9" in %r12 as ascii. I subtract $48 from ascii to get the integer "9" and store it in %r12. I add %r12 to %r13 to get the value "9" or "0x9" in %r13 Then I multiply %r13 by 10 to get the value "90" stored as "0x5a" Now that %r13 contains "0x5a". I cannot do...
movq %r13, %rdi
call putchar.
as this would print the character "Z" (value 90 in ascii table). How do I go by making it print the number "90" instead?
subq $48, %r12 # Subtract $48 to convert ascii to integer.
add %r12, %r13 # add 9 to %r13
imulq $10, %r13 # multiply by 10
add %r12, %r13 # add to return value
movq %r13, %rdi
call putchar