Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
16-bit MCU and DSC Programmer’s Reference Manual
DS70157F-page 198 © 2005-2011 Microchip Technology Inc.
CPB
Compare f with WREG using Borrow, Set Status Flags
Implemented in: PIC24F PIC24H PIC24E dsPIC30F dsPIC33F dsPIC33E
X X X X X X
Syntax: {label:} CPB{.B} f
Operands: f ∈ [0 ...8191]
Operation: (f) – (WREG) – (C
)
Status Affected: DC, N, OV, Z, C
Encoding: 1110 0011 1B0f ffff ffff ffff
Description: Compute (f) – (WREG) – (C
), and update the STATUS register. This
instruction is equivalent to the SUBB instruction, but the result of the
subtraction is not stored.
The ‘B’ bit selects byte or word operation (‘0’ for word, ‘1’ for byte).
The ‘f’ bits select the address of the file register.
Note 1: The extension .B in the instruction denotes a byte operation
rather than a word operation. You may use a .W extension to
denote a word operation, but it is not required.
2: The WREG is set to working register W0.
3: The Z flag is “sticky” for ADDC, CPB, SUBB and SUBBR.
These instructions can only clear Z.
Words: 1
Cycles:
1
(1)
Note 1:
In dsPIC33E and PIC24E devices, the listed cycle count does not apply to read and
read-modify-write operations on non-CPU Special Function Registers. For more
details, see
Note 3
in
Section 3.2.1 “Multi-Cycle Instructions”
.
Example 1:
CPB.B RAM400 ; Compare RAM400 with WREG using C (Byte mode)
Before
Instruction
After
Instruction
WREG 8823 WREG 8823
RAM400 0823 RAM400 0823
SR 0000 SR 0008 (N = 1)
Example 2:
CPB 0x1200 ; Compare (0x1200) with WREG using C (Word mode)
Before
Instruction
After
Instruction
WREG 2377 WREG 2377
Data 1200 2377 Data 1200 2377
SR 0001 (C = 1) SR 0001 (C = 1)
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ64GA004-Programmers_Reference_Manual.pdf