Section 10: The Index Register and Loop Control 113
Here is a revision of the original radioisotope decay program. This
time, we will limit the program to three executions of the loop rather
than setting a specific limit value. This example uses
e
with a
loop control number in R
2
of
3.0 0 0 0 1.
initial loop counter
decrement value
test (goal) value
Make the following changes to the program (assuming it is in memory). A
loop counter will be stored in R
2
and a line number in the Index register.
Keystrokes
Display
|
¥
000-
Program mode.
t“
013
013-43,30, 9
The second of the two loop
test condition lines.
−−
011- 42 31
Delete lines 013 and 012.
´e
2
012-42, 5, 2
Add your loop counter
function (counter stored in
R
2
).
t
V
013- 22 25
Go to given line number
(015).
Now when the loop counter (stored in R
2
) has reached zero, it will skip line
013 and go on to 014, the
n
instruction, thereby ending the program. If
the loop counter has not yet decreased to zero, execution continues with line
013. This branches to line 015 and continues the program and the looping.
To run the program, put
t
1
(day 1) in R
0
, N
0
(initial isotope batch) in R
1
the
loop counter in R
2
, and the line number for branching in the Index register.
Keystrokes
Display
|
¥
Run mode.
2
O
0
2.00000
t
1
.
100
O
1
100.0000
N
0
.
3.000001
O
2
3.0000
Loop counter. (This
instruction could also be
programmed.)
Summary of Contents for HP-15C
Page 1: ...HP 15C Owner s Handbook HP Part Number 00015 90001 Edition 2 4 Sep 2011 ...
Page 17: ...Part l HP 15C Fundamentals ...
Page 64: ......
Page 65: ...Part ll HP 15C Programming ...
Page 118: ...118 ...