cancel
Showing results for 
Search instead for 
Did you mean: 

Strange value of register

adaszeq
Associate
Posted on February 24, 2013 at 09:08

I have one strange problem. After this fragment of code program:

b = a;

a =/ 40;

if(!a)

//breakpoints

the results of two registers are: b = 50000 - good value,

a=0

The value of a should be about 1250 not 0!!

I can't find place in my program where i change value of a, because I use it only in one place. 

Any suggestion how can I find solutions of this problem?

#incorrect-expectations #wrong-value-register-bug #optimisation
4 REPLIES 4
Andrew Neil
Evangelist III
Posted on February 25, 2013 at 10:07

You have not given enough information.

Post the smallest complete  program which illustrates your problem...
luca239955_stm1_st
Senior II
Posted on February 26, 2013 at 09:03

most likely something has been optimized away: first step is to declare the variables as volatile and see if you get the expected value.

Andrew Neil
Evangelist III
Posted on February 26, 2013 at 19:46

''declare the variables as volatile and see if you get the expected value''

 

 

If you do, that may well be an indication that the expectation  was flawed...

http://bit.ly/Vv8fFg

richhamersley
Associate
Posted on March 04, 2013 at 17:16

Did you mean:  a /= 40;   

i.e., a = a/40;

instead of a =/40?

a =/ 40;  if accepted by compiler will always set a to 0.