HP -67 Owner's Handbook Manual page 202

Hide thumbs Also See for HP-67:
Table of Contents

Advertisement

198
Subroutines
In the top illustration of a branch, if you pressed £ from the keyboard,
the program would execute instructions sequentially downward
through program memory. If it encountered a
[ instruction, it
would then search for the next
3@ and continue execution from
there, until it encountered a (RTN). When it executed the
instruc-
tion, execution would stop.
However, if the running program encounters a (G55 ) (go to sub-
routine B) instruction, as shown in the lower illustration, it searches
downward for the next
3 and resumes execution. Whenit en-
counters a
(return), program execution is once again transferred,
this time back to the point of origin of the subroutine, and execution
resumes with the next instruction after the (G55 (3.
As you can see, the only difference between a subroutine and a normal
branch is the transfer of execution after the [RTN]. After a
, the
next
halts a running program; after a (G53 or (GSE1), the next
returns execution back to the main program, where it continues
until another
(or a (R/8)) is encountered. The same routine may
be executed by
and (G55 any number of times in a program.
Example: A quadratic equationis of the formax? + bx +c¢ =0. Its two
\/p2 —
roots may be found by the formulas r, = b+
ZZ
4ac
and
-
— \/p2 —
T2 =——b———2'ifl— . Notice the similarity between the solu-
tions for r; and r,. The program below permits you to key the values
fora, b, and ¢ beneath user-definable keys ¥, 1, and [3 ; the resultant
roots r; and r, are available by pressing ) and [3 . Were you to record
this program on a magnetic card, the card might look like this:
'1
Qflfi@flflf'/c
;eaors
Z'
ke ke s- e 1 e d

Advertisement

Table of Contents
loading

Table of Contents