13–4 Programming Techniques
File name 32sii-Manual-E-0424
Printed Date : 2003/4/24 Size : 17.7 x 25.2 cm
Example:
A Nested Subroutine.
The following subroutine, labeled S, calculates the value of the expression
2222
dcba
+++
as part of a larger calculation in a larger program. The subroutine calls upon
another subroutine (a nested subroutine), labeled Q, to do the repetitive
squaring and addition. This saves memory by keeping the program shorter
than it would be without the subroutine.
Starts subroutine here.
"!
Enters A.
"!
Enters B.
"!
Enters C.
"!
Enters D.
Recalls the data.
º
%
1
A
2
.
2
%
3
A
2
+ B
2
.
4
%
5
A
2
+ B
2
+ C
2
6
!
2222
DCBA
+++
!
Returns to main routine.
135
Nested subroutine
º65¸
º
-
Adds x
2
.
246
!
Returns to subroutine S.