BMI - Branch if More Than 127 Command
Branches if the minus flag is set. This occurs if you load a value greater than 127 into the accumulator or a comparison results in a negative number because the compared value was greater than the accumulator value.
If the value #0 is decremented it becomes 255 and the minus flag is set.
This is the opposite of the BPL (Branch if Plus) 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
BMI Label
Where "Label" is the label name to where you want it to branch if the minus flag is set.
Any value between 128 and 255 is classed as a minus number.
Examples
{
LDA #130 //Put the fixed decimal value 130 into the Accumulator
BMI Label //Branch to Label as Minus flag is set
LDA #120 //Put the fixed decimal value 120 into the Accumulator
BMI NotEnough //Won't branch as Minus flag is not set
ADD #10 //Add 10 more. 120+10=130
BMI Label //Branch to Label as Minus flag is set
LDA #0x06 //Put the fixed hex value 0x06 into the Accumulator
CMP #0x08 //0x06-0x08= -2 Set the Minus flag
BMI Label //Will branch as Minus flag is set
}