There is the following example in Maestro Servo Controller’s User’s Guide:
10 # start with a 10 on the stack
begin
dup # copy the number on the stack - the copy will be consumed by WHILE
while # jump to the end if the count reaches 0
8000 1 servo
500 delay
4000 1 servo
500 delay
1 minus # subtract 1 from the number of times remaining
repeat
What I do not understand here is whether this leaves a zero value staying in the stack after the completion of the countdown from 10 to 0.
If this is not the case and if the stack is all clean after running this code, in which line is this stack value being consumed?
If it is left on the stack, should we add a “drop” at the end of the repeat to prevent a potential stack overflow (to prevent these 0 stack values accumulating later in the code if many while loops are used this way)?