EasyManua.ls Logo

HP HP-32S - Program Control with (I)

HP HP-32S
312 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Program
Control
With
(i)
Since the contents of i can change each time a program runs—or even
in
different
parts
ofthe
same
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
willbe
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 numberfor 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
xand 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-
fittingmodelthat willbe usedand
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

Table of Contents

Related product manuals