5.6. Optimization Considerations when using Loops

Here is a tip if you want to optimize your assembling. Kick assembler has two modes of executing directives. ‘Function Mode’ is used when the directive is placed inside a function or define directive, otherwise ‘Asm Mode’ is used. ‘Function Mode’ is executed fast but is restricted to script commands only (.var, .const, .for, etc.), while ‘Asm Mode’ remembers intermediate results so the assembler won't have to make the same calculations in succeeding passes.

If you make heavy calculations and get slow performance or lack of memory, then place your for loops inside a define directive or inside a function. No time or memory will be wasted to record intermediate results, and the define directive or the directive that called the function, will remember the result in the succeeding passes.

Read more about the define directive in the section ‘Working with mutable values’.