BranchL
Source: Positron16 Compiler User Manual, PDF page 305
Syntax
BranchL Index, [Label1 {,...Labeln }]
Overview
Cause the program to jump to different locations based on a variable index.
Parameters
Index is a constant, variable, or expression, that specifies the address to branch to. Label1,...Labeln are valid labels that specify where to branch to. A maximum of 65536 labels may be placed between the square brackets.
Example
Device = 24FJ64GA002
' Select the device to compile for
Declare Xtal = 32
Dim Index as Byte
CLKDIV = 0
' CPU peripheral clock ratio set to 1:1
Write_OSCCONH(%00010000)
' Enable PLL
Start:
Index = 2
' Assign Index a value of 2
' Jump to label 2 (Label_2) because Index = 2
BranchL Index,[Label_0, Label_1, Label_2]
Label_0:
Index = 2
' Index now equals 2
GoTo Start
Label_1:
Index = 0
' Index now equals 0
GoTo Start
Label_2:
Index = 1
' Index now equals 1
GoTo Start
'
' Config fuses for internal oscillator with PLL
'
Config Config1 = JTAGEN_OFF, GCP_OFF, GWRP_OFF, BKBUG_OFF, COE_OFF,_
ICS_PGx1, FWDTEN_OFF, WINDIS_OFF, FWPSA_PR128, WDTPOST_PS256
Config Config2 = IOL1WAY_OFF, COE_OFF, IESO_OFF, FNOSC_FRCPLL,_
FCKSM_CSDCMD, OSCIOFNC_ON, POSCMOD_NONE
The above example we first assign the index variable a value of 2, then we define our labels. Since the first position is considered 0 and the variable index equals 2 the BranchL command will cause the program to jump to the third label in the brackets [Label_2].