<<Previous |
5.1. BRANCH
BRANCH Offset,( Label{, Label} )
Uses Offset to index into the list of labels. Execution resumes at the indexed label. For example, if Offset is zero, execution resumes at the first label specified in the list. If Offset is one, at the second label. And so on. If Offset is equal to or greater than the number of labels, no action is taken and execution resumes with the following statement.
B10,(label1,label2,label3) 'If B10=0 goto label1; if B10=1 goto label2; if B10=2 goto label3Branch
5.2. BUTTON
BUTTON Pin, Down, Delay, Rate, Var, Action, Label
Performs debounce and auto-repeat on Pin:
Pin | Pin number (0..7). | |
Down | State of pin when button is pressed (0..1). |
|
Delay | Cycle count before auto-repeat starts (0..255). If 0, no debounce or auto-repeat is performed. If 255, debounce, but no auto-repeat, is performed. |
|
Rate | Auto-repeat rate (0..255). |
|
Var | Byte variable used for delay/repeat countdown. Should be initialized to 0 prior to use. |
|
Action | State of button to perform GOTO (0 if not pressed, 1 if pressed). |
|
Label | Execution resumes at this label if Action is true. |
Button 2,0,100,10,B0,0,skip 'Check for button pressed on Pin2 and goto skip if not
5.3. CALL
CALL Label
Executes the assembly language subroutine named Label. CALL is a PICBASIC™ Compiler statement and is not supported on the BASIC Stamp. See the section on assembly language for more information.
pass 'Call assembly language subroutine named passCall
5.4. DEBUG
PBC does not support the PBASIC DEBUG statement. PBC will, however, parse DEBUG statements correctly and report syntax errors.
5.5. EEPROM
EEPROM {Location,} ( Constant{, Constant} )
Stores constants in consecutive bytes in on-chip EEPROM. If the optional location value is omitted, the first EEPROM statement starts storing at address 0 and subsequent statements store at the following locations. If the location value is specified, it specifies the location where these values are stored.
Constant can be a numeric constant or a string constant. Only the least significant byte of numeric values are stored. Strings are stored as consecutive bytes of ASCII values. No length or terminator is added automatically.
EEPROM only works with PICmicro MCUs with on-chip EEPROM such as the PIC16C84 and PIC16F84. The data is stored in the EEPROM space at the time the PICmicro is programmed, not each time the program is run.
5,(10,20,30) 'Store 10, 20 and 30 starting at EEPROM location 5Eeprom
5.6. END
END
Stops program execution and enters the low power mode by executing continuous NAP commands.
End
<<Previous |