ZHCUCH3A November 2024 – March 2025 F29H850TU , F29H859TU-Q1
借助“栈寻址”类型,可以使用寻址寄存器 A15(专用栈指针 (SP))中提供的地址读取或写入栈空间中的任何位置。
以下是与栈指针相关的关键信息列表,有助于理解这些寻址模式:
分配栈空间并访问栈上的值时,建议的过程如下:
例如:程序需要为以下各项分配空间:
考虑到对齐,要分配的总字节数可以是 32(这是高于所需 25 字节的最接近的 64 位地址):
64-bit +8 8 bytes total requires 8 bytes allocated
32-bit +4 12 bytes total requires 16 bytes allocated
32-bit +4 16 bytes total
32-bit +4 20 bytes total requires 24 bytes allocated
16-bit +2 22 bytes total
8-bit +1 23 bytes total
8-bit +1 24 bytes total
8-bit +1 25 bytes total requires 32 bytes allocated
Total Used = 25 bytes
Allocated = 32 bytes (closest multiple of 8-bytes [64-bits])