5. A subroutine can have several entry points. For instance, because of the way our main program uses
them, with
GOSUB
1000 followed immediately by
GOSUB
2000, we can replace our two subroutines by
one big one that adjusts L, S & D & then prints them. It has two entry points: one at the beginning for the
whole subroutine, & another further on for the printing part only.
Make the necessary rearrangements.
6. Run the program:
10
GOSUB
20
20
GOSUB
10
The return addresses are pushed on to the
GOSUB
stack in droves, but they never get taken off again &
eventually there is no room for any more in the computer. The program then stops with error 4 (see
appendix B).
You might have difficulty in clearing them out again without losing everything, but this will work.
(i) Delete the two
GOSUB
statements.
(ii) Insert two new lines
11
RETURN
21
RETURN
(iii) Type
RETURN
The return addresses will be stripped off until you get error 7.
(iv) Change your program so you don't get the same thing happening again.
How does this work?