LH

Load Halfword

LH rd, offset(rs1)

Loads a 16-bit halfword from memory and sign-extends it.

Details

LH loads a halfword (16 bits) from memory at address rs1+sext(offset), sign-extends it to XLEN bits, and writes it to rd.

Pseudocode Operation

R[rd] = sext(M[R[rs1] + sext(offset)][15:0]);

Example

LH x5, 4(x10)

Encoding

Binary Layout
imm[11:0]
31:20
rs1
19:15
001
14:12
rd
11:7
0000011
6:0
 
Format I-Type
Opcode 0x03
Extension RV32I

Operands

  • rd
    Destination Register
  • rs1
    Base Address
  • offset
    Byte Offset