8.2.4 Stack area allocation, stack pointer setting, and stack area initialization

The start (__STACK_ADDR_END) and end (__STACK_ADDR_START) of the stack area are determined by the linker. Since the CC-RL stack area is extended in the direction of address 0x0, set the end (__STACK_ADDR_START) of the stack area used by the system to the stack pointer. For __STACK_ADDR_START and __STACK_ADDR_END, see "6.2.2 Symbols generated by option specifications".

 

To set the SP in the startup routine, write the code as follows.

MOVW    SP,#LOWW(__STACK_ADDR_START)

 

Next, initialize the stack area. The start (__STACK_ADDR_END) of the stack area is passed as an argument. If parity error detection by reading uninitialized RAM is not performed, the stack area does not have to be initialized. To perform parity error detection by reading uninitialized RAM, enable the processing for initializing the stack area.

MOVW    AX,#LOWW(__STACK_ADDR_END)
CALL    !!_stkinit