Electronic – MIPS: MARS editor not showing correct value for ASCII string

assemblymips

I'm using the MARS simulator to explore the MIPS cpu. I have a simple assembly program:

.data
ascii1: .asciiz "8C@2"

I expect the value in the memory address for ascii1 to be 0x38434032 (the hex equivalent for the ascii bit pattern for "8C@2"). But it's not. Here's a screenshot of what MARS shows:
http://img442.imageshack.us/i/mars1.jpg/

Can someone explain why the value in 0x1001000 is not 0x38434032.

Best Answer

You have encountered the concept of Big-Endian and Little-Endian byte order.

You expect:

0x38434032

But got:

0x32404338

Note that the bytes are simply in reverse order:

38 43 40 32
32 40 43 38

Wikipedia explains it succinctly:

In computing, endianness is the ordering of individually addressable sub-units (words, bytes, or even bits) within a longer data word stored in external memory. The most typical cases are the ordering of bytes within a 16-, 32-, or 64-bit word, where endianness is often simply referred to as byte order. 1 The usual contrast is between most versus least significant byte first, called big-endian and little-endian respectively.

MIPS is generally Big Endian, while the processors you may be used to (such as Intel) are Little Endian.

Many processors allow you to set whether they are big endian or little endian in some configuration bits.