Assembly:

LH rt, offset(rs)

nanoMIPS

Load Half

Purpose:

Load Half. Load signed halfword to register $rt from memory address $rs + offset (registerplus immediate).

Availability:

nanoMIPS

Format:

LH[U12]

100001

rt

rs

0100

u

6

5

5

4

12

offset = u

LH[16]

011111

rt3

rs3

0

u[2:1]

0

6

3

3

1

2

1

rt = decode_gpr(rt3, 'gpr3')
rs = decode_gpr(rs3, 'gpr3')
offset = u

LH[GP]

010001

rt

100

u[17:1]

0

6

5

3

17

1

rs = 28
offset = u

LH[S9]

101001

rt

rs

s[8]

0100

0

00

s[7:0]

6

5

5

1

4

1

2

8

offset = sign_extend(s, from_nbits=9)

Operation:

va = effective_address(GPR[rs], offset, 'Load')
data = read_memory_at_va(va, nbytes=2)
GPR[rt] = sign_extend(data, from_nbits=16)

Exceptions:

Address Error. Bus Error. TLB Invalid. TLB Read Inhibit. TLB Refill. Watch.