SLAA534A June 2013 – June 2020
Arguments with a type that fits in a single CPU register are passed in a single CPU register.
For MSP430 and MSP430X, types up to 16 bits are passed in a single register. Pointer types are also passed in a single register, regardless of size.
For MSP430X, pointer types can be 20 bits when using large code or large data memory models, but CPU registers are also 20 bits, so pointer values always fit in a single register. For non-pointer values, MSP430X CPU registers are treated as if they had only 16 bits. A consequence of this is that the registers used to implement argument passing are the same for MSP430 and MSP430X, regardless of the memory model used.
MSP430 and MSP430X example:
C source code:
void func1(int a0, int a1, int a2, int a3);
int a0, a1, a2, a3;
void func2(void)
{
func1(a0, a1, a2, a3);
}
Compiled assembly code:
MOV.W &a0,R12
MOV.W &a1,R13
MOV.W &a2,R14
MOV.W &a3,R15
; call instruction here
MSP430X example:
C source code:
void func1(int *a0, int *a1, int *a2, int *a3);
int a0, a1, a2, a3;
void func2(void)
{
func1(&a0, &a1, &a2, &a3);
}
Compiled in large code model:
MOVX.A #a0,R12
MOVX.A #a1,R13
MOVX.A #a2,R14
MOVX.A #a3,R15
; call instruction here