subfic
Subtract from Immediate Carrying - 20 00 00 00
subfic
Instruction Syntax
Mnemonic | Format | Flags |
subfic | rD,rA,SIMM | None |
Instruction Encoding
0
0
1
0
0
0
D
D
D
D
D
A
A
A
A
A
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
Field | Bits | Description |
Primary Opcode | 0-5 | 001000 (0x08) |
rD | 6-10 | Destination register |
rA | 11-15 | Source register |
SIMM | 16-31 | Signed immediate value |
Operation
rD ← SIMM - (rA) + XER[CA] - 1
The value in rA is subtracted from the signed immediate value, the carry bit is added, and the result is placed into rD. The carry bit is updated based on the result.
Note: The subfic instruction performs subtraction with immediate value and carry. The carry bit is always updated.
Affected Registers
XER (Exception Register)
- CA (Carry)
For more information on condition codes see Section 2.1.5, "XER Register," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Subtraction with Immediate
subfic r3, r1, 10 # r3 = 10 - r1 + CA - 1 subfic r3, r1, -5 # r3 = -5 - r1 + CA - 1
Simple Arithmetic
# Subtract immediate value from register lwz r4, 0(r10) # Load value subfic r5, r4, 100 # r5 = 100 - r4 + CA - 1
Carry Bit Usage
# Use carry bit for extended precision subfic r3, r1, 0 # r3 = 0 - r1 + CA - 1 (sets carry for next operation)