The following is for a C5535 DSP using Code Composer Studio ( Version: 5.5.0.00077 ).
The following code clips shows a function ( SPIFLASH_write ) being called with three arguments.
The first clip shows the C function being called with the third parameter being assigned a value of 256.
The second clip shows the "Disasembled" C code ( mixed with the resulting assembly code ) where the compiler has saved the first argument ( bootBytes ) in the AC0 register, the second argument ( spiflash_addr ) is saved in the AC1 register, and finally the third argument ( with a value of 256 ) in the T0 register.
The third clip shows the beginning of the C function ( SPIFLASH_write ) where the arguments being passed in the function call are assigned to "src", "dst", and "len_w".
The fourth clip shows the associated disassembled, mixed C and assembly code from the start of the C function associated to the third clip. It can be seen that registers AC2, AC1, and AC0 are saved on the stack, and then in the last three lines the value from ( *SP(#04h) ) which was loaded from the AC2 register is transferred to the parameter "bytes_left" as supposedly the value of "len_w".
So, in summary. The third argument ( with a value of 256 ) is stored in the T0 register when the function is called, but the argument is "read" from the AC2 register when the function is executed. In debugging this code, I can see the value of 256 being stored in the T0 register, but the value of what ever was preveously in the AC2 register is used within the function for the value of "len_w".
The other two arguments are passed correctly as they are both saved and recalled from the AC0 and AC1 registers.
So is this an error in the compiler? Or am I doing something wrong?
I've reviewed Section "6.4 Function Structure and Calling Conventions" in the "TMS320C55X Optimizing C/C++ Compiler v 4.4 User's Guide" ( SPRU281G ) but did not see anything obvious.
