HC08: Not allocated variables

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

HC08: Not allocated variables

Jump to solution
5,252 Views
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

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
2,751 Views
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

View solution in original post

0 Kudos
Reply
7 Replies
2,751 Views
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 Kudos
Reply
2,752 Views
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 Kudos
Reply
2,751 Views
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 Kudos
Reply
2,751 Views
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 Kudos
Reply
2,751 Views
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,751 Views
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 Kudos
Reply
2,751 Views
jdiogon
Contributor I
Thank you all !
0 Kudos
Reply