Webcentive RISC-V Reference

c.add

Add

Extension
C
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
c.add xd, xs2
Length
16-bit (compressed)

Encoding

1513121176210
1001rd/rs≠0rs2≠010

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.

FieldBitsriscv-opcodes name
rd/rs≠011:7rd_rs1_n0
rs2≠06:2c_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.

Specification and related pages