flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > using types defined with EQU in structures |
Author |
|
Tomasz Grysztar 03 Dec 2006, 18:59
Since macro processing is of higher precedence than symbolic variables, this cannot be done with EQU. You may do it like:
Code: macro typedef type,base { struc type [v] \{ \common . base v \} macro type [v] \{ \common base v \} } typedef long, dd typedef DWORD, long struct STRUCT_NAME FIELD1 long ? FIELD2 DWORD ? ends |
|||
03 Dec 2006, 18:59 |
|
AsmER 03 Dec 2006, 20:38
At this point all I can say is: Woooow!!! That's realy impressive!
Thanks a lot. |
|||
03 Dec 2006, 20:38 |
|
Tomasz Grysztar 03 Dec 2006, 21:12
It may be not bad idea to include such macro in STRUCT.INC. Do you think this syntax is a good one? Using MATCH it's possible to have many alternatives, for example more C-like one:
Code: macro typedef statement { match base type,statement \{ struc type [v] \\{ \\common . base v \\} macro type [v] \\{ \common base v \\} \} } typedef dd long typedef long DWORD |
|||
03 Dec 2006, 21:12 |
|
AsmER 04 Dec 2006, 00:39
Personally I think that the first version of the macroinstruction is more readable (it's code-anyway I'm not sure what does it exactly do in cases of structures-I was reading section about macros in fasm's help file but I can't learn them) and it's syntax is a bit similar to MOV's (the second argument is 'moved' to the first one).
But actually there is a problem with it, as such macro-defined types aren't working with 'LOCAL' macros in procedures & for example 'typedef DWORD, long' will cause errors if somebody will attempt to write code like 'push DWORD 5' is there any way our 'typedef' can be improved? |
|||
04 Dec 2006, 00:39 |
|
vid 04 Dec 2006, 00:44
i prefer C-compatible syntax
|
|||
04 Dec 2006, 00:44 |
|
Tomasz Grysztar 04 Dec 2006, 17:25
With local it doesn't work because DD is not a type that can work without given value (as types defined with "struct" do), so you have to do it like "local a: dd ?" and thus "local a: long ?".
To make it work without "?" you may define "long" type like here: Code: struc long v { if <v> eq <> . dd ? else . dd v end if } Or: redefine the "dd" this way to accept empty definition and then use "typedef" macro as above. As for the possible conflict of DWORD macros (if you define such) with size operators, I can only advise to write the size overrides in other form than uppercase. |
|||
04 Dec 2006, 17:25 |
|
AsmER 04 Dec 2006, 22:22
Thanks Tomasz, that's far enough. Now I just can hope that you will still support fasm so it won't 'die' as tasm did. Thanks again.
|
|||
04 Dec 2006, 22:22 |
|
dead_body 05 Dec 2006, 06:02
to add something like: typedef long DWORD - is a good idea.(IMHO)
|
|||
05 Dec 2006, 06:02 |
|
IceStudent 05 Dec 2006, 20:24
It's good, but if will be used C syntax.
|
|||
05 Dec 2006, 20:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.