BPL - Branch if Less Than 128 Command
Branches if the minus flag is not set(cleared). This occurs if you load a value less than 128 into the accumulator or a comparison results in a negative number because the compared value was less than the accumulator value.
Any value between 128 and 255 is classed as a minus number.
If the value #0 is decremented it becomes 255 and the minus flag is set.
This is the opposite of the BMI (Branch if Minus) command.
In assembly code the left most byte (MSB) is considered the sign to differentiate between negative and positive numbers. Hence the "minus" name. |
Syntax
BPL Label
Where "Label" is the label name to where you want it to branch if the minus flag is cleared.
Any value between 128 and 255 is considered as a minus number.
Examples
Example 1
Some ways to clear the minus flag.
{
LDA #120 //Put the fixed decimal value 120 into the Accumulator
BPL Label //Branch to label as minus flag is not set
LDA #130 //Put the fixed decimal value 130 into the Accumulator
BPL TooHigh //Won't branch to label as minus flag is set
SUB #10 //Subtract 10. 130-10=120.
BPL Label //Branch to label as minus flag is not set
DIV //DIV command clears all flags
LDA #0x08 //Put the fixed hex value 0x08 into the Accumulator
CMP #0x06 //0x08-0x06= 2 Clear the minus flag
BMI Label //Will branch as minus flag is not set
}
Example 2
This task uses BPL to create a threshold.
{
P2: //Vector number 2.
Preset(A=5,P=2) //Send out a preset.
LDA ~1 //Load the step counter.
INC
CMP #NumberOfPresets //Compare to the number of steps in the task template. (~1 minus number of steps, if they are equal the minus flag is cleared)
BPL END //If we have exceeded the max steps end. If not continue
...
}