flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 08 Dec 2007, 19:55
Unrolling would be this:
Code: l%: l%: l%: l%: l%: l%: ... "repeat" does not instantiates the macro multiple times, it occurs only once at preprocessing time, so, what you need is this Code: loco@athlon64:~/Desktop$ cat plue.asm macro MK NUM { l#NUM: } rept 6 count { MK count } push l1 l2 l3 l4 l5 l6 ; Just to test that the symbols are defined loco@athlon64:~/Desktop$ fasm plue.asm flat assembler version 1.67.24 (16384 kilobytes memory) 1 passes, 12 bytes. |
|||
![]() |
|
Plue 08 Dec 2007, 20:05
What's the use for repeat if rept does it better? Why isn't the first repeat unrolled to this?
mov [v_a], % mov [v_a], % mov [v_a], % mov [v_a], % mov [v_a], % mov [v_a], % |
|||
![]() |
|
LocoDelAssembly 08 Dec 2007, 20:28
The problem is that the concatenation occurs at preprocessing time only so the assembler layer is not able to create labels attaching the value of % to them. The rept however does textual repetition of the macro so it is instantiated 6 times while the repeat assembler directive does not do any textual repetition, just interpret the lines again incrementing the output.
To summarize, this is the text that the assembler receives with rept Code: l1: l2: l3: l4: l5: l6: And this with repeat Code: repeat 6 l%: end repeat The rule is that if the macro does not define any label you can use "repeat" with them, otherwise you need the less flexible and more memory consuming (at compile time) "rept". And concerning your other code with repeat is this Code: repeat 6 mov [v_a], % end repeat And with rept 6, count is Code: ; rept 6, count {MK count} mov [v_a], 1 mov [v_a], 2 mov [v_a], 3 mov [v_a], 4 mov [v_a], 5 mov [v_a], 6 This time the output will be the same, but the source text that the assembler receives is different. |
|||
![]() |
|
Tomasz Grysztar 08 Dec 2007, 21:16
Note: when you've got a situation where both REPT and REPEAT will be good for your purpose, choose REPEAT, as it will eat less memory during the compilation, and will assemble a little bit faster, too.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.