SH1ADD

Shift Left 1 and Add

SH1ADD rd, rs1, rs2

Computes rd = rs2 + (rs1 << 1); scales an index by 2 for 16-bit elements.

Encoding

Binary Layout
0010000
31:25
rs2
24:20
rs1
19:15
010
14:12
rd
11:7
0110011
6:0
 
Format R-Type
Opcode 0x20002033
Extension Zba

Operands

  • rd
    Destination register (integer)
  • rs1
    Index
  • rs2
    Base

Example

SH1ADD x10, x11, x12

// Calculate address: x12 + (x11 * 2).

Related

More in Zba

Description

SH1ADD shifts rs1 left by 1 bit and adds the result to rs2, writing the sum to rd: rd = rs2 + (rs1 << 1). With rs1 an element index and rs2 a base address it computes the address of element rs1 of an array of 16-bit elements.

Operation

R[rd] = R[rs2] + (R[rs1] << 1);