跳转到主内容
Knowledgebase
Home
Renesas Electronics China - Knowledgebase

How to secure stack area of a particular size as user/ How big by default?

Latest Updated:05/18/2015

Question:

I am using the CC-RL compiler for RL78 devices. How large a stack area is secured by default?
I’d also like to know how to secure a stack area of a particular size as a user.

Answer:

If you have designated the -device option for the linker, find a continuous area of RAM which is not in use, then create the following symbols.
・__STACK_ADDR_START: Highest address of the area + 1
・__STACK_ADDR_END: Lowest address of the area
__STACK_ADDR_START will be the initial value of the stack pointer (SP).

To secure a stack area of a particular size, define the section for the stack in the startup routine, define the symbol for its highest address +1, and set the address of the symbol in the stack pointer (SP).
Example: Definition of a section for the stack (securing 0x200 bytes)
.SECTION .stack_bss, BSS
_stackend:
.DS     0x200
_stacktop:
Example: Configuring the stack pointer (SP)
MOVW SP,#LOWW(_stacktop)

Suitable Products
e² studio
CS+ (formerly CubeSuite+)
C Compiler Package for RL78 Family