Reputation: 171
I'm using an ARM architecture and I'm a little unclear on the concept with LDRB. LDRB being LDR with the optional B command, to load the least significant byte of the 32-bit word. Three issues.
Upvotes: 2
Views: 31780
Reputation: 20914
If you want the MSB of a 32-bit word, then get the MSB of a 32-bit word:
LDR R0, [R1]
LSR R0, #24
Anything else is confusing and completely unportable across systems of different endianness - trying to byte address words assuming LE breaks on a BE system. What works on BE-8 breaks if it ever finds itself on an ancient BE-32 system.
In fact, if loading a byte from [word ptr - #3]
really gives you the MSB rather than the second-least significant byte of the previous word then I think you are on a BE-32 system* - thus this won't work correctly on anything modern.
* or maybe BE-8 - the trickery of memory endianness vs. bus endianness and word vs. byte addressing is massively confusing and I make no claim to have fully grapsed it.
Upvotes: 6