Table 2.6 Argument classes assigned to registers
Argument type
Register assignment order
16-bit data pointer
AR0, AR1, AR2, AR3, AR4
23-bit data pointer
XAR0, XAR1, XAR2, XAR3, XAR4
16-bit data
T0, T1, AR0, AR1, AR2, AR3, AR4
32-bit data
AC0, AC1, AC2
T0
T0
AC0
AR0
int func(int i1, long l2, int *p3);
AC0
AR0
T0
T1
AR1
long func (int *p1, int i2, int i3, int i4);
AC0 AC1 AC2 Stack T0
void func (long l1, long l2, long l3, long l4, int i5);
Figure 2.13 Examples of arguments passing conventions
Return values: The calling function/routine collects the return value from the called
function/subroutine. A16-bit integer data is returned by the register T0 and a 32-bit
data is returned in the accumulator AC0. A data pointer is returned in (X)AR0. When
the called routine returns a structure, the structure is on the local stack.
Register use and preservation: When making a function call, the register assignments
and preservations between the caller and called functions are strictly defined. Table 2.7
describes how the registers are preserved during a function call. The called function
must save the contents of the save-on-entry registers (T2, T3, AR5, AR6, and AR7) if
it will use these registers. The calling function must push the contents of any other
save-on-call registers onto the stack if these register's contents are needed after the
function/subroutine call. Acalled function can freely use any of the save-on-call
registers (AC0±AC2, T0, T1, and AR0±AR4) without saving its value. More detailed
descriptions can be found in the TMS320C55x Optimizing C Compiler User's
Guide [3].
2.8 Experiments ± Assembly Programming Basics
We have introduced the TMS320C55x assembly language and several addressing modes.
Experiments given in this section will help to use different addressing modes for writing
assembly code. We also introduced the C function interfacing with assembly routines
and we will explore the C-assembly interface first.
70
INTRODUCTION TO TMS320C55X DIGITAL SIGNAL PROCESSOR