flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > The "#" on constants names |
Author |
|
THEWizardGenius 16 Aug 2005, 02:34
Quote:
*calls Tomasz* What's up with THIS? |
|||
16 Aug 2005, 02:34 |
|
revolution 16 Aug 2005, 03:12
The '#' only works inside macros (including rept and irp). For your case you will need to use the preprocessor 'rept' to make the labels. Perhaps something like this.
Code: rept 10 count {names#count=0} |
|||
16 Aug 2005, 03:12 |
|
LocoDelAssembly 16 Aug 2005, 15:23
Actually every name will have only one number, for example if I do "attach foo, bar", I'm specting foo1 and bar2 to be defined anymore.
Well I think with your help I will be able to do that now, thank you! |
|||
16 Aug 2005, 15:23 |
|
revolution 16 Aug 2005, 16:54
You need to put a double hash, one hash for each level of macro:
Code: macro attach [names]{ forward rept 10 count \{names##count=0\} ;<--- two hashes here } attach foo, bar ;display foo+'0', 13, 10 ; Doesn't work display foo1+'0', 13, 10 ; Works display bar10+'0', 13, 10 ; Works ;display names5+'0', 13, 10 ; Doesn't work rept 10 count {constant#count=0} display constant7+'0', 13, 10 ; Works |
|||
16 Aug 2005, 16:54 |
|
LocoDelAssembly 16 Aug 2005, 16:59
No, wait, it doesn't work either
Code: macro attach [names]{ forward rept 10 count \{names#count=0\} } attach foo, bar display foo+'0', 13, 10 ; Doesn't work display foo1+'0', 13, 10 ; Doesn't work display bar10+'0', 13, 10 ; Doesn't work display names5+'0', 13, 10 ; Doesn't work rept 10 count {constant#count=0} display constant7+'0', 13, 10 ; Works |
|||
16 Aug 2005, 16:59 |
|
Tomasz Grysztar 16 Aug 2005, 17:02
Actually according to the current manuals, you should use backslashes to escape the hash as many times as you need, as with any other macro-specific operators. The multiple hashes are kept for backward compatibility, but are no longer documented officially.
|
|||
16 Aug 2005, 17:02 |
|
LocoDelAssembly 16 Aug 2005, 17:33
Code: macro attach [names]{ forward rept 10 count \{names \# count=count\} } Thanks Tomasz |
|||
16 Aug 2005, 17:33 |
|
LocoDelAssembly 16 Aug 2005, 23:07
Well, after hours of tries I'm still having problems doing this
I need a macro which do the following: Code: someMacro 1, 5, 7, 10.5 ;At this point I want these numerical constants (not equates) defined and with these values ;value1 = 1 ;value2 = 5 ;value3 = 7 ;value4 = 10.5 I can't find a way to do that |
|||
16 Aug 2005, 23:07 |
|
Reverend 16 Aug 2005, 23:56
Code: irps count, 1 2 3 4 5 6 7 8 9 10 { foo # count = count } |
|||
16 Aug 2005, 23:56 |
|
LocoDelAssembly 17 Aug 2005, 00:36
Reverend, it doesn't works either. I need every constant with the values passed to the macro, not "fooX = X".
Another example: Code: someMacro 10, 7.2, aConstant ; At this point I need EXACTLY these constants defined with those values: ;foo1 = 10 ;foo2 = 7.2 if foo3 = aConstant display "OK, the macro works!!",13,10 end if |
|||
17 Aug 2005, 00:36 |
|
UCM 17 Aug 2005, 01:06
oh, btw you mean:
if foo3 eq aConstant not if foo3 = aConstant cause it woudn't be valid, = is for assigning constants. _________________ This calls for... Ultra CRUNCHY Man! Ta da!! *crunch* |
|||
17 Aug 2005, 01:06 |
|
LocoDelAssembly 17 Aug 2005, 01:11
UCM, "if foo3 = aConstant" is valid, check it with this if you want:
Code: foo = 4 bar = 5 if foo = bar display "foo = 5",13,10 end if bar = bar - 1 if foo = bar display "foo = 4",13,10 end if |
|||
17 Aug 2005, 01:11 |
|
revolution 17 Aug 2005, 01:18
Code: macro bar name,[count,value] {forward name#count=value} bar foo,1,1,2,5,3,7,4,10 bar foo,1,10,2,7.2,3,aConstant |
|||
17 Aug 2005, 01:18 |
|
LocoDelAssembly 17 Aug 2005, 01:48
revolution wrote: BUt I think you want automatic numbering? |
|||
17 Aug 2005, 01:48 |
|
UCM 17 Aug 2005, 02:09
Oh, well maybe I'm getting rather mixed up.
_________________ This calls for... Ultra CRUNCHY Man! Ta da!! *crunch* |
|||
17 Aug 2005, 02:09 |
|
Tomasz Grysztar 17 Aug 2005, 09:42
One of possible solutions is:
Code: macro someMacro [val] { common counter equ 1 forward match current,counter ; this we need to get value of counter before preprocessing \{ value \# current = val rept 2 i:current \\{ counter equ i \\} ; this increases the counter \} } someMacro 1,5,7,10.5 ; it defines value1=1, value2=5, etc. |
|||
17 Aug 2005, 09:42 |
|
Madis731 17 Aug 2005, 10:01
On a side-topic about constants:
Is there a way to visually unpack bits and FASM still generates: Code: mov eax,1000 0000b Of course FASM gives error here, but what can delete the extra spaces for FASM to assemble? |
|||
17 Aug 2005, 10:01 |
|
LocoDelAssembly 17 Aug 2005, 11:27
Excelent Tomasz, thank you!!!
Just another question, why only works with "rept 2"? I can't see why is needed repeat 2 times "counter equ i". [edit]I know now, the first time "counter EQU i" and the second time "counter EQU (i+1)", sorry [/edit] |
|||
17 Aug 2005, 11:27 |
|
vid 17 Aug 2005, 19:12
grrr, i was going to make same solution as privalov but i forgot to escape # operator... grrr, i could have been first ))
|
|||
17 Aug 2005, 19:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.