Hello!.
First, I don't want you do my homework. The hw consists in take a char chaine and convert it to a number usign macros. For example the chaine 56 in the number 56.
We have a program provided by our instructor which in theory does the same without macros. If I understand the program, the number will be stored in DX and testing in the emulator it works fine for the number with one digit (0-9), but when numbers bigger, it only save the last digit. Example: chaine:8 dx:8 (or 1000) chaine:17 dx:7 (or 111).
Could you give me some advice to fix this example and to be able to start coding the assignment.
TITLE caracteresversnombre
SPILE SEGMENT STACK
DW 100 DUP(?)
SPILE ENDS
SDATA SEGMENT
chaine db 255 dup('$')
SDATA ENDS
SCODE SEGMENT
ASSUME CS:SCODE,DS:SDATA
DEBUT:
mov AX,sdata
mov DS,AX
mov DX,offset chaine
mov AH,0ah
int 21h
mov SI,1
mov AX,0
xor CX,CX
mov CL,chaine[si]
inc SI
repeter:
mov DX,10
mul DX
mov DL,chaine[si]
sub DL,48
mov DH,0
add AX,DX
inc SI
loop repeter
MOV AX,4C00H
INT 21H
SCODE ENDS
END DEBUT
By the way: this example should work in this way:
•
Enter a chaine. example ‘827’
Number = 0
Digit = 8
Number = Number * 10 +Digit =0*10+8 = 8
Digit = 2
Number = Number * 10 + 2 = 8*10 + 2 = 82
Digit = 7
Number = Number * 10 + 7 = 82*10+7 = 827