SPRUIG8J January 2018 – March 2024
The C/C++ compiler uses a stack to:
The run-time stack grows from the high addresses to the low addresses. The compiler uses the D15 register to manage this stack. D15 is the stack pointer (SP), which points to the next unused location on the stack.
The linker sets the stack size, creates a global symbol, __TI_STACK_SIZE, and assigns it a value equal to the stack size in bytes. The default stack size is 0x2000 bytes. You can change the stack size at link time by using the --stack_size option with the linker command. For more information on the --stack_size option, see Section 12.4.
At system initialization, SP is set to the first 8-byte (64-bit) aligned address that is 16 bytes before the end (highest numerical address) of the .stack section. The SP is 8-byte aligned so that most 64-bit and smaller objects do not cross memory bank boundaries, which are 64-bits in size, and by convention, SP will always point to a free 16-byte location to optimize stack usage on function calls.
The C/C++ environment automatically decrements SP at the entry to a function to reserve all the space necessary for the execution of that function when the space required is greater than the 16 bytes reserved for each stack frame.
For more information about the stack and stack pointer, see Section 6.4.