flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Make expressions faster

Author
Thread Post new topic Reply to topic
eskizo



Joined: 22 Nov 2005
Posts: 59
eskizo
Hi,

Just thinking about make a program to output an optimized code like:

Code:
;input:
eax * 9 + 3    


Code:
;output:
mov ecx, eax
shl eax, 3
add eax, ecx
add eax, 3    


The problem is: I am too newbie to make it. I guess you can do it in less than five minutes!
Post 30 Jun 2009, 15:18
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
Optimized you say ? ... ?
Code:
lea eax,[eax + eax*8 + 3]
    
Post 30 Jun 2009, 19:53
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
r22 wrote:
Optimized you say ? ... ?
Code:
lea eax,[eax + eax*8 + 3]
    

Code:
lea eax,[eax*9 + 3]    

Let fasm do the job, it really likes to have less boring tasks to do. Wink
Post 30 Jun 2009, 20:01
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
@eskizo
Making a generic expression optimizer for x86 is not a simple task. A lot of talented computer scientists work fairly hard to create the optimizing compilers we use for HLLs. The price we pay for the Swiss-army-knife instruction set with ever increasing extensions.

An algorithm pseudo language -> optimized FASM syntax would be cool
A = A * 9 + 3 -> lea eax,[eax*9 + 3]

@Tomasz
If only FASM would optimize the stack for my Win64 invokes/fastcalls, but I guess we can't make writing optimized ASM 'too' easy or else everyone would be doing it.
Post 01 Jul 2009, 19:50
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
r22 wrote:
@Tomasz
If only FASM would optimize the stack for my Win64 invokes/fastcalls, but I guess we can't make writing optimized ASM 'too' easy or else everyone would be doing it.
Well, I think something could be done in that direction, because I already tried, however to make it really universal and reliable, the macros would have to get quite complex.
Post 01 Jul 2009, 20:57
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
If only FASM would optimize the stack for my Win64 invokes/fastcalls, but I guess we can't make writing optimized ASM 'too' easy or else everyone would be doing it.

C optimizes your stack... wonder why everyone is "doing it" Razz
Post 01 Jul 2009, 21:12
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 GitHub, YouTube, Twitter.

Website powered by rwasa.