flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Confusion with defining one macro by another (pg 75) |
Author |
|
Remy Vincent 17 Sep 2005, 00:03
Macro is a waste of time, is it so hard to copy xx times the two lines... I don't know how macro works & i hope i will never have to learn this "unstick from the Code" way of programming !
_________________ Groups lower your IQ |
|||
17 Sep 2005, 00:03 |
|
Eoin 17 Sep 2005, 00:16
Well now, macros aren't all bad. Anyway back on topic I came up with a solution;
Code: macro tprocMacro mname,[params] { common macro mname,params { forward CheckParam params common } macro tendpMacro { ; Do something here too } tproc fix tprocMacro tendp fix tendpMacro } It is used as following; Code: tproc MacroCode param1,param2 ; Do stuff tendp Now the remaining problem is that param1 seems to be counted as part of the mname parameter and so only param2 gets passed to the CheckParam macro which is supposed to perform some preprocessing on all the parameters for the macro. I take it the lack of a comma between 'MacroCode param1' is the problem, but putting one there gives an error. |
|||
17 Sep 2005, 00:16 |
|
Eoin 17 Sep 2005, 00:33
This seems a bit hacky, but it does work..
Code: macro tprocMacro mname,[params] { common match a b,mname \{ macro a b,params { CheckParam b \} forward CheckParam params } Is there a neater way? |
|||
17 Sep 2005, 00:33 |
|
Tomasz Grysztar 17 Sep 2005, 01:16
Quote:
This means that you can do something like: Code: tproc fix tprocMacro
tendp fix } tendpMacro And "tendpMacro" will be evaluated after finishing the definition started with "tprocMacro". |
|||
17 Sep 2005, 01:16 |
|
Eoin 19 Sep 2005, 01:49
Thank you for your reply Thomaz, the tendpMacro actually generates some code which needs to go with each instance of the generated macro as opposed to just with its definition, so the ordering tendp fix tendpMacro } works best in my case.
I am still having trouble processing the parameters though. I can't get a consistent method which will work for 0, 1 or 2+ parameters. The one I am using (above) accepts 2+ parameters only and work work with less. |
|||
19 Sep 2005, 01:49 |
|
Eoin 19 Sep 2005, 14:49
Ok I think I've come up with a clean solution which works for the different cases.
Code: macro tprocMacro name,[param] { common macro name param { if ~ param eq forward ; Parameter processing here common end if } macro tendpMacro { ; End stuff here } tproc fix tprocMacro tendp fix tendpMacro } In the end it seems quite simple, but sure thats what yo want. |
|||
19 Sep 2005, 14:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.