Home/Instructions/SH2ADD-UW
SH2ADD.UW

RISC-V SH2ADD.UW Instruction Details

Instruction ManualR-type

Shift unsigned word left by 2 and add (RV64)

Instruction Syntax

sh2add.uw rd, rs1, rs2
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
ZbaAddress Generation

Instruction Behavior

Zero-extends lower 32 bits of rs1 as unsigned word, shifts left by 2, adds rs2. For unsigned word-indexed array address generation. Part of Zba.

SH2ADD.UW Decode And Execute Animation

Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.

rd
rs1
rs2
sh2add.uw
,
,
Execution Context
a6(x16)
0xFFFFFFFFFFFFFFF0
a0(x10)
0x0000000000001000
31..25
24..20
19..15
14..12
11..7
6..0
0010000
funct7
01010
rs2
10000
rs1
100
funct3
00101
rd
0111011
opcode
Execution Data Path
instruction
0x20A842BB
opcode
0111011 -> OP-32
funct3
100 -> SH2ADD.UW
funct7
0010000 -> SH2ADD.UW selector
rd / rs1 / rs2
t0(x5) / a6(x16)[31:0]=0xFFFFFFF0 / a0(x10)=0x0000000000001000
zero-extend, shift, and add
EXTZ(0xFFFFFFF0) << 2 = 0x00000003FFFFFFC0; 0x0000000000001000 + 0x00000003FFFFFFC0 = 0x0000000400000FC0
x5
t0(x5) = 0x0000000400000FC0
Current Step

Concept Step: receive the 32-bit instruction encoding

The machine code is split by the current instruction format; the animation starts from encoding/decode.

encoding: 0x20A842BB
syntax : sh2add.uw t0(x5), a6(x16), a0(x10)
result : t0(x5) = 0x0000000400000FC0
Architectural Result
t0(x5) = 0x0000000400000FC0

This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.

Quick Understanding & Search Notes

SH2ADD.UW is RV64 Zba only: it zero-extends rs1[31:0], shifts it left by 2, then adds rs2.

The low 32 bits of rs1 are zero-extended, shifted left by 2, and added to rs2.
The .uw form is an RV64 address-generation instruction; apart from unsigned-word extraction from rs1, the addition is XLEN-wide.

Common Usage Scenarios

Address & Pointer

Understand this scenario with real code like «sh2add.uw x10, x11, x12 ; x10 = x12 + (zero_ext(x11[31:0]) << 2)».

Pre-Use Checklist

Syntax Check
  • Verify rd, rs1, rs2 (and rs3) are valid GPRs.
  • Confirm funct3 and funct7 encoding is correct.
Semantic Check
  • Check if the result affects subsequent branches or address calculations.
  • Ensure the rd register is not overwritten by another instruction.

Pitfalls / Common Confusions

RV64 only

FAQ

Does SH2ADD.UW access memory?

No. It only reads and writes integer registers; any memory access must be performed by a separate load or store instruction.

What is the result width of SH2ADD.UW?

rs2 and the shifted, zero-extended rs1[31:0] are added at XLEN width, and the XLEN-wide result is written to rd.