Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
gosubreturn [2019/05/07 13:45]
neils
gosubreturn [2019/05/07 13:47] (current)
neils
Line 6: Line 6:
   return   return
  
-The ''GOSUB'' command calls a subroutine marked by a label. Return will pass control back to the caller. Nesting subroutines are supported (''GOSUB'' and ''RETURN'' compiles to just plain ''JSR'' and ''RTS'', nothing fancy). Stack overflow is not checked in runtime, but is quite unlikely to encounter. Example:+The ''GOSUB'' command calls a subroutine marked by a label. ''RETURN'' will pass control back to the caller. Nesting subroutines are supported (''GOSUB'' and ''RETURN'' compiles to just plain ''JSR'' and ''RTS'', nothing fancy). Stack overflow is not checked in runtime, but is quite unlikely to encounter. Example:
  
  rem ** subroutines **  rem ** subroutines **
Line 21: Line 21:
  return  return
  
-Note #1: make sure to use the `ENDcommand before your routines if you don't want them to be executed in the normal program flow (like in the example above).+**Note #1**: make sure to use the ''[[END|END]]'' command before your routines if you don't want them to be executed in the normal program flow (like in the example above).
  
-Note #2: there is no runtime call stack checking (e. g. no `?RETURN WITHOUT GOSUB ERROR`). If your call stack is corrupted, the program is likely to break.+**Note #2**: there is no runtime call stack checking (e. g. no ''?RETURN WITHOUT GOSUB ERROR''). If your call stack is corrupted, the program is likely to break.
  
-Note #3: Unlike procedures, subroutines do not open a new local scope.+**Note #3**: Unlike procedures, subroutines do not open a new local scope.