SUB
Subtract
SUB rd, rs1, rs2
Subtracts rs2 from rs1.
Encoding
Binary Layout
0100000
31:25
rs2
24:20
rs1
19:15
000
14:12
rd
11:7
0110011
6:0
Operands
-
rd
Destination register (integer) -
rs1
Minuend -
rs2
Subtrahend
Example
SUB t0, a0, a1
Related
More in RV32I
Reference
View in RISC-V Unprivileged ISA Specification ↗
RISC-V ISA Manual
Description
SUB subtracts the value in rs2 from rs1 and writes the result to rd. Arithmetic overflow is ignored; the result is the low XLEN bits of the mathematical difference.
Operation
R[rd] = R[rs1] - R[rs2];