I'm trying to do the following, but I'm having some trouble, and the only code I find on the web is for transforming strings into a number (basicly atoi), but I need something slightly different, e.g:
num1 Db '60','30'
num2 Db '2', '3'
num3 Db '*', '*'
Basicly I only need to transform the chars in the vector into numbers (separately), so I can do the operation marked by num3
with num1
and num2
as operators, as an example, I'll use my function that multiplies two numbers.
What I tried was:
MOV AX, DADOS
MOV DS, AX
MOV CX, 2
cycle:
CMP num3[si], 2Fh
JE DIVISAO
CMP num3[si], 2Ah
JE MULTIPLICA
CMP num3[si], 2Bh
JE SOMA
CMP num3[si], 2Dh
JE SUBTRACAO
inc si
loop cycle
JMP FIM
The multiply function:
MULTIPLICA PROC
PUSH AX
MOV AH, 0
SUB num1[si], 48
MOV AL, num1[si]
SUB num2[si], 48
IMUL num2[si]
MOV DX, AX
POP AX
RET
MULTIPLICA ENDP
I thought I only needed to subtract 48 to each position to make it into the correspondant number, but I guess there's something more to it. Thanks. Edit: Did some ajustments, found out that it's only multiplying the first character, e.g: instead of 60*2, it's only doing 6*2