SUBW

Subtract Word

SUBW rd, rs1, rs2

Subtracts the lower 32 bits of rs2 from rs1 and sign-extends the result to 64 bits.

Details

SUBW subtracts rs2 from rs1, truncates to 32 bits, sign-extends to 64 bits, and writes to rd.

Pseudocode Operation

R[rd] = sext((R[rs1] - R[rs2])[31:0]);

Example

SUBW x10, x11, x12

Encoding

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

Operands

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