slc/examples/loop.slc
2025-01-27 04:03:44 +01:00

21 lines
603 B
Plaintext

// Easiest way to create loops are "misusing" the call stack!
// That is instead of creating "real" loops in SLC or labels and GOTOs,
// we can have a word (loop) that basically calls to its own code location.
// A do-while loop is then as follows:
loop
....
if(feltétel) { ret } [ endloop ]
// A while-loop is then as follows:
loop if(feltétel) {
...
ret
} endloop
// Rem.: "ret" is literally the written-out word for returning; endloop is "removing" (and throwing away) call stack top.
// Rem.: This does not make "loops into recursion" because the stack does not grow while loop is going on!