3.6 Word Move Operations
Even though the data space is byte-addressable, all move operations made in Word mode must be word-aligned. This means that for all source and destination operands, the Least Significant Address bit must be ‘0’. Likewise, for long-word accesses, last 2 bits of addresses must be zero. If a word/long-word move is made to or from an unaligned address, an address error exception is generated. Figure 3-2 shows how bytes and words may be aligned in data memory. Legal Word Move Operations contains several legal word move operations.
When an exception is generated due to a misaligned access, the exception is taken after the instruction executes. If the illegal access occurs from a data read, the operation will be allowed to complete, but the Least Significant bit (LSb) of the source address will be cleared to force word alignment. If the illegal access occurs during a data write, the write will be inhibited. Illegal Word Move Operations contains several illegal word move operations.
CLR W0 or CLR.w W0 or CLR.W W0.Legal Word Move Operations
MOV		#0x30, W0		 ; move the literal word 0x30 to W0Before Instruction:
W0 = 0x5555After Instruction:
W0 = 0x0030MOV		0x1000, W0		; move the word at 0x1000 to W0Before Instruction:
W0 = 0x5555
Data Memory 0x1000 = 0x1234After Instruction:
W0 = 0x1234
Data Memory 0x1000 = 0x1234MOV		[W0], [W1++]	    ; word move [W0] to [W1],
; then post-inc W1Before Instruction:
W0 = 0x1234
W1 = 0x1000
Data Memory 0x1000 = 0x5555
Data Memory 0x1234 = 0xAAAAAfter Instruction:
W0 = 0x1234
W1 = 0x1004
Data Memory 0x1000 = 0xAAAA
Data Memory 0x1234 = 0xAAAAIllegal Word Move Operations
MOV		0x1001, W0				; move the word at 0x1001 to W0Before Instruction:
W0 = 0x5555
Data Memory 0x1000 = 0x1234
Data Memory 0x1002 = 0x5678After Instruction:
W0 = 0x1234
Data Memory 0x1000 = 0x1234
Data Memory 0x1002 = 0x5678ADDRESS ERROR TRAP GENERATED
(source address is misaligned, so MOV is performed)
MOV		W0, 0x1001				; move W0 to the word at 0x1001Before Instruction:
W0 = 0x1234
Data Memory 0x1000 = 0x5555
Data Memory 0x1002 = 0x6666After Instruction:
W0 = 0x1234
Data Memory 0x1000 = 0x5555
Data Memory 0x1002 = 0x6666ADDRESS ERROR TRAP GENERATED
(destination address is misaligned, so MOV is not performed)
MOV		[W0], [W1++]				; word move [W0] to [W1],
; then post-inc W1Before Instruction:
W0 = 0x1235
W1 = 0x1000
Data Memory 0x1000 = 0x1234
Data Memory 0x1234 = 0xAAAA
Data Memory 0x1236 = 0xBBBBAfter Instruction:
W0 = 0x1235
W1 = 0x1002
Data Memory 0x1000 = 0xAAAA
Data Memory 0x1234 = 0xAAAA
Data Memory 0x1236 = 0xBBBBADDRESS ERROR TRAP GENERATED
(source address is misaligned, so MOV is performed)
