Defining __initial_sp, __heap_base and __heap_limit

One of several methods you can use to specify the initial stack pointer and heap bounds is to define the following symbols:

You can define these symbols in an assembly language file, or by using the embedded assembler in C.

For example:

__asm void dummy_function(void)
    EXPORT __initial_sp
    EXPORT __heap_base
    EXPORT __heap_limit

__initial_sp EQU STACK_BASE
__heap_base EQU HEAP_BASE
__heap_limit EQU (HEAP_BASE + HEAP_SIZE)

The constants STACK_BASE, HEAP_BASE and HEAP_SIZE can be defined in a header file, for example stack.h, as follows:

/* stack.h */
#define HEAP_BASE 0x20100000  /* Example memory addresses */
#define STACK_BASE 0x20200000


This method of specifying the initial stack pointer and heap bounds is supported by both the standard C library (standardlib) and the micro C library (microlib).

Show/hideSee also

Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0475C