PIC18 cheatsheet

BOV

Detailed reference for the BOV instruction in PIC18 ISA.

Description

Branch if Overflow (BOV). If the Overflow (OF) bit (bit 2) of the STATUS register is set after a previous arithmetic operation, the program counter is incremented by the word offset specified by the label; otherwise execution continues with the following instruction.

Syntax:

BOV label
  • label – the branch target. The branch is taken if OF = 1.

Examples

; BOV taken when OF=1 → branch to L1
BOV L1 ; PC jumps to label L1 because OF = 1
; BOV not taken when OF=0 → continue to next instruction
BOV L2 ; PC remains on the next word because OF = 0
; BOV taken after addition that sets OF
MOVLW 0x80
ADDLW 0x80
BOV L3 ; OF set by signed overflow, branch to L3
; BOV not taken after addition that clears OF
MOVLW 0x01
ADDLW 0x02
BOV L4 ; OF cleared, no branch
; BOV taken with WREG preloaded and signed overflow from addition
MOVLW 0x80
ADDLW 0x80
BOV L5 ; OF set, branch to L5