https://www.reddit.com/r/Assembly_language/comments/wfse2i/trying_to_convert_an_ascii_to_int/
Here is the part of my code I am struggling with. The algorithm I'm supposed to use is:
Suppose ebx points to the (ASCII) number you just read in.
Zero %eax.
Loop until %cl contains 10 decimal (0a hex).
Move a byte from (%ebx) to %cl.
Subtract 48 decimal (or 30 hex) from %cl. This converts ASCII to an actual number. Multiply %eax by 10 and add %cl.This will build the int.
I'm struggling with the last bit where I'm supposed to multiply and add. From what i've learned to multiply you just put the number you want to multiply it will automatically multiply it by ax or in my case eax, but that doesn't work and I also don't understand How I'm supposed to add a 16 bit register to a 32 bit register. Any ideas? Thanks in advance.
string_end:
. equ
len, string_end - string
.text
.globl
start
start:
movl $WRITE, %eax
movl $STDOUT, %ebx
movl $string, %ecx
movl $len,%edx
int $0x80
movl $READ, %eax
movl $STDIN, %ebx
movl %esp, %ecx
movl $30, %edx
loop:
xor %eax, %eax
incb %cl
cmpb $10, %cl
je done
movb (%ebx), %cl
sub $48, %cl
mull $10
add %cl, %eax
done:
nop