MSC100ABIRM Motorola / Freescale Semiconductor, MSC100ABIRM Datasheet - Page 21

no-image

MSC100ABIRM

Manufacturer Part Number
MSC100ABIRM
Description
SC100 Application Binary Interface Reference Manual
Manufacturer
Motorola / Freescale Semiconductor
Datasheet
2.2.1 Compound Data Type
Arrays, structures, unions and bit fields have different alignment characteristics, as described in the
following sections.
2.2.1.1 Arrays
Arrays have the same alignment restriction as their individual elements.
2.2.1.2 Structures and Unions
Members of unions and structures have the most restrictive alignments. For example, a structure
containing a char, a short, and a long word must have a 4-byte alignment to match the alignment of the
long field. In addition, the size of a union or structure must be an integral multiple of its alignment.
Padding must be applied to the end of a union or structure to make its size a multiple of the alignment. To
meet this alignment requirement, padding must be introduced between members as necessary.
2.2.1.3 Bit Fields
Members of structures are always allocated on byte boundaries. However, bit fields in structures can be
allocated at any bit and can be of any length that does not exceed the size of a long word (32-bits). Signed
and unsigned bit fields are permitted and are sign-extended when fetched. A bit field of type int is
considered signed. Bit fields will be allocated from the low-order end of a word (right to left, or little
endian). Bit field sizes are not allowed to cross a long word boundary.
In Example 2-1, the structure more has 4-byte alignment and will have the size of 4-bytes. This is because
the fundamental type of the bit fields is long, which requires a 4-byte alignment. The second structure
less
in that structure. The alignments are driven not by the width of the fields but by the underlying type. These
alignments are to be considered along with any other structure members. Structure
4-byte alignment; its bit fields only require 1-byte alignment, but the field
alignment.
Example 2-1. Structure Determined by Underlying Type
struct more {
};
struct less {
};
struct careful {
};
SC100 Application Binary Interface
requires only a 1-byte alignment because that is the requirement of the fundamental type (char) used
long first : 3;
unsigned int second : 8;
unsigned char third : 3;
unsigned char fourth : 8;
unsigned char third : 3;
unsigned char fourth : 8;
long fluffy;
Preliminary (April 2000)
fluffy
careful
requires a 4-byte
Fundamental Data Types
requires a
2-3

Related parts for MSC100ABIRM