Expand description
Load/store data shaping (T-11-003).
Pure byte-level transforms: no bus, no registers, no addresses beyond the
low bits that select alignment. The pipeline’s DC stage performs the actual
access and calls these to shape the result.
§The unaligned family is the interesting part
MIPS has no unaligned load instruction. Instead LWL/LWR (and LDL/LDR
for doublewords) are used as a pair to assemble an unaligned value from
two aligned accesses, each merging part of the addressed word into the
destination register while preserving the rest of it.
The N64 is big-endian, which decides the direction of every shift here.
LWL takes the bytes from the addressed byte to the end of the containing
word and places them at the top of the register; LWR takes the bytes from
the start of the word up to the addressed byte and places them at the
bottom. Getting the endianness backwards produces plausible-looking values
that are wrong only for unaligned addresses, which is a miserable bug to find.
Enums§
Functions§
- ldl
LDL— the doubleword form oflwl.byteisaddr & 7.- ldr
LDR— the doubleword form oflwr.- lwl
LWL— merge the bytes from the addressed byte to the end of the containing word into the top ofrt, preservingrt’s low bytes.- lwr
LWR— merge the bytes from the start of the containing word up to the addressed byte into the bottom ofrt, preservingrt’s high bytes.- sdl
SDL— the doubleword form ofswl.- sdr
SDR— the doubleword form ofswr.- swl
SWL— merge the top bytes ofrtinto the addressed word.- swr
SWR— merge the bottom bytes ofrtinto the addressed word.