SPECIAL3 011111 |
base |
rt |
offset |
0 |
LWRE 011010 |
6 |
5 |
5 |
9 |
1 |
6 |
LWRE rt, offset(base) |
MIPS32, removed in Release 6 |
Load Word Right EVA |
Load Word Right EVA
To load the least-significant part of a word from an unaligned user mode virtual memory address as a signed value while executing in kernel mode.
GPR[rt] = GPR[rt] MERGE memory[GPR[base] + offset]
The 9-bit signed offset is added to the contents of GPR base to form an effective address (EffAddr). EffAddr is the address of the least-significant of 4 consecutive bytes forming a word (W) in memory starting at an arbitrary byte boundary.
A part of W (the least-significant 1 to 4 bytes) is in the aligned word containing EffAddr. This part of W is loaded into the least-significant (right) part of the word in GPR rt. The remaining most-significant part of the word in GPR rt is unchanged.
If GPR rt is a 64-bit register, the destination word is the low-order word of the register. The loaded value is treated as a signed value; if the word sign bit (bit 31) is loaded (that is, when all 4 bytes are loaded), then the new sign bit value is copied into bits 63..32. If bit 31 is not loaded, the value of bits 63..32 is implementation dependent; the value is either unchanged or a copy of the current value of bit 31.
Executing both LWRE and LWLE, in either order, delivers a sign-extended word value in the destination register.
Only usable when access to Coprocessor0 is enabled and when accessing an address within a segment configured using UUSK, MUSK or MUSUK access mode.
Release 6 removes the load/store-left/right family of instructions, and requires the system to support misaligned memory accesses.
vAddr = sign_extend(offset) + GPR[base] (pAddr, CCA) = AddressTranslation (vAddr, DATA, LOAD) pAddr = pAddrPSIZE-1..3 || (pAddr2..0 xor ReverseEndian3) if BigEndianMem = 0 then pAddr = pAddrPSIZE-1..3 || 03 endif byte = vAddr1..0 xor BigEndianCPU2 word = vAddr2 xor BigEndianCPU memdoubleword = LoadMemory (CCA, byte, pAddr, vAddr, DATA) temp = GPR[rt]31..32-8*byte || memdoubleword31+32*word..32*word+8*byte if byte = 4 then utemp = (temp31)32 /* loaded bit 31, must sign extend */ else /* one of the following two behaviors: */ utemp = GPR[rt]63..32 /* leave what was there alone */ utemp = (GPR[rt]31)32 /* sign-extend bit 31 */ endif GPR[rt] = utemp || temp
TLB Refill, TLB Invalid, Bus Error, Address Error, Watch, Reserved Instruction, Coprocessor Unusable
The architecture provides no direct support for treating unaligned words as unsigned values, that is, zeroing bits
63..32 of the destination register when bit 31 is loaded.
In the MIPS I architecture, the LWL and LWR instructions were exceptions to the load-delay scheduling restriction.
A LWL or LWR instruction which was immediately followed by another LWL or LWR instruction, and used the same destination register would correctly merge the 1 to 4 loaded bytes with the data loaded by the previous instruction. All such restrictions were removed from the architecture in MIPS II.