BRANCH | Example |
BRANCH Offset, Label0 {, Label1, Label2, ...}
Function
Jump to the program Label specified by Offset which can be a Byte or Word variable.
Note that the value of Offset should not be greater than the number of labels-1, otherwise
the BRANCH instruction will be skipped.
Explanation
The BRANCH instruction is useful when you want to do something like this:
Test_Value: IF value = 0 THEN Case_0 ' value = 0: go to label "Case_0" IF value = 1 THEN Case_1 ' value = 1: go to label "Case_1" IF value = 2 THEN Case_2 ' value = 2: go to label "Case_2" IF value = 3 THEN Case_3 ' value = 3: go to label "Case_3" IF value = 4 THEN Case_4 ' value = 4: go to label "Case_4"
You can convert a long list of IF-THEN statements to BRANCH to like this:
Test_Value: BRANCH value, Case_0, Case_1, Case_2, Case_3, Case_4 No_Branch:
Related instructions: IF ... THEN and ON