啊,内存神马的最为烦人了,这个函数跟IAR编译器还相关,不怎么好懂,功能就是初始化STACK以及指针
static void zmain_ram_init( void )
{
uint8 *end;
uint8 *ptr;
// Initialize the call (parameter) stack
end = (uint8*)CSTK_BEG; // Lower end
ptr = (uint8*)(*( __idata uint16*)(CSTK_PTR)); // Upper end
while ( --ptr > end )
*ptr = STACK_INIT_VALUE;
// Initialize the return (address) stack
ptr = (uint8*)RSTK_END - 1; // Upper end
while ( --ptr > (uint8*)SP )
*(__idata uint8*)ptr = STACK_INIT_VALUE;
}
看着短短几行,挺简单的,里面有几个宏定义,查看一下
// Internal (MCU) Stack addresses
#define CSTK_PTR _Pragma("segment=\"XSP\"") __segment_begin("XSP")
#define CSTK_BEG _Pragma("segment=\"XSTACK\"") _