flat assembler
Message board for the users of flat assembler.

Index > Main > compiler - just curious...

Author
Thread Post new topic Reply to topic
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
Hi,

When I compile the code below it takes 1.4 seconds. If I change line 9 to

mov ecx, 20000

it then takes 10.4 seconds to compile. If I then insert an

int 03
straight after line 9 it only takes 1.1 seconds.

What's going on in the compiler to make such a drastic difference in compile times? Confused

Code:
format PE GUI 4.0

include '%fasminc%\win32a.inc'
entry start

section '.code' code readable executable
start:
        mov     edi, N
        mov     ecx, 2000
        mov     ebx, [edi+04]
        mov     eax, ecx
        inc     eax
        shr     eax, 01
        add     ebx, 02
        shl     ebx, 02
        add     ebx, eax
        push    ecx
        invoke  VirtualAlloc,NULL,ebx,MEM_COMMIT,PAGE_READWRITE
        mov     [m8], eax
        invoke  VirtualAlloc,NULL,ebx,MEM_COMMIT,PAGE_READWRITE
        mov     [m2], eax
        invoke  VirtualAlloc,NULL,ebx,MEM_COMMIT,PAGE_READWRITE
        mov     [mA], eax
        pop     ecx
        mov     eax, [edi+04]
        mov     [dws], eax
        shl     eax, 02
        mov     esi, edi
        add     esi, eax
        add     esi, 04
        mov     edi, [m2]
        add     edi, eax
    ML:
        std
        xor     edx, edx
        push    ecx
        mov     ecx, [dws]
        push    ecx
    M2:
        lodsd
        shld    edx, eax, 01
        xchg    eax, edx
        stosd
        loop    M2
        shl     edx, 01
        mov     [edi], edx
        pop     ecx
        push    ecx
        dec     ecx
        shl     ecx, 02
        mov     esi, [m2]
        add     esi, ecx
        mov     edi, [m8]
        add     edi, ecx
        add     edi, 04
        pop     ecx
        push    ecx
        mov     edx, [edi]
    M8:
        lodsd
        shld    edx, eax, 02
        xchg    eax, edx
        stosd
        loop    M8
        shl     edx, 02
        mov     [edi], edx
        pop     ecx
        inc     ecx
        mov     esi, [m2]
        mov     edi, [m8]
        mov     ebp, [mA]
        cld
        push    ecx edi
        xor     eax, eax
        mov     edi, [mA]
        rep     stosd
        pop     edi ecx
    MA:
        lodsd
        add     eax, [edi]
        adc     dword [ebp+04], 00
        add     [ebp], eax
        adc     dword [ebp+04], 00
        add     edi, 04
        add     ebp, 04
        loop    MA
        test    dword [ebp-04], -1
        jz      @f
        inc     dword [dws]
    @@:
        pop     ecx
        loop    .L
        jmp     @f
    .L:
        mov     eax, [dws]
        shl     eax, 02
        mov     esi, [mA]
        add     esi, eax
        mov     edi, [m2]
        add     edi, eax
        sub     esi, 04
        jmp     ML
    @@:
        mov     edi, [mA]
        int     03
        invoke  ExitProcess,0


section '.data' data readable writeable
N:      dd 00000000h, 00000006h, 03fb4d65h, 067da65dah, 0564fdf78h, 0ecdabc21h, 031656984h, 000932113h
m8:     dd ?
m2:     dd ?
mA:     dd ?
dws:    dd ?

section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL'

include '%fasminc%\apia\Kernel32.inc'
include '%fasminc%\apia\User32.inc'

    
Post 27 May 2006, 15:26
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
The first time I tried to compile it took 1.1 seconds, then 0.4 and then 0.1 regardless of the modifications. Are you sure that FASM ALWAYS takes those times? Compile the same code several times to be sure, that will help to cache disk R/W accesses and will make FASM faster.
Post 27 May 2006, 15:52
View user's profile Send private message Reply with quote
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
Yup, tried it many times with same results give or take 1/10 second.
Post 27 May 2006, 16:38
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
i think it depends on what programms you have in background (i mean antivirus or something like this)
Post 27 May 2006, 19:35
View user's profile Send private message Reply with quote
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
Still same results with no antivirus (or anything similar) running┬┐
Post 27 May 2006, 19:49
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
Have you tried to set the process priority to realtime?
Post 27 May 2006, 23:01
View user's profile Send private message Visit poster's website Reply with quote
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
You've lost me now lol Embarassed
Post 28 May 2006, 19:53
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
I'm still using the 1.65.17 Razz (shame on me)
and it takes 0.4 all the time - cached or without it
nothing changes between constants 2, 200, 2000, 2000000000
and neither int3 or int 3 make any difference.

I think I must use a slower computer to see any difference.
BTW, why do you use int 03? INT3 is the 'official' breakpoint.
Post 29 May 2006, 09:27
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
Oh well, must just be my poor ol' poot then. I'll have to try filling the gas cylinder, maybe it'll go faster lol.

As for the int 03, it's just something I've always used, doesn't matter about the extra byte generated as they aren't there after I've finished debugging Wink
Post 29 May 2006, 12:05
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
moriman, it might help if you state which FASM version you use as well as your computer speed...
Post 29 May 2006, 13:17
View user's profile Send private message Visit poster's website Reply with quote
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
np Wink
fasm 1.64
poot 0.5Gig(ish) AMD-K6
Win98
184 RAM
2 carrier pigeons for the cache and the aforementioned cylinder of gas Wink
Post 29 May 2006, 13:22
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
I ran the standard DOS FASM.EXE from 1.64 in "pure" DOS on a P166 (without cache running) several times with and without changes (using Win32 .INCs from FASMW 1.64), and it never took longer than 2.4 seconds. Does that help? Smile
Post 30 May 2006, 20:48
View user's profile Send private message Visit poster's website 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 GitHub, YouTube, Twitter.

Website powered by rwasa.