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 192 © 2005-2011 Microchip Technology Inc.
CP
Compare Wb with lit5, Set Status Flags
Implemented in: PIC24F PIC24H PIC24E dsPIC30F dsPIC33F dsPIC33E
X X X X
Syntax: {label:} CP{.B} Wb, #lit5
Operands: Wb ∈ [W0 ... W15]
lit5 ∈ [ 0 ... 31]
Operation: (Wb) – lit5
Status Affected: DC, N, OV, Z, C
Encoding: 1110 0001 0www wB00 011k kkkk
Description: Compute (Wb) – lit5, and update the STATUS register. This instruction is
equivalent to the SUB instruction, but the result of the subtraction is not
stored. Register direct addressing must be used for Wb.
The ‘w’ bits select the address of the Wb base register.
The ‘B’ bit selects byte or word operation (‘0’ for word, ‘1’ for byte).
The ‘k’ bits provide the literal operand, a five-bit integer number.
Note: 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.
Words: 1
Cycles: 1
Example 1:
CP.B W4, #0x12 ; Compare W4 with 0x12 (Byte mode)
Before
Instruction
After
Instruction
W4 7711 W4 7711
SR 0000 SR 0008 (N = 1)
Example 2:
CP W4, #0x12 ; Compare W4 with 0x12 (Word mode)
Before
Instruction
After
Instruction
W4 7713 W4 7713
SR 0000 SR 0001 (C = 1)
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ64GA004-Programmers_Reference_Manual.pdf