SH2ADD
Shift Left 2 and Add
SH2ADD rd, rs1, rs2
Shifts rs1 left by 2 and adds rs2. Used for calculating addresses of 32-bit elements.
Encoding
Binary Layout
0010000
31:25
rs2
24:20
rs1
19:15
100
14:12
rd
11:7
0110011
6:0
Operands
-
rd
Destination register (integer) -
rs1
Index -
rs2
Base
Example
SH2ADD x10, x11, x12
// Calculate address: x12 + (x11 * 4).
Related
More in Zba
Reference
View in RISC-V Unprivileged ISA Specification ↗
RISC-V ISA Manual
Description
SH2ADD shifts rs1 left by 2 bits, then adds to rs2, writing to rd. Used for stride-4 array indexing (e.g., int32 arrays).
Operation
R[rd] = R[rs2] + (R[rs1] << 2);