flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
IronFelix 05 Feb 2009, 21:35
Hapkidoyoka, maybe this will work as you need:
Code: macro setprefix prefix { global_prefix equ prefix defvar_count = 0 } macro defvar name { match pref , global_prefix \{ pref\#name = defvar_count \} defvar_count = defvar_count+1 } |
|||
![]() |
|
Hapkidoyoka 05 Feb 2009, 22:00
Many thanks IronFelix, It works nicely.
Now I've never understood the match directive. I can see what it does, just not a clear how/why. Thanks again ![]() |
|||
![]() |
|
IronFelix 05 Feb 2009, 22:10
You are welcome, Hapkidoyoka. As for "match" - it is very powerful and very useful preprocessor directive.
|
|||
![]() |
|
Hapkidoyoka 05 Feb 2009, 22:22
Not wanting to start a new thread...
Code: macro setprefix prefix { global_prefix equ prefix defvar_count = 0 } macro defvar name { match pref , global_prefix \{ pref\#name = defvar_count \} defvar_count = defvar_finished - defvar_count+1 } macro endprefix { defvar_finished = defvar_count } setprefix lvo defvar one defvar two .... endprefix The intent is to define the values in the reverse order. So there is initially an unknown number of them. Is there some kind of equ 'trick' to accomplish this? |
|||
![]() |
|
IronFelix 06 Feb 2009, 17:22
Not a "trick" I think
![]() Code: Def@VarList equ macro addto_equlist ListName,[param] { common match any , ListName \{ ListName equ any,param \} match , ListName \{ ListName equ param \} } macro setprefix prefix { global_prefix equ prefix } macro defvar name { addto_equlist Def@VarList, name } macro reverse_enum_defvars [defvar] { common local ind ind = 0 reverse match pref , global_prefix \{ pref\#defvar = ind ind = ind + 1 \} } macro endprefix { match all, Def@VarList \{ reverse_enum_defvars all \} } setprefix lvo defvar one defvar two endprefix display "lvoone = ",lvoone + 48,13,10 display "lvotwo = ",lvotwo + 48,13,10 Suppose this will do what you need. |
|||
![]() |
|
Tomasz Grysztar 06 Feb 2009, 17:36
The much simpler correction may be enough:
Code: macro setprefix prefix { global_prefix equ prefix defvar_count = 0 } macro defvar name { match pref , global_prefix \{ pref\#name = defvar_finished - defvar_count \} defvar_count = defvar_count+1 } macro endprefix { defvar_finished = defvar_count } setprefix lvo defvar one defvar two endprefix |
|||
![]() |
|
Hapkidoyoka 06 Feb 2009, 17:59
IronFelix,
With your previous advice I was coming up with something very similar; So cudos to the teacher. I'm not sure what the slash does in pref\#name, that got me into a little trouble ![]() Does the @ symbol in Def@VarList do anything special? I'm up and running, now I can concentrate more on code than macros. Again you have my thanks, you're a diamond sir. |
|||
![]() |
|
IronFelix 06 Feb 2009, 18:29
Too much thanks for such small advice, Hapkidoyoka... You are just welcome.
Tomasz, thank for your correction. And in order not to make a new thread please tell me, what is faster compiled: code with a lot of assembler directives (constants and arithmetic/logical operators), which can increase compile passes I suppose, or using preprocessor where possible (equ, define, match), as it is done only one pass with it? If there are any mistakes in my suggestions, sorry for that. |
|||
![]() |
|
IronFelix 06 Feb 2009, 18:30
As for @ symbol - it has no special meaning.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.