subfme
Subtract from Minus One Extended - 7C 00 00 52
subfme
Instruction Syntax
Mnemonic | Format | Flags |
subfme | rD,rA | OE = 0, Rc = 0 |
subfme. | rD,rA | OE = 0, Rc = 1 |
subfmeo | rD,rA | OE = 1, Rc = 0 |
subfmeo. | rD,rA | OE = 1, Rc = 1 |
Instruction Encoding
0
1
1
1
1
1
D
D
D
D
D
A
A
A
A
A
0
0
0
0
0
OE
0
1
0
1
0
0
0
0
1
0
Rc
Field | Bits | Description |
Primary Opcode | 0-5 | 011111 (0x1F) |
rD | 6-10 | Destination register |
rA | 11-15 | Source register |
Reserved | 16-20 | 00000 |
OE | 21 | Overflow Exception |
XO | 22-29 | 42 (Extended opcode) |
Reserved | 30 | 0 |
Rc | 31 | Record Condition Register |
Operation
rD ← -1 - (rA) + XER[CA]
The value in rA is subtracted from -1, the carry bit is added, and the result is placed into rD. The carry bit is updated based on the result.
Note: The subfme instruction performs subtraction from -1 with extended carry. If OE = 1, overflow exceptions are enabled. If Rc = 1, the condition register is updated.
Affected Registers
Condition Register (CR0 field)
(if Rc = 1)
- LT (Less Than)
- GT (Greater Than)
- EQ (Equal)
- SO (Summary Overflow)
Note: CR0 field may not reflect the infinitely precise result if overflow occurs (see XER below).
XER (Exception Register)
(if OE = 1)
- SO (Summary Overflow)
- OV (Overflow)
- CA (Carry)
For more information on condition codes see Section 2.1.3, "Condition Register," and Section 2.1.5, "XER Register," in the PowerPC Microprocessor Family: The Programming Environments manual.
Examples
Basic Subtraction from Minus One
subfme r3, r1 # r3 = -1 - r1 + CA subfme. r3, r1 # Same as above, but also sets condition register
Simple Arithmetic
# Subtract from -1 with carry lwz r4, 0(r10) # Load value subfme r5, r4 # r5 = -1 - r4 + CA
Overflow Detection
subfmeo r3, r1 # Subtract from -1 with overflow exception enabled # If overflow occurs, an exception is raised