SPRAC71B February 2019 – October 2023
Arguments with a type that fits in a single CPU register are passed in a single CPU register. That is, types up to 16 bits are passed in a single register. Pointer types are also passed in a single register, regardless of size.
Pointer types are stored as 32-bit values but should be treated as having a 22-bit limit on the address space.
Example 1:
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:
MOVW DP,#a0
MOV AL,@a0
MOV AH,@a1
MOVZ AR4,@a2
MOVZ AR5,@a3
; call instruction here
Example 2:
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:
MOVL XAR4,#a2
MOVL XAR5,#a1
MOVL *-SP[2],XAR4
MOVL XAR4,#a3
MOVL *-SP[4],XAR4
MOVL XAR4,#a0
; call instruction here