NEG

Negate

NEG rd, rs

Computes the two's complement negation (arithmetic negative).

Details

NEG negates rs1 and writes to rd. It is a pseudoinstruction for SUB rd, x0, rs1.

Pseudocode Operation

R[rd] = 0 - R[rs];

Example

NEG x5, x6

Encoding

Binary Layout
010000000000
31:20
rs1
19:15
000
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x40000033
Extension Pseudo

Operands

  • rd
    Destination register (integer)
  • rs
    Source