Branch
PC = [PC+1+X]
The Branch
instruction allows an "n-way" branch on the contents of the X register. A Branch
instruction must always be followed by a list of one or more program labels used as arguments in Target
instructions. Example
Branch
Target Again ;target if X=0
Target More ;target if X=1
Target Orless ;target if X=2
In the example, the program will transfer to label Again
if X=0, to More
if X=1 and to Orless
if X=2.
For any other value of X the results are unpredictable in SPLat hardware.
On 8 bit controllers (green boards), there may be up to 127 Target instructions following it. On 32 bit controllers (black boards) there may be 256 Targets.
See also Target
BranchM
BranchR BranchJ
When using Branch and Target take extra care. If the offset in X points to a line past the end of the Target list, there is no guarantee of what will happen. Your controller will either crash or behave very strangely.