Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

converting ascii to an integer

[b][red]This message was edited by ju1c3 at 2004-11-7 19:59:29[/red][/b][hr]
[b][red]This message was edited by ju1c3 at 2004-11-7 19:55:41[/red][/b][hr]
[b][red]This message was edited by ju1c3 at 2004-11-7 19:55:17[/red][/b][hr]
ok, i cant seem to convert a group of ascii valuse to a integer.this is the code i have so far and it doesnt seem to work. i am using masm615. any code/ help would be great.

parseInt PROC;

push Bx ; push all of the registers so none are corrupted
push SI ;
push CX ;
mov DI, 0h ;
MOV bX, si ; get addy to place string
mov si, 10 ; 10 for the multiplication

again:
cmp byte ptr [bx], 48 ; is it a null
jz done ;
cmp byte ptr [bx], 48 ; is it less then 0
JLE next ;
cmp byte ptr [bx], 57 ; is it greater then 9
JGE next ;
sub byte ptr [bx], 30h ; make a number
mov ax, [bx] ; get the value into ax so it can multiply
mul si ; multiply
inc bx ; go to next char in bx
push bx
sub byte ptr [bx], 30h ;
add ax, [bx] ; add dx and bx to get the new number
pop bx
dec cx ; count one less
cmp cx, 0h ;
jnz again ; if count is not zero go again
jmp done ; if it is zero, end

next:
inc bx ;
jmp again ;

done:
mov ax, [bx] ; mov the addy of bx into ax
pop CX ;
pop SI ; pops all the registers
pop BX ;






Sign In or Register to comment.