I am trying to get this code to work, however I keep experiencing problems in the conversion, I tried a bunch of examples that were answers to similar questions, but none of them work, but from it I sort of patched my own version of the code, I think, however it still doesn't work.
org 100h
jmp calc
message db 0dh, 0ah, "Input width. $"
width dw 10,?, 10 dup('?')
w dw 0
calc:
mov dx, offset message
mov ah, 9 ;output message
int 21h
mov dx, offset width
mov ah, 0ah ;read input for width
int 21h
mov dx, width
.next_digit1:
mov cx, width[bx+2]
inc bx
sub cx, '0'
mul w, 10 ;convert width string into a number
add w, cx
loop .next_digit1
mov cx, w
add cx, 100 ; do calculation
mov w, cx
mov ah, 2 ;output the result
int 21h
my biggest problem is that the string to number conversion isn't working, and the other conversion method I tried that was suggested to me here previously:
; Input:
; ESI = pointer to the string to convert
; Output:
; EAX = integer value
string_to_int:
xor ebx,ebx ; clear ebx
.next_digit:
movzx eax,byte[esi]
inc esi
sub al,'0' ; convert from ASCII to number
imul ebx,10
add ebx,eax ; ebx = ebx*10 + eax
loop .next_digit ; while (--ecx)
mov eax,ebx
ret
does not seem to work, mainly because the line
movzx eax,byte[esi]
gives an illegal instructor error, and if i change it to just mov, then byte[esi] gives a wrong parameter error and undefined var error.