SUB

Subtract

SUB rd, rs1, rs2

Subtracts rs2 from rs1.

Details

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.

Pseudocode Operation

R[rd] = R[rs1] - R[rs2];

Example

SUB t0, a0, a1

Encoding

Binary Layout
0100000
31:25
rs2
24:20
rs1
19:15
000
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x33
Extension RV32I

Operands

  • rd
    Destination register (integer)
  • rs1
    Minuend
  • rs2
    Subtrahend