Question

I'm writing code using arm assembly language for college and the I'm really confused about endianess.

The default should be little endian but I'm sure the test string has been stored big endian. The first byte in memory at 0xA1000004 is 0x30 which is 'O', and 0xA1000007 is 'j', but surely if its little endian the 'j' character should be stored first.

I'm not sure if it's stored incorrectly or if I'm reading the memory wrong but I'm so confused about it all.

Any and all help appreciated,

Thanks, Richardenter image description here

enter image description here

Was it helpful?

Solution

Timothy's answer is correct, but not complete enough to understand what is going on here.

Strings are a sequence of bytes; there is no "endianness" for strings because bytes have no endianess.

Endianess refers to the byte order that is used to store larger multiple-byte items in memory.

So, for big endian the most significant byte is stored at the lowest address for the memory range that stores the item.

For little endian, the least significant byte is stored at the lowest address.

The thing that is confusing you is a tool behavior; your memory browser is showing 4-byte words, and it is on a little endian system. So the byte at the lowest address is being displayed as the Least significant byte of the 4-byte word.

Eg. In memory

0x30 0x55 0x4c 0x64 ...
\ one 4 byte word /
     0x644c5530
             --
              ^- LSB, at the lowest memory address

See if you can set up memory browser to display bytes rather than 4-byte integers; you'll see that the string is stored as you expect.

OTHER TIPS

Endianness applies to number types (like int/long/double...). You stored a string (an array/list of characters). Therefore the bytes of your string are stored in order of appearance regardless of the processors endianness.

Licensed under: CC-BY-SA with attribution
scroll top