I made a program that reads a string and converts it into a number. A string representation of the number entered in the decimal system. The result of of converting is in re
You could, for example, extend your multiplication by 10 from 16 to 32 bits like this:
; file: mul32ten.asm
; compile: nasm.exe mul32ten.asm -f bin -o mul32ten.com
bits 16
org 0x100
xor dx, dx
xor ax, ax
mov si, MyStr
NextDigit:
mov bl, [si]
or bl, bl
je Done
call MulDxAxBy10
sub bl, '0'
add al, bl
adc ah, 0
adc dx, 0
inc si
jmp NextDigit
Done:
; dx:ax should be equal to 7FFFFFFF now
ret
MulDxAxBy10:
push si
push di
shld dx, ax, 1
shl ax, 1 ; dx:ax = n * 2
mov si, ax
mov di, dx ; di:si = n * 2
shld dx, ax, 2
shl ax, 2 ; dx:ax = n * 8
add ax, si
adc dx, di ; dx:ax = n * 8 + n * 2 = n * (8 + 2) = n * 10
pop di
pop si
ret
MyStr db "2147483647", 0