creqv
Condition Register Equivalent - 4C 00 04 82
creqv
Instruction Syntax
Mnemonic | Format | Flags |
creqv | crbD,crbA,crbB | - |
crset | crbD | Simplified (crbD,crbD,crbD) |
Instruction Encoding
0
1
0
0
1
1
D
D
D
D
D
A
A
A
A
A
B
B
B
B
B
1
0
0
1
0
0
0
0
1
0
0
Field | Bits | Description |
Primary Opcode | 0-5 | 010011 (0x13) |
crbD | 6-10 | Condition Register bit Destination |
crbA | 11-15 | Condition Register bit A |
crbB | 16-20 | Condition Register bit B |
XO | 21-30 | 1001000010 (578) |
Reserved | 31 | 0 |
Operation
CR[crbD] ← CR[crbA] ≡ CR[crbB]
The condition register equivalent instruction performs a logical equivalence (XNOR) operation between condition register bits crbA and crbB, and stores the result in condition register bit crbD. The result is 1 if both bits have the same value (both 0 or both 1), and 0 if they differ.
Note: When all three operands are the same (crset), this sets the bit to 1.
Affected Registers
Condition Register (CR)
(crbD bit only)
- CR[crbD] ← CR[crbA] ≡ CR[crbB]
For more information on condition register operations see Section 2.1.3, "Condition Register," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Equivalence Test
# Test if two conditions have same state cmpwi cr0, r3, 0 # Compare r3 with 0 cmpwi cr1, r4, 0 # Compare r4 with 0 creqv 2, 2, 6 # CR0[EQ] = CR0[EQ] ≡ CR1[EQ] beq same_state # Branch if both are zero or both non-zero
Set Condition Register Bit (crset)
# Set CR0[EQ] to 1 (always true condition) crset 2 # CR0[EQ] = 1 (equivalent to creqv 2,2,2) beq always_branch # This will always branch
Complex Condition Matching
# Test if error states match lwz r3, error_flag1(r0) lwz r4, error_flag2(r0) cmpwi cr0, r3, 0 # Test first error flag cmpwi cr1, r4, 0 # Test second error flag creqv 2, 2, 6 # Check if both have same error state beq consistent_state # Branch if error states are consistent
Initialize Condition Bits
# Set multiple condition bits to known states crset 0 # Set CR0[LT] = 1 crset 1 # Set CR0[GT] = 1 crset 2 # Set CR0[EQ] = 1 crset 3 # Set CR0[SO] = 1