Knowledge Base

GoTo, GoSub and related instructions

There are a number of instructions for making program flow break off and jump to another part of your program. Nearly all of them are conditional, meaning you can test some condition and jump one way or another depending on the outcome.

There is also a rich set of conditional subroutine call (GoSub) and Return instructions. A GoSub instruction differs from a GoTo in that it saves away the address that it comes from, so it is possible to later do a Return and get back again. Subroutines can be nested to a depth that depends on the language dialect, meaning there is a limit to how far you can go having one subroutine call another, because there is a limit to how much memory is dedicated to remembering return addresses.