Crazy arguments receiving in functions: help!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Crazy arguments receiving in functions: help!

Jump to solution
2,766 Views
Ciccio_unico
Contributor II

Hi,

I use MC9S08LL16 with this version of Codewarrior:

ColdFireV1 build 080723
HCS08LL16 Service Pack 080813
HCS08SE8 Service Pack 080829
Release 8127
PE V.3.04 Service Pack 081024

 

I have declared in funcs.h this function:

unsigned char GestioneMani(unsigned char ,unsigned char );

In funcs.c I have write my function:

unsigned char GestioneMani(unsigned char TempPassata,unsigned char UmidPassata)

if( (TempPassata<26) && (UmidPassata<80))
  return VERDE;

.......

 

Problem: 

the arguments receiving are differents???!!!

This is a call:

CALL

 

and this is inside the function:inside

 

 

Why?

thanks

Labels (1)
0 Kudos
1 Solution
459 Views
Ciccio_unico
Contributor II
I have resolved setting in Standard Settings-->Compiler-->Options-->Disable Optimization (-O0)

View solution in original post

0 Kudos
7 Replies
460 Views
Ciccio_unico
Contributor II
I have resolved setting in Standard Settings-->Compiler-->Options-->Disable Optimization (-O0)
0 Kudos
459 Views
Ciccio_unico
Contributor II
Thanks for your help!
No, the stack is not in overflow!
I dont used floating.
Temperatura is global.
I have resolve in this mode:
unsigned char GestioneMani(unsigned char ,unsigned char );
and call with GestioneMani(Temperatura,Umidita);
transformed in:
unsigned char GestioneMani(void);
and call in  GestioneMani();
I dont like this and I don't understand why, as soon as possible I deepens this problem.
I see the same problem when I forgot the include file.h but here there is it!
0 Kudos
459 Views
Ciccio_unico
Contributor II

OK, thanks!

Sorry for stupid question but where I can see my stack size?

I have seen the setting size in PRN file:

STACKSIZE 0x50

I have seen in MAP file where the compiler insert my stack:

.stack  80   R/W      0x167      0x1B6   RAM

Now I can see in debug mode how much stack I use?

 

Thanks again

0 Kudos
459 Views
bigmac
Specialist III

Hello,

 

During debug, after you have entered the function and the function parameters are on the stack, ascertain the current address of the stack pointer. If this is less than the lowest allocated address for the stack (0x0167 from the map file), it is possible that you have overwritten some of the global or static variables.

 

Even if the pointer is slightly above the lowest address, this could still be problematic should an interrupt occur whilst within the function.

 

If the variable Temperatura is global, it may even be possible that this becomes overwritten by the stack during execution of a completely different part of the program.

 

Does your program use any float variables?  If so, this will greatly increase the stack size requirement.

 

Regards,

Mac

Message Edited by bigmac on 2009-05-27 03:35 PM
0 Kudos
459 Views
CompilerGuru
NXP Employee
NXP Employee

- Is this a debug information issue (say the debugger shows the wrong values, but the code otherwise behaves properly)?

- Implicit parameter declaration, are there any compiler warnings (possibly disabled...)?

- Could also be a stack overflow, try to increase the STACKSIZE in the prm.

 

Daniel

0 Kudos
459 Views
Ciccio_unico
Contributor II
0 Kudos
459 Views
jbezem
Contributor III

Sorry, but your inserted pictures seem to be only 2x1 pixel in size, and don't contain any readable information to me. Can you cut an paste the real pictures after verifying they are correct?

 

BR,

 

Johan

0 Kudos