flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Roman 11 Jul 2013, 12:38
I would like to expect new features in the new version of the Fasm.
|
|||
![]() |
|
baldr 11 Jul 2013, 16:11
Roman,
You must learn existing features better before proposing new ones. Code: match val snip endofline, a+b-c/d { display "val=", `val, 13, 10 display "snip=", `snip, 13, 10 display "endofline=" irps s, endofline \{ display \`s \} display 13, 10 } Code: val=a snip=+ endofline=b-c/d |
|||
![]() |
|
Roman 11 Jul 2013, 16:24
Baldr
I mean this: Code: macro def_XMMath { macro XMMath [str*] \{ common define OK = def_XMMath ; allow recursion ; low precedence operations first match R == A + B,XREG OK str \\{ restore OK define OK , XMMath A ; recurse on A restore XREG ; preserve value XMMath B ; recurse on B ; movss R,A ;addss R,B ; addss R,XREG XREG equ R \\} match R == A * B,XREG OK str \\{ restore OK define OK , XMMath A ; recurse on A restore XREG XMMath B ; recurse on B ; movss R,A ; mulss R,B mulss R,XREG XREG equ R \\} match R == A / B,XREG OK str \\{ restore OK define OK , XMMath A ; recurse on A restore XREG XMMath B ; recurse on B ;movss R,A ;Esli v primer [.]/[.] work. No ne work if [.]/[.]/[.] ! ;divss R,B ; divss R,XREG XREG equ R \\} ; no match, assume memory value match R ==,XREG OK \\{ movss R,str ;Tut billo \\} purge XMMath restore OK \} } def_XMMath if we write XMMath [_t]/[_t]/[_dv] we get 2.0 ! Must be 0.5 ! _dv dd 2.0 _t dd 4.0 And match is not always convenient and understandable especially if a lot of operation like this: XMMath [_dv] + [_t] + [_t] + [_dv] * [_t] + [_dv] +[_t] +[_t]*[_t] |
|||
![]() |
|
Roman 11 Jul 2013, 16:31
Baldr
Thanks for you example: match val snip endofline, a+b-c/d { display "val=", `val, 13, 10 display "snip=", `snip, 13, 10 display "endofline=" irps s, endofline \{ display \`s \} display 13, 10 } Do not be angry, but in this example,very hard to understand from the first time it is found as a sign + and how this example work. For this reason, I believe that the match is a crutch. And new function Cut and Set more easy understand and less to write And Baldr how about this: match val snip endofline, [a]+b-c/d { display "val=", `val, 13, 10 ;val = '[' ! display "snip=", `snip, 13, 10 display "endofline=" irps s, endofline \{ display \`s \} display 13, 10 } As we can see an example of the more complex the more it is necessary to inflate and complicate |
|||
![]() |
|
bitRAKE 11 Jul 2013, 22:45
The manual is very clear about how match works:
Quote: Each name is always matched with as few symbols as possible, leaving the rest for the following ones (a+(b+(...(y+z)...) If the operator is divide then the result is not what you expect it to be. (...(a/b)...)/x)/y)/z) So, your question is how can the macro be changed to process operators from left to right, when match only matches fewest symbols? I doubt the general solution is needed, but just a match for a/b/c. Note how (a) and (b) will not have any "/" operator due to FASM's matching of fewest possible symbols. Code: match R == A / B / C,XREG OK str \\{ restore OK define OK XMMath A restore XREG XMMath B divss R,XREG XREG equ R XMMath R / C \\} Need to get rid of the MOVSS XMM7,XMM7 instructions now. |
|||
![]() |
|
Roman 13 Jul 2013, 07:59
While I believe that the new features are needed (Cut, Set)
+ they more easily understood + less to write + with Cut and Set macros is not bloated And function Cut and Set to empower. Example: Va EQU [a]+10.0/(a+b/2) Cut Va,/(a ;its mean function Cut faind in Va this /(a and Va = [a]+10.0 Its more understood and more easily write. And function Set: Va EQU [a]+10.0/(a+b/2) Set Va,(a+b/2) ; Cut Va,/2) ; Va = (a+b Set Va,a+b Cut Va,+b ; Va = a ! |
|||
![]() |
|
Roman 13 Jul 2013, 08:37
Function Set setpose (not cuting). Function Set setpose for function Cut
|
|||
![]() |
|
Roman 16 Jul 2013, 09:50
I think the ElseEQU can be useful.
We know that macro does not give the result you think the first time. Quote:
In code: Quote:
We all ways get Ost = "123" And the macro to be more readable and understandable should be added the ElseEQU. I look forward to understanding the author of the program. If we get new ElseEQU then code look like this: Quote:
|
|||
![]() |
|
bitRAKE 16 Jul 2013, 11:36
EQU statements happen and are not seen by assembler stage. The IF/END IF are assembler directives - they are transparent to preprocessor (where EQU is evaluated).
Adding another directive would not change this - the two stages are separate. For example, if we just use assembler stage: Code: macro Gh arg { Ost = 5 if `arg = `- Ost = 123 end if } Okay, now we just use preprocessor: Code: macro Gh arg { Ost EQU 5 match -,arg \{ Ost EQU 123 \} } The product of the preprocessor is the code for the assembler. This is why there are different names for conceptually similar directives. Different languages for different stages. Similar to the way #define is not a keyword for C++, it is the preprocessor. |
|||
![]() |
|
Roman 16 Jul 2013, 13:16
bitRAKE
Thanks for the explanation. I thank you showed me how can get. Sorry for the correction. But code must be: Quote:
Example: Gh -1 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.