EasyManua.ls Logo

HP HP-32S - Calling Subroutines (XEQ, RTN)

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...
For example, look at the program for 'Normal and Inverse-Normal
Distributions" on page 215 in part 4. This program has four routines,
labeled
S, D, N, and R
Routine
S 'initializes" the
program
by
collect
ing the input for the mean
and
standard deviation. Routine D sets a
limit
of
integration,
executes
routine N, and
displays
the
result.
Rou
tine N integrates the function defined in routine F
and
finishes the
probability calculation of
Q(x).
A routine typically starts with a label
(LBL)
and ends with an instruc
tion that alters or stops program execution, such as
RTN,
GTO, or
STOP,
or perhaps another label.
Calling
Subroutines
(XEQ, RTN)
A
subroutine
is a routine that is
called
from
(executed
by)
another rou
tine
and
returns
to
that
same
routine
when
the
subroutine is finished.
The subroutine must
start
with
a LBL
and
end
with
a RTN. A subrou
tine
is itself a
routine,
and
it
can
call
other
subroutines.
XEQ
must
branch
to a
label
(LBL)
for the
subroutine.
(It
cannot
branch to a line number.)
At the very
next
RTN
encountered,
program
execution
returns to
the line after the originating
XEQ.
For example, routine N in the 'Normal and Inverse-Normal Distribu
tions"
program
is a subroutine (to
calculate
Q(x))
that is
called
from
routine D by line D03
XEQ
N.
Routine N ends with a RTN instruc
tion that sends
program
execution
back to routine D (to store and
display the result) at line D04.
001
LBL
0
D02
INPUT
X
D03
XEQ
N
D04
STO
Q
005
VIEW
Q
006
GTO
D
N01
LBL
N
N02
RCL
X
\L
-, Calls subroutine at
LBL
N.
Starts
subroutine.
—•
N16
RTN
V Returns to the
calling
routine.
6:
Programming
Techniques
91

Table of Contents

Related product manuals