Reputation: 163
In MIPS1, are hex values stored as little or big endian, for example add t1 t2 t3. Would this be stored as 00000001010010110100100000100000 0x014B4820 or 00000100000100101101001010000000 412D280
Upvotes: 0
Views: 382
Reputation: 18493
... or 00000100000100101101001010000000 412D280
Why do you think that add t1, t2, t3
could be stored like this?
In the CPU manuals (like the MIPS manuals) instructions are typically described like this:
+--------+-------+-------+-------+-------+--------+
| 000000 | Reg 2 | Reg 3 | Reg 1 | 00000 | 100000 | ADD
+--------+-------+-------+-------+-------+--------+
And in this kind of drawing the highest bit is at the left side and the lowest bit is at the right side.
This means that 00000001010010110100100000100000 or 0x014B4820 is correct.
However, this has nothing to do with big and little endian!
Big and little endian is used to define how bytes, 16-bit values and 32-bit values are related in memory:
Is the number 0x12345678 stored like the four bytes 0x12, 0x34, 0x56, 0x78 or like the four bytes 0x78, 0x56, 0x34, 0x12?
In both cases the instruction add t1, t2, t3
is stored the same way the 32-bit number 0x014B4820 is stored.
However, on a little-endian system this number is stored like the four bytes 0x20, 0x48, 0x4B, 0x01; on a big-endian system this number is stored like the four bytes 0x01, 0x4B, 0x48, 0x20.
Upvotes: 2