Greetings: Here is an odd one that I hope someone can point out the obvious thing I am doing wrong. In the accompanying extremely simplified source code, compiled with uVision3 V3.12a, I am just calling a function with six parameters. Nothing earth shattering about that, and running this code under the simulator it works fine. Prior to the function call the first four parameters are loaded into registers and the fifth and sixth are pushed on the sack, as other forum discussions state that it should. The function returns the sum of the parameters, as expected. When I run this on the target environment, however, the processor pushes zeros onto the stack instead of the fifth and sixth parameter and, of course, the return value is wrong.
//* Main.c ********************************** #include <LPC22XX.H> unsigned char Param6Test ( char, char, char, char, char, char ); //******************************************* void main ( void ) { char Param1; char Param2; char Param3; char Param4; char Param5; char Param6; char RetVal; Param1 = 1; Param2 = 2; Param3 = 3; Param4 = 4; Param5 = 5; Param6 = 6; while ( 1 ) { RetVal = Param6Test ( Param1, Param2, Param3, Param4, Param5, Param6 ); if ( RetVal == 1 ) Param1++; } } //******************************************* char Param6Test ( char x1, char x2, char x3, char x4, char x5, char x6 ) { char charRetval; charRetval = x1; charRetval = charRetval + x2; charRetval = charRetval + x3; charRetval = charRetval + x4; charRetval = charRetval + x5; charRetval = charRetval + x6; return ( charRetval ); } //*******************************************