SPRUIY2A November 2024 – March 2025 F29H850TU , F29H859TU-Q1
All data accesses are aligned to the nearest word size. This is enforced by the memory or peripheral being accessed.
This means that the following are required for all data accesses:
An example regarding the base address: The base pointer address must be aligned to the data word width. So if a 64-bit (8-byte) data instruction like "LD.64" is used, the base address must be aligned to the 64-bit word boundary. Therefore, the last three digits of the address in binary must be 0, since that means the value is divisible by 8. "LD.32 D2,*(0:#0xF8)" can therefore be valid (because in binary, this is 0b1111 1000), but "LD.32 D2,*(0:#0xF9)" can not be valid (because in binary, this is 0b1111 1001).
An example regarding the offsets: Any offset value used (which is in bytes) must be a multiple of the instruction's data size. So if a 32-bit (4-byte) data instruction like "LD.32" is used, the offset must be a multiple of 4. "LD.32 D2,*(A2 + #4)" can therefore be valid, but "LD.32 D2,*(A2 + #5)" can not be valid. Alignment of the base pointer is also required for these instructions.
Some additional examples of correct and incorrect alignment are provided here:
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.