GOSUB
GOSUB is a control flow instruction found in many BASIC dialects. It transfers program execution to a subroutine located at a specified line number or label and, when the subroutine completes, returns to the statement immediately following the GOSUB via the RETURN command. The language generally implements this with a return stack that records the address to resume after each GOSUB call, allowing nested subroutines up to the interpreter’s limit.
In typical usage, a GOSUB 1000 would jump to line 1000. The subroutine runs and ends with
GOSUB does not provide formal parameter passing; any data required by the subroutine is usually accessed through