neg

Negate

neg RT, RA

Computes the two's complement negation of a register (0 - RT).

Details

The neg instruction negates the value in register RA and places the result into register RT. If OE is set to 1, it also sets the overflow (OV) and overflow summary (SO) bits in the XER register if an overflow occurs. The carry bit (CA) and CA32 are updated based on the operation.

Pseudocode Operation

RT <- (~RA) + 1

Programming Note

When Rc=1 (dot form), CR0 is updated with the signed comparison of the result against zero (LT, GT, EQ) and the current SO bit from XER.

Example

neg r3, r4

Encoding

Binary Layout
31
0
RT
6
RA
11
00000
16
OE
21
104
22
Rc
31
 
Format XO-form
Opcode 0x7C0000D0
Extension Base
Registers Altered CR0

Operands

  • RT
    Target Register
  • RA
    Source Register