The TMS320C2X/C5X fixed-point processor has two types of memory: program memory and data memory. The program memory mainly contains executable program code, while the data memory mainly contains external variables, static variables, and system stack. Each block of program or data generated by the C program is stored in a continuous block of storage space. (I) Blocks generated by the C compiler There are six types of blocks compiled and generated by the TMS320C2X/C5X compiler, which can be divided into two categories. Among the six blocks, in addition to the five blocks generated by the floating-point C compiler, there is also a .switch block, which is an initialized block that contains a table established for the .switoh statement. (II) C system stack The function of the fixed-point C system stack is exactly the same as that of the floating-point C compiler's C system stack, and the method of managing the stack is basically similar. However, the registers used to manage the same C stack are different. The fixed-point C compiler uses the following two registers to manage the stack: AR1 is the stack pointer (SP). It points to the top of the stack. AR0 is the frame pointer (FP). It points to the beginning of the current frame. When each function is activated, a new frame is created in the stack to allocate local variables and temporary variables. The C environment can automatically manage these registers. If you need to write an assembly program that uses the runtime stack, you must use these registers correctly. Like the floating-point C compiler, the stack length of the fixed-point C compiler is also determined by the linker. The value of the global symbol _STACK_SIZE is equal to the stack length in bytes, and the default value is 1K bytes. Similarly, when you need to change the stack length, use the -stack option when linking and specify a value after it. (III) Dynamic memory allocation In the runtime support library, there are several functions that allow dynamic memory allocation at runtime, such as malloc, calloc, and realloc. The method of dynamic memory allocation is exactly the same as the dynamic memory allocation of the floating-point C compiler. (IV) Memory allocation for static and global variables Each external or static variable declared in a C program is allocated to a unique continuous space. The address of the space is determined by the linker. The compiler ensures that the space for these variables is allocated in multiple words so that each variable is aligned to a word boundary. (V) Alignment of domains/structures When the compiler allocates space for a structure, it allocates enough words to contain all structure members. In a group of structures, each structure starts on a word boundary. All non-domain types are aligned to word boundaries. Allocate enough bits to a field so that adjacent fields fit into adjacent bits of a word, but do not span two words. If a field spans two words, the entire field is allocated to the next word.