RTEMS Logo

RTEMS 4.7.99.2 On-Line Library


Texas Instruments C3x/C4x Specific Information Parameters Passed in Memory

PREV UP NEXT Bookshelf RTEMS CPU Architecture Supplement

9.2.4.1: Parameters Passed in Memory

When passing parameters on the stack, the calling convention assumes that arguments are placed on the current stack before the subroutine is invoked via the XXX instruction. The first argument is assumed to be closest to the return address on the stack. This means that the first argument of the C calling sequence is pushed last. The following pseudo-code illustrates the typical sequence used to call a subroutine with three (3) arguments:

push third argument
push second argument
push first argument
invoke subroutine
remove arguments from the stack

The arguments to RTEMS are typically pushed onto the stack using a sti instruction with a pre-incremented stack pointer as the destination. These arguments must be removed from the stack after control is returned to the caller. This removal is typically accomplished by subtracting the size of the argument list in words from the current stack pointer.

With the GNU Compiler Suite, parameter passing via the stack is selected by invoking the compiler with the -mmemparm XXX argument. This argument must be included when linking the application in order to ensure that support libraries also compiled assuming parameter passing via the stack are used. The default parameter passing mechanism is XXX.

When this parameter passing mecahanism is selected, the XXX symbol is predefined by the C and C++ compilers and the XXX symbol is predefined by the assembler. This behavior is the same for the GNU and Texas Instruments toolsets. RTEMS uses these predefines to determine how parameters are passed in to those C3x/C4x specific routines that were written in assembly language.


PREV UP NEXT Bookshelf RTEMS CPU Architecture Supplement

Copyright © 1988-2004 OAR Corporation