Is there an easy way of make unrolled loops with macros?
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Is there an easy way of make unrolled loops with macros?
The guy who programmed Toy Story used unrolled loops for 3D maze. Is that possible to do bass.exe or other assemblers?
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Is there an easy way of make unrolled loops with macros?
ca65 has the .repeat directive.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Is there an easy way of make unrolled loops with macros?
I looked through the documentation of bass.exe, and I figured out how to have a repeating macros.
Code: Select all
define n(0)
while {n} < 16 {
jsr spawn_single_explosion
evaluate n({n}+1)
}
Re: Is there an easy way of make unrolled loops with macros?
I always use macros to make unrolled loops. Doing it manually is too error-prone and difficult to maintain.
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Is there an easy way of make unrolled loops with macros?
In a situation where you have a way to define a macro (but no repeat), I've found this kind of thing to be a relatively straightforward / low risk of error way to unroll loops:
Mostly this has come up for me in C or C++ cases where I knew an unroll was warranted but the compiler's optimizer wasn't going to do it on its own. (In a lot of cases just writing a for loop with a simple static range is enough to get the optimizer to unroll anyway, though. This is not something I've had to use frequently at all.)
Code: Select all
.macro THING index
; loop iteration here
.endmacro
THING 0
THING 1
THING 2
THING 3
THING 4
THING 5
; ...
Re: Is there an easy way of make unrolled loops with macros?
^This, and automated with the command to print it in comments.
// for i in `seq 0 15`; do echo THING $i; done
// for i in `seq 0 15`; do echo THING $i; done