c.add
Add
- Extension
- C
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
c.add xd, xs2- Length
- 16-bit (compressed)
Encoding
| 1513 | 12 | 117 | 62 | 10 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 1 | rd/rs≠0 | rs2≠0 | 10 | |||||||||||
Match 0x9002, mask 0xf003. Source: c.add rd_rs1_n0 c_rs2_n0 1..0=2 15..13=4 12=1 in riscv-opcodes/extensions/rv_c.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rd/rs≠0 | 11:7 | rd_rs1_n0 |
| rs2≠0 | 6:2 | c_rs2_n0 |
Description
Add the value in xs2 to xd, and store the result in xd.
C.ADD expands into add xd, xd, xs2.
Description from riscv-unified-db, reformatted.
Operation
XReg t0 = X[xd]; XReg t1 = X[xs2]; X[xd] = t0 + t1;
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.