flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > remove "jmp" to next instruction...

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Hi all!
Tomasz, i have little suggestion - is it possible to make next jump excluded by FASM:

Code:
 jmp @F
@@:     


It is very simple example, but in case of macro constructs such situations require some additional compiler directives code to check, if it is jump to next instruction or not in order to remove unnecessary ones. Maybe it is better to use FASM compiler itself, as it knows after all compile passes what situations with jumps are?

Thanks and regards.

_________________
Flat Assembler is the best!
Post 19 Feb 2009, 21:03
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
First: that would be way beyond the line of what the low-level assembler should optimize by itself. You should do that with macros, just like some other optimizations discussed on this board. Just overload the "jmp" instruction with a macro, it should work like a charm. And if slows down compilation too much for you, you can enable this macro only when making the final executable (for release).

Second: this kind of jump is sometimes needed, like when you enter processed mode. I cannot image how angry (and confused) some programmers would get when assembler did such optimization for them in such case.
Post 19 Feb 2009, 21:21
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Thank for your quick reply, Tomasz. I'll try to do it with assembler directives in my case.
Post 19 Feb 2009, 21:28
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
I wrote a sed script / .BAT for this for checking my simple DOS programs (which can have this due to too many careless cut n' pastes). Of course, it wouldn't work on your macro use since "@f" and "@@" don't match. But it can be done. Wink And I still say something like this internally to FASM is unlikely to bite more than 1% of users. (Of course, just make it optional via some directive: NOBLOAT or similar, heh.)
Post 24 Feb 2009, 07:22
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
I was thinking about collecting all such macros into one "agressive optimization" macro package. You could just include it into your sources just to compile the final release.
Post 24 Feb 2009, 11:58
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Agree. FASM core shouldn't do things like drop jumps, replace MOV by XOR, CMP by TEST, ...
Post 25 Feb 2009, 00:07
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
The thing core defenitely should do is apply short variant of instructions (implied sign extension if possible & need, short jumps, smart indirect addressing encoding/optimization) by default. That's enough /for the first time;)?/
Post 25 Feb 2009, 16:13
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
DOS386 wrote:
Agree. FASM core shouldn't do things like drop jumps, replace MOV by XOR, CMP by TEST, ...


Don't forget that TASM was part of the inspiration behind FASM, and it had normal MASM mode as well as an improved IDEAL mode. So, with that reasoning, there's no reason that FASM (in theory) couldn't support more, including a separate mode for more aggressive optimizations.

The jump issue could be handled by a warning, however. Maybe that's the best answer, add a diagnostics mode that returns more warnings than normal without actually changing anything.
Post 27 Feb 2009, 08:15
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.

Powered by rwasa.