subfo.

Subtract From (Overflow, Record)

subfo. RT,RA,RB

Subtracts the contents of register RA from register RB and places the result in RT.

Encoding

Binary Layout
 
Format D-form
Opcode
Extension Base

Operands

  • RT
    Target Register
  • RA
    Source Register (subtracted)
  • RB
    Source Register (minuend)

Example

subfo. r3, r4, r5

// r3 = r4 + 10 (Updates CA)

Registers Altered

CR CR0 (if Rc=1); XER SO OV OV32 (if OE=1)

Related

More in Base

Reference

Description

The sum ¬(RA) + (RB) + 1 is placed into register RT. This is equivalent to RB - RA.

Operation

RT ← ¬(RA) + (RB) + 1

Extended Mnemonics

Extended Mnemonic Equivalent Instruction
sub RT,RB,RA subf RT,RA,RB
sub. RT,RB,RA subf. RT,RA,RB
subo RT,RB,RA subfo RT,RA,RB
subo. RT,RB,RA subfo. RT,RA,RB

Programming Note

The subf instruction subtracts the contents of register RA from register RB (RT = RB - RA); note the 'subtract from' operand order. Assemblers provide the extended mnemonic sub RT,RA,RB, implemented as subf RT,RB,RA. This instruction operates at user privilege level.