flat assembler
Message board for the users of flat assembler.

Index > Main > anyone got a asm atol() or atoi() ?

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
anyone got a asm atol(), atoi()?
maybe like proc atol, ptstring ?

thank you.
Post 03 May 2006, 16:40
View user's profile Send private message Visit poster's website Reply with quote
Ivan2k2



Joined: 08 Sep 2004
Posts: 80
Location: Russia, Angarsk
Ivan2k2
hi vbVeryBeginner

here code from masm32 package and converted 2 fasm syntax
Code:
proc atol lpsrc

   xor eax, eax
   xor ecx, ecx
   mov edx, [lpsrc]

   sub edx, 1
  @@:
   add edx, 1
   cmp byte [edx], 32
   je @b
   cmp byte [edx], 9
   je @b

   mov al, [edx]
   add edx, 1

   .if al = '-'
       add ecx, 1
       mov al,[edx]
       add edx, 1
   .elseif al = '+'
       mov al,[edx]
       add edx, 1
   .endif
   push ecx
   xor ecx,ecx
@@:
   sub al,'0'
   jc  @f
   lea ecx,[ecx+ecx*4]
   lea ecx,[eax+ecx*2]
   mov al,[edx]
   add edx, 1
   jmp @b
@@:
   mov eax,ecx
   pop ecx
   shr ecx,1
   jnc @f
   neg eax
@@:

ret
endp
    
Post 03 May 2006, 18:06
View user's profile Send private message ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
great, gonna use it.
thanks a lot. ivan2k2
Post 03 May 2006, 18:20
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
atoi will be something like this

Code:
int _atoi(char *s)
{
        UINT    i=0,n;

        for(n = 0; s[i]; i++) n = 10 * n + s[i] - '0';

        return n;
}
    
Post 04 May 2006, 10:05
View user's profile Send private message 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.