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

  • 1
  • 4
    This reads more like an issue with understanding how endianness works and when it is meaningful than a request for coding help per se. – James McLeod Dec 3 '17 at 18:36
  • Did you check the endianness of the memory pane (the lower-right window)? It is possible that an endianness swap is performed by the window between what it reads from the memory and what it shows on the screen. I ask this because the window displays in groups of 32-bits. – rwong Dec 3 '17 at 22:04

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 /
              ^- 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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.