Chapter
3:
Programming the
VIC
20
Computer
97
Start of program -
=r:
: }
+}~
I Repeated routine
t::J
T
etc.
To solve this problem, you could separate out the repeated statements
and branch to them. This group
of
statements
is
referred to as a subroutine.
But a problem arises. Branching from your program to the subroutine
is
simple enough, since the subroutine starts at a given line number. How-
ever, where do you branch back to
at
the end
of
the subroutine? You could
execute a GOTO statement whenever you wish to branch to a subroutine.
Arbitrarily selected
line numbers
Start of
program-
10
Subroutine
-start
__
2000
--- /..
etc.
100
GOTO
2000
- - - - "
.~
110
/
/1
/
I,
,/'
/ I
,,"
/ I
/ 1 /
".I'
/ /
190
GOTO
200(}
/ 1 /
200
/1
/
I /
1 /
1 ,
1 /
• I /
250
GOTO 2000' /
260
I
,
/
/
2150
_end
-... ,
\
....
-......
,
;'
'\)
"
'1
,
"'--,,)/1
;"
__
'"
'I
I
/I
\
/1
'--"
I
I
/
/
Return ","
where?
--
480
GOTO
2000
500