armV6 and armV7 in XCode
Using the correct data types for your variables helps to maximize the performance and portability of your programs. Data alignment specifies how data is laid out in memory. A data type’s natural alignment specifies the default alignment of values of that that type.
Table 1 lists the ANSI C scalar data types and their sizes and natural alignment in this environment
Data type |
Size (in bytes) |
Natural alignment (in bytes) |
---|---|---|
|
1 |
1 |
|
1 |
1 |
|
1 |
1 |
|
2 |
2 |
|
2 |
2 |
|
4 |
4 |
|
4 |
4 |
|
4 |
4 |
|
4 |
4 |
|
8 |
4 |
|
8 |
4 |
|
4 |
4 |
|
8 |
4 |
|
8 |
4 |
pointer |
4 |
4 |
These are some important details about this environment:
-
A byte is 8 bits long.
-
A null pointer has a value of
0
. -
This environment uses the little-endian byte ordering scheme to store numeric and pointer data types. That is, the least significant bytes go first, followed by the most significant bytes.
These are the alignment rules followed in this environment:
-
Scalar data types use their natural alignment.
-
Composite data types (arrays, structures, and unions) take on the alignment of the member with the highest alignment. An array assumes the same alignment as its elements. The size of a composite data type is a multiple of its alignment (padding may be required).
Stack Structure
The ARM environment uses a stack that—at the point of function calls—is 4-byte aligned, grows downward, and contains local variables and a function’s parameters.Next figure shows the stack before and during a subroutine call. (To help prevent the execution of malicious code on the stack, GCC protects the stack against execution.)
The stack pointer (SP) points to the bottom of the stack. Stack frames contain the following areas:
-
The parameter area stores the arguments the caller passes to the called function or stores space for them, depending on the type of each argument and the availability of registers. This area resides in the caller’s stack frame.
-
The linkage area contains the address of the caller’s next instruction.
-
The saved frame pointer (optional) contains the base address of the caller’s stack frame.
-
The local storage area contains the subroutine’s local variables and the values of the registers that must be restored before the called function returns.
-
The saved registers area contains the values of the registers that must be restored before the called function returns.
In this environment, the stack frame size is not fixed.