Branch Instructions
Unconditional Branch Instructions
Branch Always  BRA
Regarded as the simplest branch instruction. A label is placed in front of the instruction to which to branch to. It is good practice to choose a meaningful name for the label.
Conditional Branch Instructions
Branch if equal to zero  BEQ
Control branches to the instruction labelled, only if the result of the previous instruction was zero. Otherwise control simply moves on to the next instruction.
Branch if not equal to zero  BNE
Control branches to the instruction labelled, only if the result of the previous instruction was not zero. Otherwise control simply moves on to the next instruction.
Branch if higher than zero  BHI
Control branches to the instruction labelled, only if the result of the previous instruction was higher than zero. Otherwise control simply moves on to the next instruction.
Logical Shift Left  LSL
Shift to be performed on rightmost byte of data register D2
v
LSL.B #1, D2
^
Number of bits to shift
Branch if Carry Clear  BCC
Looks at the value placed in the carry flag by the previous instruction. If this value is zero the branch is taken, otherwise control simply moves to the next instruction.
Often used with LSL
. Control will branch to the instruction labelled if the bit that fell off into the carry flag was zero. Otherwise control moves to the next instruction.
Branch if Carry Set  BCS
Causes control to branch if the value placed in the carry flag by the previous instruction is 1.
Compare Instruction  CMP
SUB.B D1, D2
subtracts the rightmost byte in the data register D1
from the rightmost byte in data register D2
, and stores the result in data register D2
. The compare instruction CMP.B D1, D2
performs exactly the same subtraction, but does not store the result.
A compare instruction is often used with a conditional branch instruction.
Summary of Conditional Branch Instructions
Instruction  Numbers interpreted as signed or unsigned  Branch taken if result of previous instruction was... 

Unsigned  equal to zero 
BNE 
Unsigned  not equal to zero 
BGT 
Signed  greater than zero 
BLT 
Signed  less than zero 
BGE 
Signed  greater than or equal to zero 
BLE 
Signed  less than or equal to zero 
BHI 
Unsigned  higher than zero 
BLS 
Unsigned  lower than zero or the same 
No Comments