NEG
Negate
NEG rd, rs
Computes the two's complement negation (arithmetic negative).
Encoding
Binary Layout
010000000000
31:20
rs1
19:15
000
14:12
rd
11:7
0110011
6:0
Operands
-
rd
Destination register (integer) -
rs
Source
Example
NEG x5, x6
// x5 = -x6
Related
More in Pseudo
Reference
View in RISC-V Unprivileged ISA Specification ↗
RISC-V ISA Manual
Description
NEG negates rs1 and writes to rd. It is a pseudoinstruction for SUB rd, x0, rs1.
Operation
R[rd] = 0 - R[rs];