Conditional Branches

Detection of overflow when adding or subtracting:

For example, assuming the 8-bit addition Sum<-A+B, here is how the CC would be set:

 A  B   Sum   N Z V C
 -- -- -----  - - - -
 1F FF (1)1E  0 0 0 1
 01 FF (1)00  0 1 0 1
 40 40 (0)80  1 0 1 0
 A0 A0 (1)40  0 0 1 1
 00 01 (0)01  0 0 0 0
 A  B  -B  Diff  N Z V C
 -- -- -- -----  - - - -
 1F FF 01 (0)20  0 0 0 1
 01 FF 01 (0)02  0 0 0 1
 FF 01 FF (1)FE  1 0 0 0
 22 00 00 (0)22  0 0 0 0
 40 40 C0 (1)00  0 1 0 0
 A0 60 A0 (1)40  0 0 1 0
 40 C0 40 (0)80  1 0 1 1
 bcc Label (replace "bcc" by one of the opcodes below)

 Branch condition Branch if 680x0 opcode SPARC opcode
Check on particular bit in the CC:
Z bit is 1 Z=1 beq be
Z bit is 0 Z=0 bne bne
N bit is 1 N=1 bmi bneg
N bit is 0 N=0 bpl bpos
V bit is 1 V=1 bvs bvs
V bit is 0 V=0 bvc bvc
C bit is 1 C=1 bcs bcs
C bit is 0 C=0 bcc bcc
Use after SIGNED comparisons (eg. CMP A,B or SUBCC B,A,%g0)
B = A Z = 1 beq be
B < > A Z = 0 bne bne
B < A N * V = 1 blt bl
B >= A N * V = 0 bge bge
B <= A Z + (N * V) = 1 ble ble
B > A Z + (N * V) = 0 bgt bg
Use after UNSIGNED comparisons (eg. CMP A,B or SUBCC B,A,%g0)
B = A Z = 1 beq be
B < > A Z = 0 bne bne
B < A C = 1 blo (bcs) blu (bcs)
B >= A C = 0 bhs (bcc) bgeu (bcc)
B <= A Z + C = 1 bls bleu
B > A Z + C = 0 bhi bgu
Unconditional branches
Always branch 1 = 1 bra ba
Never branch 1 = 0 --- bn

WARNING - SPARC uses "delayed branching"