Encoding:

EXTEND

11110

Imm[10:5]

Imm[15:11]

LWSP

10010

rx

sel = 2

Imm[4:0]

5

5

5

5

5

3

3

Format:

LH rx, immediate(gp)

MIPS16e2

Load Halfword (GP-relative) Extended

Purpose:

Load Halfword (GP-relative) Extended

To load a halfword from memory as a signed value.

Description:

GPR[rx] = memory[GPR[gp] + immediate]

The 16-bit immediate value is sign-extended, then added to the contents of GPR 28 to form the effective address. The contents of the halfword at the memory location specified by the effective address are sign-extended and loaded into

GPR rx.

Restrictions:

Unpredictable prior to MIPS16e2. The effective address must be naturally-aligned. If the least-significant bit of the address is non-zero, an Address Error exception occurs.

Operation:

vAddr = sign_extend(immediate) + GPR[28]
if vAddr0 != 0 then
   SignalException(AddressError)
endif
(pAddr, CCA) = AddressTranslation (vAddr, DATA, LOAD)
pAddr = pAddrPSIZE-1..2 || (pAddr1..0 xor (ReverseEndian || 0))
memword = LoadMemory (CCA, HALFWORD, pAddr, vAddr, DATA)
byte = vAddr1..0 xor (BigEndianCPU || 0)
GPR[Xlat(rx)] = sign_extend(memword15+8*byte..8*byte)

Exceptions:

TLB Refill, TLB Invalid, Bus Error, Address Error