Section 6: Branching and Looping 77
Keystrokes Display
t04
23- 22 04
If condition is false,
branches to line 04 to
continue program by
restarting loop. (Note
that the line number
specified has been
changed.)
To run this revised program, we proceed as follows:
Keystrokes Display
¥
Sets calculator to Run
mode.
´CLEAR Q
0.000
100O1
100.000
Stores N
0
in R
1
.
4
4.
Keys in t.
¦
4.000
t.
70.711
8.000
N
4
.
50.000
12.000
N
8
.
35.355
N
12
.
0.000
Loop counter equals 0.
Exercise: Write a program that will enable a
salesperson to compute a commission at the rates
of 10% for sales up through $1,000 and 12.5%
for sales over $1,000. The test value (1,000) and
the commission rates can be stored for recall or
included in the program. Below, they are stored
in registers R
0
through R
2
for later recall by the
program.
Note: If a program requires that certain
numbers be in the X- and Y-registers
when instructions such as ® are executed, it is helpful when
writing the program to show the quantities in each register after
each instruction is executed, as in the following diagram.