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 
represented by 4 bits (a nibble). So 0x12 will be stored in one byte and 0x34 will be stored in another 
byte.

A big endian computer would store the number 0x1234 in memory as follows, where A is a pointer to a 
byte in memory.

Starting with the leftmost byte of the number and working towards the right. 0x12 will be stored at A 
and the last byte 0x34 will be stored at A+1. In memory this would look like.

A       A+1 
0x12  0x34 

The same applies for larger numbers. A 32 bit number (4 bytes) 0x12345678 will be stored at address 
A as follows. The leftmost byte 0x12 will be stored at A, the next byte 0x34 at A+1, the next 0x56 and 
A+2 and the last byte 0x78 at A+3.

A       A+1   A+2   A+3
0x12  0x34  0x56  0x78
 

Little Endian

Little endian computers on the other hand use the opposite method to big endian computers. The 
number 0x1234 would be stored at location A as follows.

This time we start with the rightmost byte of the number 0x34 and place this at address A. The next 
byte (working left) 0x12 is then placed at A+1.

A       A+1
0x34  0x12

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 
rightmost byte 0x78 is stored at A, the next byte 0x56 is stored at A+1, the next byte 0x34 is stored at 
A+2 and the last byte 0x12 is stored at A+3.
 

A       A+1   A+2  A+3
0x78  0x56  0x34  0x12

This document in word format. 
This document in text format.