This code below takes in an two digit number (let's say 12) in ASCII and should return this number as the number 12. (NOT ASCII)
mov $IBUFF, %eax # IBUFF stores the ASCII number 12
movl $NUMBER, %ecx # NUMBER will i put the number 12 (NO ASCII)
movb (%eax), %bl # Moves the first byte (1) to %bl
subb $48, %bl # Decrease %bl so it is not longer a ASCII sign.
movb %bl, (%ecx) # Moves this byte into the first place in NUMBER
inc %eax # Increase IBUFF so it points to the next integer
inc %ecx # Increase NUMBER so it points to the next empty space
movb (%eax), %bl # Same as above
subb $48, %bl # Same as above
movb %bl, (%ecx) # Same as above
mov NUMBER, %eax # Move the number 12 from NUMBER to %eax (return register)
When i run this code the return value is 513, not 12. What am i doing wrong?