SLAA534A June 2013 – June 2020
See Section 11.6.1.4 for MSP430-native instructions assembled on MSP430X.
MSP430X has instruction encodings with immediate fields that are different than MSP430, requiring distinct relocations.
The "ABS20" and "PCR20" relocations are used for "MSP430X extended instructions." These instructions require an extra op-code prefix word to encode 20-bit addressing modes (MOVX, CMPX, ADDX, etc).
The "ABS20" relocations are also used for the "MSP430X address instructions." These instructions allow one 20-bit addressing mode without requiring an extra op-code prefix word (ADDA, MOVA, CMPA, SUBA, CALLA).
R_MSP430X_ABS20_EXT_SRC, R_MSP430X_ABS20_EXT_DST, and R_MSP430X_ABS20_EXT_ODST relocations are used for Absolute, Indexed, and Immediate addressing modes, but only on MSP430X. They are distinct because they encode different fields in the instruction encoding. SRC relocates the source operand; DST and ODST relocate the destination operand. ODST is used instead of DST if the addressing mode of the source operand requires an additional word to encode, including 20-bit addresses and 20-bit immediate constants that cannot be handled with the constant generator.
MOVX &X, R5 ; R_MSP430X_ABS20_EXT_SRC
MOVX #X, R5 ; R_MSP430X_ABS20_EXT_SRC
MOVX R5, &Y ; R_MSP430X_ABS20_EXT_DST
MOVX #0xabcde, &Y ; R_MSP430X_ABS20_EXT_ODST (Y)
MOVX &X, &Y ; R_MSP430X_ABS20_EXT_SRC (X) and R_MSP430X_ABS20_EXT_ODST (Y)
MOVX #X, &Y ; R_MSP430X_ABS20_EXT_SRC (X) and R_MSP430X_ABS20_EXT_ODST (Y)
ADDX K(R4), R5 ; R_MSP430X_ABS20_EXT_SRC (K)
R_MSP430X_PCR20_EXT_SRC, R_MSP430X_PCR20_EXT_DST, and R_MSP430X_PCR20_EXT_ODST are similar to the EXT20 relocation types, except that they are used for Symbolic addressing mode.
MOVX X, R5 ; R_MSP430X_PCR20_EXT_SRC
MOVX R5, Y ; R_MSP430X_PCR20_EXT_DST
MOVX #0xabcde, Y ; R_MSP430X_PCR20_EXT_ODST (Y)
MOVX X, Y ; R_MSP430X_PCR20_EXT_SRC (X) and R_MSP430X_PCR20_EXT_ODST (Y)
R_MSP430X_PCR20_CALL is used for CALLA with Symbolic addressing mode:
CALLA Y ; R_MSP430X_PCR20_CALL
For R_MSP430X_PCR20_EXT_SRC, R_MSP430X_PCR20_EXT_DST, R_MSP430X_PCR20_EXT_ODST, and R_MSP430X_PCR20_CALL, the effective PC does not match the address of the relocation container. To compensate for this, the assembler must adjust the relocation addend by the difference. The addend must be adjusted by adding -4 for SRC and DST, -6 for ODST, and -2 for CALL.
R_MSP430X_ABS20_ADR_SRC and R_MSP430X_ABS20_ADR_DST are used for Absolute, Indexed, and Immediate addressing modes, but only on MSP430X. They are distinct because they encode different fields in the instruction encoding. SRC relocates the source operand; DST relocates the destination operand. CALLA uses DST.
MOVA &X, R5 ; R_MSP430X_ABS20_ADR_SRC
MOVA R5, &X ; R_MSP430X_ABS20_ADR_DST
MOVA #X, R5 ; R_MSP430X_ABS20_ADR_SRC
CALLA #X ; R_MSP430X_ABS20_ADR_DST
CALLA &X ; R_MSP430X_ABS20_ADR_DST
R_MSP430_ABS_HI16 is used to load a 32-bit linker symbol value. A linker symbol value is larger than a 20-bit pointer, so a single instruction cannot be used to load the entire value. The value must be split into two relocations. This relocation type represents the MSW of the value. It is intended to be used as a pair with R_MSP430_ABS16 representing the LSW. This relocation type is legal but unused on MSP430 .
Example: The TI compiler will generate this type of relocation pair from the following C code:
extern char X;
unsigned long fn()
{
return _symval(&X);
}
MOV #$LO16(X), R12; R_MSP430_ABS16
MOV #$HI16(X), R13; R_MSP430_ABS_HI16