char and short Data Types (signed and unsigned)

The char and unsigned char data types are stored in memory as a single byte and are loaded to and stored from bits 0-7 of a register (see Figure 8-1). Objects defined as short or unsigned short are stored in memory as two bytes at a halfword (2 byte) aligned address and they are loaded to and stored from bits 0-15 of a register (see Figure 8-1).

In big-endian mode, 2-byte objects are loaded to registers by moving the first byte (that is, the lower address) of memory to bits 8-15 of the register and moving the second byte of memory to bits 0-7. In little-endian mode, 2-byte objects are loaded to registers by moving the first byte (that is, the lower address) of memory to bits 0-7 of the register and moving the second byte of memory to bits 8-15.

Figure 8-1 Char and Short Data Storage Format
Signed 8-bit char
MS LS
S S S S S S S S S S S S S S S S S S S S S S S S S S I I I I I I
31 7 0
Unsigned 8-bit char
MS LS
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 U U U U U U U
31 7 0
Signed 16-bit short
MS LS
S S S S S S S S S S S S S S S S S I I I I I I I I I I I I I I I
31 15 0
Unsigned 16-bit short
MS LS
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 U U U U U U U U U U U U U U U U
31 15 0
LEGEND: S = sign, I = signed integer, U = unsigned integer, MS = most significant, LS = least significant