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 R2 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 R2 and a line number in the Index register.

Keystrokes

Display

¥

000-

t“013

013-43,30, 9

−−011- 42 31

´e2

012-42, 5, 2

tV

013- 22 25

Program mode.

The second of the two loop test condition lines.

Delete lines 013 and 012.

Add your loop counter function (counter stored in R2).

Go to given line number (015).

Now when the loop counter (stored in R2) has reached zero, it will skip line 013 and go on to 014, the ninstruction, 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 t1 (day 1) in R0, N0 (initial isotope batch) in R1 the loop counter in R2, and the line number for branching in the Index register.

Keystrokes

Display

 

¥

 

Run mode.

2 O0

2.00000

t1.

100 O1

100.0000

N0.

3.000001 O2

3.0000

Loop counter. (This

 

 

instruction could also be

 

 

programmed.)