Download  Print this page

Program Control With (i) - HP -32S Owner's Manual

Rpn scientific calculator.
Hide thumbs

Advertisement

Program Control With (i)
Since the contents of i can change each time a program runs—or even
in different parts of thesame program—a program instruction such as
GTO <i > can branch to a different label at different times. This main
tains flexibility by leaving open (until the program runs) exactly
which variable or program label will be needed. (See the first example
below.)
Indirect addressing is very useful for counting and controlling loops.
The variable i serves as an index, holding the address of the variable
that contains the loop-control number for the functions DSE and ISG.
(See the second example below.)
Example: Choosing Subroutines With (f). The 'Curve Fitting' pro
gram on page 204 in part 4 uses indirect addressing to determine
which model to use to compute estimated values for x and y. (Differ
ent subroutines compute x and y for the different models.) Notice that
i is stored and then indirectly addressed in widely separated parts of
the program.
The first four routines (S, L, E, P) of the program specify the curve-
fitting modelthat will be used and assign a number (1, 2, 3, 4) to each
of these models. This number is then stored during routine Z, the
common entry point for all models:
Z83
STO
i
Routine Y uses i to call the appropriate subroutine (by model) to cal
culate the x- and y-estimates. line Y03 calls the subroutine to
compute y:
Y03
XEGKi)
and line Y08 calls a different subroutine to compute x after i has been
increased by 6:
Y86
6
Y07
ST0+
i
Y08
XEGKi)
6: Programming Techniques
105

Advertisement

Table of Contents

   Related Manuals for HP HP-32S

Comments to this Manuals

Symbols: 0
Latest comments: