thankx is advance
What do you have so far? Have you looked at the implementation of atoi() in
the C runtime library? The idea is really simple:
"1234" = 1*10^3 + 2*10^2 + 3*10^1 + 4*10^0
Here's a hint. The equation can be rearranged like so:
(((1*10+2)*10)+3*10)+4
You should be able to use that to construct a loop that reads a digit and
accumulates it.
-Matt
This may not be the best, but this is working code for A386 real
mode....
jmp start
str1: db '1024',0
mult1: dw 10
eostr1 equ $
start: mov si, str1
CALL AtoI
RET
atoi: sub edx, edx ; Value = 0
sub eax, eax ; eax = 0
cld ; increment
lop: lodsb
OR AL, AL ; AL = 0?
JZ End1 ; If So, Exit Loop
PUSH AX ; Save AX
XCHG DX, AX ; Swap DX and AX
SUB DX, DX ; Clear DX
MUL WORD [mult1] ; Multiply by 10
XCHG DX, AX ; Move back to DX
POP AX
sub al, 30h ; Convert to dec.
SUB AH, AH
ADD DX, AX ; Add the next digit in...
JMP Lop ; Keep going till we hit the null....
End1: RET
"blakMole" <obliv...@yahoo.com> wrote in message
news:3ff7532be9e80aaa...@localhost.talkaboutprogramming.com...