Syntax: |
Operation: |
Operands: |
Program Counter: |
Opcode |
Comment |
Stack |
CPI Rd,K |
Rd - K |
16 <= d <= 31, 0 <= K <= 255 |
PC = PC + 1 |
0011KKKKddddKKKK |
This instruction performs a compare between register Rd and a constant. The register is not changed. All conditional branches can be used after this instruction.
I |
– |
||
T |
– |
||
H |
⇔ |
~Rd3 AND K3 OR K3 AND R3 OR R3 AND ~Rd3 |
Set if there was a borrow from bit 3; cleared otherwise. |
S |
⇔ |
N XOR V, for signed tests. |
|
V |
⇔ |
Rd7 AND ~K7 AND ~R7 OR ~Rd7 AND K7 AND R7 |
Set if two's complement overflow resulted from the operation; cleared otherwise. |
N |
⇔ |
R7 |
Set if MSB of the result is set; cleared otherwise. |
Z |
⇔ |
~R7 AND ~R6 AND ~R5 AND ~R4 AND ~R3 AND ~R2 AND ~R1 AND ~R0 |
Set if the result is 0x00; cleared otherwise. |
C |
⇔ |
~Rd7 AND K7 OR K7 AND R7 OR R7 AND ~Rd7 |
Set if the absolute value of K is larger than the absolute value of Rd; cleared otherwise. |
R (Result) |
R (Result) after the operation. |
cpi r19,3 ; Compare r19 with 3 brne error ; Branch if r19<>3 ... error: nop ; Branch destination (do nothing)
1 (2 bytes)
Name |
Cycles |
AVRe |
1 |
AVRxm |
1 |
AVRxt |
1 |
AVRrc |
1 |