Section 5: Programming Basics 67
Stopping Program Execution Automatically
Program execution is automatically halted when the program executes a ¦
instruction. To resume executing the program from the program line at which
execution was halted, press ¦.
Example: Mother's Kitchen, a canning
company, wants to package a ready-to-eat
spaghetti mix containing three cans: one of
spaghetti sauce, one of grated cheese, and one
of meatballs. Mother's needs to calculate the
base areas, total surface areas, and volumes of
the three cylindrically shaped cans. It would
also like to know, per package, the total can
base area, surface area, and volume.
The program to calculate this information uses
these formulas and data:
base area = πr
2
volume = base area × height = πr
2
h
surface area = 2 × base area + side area = 2πr
2
+ 2πrh
The keystroke sequence will use storage register arithmetic (described on page
30) in registers R
1
, R
2
, and R
3
to calculate area and volume sums. We will clear
the registers before starting to ensure that the column sums are initialized to
zero.
Since r must be used twice in the course of the calculations, we'll store r in R
0
.
We will do this prior to running the program, since r will vary with each run.
We will then recall r in the program with a l instruction. We will enter h
directly, right after the base area calculation is made. We will provide for the
program to stop at this point, so that the data can be entered. This is
accomplished with an ¦ instruction in the program. We can then manually
restart the program by pressing ¦. (Alternatively, we could store and recall
h, as for r, though in this program it would require more total keystrokes to do
so.) This illustrates the two modes of data entry in a program:
1. Prior entry. Store (with O the data in a storage register prior to
running the program, and then recall it (with l) within the
program.