HC08: Not allocated variables

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

HC08: Not allocated variables

跳至解决方案
5,348 次查看
jdiogon
Contributor I
Hi everybody !

I've some problems while debugging code with CodeWarrior :
some of my variables are indicated as "not allocated", and appear in grey.
Then my code doesn't work.

Is there anybody here who knows how to solve this ?

Thanks a lot in advance.

Message Edited by CrasyCat on 2007-04-13 11:05 AM

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
2,847 次查看
Nouchi
Senior Contributor II
Hi,

Your variable appears in Grey because it's optimized, so if you don't want optimization only for this variable, you have to declare it as "volatile".


regards,
Emmanuel

在原帖中查看解决方案

0 项奖励
回复
7 回复数
2,847 次查看
jdiogon
Contributor I
I'm working with a HCS08.

I'm gonna look if I can see registers in the debugger.

Thank you again for all your answers.

PS : Emmanuel : je pense que nous sommes tous deux français...
J'étudie à l'ISIMA à Clermont-Ferrand.
Et toi tu es d'où ? :smileywink:

Message Edited by jdiogon on 2007-01-1908:22 PM

0 项奖励
回复
2,848 次查看
Nouchi
Senior Contributor II
Hi,

Your variable appears in Grey because it's optimized, so if you don't want optimization only for this variable, you have to declare it as "volatile".


regards,
Emmanuel
0 项奖励
回复
2,847 次查看
jdiogon
Contributor I
Thanks.

Is there any solution to avoid this for all code ?
I'd like to be able to access all my variables in the debugger easily.
0 项奖励
回复
2,847 次查看
Stephen
Contributor III
(Without knowing which processor and debugger you are using) does your debugger show you the current contents of the registers and accumulators? Usually "optimisation" just means the C-level instruction is being carried out directly in registers and accumulators.
When I have been faced with debugging in similar circumstances on an HCS12 processor, I have usually found I can still work out what's happening from watching the registers and accumlator. An 8-bit variable is usually put in ACC.B, a 16 bit in ACC.D. A display of the compiled code in assembler also helps.
 
An early career writing everything in assembler is never completely wasted! :smileyhappy:
0 项奖励
回复
2,847 次查看
CrasyCat
Specialist III
Hello
 
  There is no way to disable all optimization in the compiler.
  The compiler will always optimize access to variables with local scope.
 
CrasyCat
2,847 次查看
Lundin
Senior Contributor IV
"There is no way to disable all optimization in the compiler."

Why not?

- Every other compiler in the known world has this feature, including crappy freeware compilers made by hobbyists.
- It can't be awfully hard to implement it.
- Debugging optimized code is incredible annoying.
0 项奖励
回复
2,847 次查看
jdiogon
Contributor I
Thank you all !
0 项奖励
回复