什么是编译堆栈?
What is a compiled stack?
我偶然发现了上述术语,并且已经知道它以某种方式用于微控制器,但没有找到任何解释。什么是编译堆栈,它有什么用,为什么?
Compiled stack是微控制器PIC范围内使用的技术
来自MPLAB XC8 C Compiler User's Guide:
A compiled stack is a static allocation of memory for stack-based objects that can be built up in multiple data banks. See Section 5.5.2.2.1 “Compiled Stack Operation” for information about how objects are allocated to this stack. Objects in the stack are in fixed locations and can be accessed using an identifier (hence it is a static allocation). Thus, there is no stack pointer. The size of the compiled stack is known at compile time, and so available space can be confirmed by the compiler. The compiled stack is allo-cated to psects that use the basename cstack; for example, cstackCOMMON, cstackBANK0. See Section 5.15.2 “Compiler-Generated Psects” for more information on the naming convention for compiler-generated psects.
By contrast, the software stack has a size that is dynamic and varies as the program is executed. The maximum size of the stack is not exactly known at compile time and the compiler typically reserves as much space as possible for the stack to grow during pro-gram execution. The stack is always allocated a single memory range, which may cross bank boundaries, but within this range it may be segregated into one area for main-line code and an area for each interrupt routine, if required. A stack pointer is used to indicate the current position in the stack. This pointer is permanently allocated to FSR1.
我偶然发现了上述术语,并且已经知道它以某种方式用于微控制器,但没有找到任何解释。什么是编译堆栈,它有什么用,为什么?
Compiled stack是微控制器PIC范围内使用的技术
来自MPLAB XC8 C Compiler User's Guide:
A compiled stack is a static allocation of memory for stack-based objects that can be built up in multiple data banks. See Section 5.5.2.2.1 “Compiled Stack Operation” for information about how objects are allocated to this stack. Objects in the stack are in fixed locations and can be accessed using an identifier (hence it is a static allocation). Thus, there is no stack pointer. The size of the compiled stack is known at compile time, and so available space can be confirmed by the compiler. The compiled stack is allo-cated to psects that use the basename cstack; for example, cstackCOMMON, cstackBANK0. See Section 5.15.2 “Compiler-Generated Psects” for more information on the naming convention for compiler-generated psects.
By contrast, the software stack has a size that is dynamic and varies as the program is executed. The maximum size of the stack is not exactly known at compile time and the compiler typically reserves as much space as possible for the stack to grow during pro-gram execution. The stack is always allocated a single memory range, which may cross bank boundaries, but within this range it may be segregated into one area for main-line code and an area for each interrupt routine, if required. A stack pointer is used to indicate the current position in the stack. This pointer is permanently allocated to FSR1.