PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
PICBASIC PLUS LITE Manual - Profe Saul
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.27. GOSUBSyntax :Overview :Operators :GOSUB Label……RETURNGOSUB jumps the program to a defined label and continues executionfrom there. Once the program hits a RETURN command the programreturns to the GOSUB that called it and continues executionfrom that point.Label is a user-defined label placed at the beginning of a line whichmust have a colon ‘:’ directly after it.Example : GOTO Start ‘ Jump over the subroutinesSubA: { subroutine A code…………}RETURNStart:SubB: { subroutine B code…………}RETURN‘ Actual start of the main programGOSUB SubAGOSUB SubBSTOPNotes :<strong>PICBASIC</strong> <strong>PLUS</strong> allows any amount of GOSUBs in a program, butthe 14-bit PIC architecture only has an 8-level stack, which only allows8 GOSUBs to be nested. The compiler only ever uses a maximumof 4-levels for it’s library subroutines, therefore do not use morethan 4 GOSUBs within subroutines.A subroutine must always end with a RETURN command.See also :CALL, GOTO62Copyright Crownhill 2001