C code not generating correct assembly

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

C code not generating correct assembly

3,171件の閲覧回数
ScottC
Contributor I
I am using CW and noticed code that I wrote to set a variable is being ignored, sometimes.  I looked at the assemly listing.  '08ap32
 
Any ideas?
ラベル(1)
タグ(1)
0 件の賞賛
返信
4 返答(返信)

538件の閲覧回数
J2MEJediMaster
Specialist I

It would help to have a look at your code and know what optimization level you're using with the compiler. When generating highly optimized code, the compiler may interpret some code is being run once and can be optimized out of existence.

 

---Tom

0 件の賞賛
返信

538件の閲覧回数
ScottC
Contributor I
I am just setting a global variable.  In one section of the code it is ignored.  In another, the code in the listing file is as it should be.
 
It happens to be ignored in the same in the same routine when set at different times.
 
How do I check optimization settings?

Message Edited by Scott C on 04-24-200604:47 PM

Message Edited by Scott C on 04-24-200604:53 PM

Message Edited by Scott C on 04-24-200604:54 PM

0 件の賞賛
返信

538件の閲覧回数
CrasyCat
Specialist III

Hello

Basically the compiler is optimizing access to global variables. If you have something like

var = 4;

var = 5;

the compiler will only generate code to assign 5 to var.

To make sure the compiler does not optimize access to a variable, define it as volatile. 

CrasyCat

0 件の賞賛
返信

538件の閲覧回数
ScottC
Contributor I
I just define it to pass to another routine, but I will give it a try.
 
Thanks
0 件の賞賛
返信