Section 06 Part 05 – The BVC & BVS Instructions

 

“An overflow of good converts to bad.” ~William Shakespeare

 

 

 

Introduction

 

These two are conditional branches that will branch depending on the V flag.  It should be noted that these branch instructions have two sizes; .s for short and .w for word.  For details see Section 05 Part 03 (The BRA Instruction).

 

 

 

The BVC Instruction

 

BVC – Branch on oVerflow Clear

 

If the V flag of the CCR is clear, the destination operand will be added to the PC, and the 68k will continue reading at the new offset held in PC.  If the V flag is set, the instruction is ignored.

 

 

 

Examples

 

This is based on whether or not overflow occurred:

 

          cmpi.w    #$0020,d0

          bvc.s     FlagVIsClear

          move.w    #$0000,d0

 

FlagVIsClear:

 

 

We’ll pretend d0 contains 2400801E, the CMP is word, so only the 801E is taken into account.  801E - 0020 = 7FFE.  Since we’re subtracting from a negative value, the result is suppose to be negative.  But, since the result has turned positive, we have an impossible result (i.e. overflow).  The V flag has been set.

 

 

 

 

The BVS Instruction

 

BVS – Branch on oVerflow Set

 

If the V flag of the CCR is set, the destination operand will be added to the PC, and the 68k will continue reading at the new offset held in PC.  If the V flag is clear, the instruction is ignored.

 

 

 

Examples

 

This is the opposite of BVC:

 

          cmpi.w    #$0020,d0

          bvs.s     FlagVIsSet

          move.w    #$0000,d0

 

FlagVIsSet:

 

 

Again, using the same example, with d0 containing 2400801E.  801E - 0020 = 7FFE, the result is impossible, overflow has occurred.  The V flag is set.

 

 

 

Previous Part

Main Page

Next Part