cror
Condition Register OR - 4C 00 07 82
cror
Instruction Syntax
Mnemonic | Format | Flags |
cror | crbD,crbA,crbB | - |
crmove | crbD,crbA | Simplified (crbD,crbA,crbA) |
Instruction Encoding
0
1
0
0
1
1
D
D
D
D
D
A
A
A
A
A
B
B
B
B
B
1
1
1
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 | 1111000010 (962) |
Reserved | 31 | 0 |
Operation
CR[crbD] ← CR[crbA] | CR[crbB]
The condition register OR instruction performs a logical OR operation between condition register bits crbA and crbB, and stores the result in condition register bit crbD. The result is 1 if either input bit is 1, and 0 only when both input bits are 0.
Note: When used with the same bit for both operands (crmove), this copies one condition register bit to another.
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 OR Operation
# Test: either condition is true cmpwi cr0, r3, 0 # Compare r3 with 0 cmpwi cr1, r4, 0 # Compare r4 with 0 cror 2, 1, 5 # CR0[EQ] = CR0[GT] | CR1[GT] beq either_positive # Branch if either is positive
Move Condition Register Bit (crmove)
# Copy one condition register bit to another cmpwi cr1, r3, 0 # Compare r3 with 0 in CR1 crmove 2, 6 # Copy CR1[EQ] to CR0[EQ] (equivalent to cror 2,6,6) beq branch_on_cr1 # Branch based on CR1 comparison using CR0
Error Flag Combination
# Combine error conditions: branch if any error 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 cror 2, 6, 2 # Check if any error is set bne handle_error # Branch if any error condition
Complex Branching Logic
# Branch if: (r3 > 100) OR (r4 < 0) cmpwi cr0, r3, 100 # Compare r3 with 100 cmpwi cr1, r4, 0 # Compare r4 with 0 cror 2, 1, 4 # Combine GT from cr0 with LT from cr1 beq complex_condition # Branch if either condition met