[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Assembler Language Reference

neg (Negate) Instruction

Purpose

Changes the arithmetic sign of the contents of a general-purpose register and places the result in another general-purpose register.

Syntax

neg RT,RA
neg. RT,RA
nego RT,RA
nego. RT,RA

Description

The neg instruction adds 1 to the one's complement of the contents of a general-purpose register (GPR) RA and stores the result in GPR RT.

If GPR RA contains the most negative number (that is, 0x8000 0000), the result of the instruction is the most negative number and signals the Overflow bit in the Fixed-Point Exception Register if OE is 1.

The neg instruction has four syntax forms. Each syntax form has a different effect on Condition Register Field 0 and the Fixed-Point Exception Register.

Syntax Form Overflow Exception (OE) Fixed-Point Exception Register Record Bit (Rc) Condition Register Field 0
neg 0 None 0 None
neg. 0 None 1 LT,GT,EQ,SO
nego 1 SO,OV 0 None
nego. 1 SO,OV 1 LT,GT,EQ,SO

The four syntax forms of the neg instruction never affect the Carry bit (CA) in the Fixed-Point Exception Register. If the syntax form sets the Overflow Exception (OE) bit to 1, the instruction affects the Summary Overflow (SO) and Overflow (OV) bits in the Fixed-Point Exception Register. If the syntax form sets the Record (Rc) bit to 1, the instruction affects the Less Than (LT) zero, Greater Than (GT) zero, Equal To (EQ) zero, and Summary Overflow (SO) bits in Condition Register Field 0.

Parameters

RT Specifies target general-purpose register where result of operation is stored.
RA Specifies source general-purpose register for operation.

Examples

  1. The following code negates the contents of GPR 4 and stores the result in GPR 6:
    # Assume GPR 4 contains 0x9000 3000.
    neg 6,4
    # GPR 6 now contains 0x6FFF D000.
  2. The following code negates the contents of GPR 4, stores the result in GPR 6, and sets Condition Register Field 0 to reflect the result of the operation:
    # Assume GPR 4 contains 0x789A 789B.
    neg. 6,4
    # GPR 6 now contains 0x8765 8765.
  3. The following code negates the contents of GPR 4, stores the result in GPR 6, and sets the Fixed-Point Exception Register Summary Overflow and Overflow bits to reflect the result of the operation:
    # Assume GPR 4 contains 0x9000 3000.
    nego 6,4
    # GPR 6 now contains 0x6FFF D000.
  4. The following code negates the contents of GPR 4, stores the result in GPR 6, and sets Condition Register Field 0 and the Fixed-Point Exception Register Summary Overflow and Overflow bits to reflect the result of the operation:
    # Assume GPR 4 contains 0x8000 0000.
    nego. 6,4
    # GPR 6 now contains 0x8000 0000.

Related Information

Fixed-Point Processor .

Fixed-Point Arithmetic Instructions .


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]