Arm/load align

From ASMBits

Write a function that reads a 32-bit word from memory and returns it. The location to read is passed as the first parameter to the function. This pointer is not necessarily 4-byte aligned, but your function must emulate what an unaligned load would do, while only using properly aligned accesses,

int load (int* p);

Expected solution length: Around 10 lines.

Sample Input

Pointer: .word 1234

Sample Output

1234

The easiest method is probably to use a sequence of byte-sized loads, as byte-sized loads have no alignment requirements.

Write your solution here

Upload a source file...