flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > mixed multiple optional macro arguments |
Author |
|
pelaillo 20 Feb 2004, 19:15
Code: macro foo title,[name,value] { i = 0 forward i = i + 1 display "foo ",i+30h display 9,"name:",9,name,13,10 display 9,9,"value:",9,value,13,10 common display name,13,10 bar name,value } macro bar [name,value] { common bar2 name,value } macro bar1 [name,value] { i = 0 forward i = i + 1 display "bar ",i+30h display 9,"name:",9,name,13,10 display 9,9,"value:",9,value,13,10 } macro bar2 [name,value] { common bar1 name,value } |
|||
20 Feb 2004, 19:15 |
|
comrade 20 Feb 2004, 21:38
Heh, nice Fixing the bug by using the bug
Muchos gracias |
|||
20 Feb 2004, 21:38 |
|
comrade 20 Feb 2004, 21:49
Hmm, the amount of passing you have to do depends on number of name/value pairs. Trying to make recursive passage leads to "illegal instruction error". It look like FASM does not allow make recursive macro call. Even if you have two macros, one calling each other, it will still have same error, because apparently macro cannot call its parent (theoretically that also result in recursive call).
|
|||
20 Feb 2004, 21:49 |
|
pelaillo 20 Feb 2004, 23:23
Yes, I'm affraid
I was triyng with counters and mod but nothing. I think it remains only to fix the bug |
|||
20 Feb 2004, 23:23 |
|
comrade 20 Feb 2004, 23:43
And so we wait for the master...
|
|||
20 Feb 2004, 23:43 |
|
S.T.A.S. 21 Feb 2004, 05:07
Code: macro foo title,[name,value] { common i = 0 local boo forward i = i + 1 display "foo ",i+30h,":",13,10 display 9,"name:",9,name,13,10 display 9,"value:",9,value,13,10 boo fix boo, name,value common bar boo } macro bar dummy,[name,value] { i = 0 forward i = i + 1 display "bar ",i+30h,":",13,10 display 9,"name:",9,name,13,10 display 9,"value:",9,value,13,10 } result Code: foo 1: name: include value: yes foo 2: name: name value: value foo 3: name: one value: 1 foo 4: name: two value: 2 bar 1: name: include value: yes bar 2: name: name value: value bar 3: name: one value: 1 bar 4: name: two value: 2 |
|||
21 Feb 2004, 05:07 |
|
Tomasz Grysztar 21 Feb 2004, 09:53
From the fasm's manual:
Quote: If some name inside macroinstruction has multiple values (it is either one of the arguments enclosed in square brackets or local name defined in the block following forward or reverse directive) and is used in block following the common directive, it will be replaced with all of its values, separated with commas. So when "name" has multiple values of "include", "name", "one" and "two"; in common block "name" is replaced with "include,name,one,two". In the same way the "value" is replaced in common block with "yes,value,1,2". So when you write: Code: common
bar name,value it becomes: Code: bar "include","name","one","two" , "yes","value","1","2" |
|||
21 Feb 2004, 09:53 |
|
comrade 21 Feb 2004, 17:16
Ok, so how do I get desirable effect?
|
|||
21 Feb 2004, 17:16 |
|
Tomasz Grysztar 21 Feb 2004, 21:24
Use "fix", as S.T.A.S, or just redesign your macros.
|
|||
21 Feb 2004, 21:24 |
|
comrade 21 Feb 2004, 22:53
Don't you agree desireable effect is not to concatenate into one line? I do not understand why this "behaviour" is considered correct
|
|||
21 Feb 2004, 22:53 |
|
comrade 22 Feb 2004, 01:34
Problem with fix is it is constant; I desire dynamic values
|
|||
22 Feb 2004, 01:34 |
|
S.T.A.S. 22 Feb 2004, 07:07
Quote: not to concatenate into one line It's not desirable *every* time. For your current purpose it's better to be so, for other ones it could be better to keep things as they are. IMHO, it's always better to have the choise. And FASM gives us it. We can use current sintaxis or just FIX some thing BTW, I'm confused, why fix don't suit you? It's not constant, "fix" just builds a list of foo's parameters avery time you call the macro, and then pass them to the next macro, just adding emty one at the beginning of the list. So bar always get the same parameters as foo has. Just one thing to be worked arround - the first "dummy" parameter, but it's not problem at all, I think. I guess, your real macro are much more complex that this given example |
|||
22 Feb 2004, 07:07 |
|
Tomasz Grysztar 22 Feb 2004, 14:32
comrade wrote: Don't you agree desireable effect is not to concatenate into one line? I do not understand why this "behaviour" is considered correct What do you really mean? The current behavior logically comes from the idea of "forward"/"reverse"/"common" feature - with "common" block you have an arrays of parameters, as this block is processed for all the parameters at once. So the names of parameters are replaced with the entire arrays; the only other logical solution was to not allow to use such names in common blocks at all, but it would be only more limiting (though I often used such kind of design in fasm, just to avoid any logical inconsequencies). |
|||
22 Feb 2004, 14:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.