Byte and word issues

The MSP430 is byte-addressed, and little-endian. Word operands must be located at even addresses. Most instructions have a byte/word bit, which selects the operand size. Appending ".b" to an instruction makes it a byte operation. Appending ".w" to an instruction, to make it a word operation, is also legal. However, since it is also the default behaviour, if you add nothing, it is generally omitted. A byte instruction with a register destination clears the high 8 bits of the register to 0. Thus, the following would clear the top byte of the register, leaving the lower byte unchanged:

mov.b Rn,Rn

The on-chip peripherals are divided into an 8-bit bank and a 16-bit bank. The 8-bit peripherals must only be accessed using 8-bit instructions; using a 16-bit access produces garbage in the high byte. The 16-bit peripherals must only be accessed at even addresses. Byte accesses to even addresses are legal, but not usually useful.

The processor's behaviour when a word is accessed at an odd location is poorly documented. In all current processors the lower bit is just silently ignored. The effect is, therefore, the same as specifying an address which is one less.

It should be noted that the the byte and word addressing behaviour of the MSP430 prevents the processor supporting strict compliance with the standard C language. In standard C everything should be copiable, by copying at the byte level. This usually has little impact on the types of embedded program for which the MSP430 is typically used. However, it can sometimes catch you out!