Hi Graham
But the return pointer has to be stored for every iteration.
Yes, true, BUT ...
If I think in terms of Assembler, a return address does have to be stored on the stack, but it gets overwritten with each call. After all, once the program returns from the called sub, the pointer on the stack can be wiped out (ie, overwritten). So calling a sub 10 times or 10,000 times makes no changes in stack size per se. OK, I don't know how Mach3 is written, but would think the same would apply for (most) any language.
Nested subroutines? Yes, already done of course.
That even has some advantages: where I don't need the extra resolution, I can just put the 2nd loop parameter equal to 1 rather than, say, 20. Not that it matters very much with a gigahertz processor driving a metal-working CNC!
But still, I ask why?
Cheers
Roger