Skip to main content
Knowledgebase
Home
Renesas Electronics Europe - Knowledgebase

RAM Cleaning: Is it possible to refer to the address in the C language?

Latest Updated:11/20/2014

Question:

I am using the RL78/78K0R compiler. I want to create a program to clear RAM in areas other than the stack area by using the C language. Is it possible to refer to the current stack addresses in the C language?

Answer:

When the -s option for the linker is used, the stack symbols _@STEND and _@STBEG are output, but these cannot be used in C source code. Reference to the stack addresses is only possible in assembly source code; create assembly functions like that shown below and call them by reference from the C source code.

(Example of definition of the assembly function (to _@STEND))
		PUBLIC _stkadr
		EXTRN _@STEND
		CSEG	
	stkadr:
		MOVW BC, #LOWW _@STEND
		MOVW DE, #HIGHW _@STEND
		END	
	
(Example of reference in the C source code (to _@STEND))
	__far unsigned char * stkadr(void);
	__far unsigned char *endadr;
	endadr = stkadr();

Suitable Products
C Compiler Package for RL78 and 78K Families
Compiler for RL78 Family and 78K0R [CA78K0R]
Compiler for 78K0R [CC78K0R]