Operation Manual

Section 9: Branching and Looping 107
Y-registers (as also explained in Appendix A): that is, it will place the income
back into the X-register and place the test value into the Y-register. This is
necessary because when either the :2 instruction in line 005 or the :1
instruction in line 007 is executed, the number in the X-register is moved into the
Y-register; if the ~ instruction were not included, the test value 20,000, rather
than the income, would be in the Y-register when the b instruction in line 008
is executed.
Now, we'll store the required numbers in registers R
0
, R
1
, and R
2
, then we’ll run
the program, using Ê so that we can check that the branching occurs properly.
It’s good practice with programs containing conditional test instructions to check
that the program branches correctly for all possible conditions: in this case, if the
income is less than, equal to, or greater than the test value.
Keystrokes
(RPN mode)
Display
fs
007,43,33,002
Sets calculator to Program mode.
(Display shows program line at
which execution was halted at end
of preceding example.)
f]
007,43,33,002
Sets RPN mode.
fCLEARÎ
000,
Clears program memory.
:0
001, 45 0
Recalls test value into X register
and places income in Y-register.
~
002, 34
Places income in X register and
test value in Y-register.
go
003, 43 34
Tests whether number in
X-register (income) is less than or
equal to number in Y-register
(20,000).
gi007
004,43,33,007
If condition is true, branches to
program line 007.
:2
005, 45 2
If condition is false, recalls 25%
tax rate to X-register.
gi008
006,43,33,008
Branches to program line 008.
:1
007, 45 1
Recalls 20% tax rate to X-register.
b
008, 25
Calculates tax.
fs
–12.36
Sets calculator to Run mode.
(Display shows results of running
of previous program.)