Subroutine Command (Gosub, Return) - Radio Shack TRS-80 PC-4 Owner's Manual

Trs-80 pc-4
Hide thumbs Also See for TRS-80 PC-4:
Table of Contents

Advertisement

FOR 1=1
TO
5
STEP1
FOR
J
=2
TO
2m
STEP
2
x
~
NEXT I
This kind of FOR-NEXT loop
cannot be assembled.
NEXT
J
Furthermore, exit from FOR-NEXT loop is permitted but entry to FOR-NEXT loop is
not permitted.
x
FOR
A=···· .. ·········
FOR B=······· .. ···· ..
IF·········THEN····· .... ······
\
NEXT B
NEXT A
o
5·6·6 Subroutine Command
GOSU B statement
A subroutine is also called a
"subp~ogram".
Subroutines are separate programs to be
called out from a main routine.
The command to call out a subroutine is a GOSUB statement. Using this command,
program execution jumps from the main routine to the subroutine. After the sub-
routine is executed, the program returns to the original location in the main program
(using the RETURN statement in the subroutine).
Format: GOSUB {nUmerical expression
#
numerical expression
subroutine callout (jump) command
RETURN
command to return to main routine
-51-

Advertisement

Table of Contents
loading

Table of Contents