flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > help me please... |
Author |
|
luckystar 07 Nov 2007, 04:49
1. How to get macroinstructions parameter count?
2. How to show current line number by use "display"? |
|||
07 Nov 2007, 04:49 |
|
vid 07 Nov 2007, 05:22
1.
Code: macro [a] { common count=0 if ~ a eq ;in case there are 0 arguments forward count=count+1 common end if ;here, "count" holds number of arguments } 2. you need to make some macro which converts number to ascii digits. You can download FASMLIB and take a look at src/fasmlib/display.inc. Usage of macro is described in doc/fasmlib.chm -> FASM-Specific -> disp |
|||
07 Nov 2007, 05:22 |
|
vid 07 Nov 2007, 06:43
another (funny) way for parameter count:
Code: macro name [arg] { common count equ 0 forward match c, count \{ count equ (c+1) ; <- this instead of rept \} common match ,args \{ restore count \} } Quote: vid, but wouldn't he need Tomasz's modification to support line numbers too? hmm, i thought some kind of %L is built-in, isn't it? |
|||
07 Nov 2007, 06:43 |
|
LocoDelAssembly 07 Nov 2007, 15:56
haha. But note that count will be usable only from assembling time as you previous code.
And no there is no such built-in (unless it is undocumented, I've just checked), but I remember that Tomasz posted how to modify fasm sources to get this feature. Where he posted it is the question |
|||
07 Nov 2007, 15:56 |
|
Tomasz Grysztar 07 Nov 2007, 16:00
I posted it here.
|
|||
07 Nov 2007, 16:00 |
|
MCD 11 Nov 2007, 23:20
I have a little optimized version of your macro, vid:
Code: macro name [arg] { common count equ 0 forward match c, count \{ count equ c+1 ;removed the parenthesises \} common match ,args \{ restore count \} } unfortunately, both mine and vid's version have the disadvantage of O(n^2) memory requirement if you want to count to n, which is pretty unusable. LocoDelAssembly's version only require O(n) memory. |
|||
11 Nov 2007, 23:20 |
|
LocoDelAssembly 11 Nov 2007, 23:53
I've never quantified memory usage
Sorry to insist so much with this but I say again, vid version and yours does not make "count" usable on preprocessing time and hence both have no benefits over first vid's version. Example: Code: ; Supposing that my version does not make "count" local name a, b, c match c, count { display "Output: " rept c \{display "^"\} display 13, 10 } Displays "Output: ^^^" vid's version fails at " rept c \{display "^"\}" telling "invalid value" and yours for my surprise works (in the sense of no errors) but displays "Output: " only. However IMHO your version should trigger an error too so seems that you have discovered a bug! This is the result after passing FASMPRE with your version Code: ;match c,0+1+1+1 ;{ ; display 'Output: ' ; rept c \{ display '^' \} ; display 13,10 ;} display 'Output: ' ;rept 0+1+1+1{display '^'} display 13,10 However, if instead of starting with "0+" it starts with a non-zero value then it fails as expected. |
|||
11 Nov 2007, 23:53 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.