MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / do_lwl

Function do_lwl

include/recomp.h:126–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 load_doubleword(rdram, offset, reg)
125
126static inline gpr do_lwl(uint8_t* rdram, gpr initial_value, gpr offset, gpr reg) {
127 // Calculate the overall address
128 gpr address = (offset + reg);
129
130 // Load the aligned word
131 gpr word_address = address & ~0x3;
132 uint32_t loaded_value = MEM_W(0, word_address);
133
134 // Mask the existing value and shift the loaded value appropriately
135 gpr misalignment = address & 0x3;
136 gpr masked_value = initial_value & (gpr)(uint32_t)~(0xFFFFFFFFu << (misalignment * 8));
137 loaded_value <<= (misalignment * 8);
138
139 // Cast to int32_t to sign extend first
140 return (gpr)(int32_t)(masked_value | loaded_value);
141}
142
143static inline gpr do_lwr(uint8_t* rdram, gpr initial_value, gpr offset, gpr reg) {
144 // Calculate the overall address

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected