Skip to main content
Visitor II
February 24, 2013
Question

Strange value of register

  • February 24, 2013
  • 4 replies
  • 935 views
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
    This topic has been closed for replies.

    4 replies

    Super User
    February 25, 2013
    Posted on February 25, 2013 at 10:07

    You have not given enough information.

    Post the smallest complete  program which illustrates your problem...
    Visitor II
    February 26, 2013
    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.

    Super User
    February 26, 2013
    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

    Visitor II
    March 4, 2013
    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.