Crazy function for local scope: help!

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Crazy function for local scope: help!

ソリューションへジャンプ
1,709件の閲覧回数
cicciounico
Contributor III
Hi,
I use MC9S08LC36.
I have make a function defined in funcs.h :
void CaricoOre(unsigned char );

I use this function and I pass it a global var defined in ram.h with:

#ifdef _MAIN_C
   #define g_var
#else
   #define g_var extern
#endif

g_var unsigned char ore;

My problem is: when I call My function, the var passed is 0 but insiede the function is random value!!
Why?
The screen shot: call function
http://ciccioamore.altervista.org/1.jpg

Inside the function:
http://ciccioamore.altervista.org/2.jpg





Thanks
ラベル(1)
タグ(1)
0 件の賞賛
1 解決策
597件の閲覧回数
cicciounico
Contributor III
YUUuuuuuuuuuu!   :smileyhappy:
Thanks: I have insert option: -Wpd
and the compiler have alert me with warnig!
Missing : #include funcs.h     :smileysurprised:

thanks again!   :smileyhappy:

元の投稿で解決策を見る

0 件の賞賛
3 返答(返信)
597件の閲覧回数
Navidad
Contributor III
Hi,

I am no debugger expert, but what happens here is that the parameter is passed through a register (namely A), and not on the stack. Check the value of the A register (the register view is not included in you screenshots). I would expect it to be 0. Note that for functions with a fixed number of arguments and when the size of the last argument is one byte, the compiler will always pass this last argument through a A register (this behavior is documented in the compiler manual in this section: "Calling Protocol and Conventions" ).

Navidad
597件の閲覧回数
CrasyCat
Specialist III
Hello
 
It would be worthwhile checking if you have a prototype of function Caricoure in module where ShowLCD is implemented.
 
In order to figure that out, can you please add the option -Wpd to your compiler command line? If you get an error message that means you are invoking the function, but there is no prototype for it. 
 
Please add a prototype for the function before you call it.
 
If this does not help, I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

Attach the generated .zip file to the SR.
CrasyCat
598件の閲覧回数
cicciounico
Contributor III
YUUuuuuuuuuuu!   :smileyhappy:
Thanks: I have insert option: -Wpd
and the compiler have alert me with warnig!
Missing : #include funcs.h     :smileysurprised:

thanks again!   :smileyhappy:
0 件の賞賛