c.subw
Subtract word
- Extension
- C
- XLEN
- RV64 only
- Assembly (riscv-unified-db)
c.subw xd, xs2- Length
- 16-bit (compressed)
Encoding
| 1513 | 1210 | 97 | 65 | 42 | 10 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 111 | rs1′/rs2′ | 00 | rs2′ | 01 | ||||||||||
Match 0x9c01, mask 0xfc63. Source: c.subw rd_rs1_p rs2_p 1..0=1 15..13=4 12..10=0b111 6..5=0 in riscv-opcodes/extensions/rv64_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1′/rs2′ | 9:7 | rd_rs1_p |
| rs2′ | 4:2 | rs2_p |
Description
Subtract the 32-bit values in xs2 from xd, and store the result in xd.
The xd and xs2 register indexes should be used as xd+8 and xs2+8 (registers x8-x15).
C.SUBW expands into subw xd, xd, xs2.
Description from riscv-unified-db, reformatted.
Operation
Bits<32> t0 = X[creg2reg(xd)][31:0]; Bits<32> t1 = X[creg2reg(xs2)][31:0]; X[creg2reg(xd)] = sext(t0 - t1, 32);
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.