flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > String instructions in Fasm source

Author
Thread Post new topic Reply to topic
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas 30 Jun 2005, 21:00
I was browsing Fasm source code, to gain more understanding of its internals, and noticed the heavy use of string instructions. Non repeated string instructions are quite slow in modern processors, and are used in Fasm sometimes in inner loops. Maybe they should be replaced for faster code?

But then, Fasm is already very fast Wink
Post 30 Jun 2005, 21:00
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 30 Jun 2005, 21:56
well, it still needs to remain readable and easily editable. But maybe some optimizations could be achieved by macros.
Post 30 Jun 2005, 21:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 30 Jun 2005, 22:31
I am still optimizing mainly as if I was optimizing for 80386 - well, this one needs the optimizations the most, isn't it? Wink
Post 30 Jun 2005, 22:31
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 01 Jul 2005, 11:17
[EDIT]

heh, it seems I'm out of the topic, you're talking about non repeated string instructions...

[/EDIT]

I, personally, use macros like repmovs, repecmps, repnecmps, repstos, repescas, repnescas (replods is unnecessary). They replace original instructions with loops. They have two optional parameters:

  • ecxz - test if ecx zero (rarely needed)
  • rev - simulate DF=1 (default is DF=0)

repmovs and repcmps have additionally one more optional parameter - temporary register for memory-to-memory operation.

Examples:
Code:
repstosb ecxz

repnecmpsd ecxz, rev, eax
    


Last edited by MazeGen on 01 Jul 2005, 12:40; edited 1 time in total
Post 01 Jul 2005, 11:17
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 01 Jul 2005, 12:33
El Tangas wrote:
Non repeated string instructions are quite slow in modern processors, and are used in Fasm sometimes in inner loops. Maybe they should be replaced for faster code?

Actually, this is what I am currently doing with my version of Fasm, and yes, you guess it, doing such optimization is actually rather superfluous, cause it takes an outrages amount of dump coding time with only weak effects on the execution speed, and furthermore it just bloats the executable a lot, since usual MOVs, INCs, DECs, ADDs and SUBs take up more space than shorte string instructions.

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 01 Jul 2005, 12:33
View user's profile Send private message Reply with quote
El Tangas



Joined: 11 Oct 2003
Posts: 120
Location: Sunset Empire
El Tangas 01 Jul 2005, 17:12
Yep, to do real optimization you would need to profile the code and see where Fasm spends its time. Thats just to much work for small gains.
Anyway, I also found a few "leftover" instructions in the code, maybe I'll report them as bugs if I find enought of them.
Post 01 Jul 2005, 17:12
View user's profile Send private message Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 01 Jul 2005, 17:36
Right - it's so fast as it is, it's hard to imagine huge gains. When my projects takes less than a second to compile, I don't really need it to go faster.
Post 01 Jul 2005, 17:36
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 01 Jul 2005, 18:30
FASM is very fast already. But, if removing or changing the string instruction usage would make it any faster, then good.
Most short programs assemble quickly, but long programs (for example FASM itself) can take a lot of time to assemble. I doubt if anyone here even uses the 386 anymore- to be compatible with 386 is one thing, but to be optimized for 386 seems to miss the point. Am I wrong?
Post 01 Jul 2005, 18:30
View user's profile Send private message AIM Address Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 01 Jul 2005, 18:54
I know some people using 386 machines and even using fasm there. And since on 386 it really takes noticeable time to assemble larger project, I see no point in making it slower there just to make it faster on some modern processor, where you won't anyway see the difference.

Also on the newest processors even non repeated string instructions seem to perform quite well. Not saying that the encodings are much shorter. And what work for the fasm's speed are mainly chosen algorithms, not chosen instructions.
Post 01 Jul 2005, 18:54
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 02 Jul 2005, 14:37
THEWizardGenius wrote:
I doubt if anyone here even uses the 386 anymore

Cool I have a lovely 386 still running at home. There are a lot of tasks that this computer can accomplish and given its power consumption, it is optimal for an always on system. It doesn't even need a fan.
Post 02 Jul 2005, 14:37
View user's profile Send private message Yahoo Messenger Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 02 Jul 2005, 14:54
What are you using it for? Only thing that come to my mind is testing some OS code like bootloader... or an internet gate for local network (if 386 is enough for that...).
I have a working P166 box that is used only by my mother and only for chatting Wink
Post 02 Jul 2005, 14:54
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 02 Jul 2005, 14:55
I also have a running 386 that I run FASM on. It's a nice workstation for testing hobby OSes!
Post 02 Jul 2005, 14:55
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.