flat assembler
Message board for the users of flat assembler.
Index
> Main > Redefining the syntax (flat assembler 1.61) Goto page 1, 2, 3, 4, 5 Next |
Do you like the proposed changes (read below)? | ||||||||||||||
|
||||||||||||||
Total Votes : 25 |
Author |
|
Tomasz Grysztar 08 Jun 2005, 15:48
My recent additions have finally shown that my design of FIX directive was really a bit unfortunate. The explanations I had to give to define the source of problem FIX causes when combined with new REPT and MATCH directives have shown why people were reporting that usage of FIX is hard to understand - it was not really doing exactly the thing, that was defined to be its purpose: the absolute precedence over any other preprocessing.
So now I have an idea to clean up this mess. First, extend the new MATCH directive so it could be used for all the current applications of FIX where the messy details of FIX processing were exploited. Second, reimplement the FIX directive to behave in a clearly predictable way, always preceding any other preprocessing, on the lines from actual source. Here's an example how the "true" FIX would work: Code: V fix { macro some V ; begins macro V fix } ; Even though we are defining macro now, ; the FIX has precedence over all other preprocessing, ; so V gets redefined now ; and this line doesn't become actually part of macro. V ; ends macro So only this one application of FIX would be left and probably the most of the confusion with this directive would be avoided. And so the question is: if all the current applications of FIX would be still possible to achieve with different methods (EQU combined with proposed MATCH), would you accept such backward-compatibility-breaking change? Last edited by Tomasz Grysztar on 06 Jul 2005, 20:21; edited 3 times in total |
|||
08 Jun 2005, 15:48 |
|
UCM 08 Jun 2005, 22:03
You could implement a directive, something like new_syntax, and it would imply that the source would be using the proposed 'fix' syntax. Old code would default to using the old syntax, and would be processed properly. Although it might be a bit too complicated to explain in the documentation.
_________________ This calls for... Ultra CRUNCHY Man! Ta da!! *crunch* |
|||
08 Jun 2005, 22:03 |
|
Tomasz Grysztar 08 Jun 2005, 22:32
I'd prefer to clean up the things completely.
|
|||
08 Jun 2005, 22:32 |
|
tom tobias 08 Jun 2005, 22:52
As the famous saying goes, Cleanliness is next to Godliness.... However, if by 'CLEANING up completely' you wish to imply a formidible alteration to an existing masterpiece, then I wish to submit that "fix" is not actually an elegant term to employ.......
A good beginning to a more thorough revision, assuming one is needed, might include a detailed analysis of the goal of each of the elements of the assembler, together with a frank assessment of the current status of the code for each of the major sections. Instead of "fix", or "patch", one might then be asking, especially for this macro capability, "Is this operation really essential to the central artistic vision of FASM, or has the project outgrown its original scope?" Just my opinion, probably not worth the space it occupies, but, I believe simpler is more elegant.... |
|||
08 Jun 2005, 22:52 |
|
crc 08 Jun 2005, 23:22
I don't use fix often, but I see nothing wrong with breaking backwards-compatibility if the end result is cleaner than the original.
|
|||
08 Jun 2005, 23:22 |
|
Chewy509 09 Jun 2005, 00:35
crc wrote: I don't use fix often, but I see nothing wrong with breaking backwards-compatibility if the end result is cleaner than the original. My thoughts exactly. |
|||
09 Jun 2005, 00:35 |
|
Tomasz Grysztar 09 Jun 2005, 01:54
With such positive income I have implemented those changes today and thus came the 1.61.11 release - check it out, the Win32 version already contains the corrected macros where it was necessary (and not only - the old "proc" macro would still work, but is now cleaned up a bit thanks to "match", perhaps also other macros can be improved with use of the new features).
The improved "match" directive expands the symbolic constants inside the values to match, and one of my first samples of how it can be used now looks like: Code: macro freeform [arg] { common DONE equ NO match src->dst, arg \{ mov dst,src DONE equ YES \} match =NO dst<-src, DONE arg \{ mov dst,src DONE equ YES \} match =NO, DONE \{ unrecognized syntax \} } freeform eax -> ebx ; mov ebx,eax freeform al <- [esi+1] ; mov al,[esi+1] And revolution's macros can be rewritten for example this way: Code: end_ifdef fix } macro ifdef name { match =defined, name { } macro ifndef name { match =name, name { } The application of "match" in the "proc"/"endp" macros is especially nice, in "proc" there's now line: Code: all@args equ arg which defines the symbolic constant with value containing list of all arguments to procedure; and the "endp" macro contains: Code: match all,all@args \{ restore all \} There are two features of "match" used here: first is that it replaces the "all@args" with its value before matching and therefore passes the whole list of arguments to "restore" directive, second is that it doesn't match empty values, so if there were not arguments at all, the "restore" won't be processed. |
|||
09 Jun 2005, 01:54 |
|
revolution 09 Jun 2005, 02:39
Fabulous, I don't mind doing a little editing of my sources if it means that you can improve the syntax.
|
|||
09 Jun 2005, 02:39 |
|
IronFelix 09 Jun 2005, 06:04
Please, explain why this doesn't work with new release and how it must be implemented now:
Code: macro try _name { @name fix _name } macro close { @name#_lab: } try Asd close try Zxc close Thanks. _________________ Flat Assembler is the best! |
|||
09 Jun 2005, 06:04 |
|
Tomasz Grysztar 09 Jun 2005, 08:16
As I can explained in the first post above, the corrected FIX is now so prioritized, that it even doesn't become part of macro definition (I have given the example there, I though it's a good one). However for this application the good old EQU regains favor, with help of one of the MATCH directive's features:
Code: macro try _name { @name equ _name } macro close { match name,@name \{ name\#_lab: \} restore @name } BTW, that RESTORE gives the feature that was not present in the old-FIX-based solution - it allows nesting. Last edited by Tomasz Grysztar on 09 Jun 2005, 08:34; edited 2 times in total |
|||
09 Jun 2005, 08:16 |
|
IronFelix 09 Jun 2005, 08:21
Thanks a lot for your explanation, Privalov!
I think it is very powerful feature. Regards. |
|||
09 Jun 2005, 08:21 |
|
Madis731 09 Jun 2005, 08:22
Yeah, Flat Assembler is the best
...but I wouldn't call this: Code: \} match =NO, DONE \{ unrecognized syntax \} I wish there would be a possibility to elegantly remove ""s from syntax as much as possible. Though, they are logical in the linechange - don't change that, please! |
|||
09 Jun 2005, 08:22 |
|
Tomasz Grysztar 09 Jun 2005, 09:31
The backslash was chosen for escaping since it was the best choice from the internals design point of view, and also seemed to be accepted so far. Hope you can get used to it.
The new version of HLL macros I've made today: Code: macro .if [arg] { common __IF equ local ..endif __ENDIF equ ..endif local ..else __ELSE equ ..else JCOND __ELSE,arg } macro .else { jmp __ENDIF __ELSE: restore __IF __IF equ , } macro .elseif [arg] { common jmp __ENDIF __ELSE: restore __ELSE local ..else __ELSE equ ..else JCOND __ELSE,arg } macro .endif { if __IF eq __ELSE: end if __ENDIF: restore __ELSE restore __ENDIF restore __IF } macro .while [arg] { common local ..while __WHILE equ ..while local ..endw __ENDW equ ..endw __WHILE: JCOND __ENDW,arg } macro .endw { jmp __WHILE __ENDW: restore __ENDW restore __WHILE } macro .repeat { local ..repeat __REPEAT equ ..repeat __REPEAT: } macro .until [arg] { common JCOND __REPEAT,arg restore __REPEAT } macro JCOND label,[cond] { common match =COND v1>==v2, COND cond \{ cmp v1,v2 jb label COND equ \} match =COND v1<==v2, COND cond \{ cmp v1,v2 ja label COND equ \} match =COND v1==v2, COND cond \{ cmp v1,v2 jne label COND equ \} match =COND v1<>v2, COND cond \{ cmp v1,v2 je label COND equ \} match =COND v1>v2, COND cond \{ cmp v1,v2 jbe label COND equ \} match =COND v1<v2, COND cond \{ cmp v1,v2 jae label COND equ \} match =COND v1=,c=,v2, COND cond \{ cmp v1,v2 jn\#c label COND equ \} match =COND v, COND cond \{ cmp v,0 je label COND equ \} restore COND } jnne equ je jnna equ ja jnnb equ jb jnng equ jg jnnl equ jl jnnae equ jae jnnbe equ jbe jnnge equ jge jnnle equ jle The new syntaxes can be used aswell as the old ones: Code: .if eax = 4 .elseif ebx > ecx .elseif ecx, le, 2 .elseif edx .else .endif and it can be quite easy for anyone to add even more syntaxes there. |
|||
09 Jun 2005, 09:31 |
|
IronFelix 09 Jun 2005, 10:44
Please, help me again. How must I rewrite this code for new release:
Code: macro declare { @data fix } macro _data Name,Type,Value { @data fix @data,Name,Type,Value } macro insert_data space,[Name,Type,Value] { forward Name Type Value } macro close { insert_data @data } declare _data a , dd , 100 _data b , db , 200 close Thanks. _________________ Flat Assembler is the best! |
|||
09 Jun 2005, 10:44 |
|
Tomasz Grysztar 09 Jun 2005, 10:49
This exactly the same kind of problem, you were using FIX to create a list of arguments for macro, what is no longer possible - now you should use the standard EQU to create list and then MATCH directive to pass the value of list to macro:
Code: macro declare { @data equ } macro _data Name,Type,Value { @data equ @data,Name,Type,Value } macro insert_data space,[Name,Type,Value] { forward Name Type Value } macro close { match data,@data \{ insert_data data \} } Do you need some more explanation to be able to write such macros yourself? This is important, seeing what troubles you might got with understanding it will help me write better manual. Hmm, or maybe even design something like multiple-matching, similar to the multiple macro arguments? The "forward" and family are currently unemployed in "match" block, and this would allow to do all the processing inside the "match" in sample above instead of calling another macro. But - again - I have to be careful with new ideas, I don't know yet how it could be done cleanly. |
|||
09 Jun 2005, 10:49 |
|
Tomasz Grysztar 09 Jun 2005, 11:22
Some cryptic macro sample just for the fun of it:
Code: include 'win32ax.inc' macro AddAPI param { match (name),param \{ macro name [params] \\{ \\common match (args),params \\\{ invoke name,args \\\} match =dd any,params \\\{ name dd any \\\} \\} \} } .code start: AddAPI(MessageBox); AddAPI(ExitProcess); MessageBox(HWND_DESKTOP,"Hi! I'm the example program!","Win32 Assembly",MB_OK); ExitProcess(0); .end start |
|||
09 Jun 2005, 11:22 |
|
IronFelix 09 Jun 2005, 11:38
Thanks again, Privalov!
I have seen these new features only few years ago that's why I have't enough time to study it somehow. I am interesting in replacing fix with new features because such tecniques (I mean fixes) are used in my OOP macros. With new release it doesn't work. I am very lucky because I thought about OOP macros improvement and haven't done it earlier. In this case I would get a lot of convertions to do. Moreover, this new features will be very helpful in my work. I think I will be able to write such macros myself, but if I have any question I will ask, of course. Thanks and regards. |
|||
09 Jun 2005, 11:38 |
|
decard 09 Jun 2005, 15:24
I have a problem with Fresh macros for data definition (obviously they don't work). Currently they are:
Code: macro iglobal { IncludeIGlobals fix IncludeIGlobals, macro __IGlobalBlock { } macro uglobal { IncludeUGlobals fix IncludeUGlobals, macro __UGlobalBlock { } endg fix } macro __IncludeIGlobals dummy,[n] { forward __IGlobalBlock purge __IGlobalBlock } macro __IncludeUGlobals dummy,[n] { common local begin, size begin = $ virtual at $ forward __UGlobalBlock purge __UGlobalBlock common size = $ - begin end virtual rb size } macro IncludeAllGlobals { IncludeIGlobals IncludeUGlobals } IncludeIGlobals fix __IncludeIGlobals IncludeUGlobals fix __IncludeUGlobals I can't correct them |
|||
09 Jun 2005, 15:24 |
|
Tomasz Grysztar 09 Jun 2005, 15:58
Actually it's the same kind of solution as with IronFelix's macros:
Code: macro iglobal { IncludeIGlobals equ IncludeIGlobals, macro __IGlobalBlock { } macro uglobal { IncludeUGlobals equ IncludeUGlobals, macro __UGlobalBlock { } endg fix } macro __IncludeIGlobals dummy,[n] { forward __IGlobalBlock purge __IGlobalBlock } macro __IncludeUGlobals dummy,[n] { common local begin, size begin = $ virtual at $ forward __UGlobalBlock purge __UGlobalBlock common size = $ - begin end virtual rb size } macro IncludeAllGlobals { match I:U, IncludeIGlobals:IncludeUGlobals \{ I U \} } IncludeIGlobals equ __IncludeIGlobals IncludeUGlobals equ __IncludeUGlobals |
|||
09 Jun 2005, 15:58 |
|
Goto page 1, 2, 3, 4, 5 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.