flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM optimizes code?

Thread Post new topic Reply to topic

Joined: 26 Jan 2012
Posts: 2
ogo 26 Jan 2012, 22:20
First of all I wanna say that FASM is the greatest assembler i have ever seen.

But! Wink

Are there any optimization algorithms within?

Sometimes it seems that fasm is iterating my loops to see if they are making sens? In this case you can allways see a status bar. Which you could normally not see if the program is very small. So what is fasm doing?
If I only some iterations in a loop FASM assembles fast.
If I have a greate amount of iterations (maybe a 1000000 times) it assembles very slow.

Another case was a dll. I used the smallest implementation of the essential DllEntry function. Looks like...

mov eax,1

This dll does not work because the DllEntry was not to find in the binary file.

But when I implemented some more instructions to the DllEntry...

mov eax,[esp+12]
je .process_attach
je .process_detach
je .thread_attach
je .thread_detach

inc [instance_counter]
jmp .end_of_reason_check
dec [instance_counter]
jmp .end_of_reason_check
jmp .end_of_reason_check
jmp .end_of_reason_check

mov eax,TRUE

...then everything is fine.

So what on earth is going on there?

And if there are any optimization, how can I disable them?

Please help.
Post 26 Jan 2012, 22:20
View user's profile Send private message Reply with quote
Your code has a bug

Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 27 Jan 2012, 00:10
Other than instruction encoding size optimization, there are no optimizations. I'm not so sure what do you mean about the iterations, could you exemplify with code so we can see when fasm takes little time and the code which takes long to compile?

Finally, in the case of the DLL, you should use "ret 12", and the reason reason for the first one to not work may be due to this (follow the links for explanation and use Tomasz's code rather than mine). You don't have this problem with your longest code because there are many references that must be relocated and hence the relocs are not empty.
Post 27 Jan 2012, 00:10
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.