ZHCUCH3A November 2024 – March 2025 F29H850TU , F29H859TU-Q1
所有数据访问都与最近的字大小对齐。这由正在访问的存储器或外设强制执行。
这意味着所有数据访问都需要执行以下操作:
有关基地址的示例:基指针地址必须与数据字宽度对齐。因此,如果使用诸如“LD.64”的 64 位(8 字节)数据指令,基址必须与 64 位字边界对齐。因此,二进制地址的最后三位数字必须为 0,因为这意味着该值可以被 8 整除。因此“LD.32 D2,*(0:#0xF8)”可以有效(因为在二进制中,这是 0b1111 1000),但“LD.32 D2,*(0:#0xF9)”不能有效(因为在二进制中,这是 0b1111 1001)。
有关偏移的示例:使用的任何偏移值(以字节为单位)都必须是指令数据大小的倍数。因此,如果使用诸如“LD.32”的 32 位(4 字节)数据指令,则偏移必须是 4 的倍数。因此,“LD.32 D2,*(A2 + #4)”可能有效,但“LD.32 D2,*(A2 + #5)”可能无效。这些指令还要求基指针对齐。
下面提供了一些有关正确和错误对齐的其他示例:
MV.32 A2,#ArrayX ; Assume that the array is aligned
; to a 64-bit word boundary for this example.
; CORRECT Examples:
; Pointer Addressing With #Immediate Offset Examples
LD.B0 D0,*(A2+#9) ; Byte offset can be any value
LD.U16 D1,*(A2+#10) ; 16-bit offset can only be a multiple of 2 bytes
LD.32 D2,*(A2+#4) ; 32-bit offset can only be a multiple of 4 bytes
LD.64 XD4,*(A2+#16) ; 64-bit offset can only be a multiple of 8 bytes
; Scaled values (left shift or multiplied values)
LD.U16 D1,*(A2+#1<<1) ; 16-bit offset can only be a multiple of 2 bytes
LD.U16 D1,*(A2+#3<<1) ; 16-bit offset can only be a multiple of 2 bytes
LD.64 XD4,*(A2+#2<<3) ; 64-bit offset can only be a multiple of 8 bytes
; Pointer Addressing with #Immediate Increment/Decrement Examples
LD.B0 D0,*(A2++#9) ; Byte offset can be any value
LD.U16 D1,*(A2++#10) ; 16-bit offset can only be a multiple of 2 bytes
LD.32 D2,*(A2++#4) ; 32-bit offset can only be a multiple of 4 bytes
LD.64 XD4,*(A2++#24) ; 64-bit offset can only be a multiple of 8 bytes
; INCORRECT Examples:
LD.U16 D1,*(A2++#5) ; INCORRECT: offset can only be a multiple of 2
LD.U16 D1,*(A2+#3<<0) ; INCORRECT: offset can only be a multiple of 2
LD.64 XD4,*(A2+#10) ; INCORRECT: offset can only be a multiple of 8
; If ArrayX is not aligned to a 32-bit boundary and LD.32 is called,
; then a CPU addressing fault is generated.