Technical Note | : SLE0004 |
Author | : Scott Evans |
Created/Modified | : 30/10/97 |
Description | : An explanation of byte ordering |
The term byte ordering refers to the order in which a computer stores
bytes in memory. This document
describes the little endian and big endian byte ordering methods. The R3000 (Yaroze CPU) uses the little endian method. Big Endian The hexadecimal number 0x1234 will occupy two bytes of memory.
Each hexadecimal digit can be
A big endian computer would store the number 0x1234 in memory
as follows, where A is a pointer to a
Starting with the leftmost byte of the number and working towards the
right. 0x12 will be stored at A
A A+1
The same applies for larger numbers. A 32 bit number (4 bytes) 0x12345678
will be stored at address
A A+1 A+2
A+3
Little Endian Little endian computers on the other hand use the opposite method to
big endian computers. The
This time we start with the rightmost byte of the number 0x34
and place this at address A. The next
A A+1
It has the same byte ordering as a big endian computer storing the number 0x3412. The number 0x12345678 will be stored as the number 0x78563412
on a big endian computer. So the
A A+1 A+2 A+3
|