Keil Logo Arm Logo

C166 User's Guide

E. Byte Ordering

Most microprocessors have a memory architecture composed of 8-bit address locations known as bytes. Many data items (addresses, numbers, and strings) are too long to be stored using a single byte and must be stored in a series of consecutive bytes.

When using data stored in multiple bytes, byte ordering becomes an issue. Unfortunately, there is not just one standard for the order in which bytes in multi-byte data are stored. There are two popular methods of byte ordering currently in widespread use.

The first method is called little endian and is often referred to as Intel order. In little endian, the least significant, or low-order, byte is stored first. For example, a 16-bit integer value of 0x1234 (4660 decimal) would be stored using the little endian method in two consecutive bytes as follows:

Address +0 +1
Contents 0x34 0x12

A 32-bit integer value of 0x57415244 (1463898692 decimal) would be stored using the little endian method as follows:

Address +0 +1 +2 +3
Contents 0x44 0x52 0x41 0x57

A second method of accessing multi-byte data is called big endian and is often referred to as Motorola order. In big endian, the most significant, or high-order, byte is stored first and the least significant, or low-order, byte is stored last. For example, a 16-bit integer value of 0x1234 would be stored using the big endian method in two consecutive bytes as follows:

Address +0 +1
Contents 0x12 0x34

A 32-bit integer value of 0x004A4F4E would be stored using the big endian method as follows:

Address +0 +1 +2 +3
Contents 0x00 0x4A 0x4F 0x4E

The C16x/ST10 is a 16-bit machine and has no instructions to directly manipulate data objects larger than 16-bits. Multi-byte data are stored according to the following rules:

  • The C16x/ST10 architecture uses the little endian format.
  • Floating-point numbers are stored according to the IEEE-754 format and are stored in little endian format. Refer to Floating-point Numbers for more information.

If your C16x/ST10 embedded application performs data communications with other microprocessors, it may be necessary to know the byte ordering method used by the other CPU. This knowledge is required when transmitting raw binary data.

arm-logo-small

Keil logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.