Skip to main content
adaszeq
Visitor II
February 24, 2013
Question

Strange value of register

  • February 24, 2013
  • 4 replies
  • 1176 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

    Andrew Neil
    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...
    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    luca239955_stm1_st
    Associate
    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.

    Andrew Neil
    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

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    richhamersley
    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.