Webcentive RISC-V Reference

lh

Load halfword

Extension
RV32I/RV64I base integer
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
lh xd, imm(xs1)
Length
32-bit

Encoding

3120191514121176210
imm[11:0]rs1001rd0000011

Match 0x00001003, mask 0x0000707f. Source: lh rd rs1 imm12 14..12=1 6..2=0x00 1..0=3 in riscv-opcodes/extensions/rv_i.

FieldBitsriscv-opcodes name
imm[11:0]31:20imm12
rs119:15rs1
rd11:7rd

Description

Load 16 bits of data into register xd from an address formed by adding xs1 to a signed offset. Sign extend the result.

Description from riscv-unified-db, reformatted.

Operation

XReg virtual_address = X[xs1] + $signed(imm);

X[xd] = sext(read_memory(16, virtual_address, $encoding), 16);

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages