HP-28S
START Usage:
• start end START instructions NEXT
• start end START instructions step-size STEP
"start" end "end" denote the start and end values of the loop counter. With
NEXT "instructions" are executed end-start+1 times.
With STEP the loop counter is incremented by "step-size" and the loop stops
when the loop counter exceeds "end".
Note that the value of the loop counter is not accessible to the program!
FOR Usage:
• start end FOR name instructions NEXT
• start end FOR name instructions step-size STEP
"start" and "end" denote the start and end values of the loop counter. The
current value of the loop counter is stored in the local variable "name".
With NEXT "instructions" are executed end-start+1 times.
With STEP the loop counter is incremented by "step-size" and the loop stops
when the loop counter exceeds "end". Example:
<<→ n << 1 n START x x DUP * NEXT n →LIST >>
returns a list of squares from 1 to n.
The "instructions" are never executed if initially start>end.
NEXT Used with START and FOR
STEP Used with START and FOR
IFT Similar to IF-THEN-END:
• test-instruction true-instruction IFT
If "test-instructions" evaluates to a non-0 value then the true-instruction is
executed (evaluated). Otherwise no action occurs.
1 2 3 IFT results in 1 3 because 2 evaluates to true and 3 is executed.
IFTE Similar to IF-THEN-ELSE-END:
• test-instruction true-instruction false-instruction IFT
If "test-instructions" evaluates to a non-0 value then the true-instruction is
executed (evaluated). Otherwise the false-instruction is executed.
1 2 3 IFTE results in 2 because 1 evaluates to true and 2 is executed but 3
is not.
DO Usage:
• DO loop-instructions UNTIL test-instruction END
The "loop-instructions" are evaluated until the "test-instructions" evaluates to
a non-0 value. The "loop-instructions" are evaluated at least once.
UNTI UNTIL. Used with DO
END Used with various branch instructions
WHIL WHILE. Usage:
• WHILE test-instruction REPEAT loop-instructions END
While the "test-instruction" evaluates to a non-0 value the "loop-instructions"
are executed. The "loop-instructions" may never be executed.
REPEA REPEAT. Used with WHILE.
END Used with various branch instructions
27