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 6-1). By default, the
char
type is signed.
The
bool
type is also stored as an 8-bit type in bits 0-7 of a register.
Objects defined as
short
or
unsigned short
are stored in memory as two bytes at a halfword (2 byte) aligned address. They are loaded to and stored from bits 0-15 of a register (see Figure 6-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 6-1 Char and Short Data Storage Format 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 |
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 |
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 |
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 |
LEGEND: S = sign, I = signed integer, U = unsigned integer, MS = most significant, LS = least significant |