flat assembler
Message board for the users of flat assembler.
Index
> Main > flat assembler 1.65 Goto page 1, 2, 3, 4 Next |
Author |
|
LocoDelAssembly 02 Jan 2006, 00:31
Tomasz Grysztar wrote: The RET instruction with 0 parameter is now assembled into short form, unless you force using the 16-bit immediate with "word" operator. Thanks |
|||
02 Jan 2006, 00:31 |
|
revolution 02 Jan 2006, 03:05
Quote:
Code: if eax eq EAX | 0/0 nop end if |
|||
02 Jan 2006, 03:05 |
|
Tomasz Grysztar 02 Jan 2006, 09:24
The "eax eq EAX" is now predicted by the parser, at the time where "0/0" means for it nothing more or less than "0<0".
Yes, the conditional expression parsing got a bit complicated - but note that in cases, where it did not cause error in the past, it will still behave the same way. The only differences are that more cases are accepted now, and - you're right - it might appear to be a bit unpredictable, because it got a little more complex. In general, the parsing of conditional expressions evaluates all the values involving "eq", "eqtype" or "in" and reduces the conditional expression this way. So: "0/0 | eax eq EAX" gets reduced first to "0/0 | True" and then to just "True". If it was "0/0 & eax eq EAX" it would be reduced to simple "0/0" and then cause error at the assembly time. At the assembly time, however, the "lazy evaluation" is performed in its standard way, from left to right. Thus: Code: if defined alpha & alpha doesn't cause error when "alpha" is not defined, but Code: if alpha & defined alpha Note that these are actually two separate features - I could disable "lazy evaluation" for the assembler and still leave the optimization of IFs by the parser. What parser does, might appear to ignore some errors sometimes, but it is done with better performance as the main aim (and the internal code generated to feed assembler gets generally smaller), so it reduces as much as it can. Allowing "|" and "&" reduction to happen only from the left might be a solution to this problem - so "eax eq EAX | 0/0" would get reduced to just "True" (and thus the "if", "else" with what follows and "end if" would get stripped out at all), but "0/0 | eax eq EAX" would get reduced to "0/0 | True" (and the "if" block would be left intact). This would kill the optimization in some cases, but overall might be not bad idea - the whole thing would get quite predictable this way. |
|||
02 Jan 2006, 09:24 |
|
Tomasz Grysztar 02 Jan 2006, 10:13
In my tests the performance doesn't suffer at all from such limitation of parser's reduction - the conditional blocks like those are not often used, and this is the reason. So I made it work this way, so now both parser and assembler make it look like "lazy evaluation".
The update to WHATSNEW:
|
|||
02 Jan 2006, 10:13 |
|
revolution 02 Jan 2006, 11:06
Since you are in the mood for a new version (with 1.65 being posted) I would like to suggest something. I have mentioned this in the past but after reading through the threads I think I didn't get my point across well.
My suggestion is to add UNFIX. But this is where I would like to make clear that while it may look similar to purge and restruc the important difference is that is does not restore any previous FIXes but puts the symbol back to the same as having no fix. Example: Code: a fix b mov eax,a ;becomes mov eax,b a fix c mov eax,a ;becomes mov eax,c unfix a mov eax,a ;becomes mov eax,a Code: .code fix something ;... include 'someoneElsesCode/aLibrary.inc' Code: struc foo { .code dd ? ;<-- error: } Code: .code fix something ;... unfix .code include 'someoneElsesCode/aLibrary.inc' .code fix something Code: a fix b mov eax,a ;becomes mov eax,b a fix c mov eax,a ;becomes mov eax,c unfix a mov eax,a ;becomes mov eax,a refix a mov eax,a ;becomes mov eax,c refix a ;nothing happens, 'a' already FIXed unfix a mov eax,a ;becomes mov eax,a refix a mov eax,a ;becomes mov eax,c refix a ;nothing happens Code: .code fix something .data fix somethingElse ;... unfix .code,.data include 'someoneElsesCode/aLibrary.inc' refix .code,.data |
|||
02 Jan 2006, 11:06 |
|
revolution 02 Jan 2006, 11:09
Quote: "lazy evaluation" |
|||
02 Jan 2006, 11:09 |
|
Tomasz Grysztar 02 Jan 2006, 11:39
I think it would be a bit of overuse of the FIX directive, after it faded into what it is now (with the introduction of MATCH directive). The FIX in its current form is thought only to be the kind of global "search and replace" and I suggest to use EQU (and now also DEFINE), macros, and MATCH instead of FIX for any other appliances. What you propose pretty much made sense with the old FIX, but with the current one, after the MATCH has been introduced, I don't want to make FIX anything more sophisticated again - and I suggest to avoid using FIX at all, especially in the libraries and includes. Note that there's no single FIX in the new Win32 macros.
However there's one thing I could do: make FIX don't replace anything in the value before assigning it - as I think it's anyway not good thing to do with the current FIX. So then to do "unfix" you would just do something like "a fix a". |
|||
02 Jan 2006, 11:39 |
|
Tomasz Grysztar 02 Jan 2006, 12:14
Yes, I think it better suits the current purpose of the FIX (and also better suggest that FIX is no longer just a bit different EQU) - I made it into 1.65.2 (a new development spree, isn't it? )
So solution for your problem (if you anyway REALLY need to use FIX directive in such way) can now be: Code: .code fix something ;... .code fix .code include 'someoneElsesCode/aLibrary.inc' .code fix something Also note that FIX from the beginning was implemented a bit different from EQU in the aspect that it doesn't stack up its assignments (what makes RESTORE possible in case of EQU) - so FIXing the same name many times doesn't cause any additional memory usage. |
|||
02 Jan 2006, 12:14 |
|
revolution 02 Jan 2006, 13:13
I use fix in one place now (with 1.64):
Code: .code fix } Quote: Also note that FIX from the beginning was implemented a bit different from EQU in the aspect that it doesn't stack up its assignments Code: .code fix .code |
|||
02 Jan 2006, 13:13 |
|
Tomasz Grysztar 02 Jan 2006, 13:31
I'm glad you like it.
BTW, the new DEFINE directive allowed me to improve the "struct" macro so that it no longer has the problem with definitions like: Code: x equ dqword struct POINT x dd ? y dd ? ends I think you should like it, too. |
|||
02 Jan 2006, 13:31 |
|
Tomasz Grysztar 02 Jan 2006, 14:53
And now some fun: actually the DEFINE would be enough as a directive for defining symbolic constants, since EQU can be emulated with it:
Code: struc equ value { match processed,value \{ define . processed \} } But don't worry, I won't take it as a hint to remove EQU from fasm. |
|||
02 Jan 2006, 14:53 |
|
revolution 02 Jan 2006, 15:04
Quote:
This is a good thing |
|||
02 Jan 2006, 15:04 |
|
Borsuc 02 Jan 2006, 15:19
equ is still a lot faster than the 'emulated' way with define, because it's not much overhead for assembler. (like a struc and a match).
|
|||
02 Jan 2006, 15:19 |
|
Tomasz Grysztar 02 Jan 2006, 15:35
Of course, I told it's just for fun. But you can play more to make other interesting variants. Here's the one that doesn't stack up the values:
Code: struc equ2 value { match processed,value \{ restore . define . processed \} } |
|||
02 Jan 2006, 15:35 |
|
revolution 03 Jan 2006, 00:19
Quote:
Code: offset equ |
|||
03 Jan 2006, 00:19 |
|
revolution 03 Jan 2006, 00:47
Today is my first chance to try 1.65.2 and the very first try gives me an error for this:
Code: if (4 >= 2) ;<-- error: Invalid expression nop end if Code: if 4 >= 2 nop end if |
|||
03 Jan 2006, 00:47 |
|
Tomasz Grysztar 03 Jan 2006, 06:30
A stupid mistake when re-optimizing the code.
Fixed now. Tried with (overloaded with brackets) Code: if (((4>=2)&((3<2)|(eax eq eax)))) nop end if PS. You're right with empty EQU, and with checking for empty value it will no longer be so elegant. But, as I said, I am not really trying to get rid of EQU in favor of some macro. |
|||
03 Jan 2006, 06:30 |
|
halyavin 03 Jan 2006, 09:21
This code successfully compiles in fasm 1.64 but doesn't compile in fasm 1.65.3 ("error: invalid expression" for if statement):
Code: c equ <u> macro x a,b { if (a in c) & (b eqtype 0) end if } x [v],v This ruin almost all my fasm programs because this is a part of mov command optimization . |
|||
03 Jan 2006, 09:21 |
|
mike.dld 03 Jan 2006, 10:00
There's a problem with new feature ("the assembler is now calculating only as many logical values as it needs to determine the condition").
Suppose we have such macro: Code: macro __mov reg,a,b { if (~a eq)&(~b eq) mpack reg,a,b else if (~a eq)&(b eq) mov reg,a end if } Using it like Code: __mov eax,5 expands the macro (errorneously) into Code: mpack eax,5, The problem here as I see it is that assembler checks (~a eq) and and doesn't further check (~b eq) since first expression was true. |
|||
03 Jan 2006, 10:00 |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.