Subroutinelusage - HP -11C Owner's Handbook Manual

Hide thumbs Also See for HP-11C:
Table of Contents

Advertisement

Section 8: Subroutines
121
The calculator can return back to the main program from
subroutines that are nested four deep, as shown. If you attempt to
call a subroutine that is nested five levels deep, the calculator will
halt and display Error 5 when it encounters the instruction calling
the fifth subroutine level.
Note: While any one set of nested subroutines can be up to
four levels deep, there is no limit to the number of nested
subroutine sets or non-nested subroutines you can include
in a program.
Subroutine Usage
Example. Write a program for cal-
culating the average slope between
x; and x5 on the graph shown, where
y=x?—sinx.
X1 X2
Solution: The average slope is given by the formula
yo—y1
_ (x° —sinxy) —(x2 —sinx))
X9 — X4
X9 — X1
Notice that the solution requires two computations of the
expression x2 — sin x (once for x = x; and again for x = x,).
Since the solution includes an expression that must be repeated for
both values of x, we can create a subroutine to execute the
repetition and save space in program memory.

Advertisement

Table of Contents
loading

Table of Contents