flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > extra 0

Author
Thread Post new topic Reply to topic
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740
... this macro converts an string to an integer...
but for example, if the 0 ended string is string db '634',0
the integer value converted is 6340 Confused
so... any idea? (i don't know why this happens... the code was in this forum, but i don't remeber who wrote it
Code:
macro atoi string,destination
{
xor eax,eax
mov esi,string

mov ebx,10 ;we'll be multiplying by 10
.digitloop:
mul ebx ;shift eax by one decimal digit left (eg. multuiply by 10)
;or dx,dx             ;check if edx was affected... then overflow
;jz .overflow
movzx ecx,byte [esi]  ;mov byte[si] to CL and zero CH
inc esi
or ecx,ecx ;end if 0 found
jz .done
sub ecx,'0' ;convert from ascii digit to digit
add eax,ecx
jmp .digitloop
.done:
mov [destination],eax
}    
Post 06 Dec 2005, 16:23
View user's profile Send private message Reply with quote
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740
i found the solution, thanx anyway
Post 06 Dec 2005, 16:42
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
don't do such things with macros, use procedures
Post 06 Dec 2005, 17:05
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.