Sudioulines - HP -11C Owner's Handbook Manual

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

Advertisement

210
Section 11: Programming Techniques
At first glance this may look complicated, but closer inspection
reveals a simple logic. To read the chart, start at the upper left-
hand corner and follow the arrows. Each box is connected to the
next by one-way arrows. In other words, the flow is in one
direction, generally from top to bottom.
Note that at the box marked #1 there is a choice of exits or a
"branch". The direction of flow at this point is determined by the
answer to the question asked within the box, in this case, "Is the
value in Ry greater than or equal to zero?" An answer of "yes"
channels the flow to the right while an answer of "no'"' channels
the flow downward.
As you can see, a flowchart can be very useful in eliminating
confusion, especially around branches and loops, where there is an
option in the direction of program flow.
Subroutines
Perhaps the first thing you notice when previewing the Matrix
Algebra program is its surprising length. It is so long that it cannot
be contained, in its entirety, in the memory of the calculator. What
is not immediately obvious is that it is also a highly condensed
program. This is because the program takes advantage of the
many repeated patterns involved in solving the problem. In fact,
even the operation of taking the matrix's inverse is repeated.
Therefore, this and several lesser functions have been incorporated
into the program as subroutines.
Technically, in the language of the calculator, a subroutine can be
any series of keystrokes that begins with a label (
n) and ends
with a return ([RTN]) or the end of the program. These boundaries
allow entry into and exit from the subroutine. (In fact, entry into a
subroutine may be achieved at any line number. Refer to page 137,
Indirect Line Number Branches and Subroutines.)
Access is gained to the subroutine via the
n (go to subroutine
n) command. Notice that in the main body (steps 000 through 078)
of the Matrix Algebra program
8 is encountered eight times.
Each time, the flow jumps from
8 to
8, completes the
series of steps between
8 and [RTN], and returns to the step
immediately following
8.
The usefulness of the subroutine becomes obvious first in its space
savings. It is better to call subroutine 8 with eight [GSB]'s than to

Advertisement

Table of Contents
loading

Table of Contents