This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error in keil 7.06 a

1 open project HELLO
2 insert int e,b,c; after main
3 in project devce select extended linker
4 translate
5 debug and see that variable e ?????
what is it?
is it new version?

  • I suspect what you are seeing is the variable 'e' being optimised out because you don't use it. However, your problem description is not clear enough to be sure.

    Stefan

  • no sir - variable c and b are ok and if you change e to a you will see ok adres

    and it is only example in real proejct on cygnal i dont see all variable

  • I did as you suggested and I receive the following compiler warnings:

    *** WARNING C280 IN LINE 24 OF HELLO.C: 'e': unreferenced local variable
    *** WARNING C280 IN LINE 24 OF HELLO.C: 'b': unreferenced local variable
    *** WARNING C280 IN LINE 24 OF HELLO.C: 'c': unreferenced local variable

    Since these variables are unreferenced and uninitialized the compiler is free to completely exclude them from the compilation.

    The reason you see results when you look at b and c is because B is the B register (used in MUL and DIV instructions) and C is the carry flag (from the PSW).

    Jon

  • for example add line e=10;
    and you will see the same question ????
    e-> ???????
    what is it ;-)

  • Please send me your c and uv2 file a don't to achieve your results so I probe with your files.
    holatron@seznam.cz

  • If you assign a value to a variable and never use the variable anywhere else, what should the compiler do? Should it optimize this out or not?

    If you don't want the compiler to optimize out useless code, set the optimizer level to 0. Then, you will be happy. Of course, the code generated will be unoptimized.

    Jon

  • If you assign a value to a variable and never use the variable anywhere else, what should the compiler do? Should it optimize this out or not?

    To answer the rhetorical question:

    Depends on whether the variable is declared volatile or not. If it's volatile, then there are perhaps side effects from the write -- say if it's a hardware register -- and you need to keep the assignment. If not, optimize away.

    So, if you're bent on keeping the variable e in the program, make sure to do something with it. Printf() it. Use it as a loop counter. Something, just to give it a reason to exist. Or just declare it volatile.

  • special for you
    insert e=0;
    e=e=10;
    and write e
    you will have same effect æ-)))

  • special for you




    e=0;
    /*------------------------------------------------
    Note that an embedded program never exits (because
    there is no operating system to return to). It
    must loop and execute forever.
    ------------------------------------------------*/
    while (1) {
    P1 ^= 0x01; /* Toggle P1.0 each time we print */
    printf ("Hello World %i \n",e); /* Print "Hello World" */
    e=e+10;
    P0 =e;
    }

  • Yes! It's true.
    I just now repeat this experiment and see: if I select extended linker LX51 then I don't see value of variable 'e', ever I use this variable in my program. When I change C51 Optimizing Level to 7 (Extended Index Access Optimizing) - voila! I see variable in debugger! Great! But if optimizing level more than 7 or Emphasis no 'Favor Speed' or I check box 'Linker Code Packing' - this bug return.

    What is it?

  • "But if optimizing level more than 7 or Emphasis no 'Favor Speed' or I check box 'Linker Code Packing' - this bug return."

    Have you actually tried reading any of the answers to your original post? You have just demonstrated in agreement with those answers that you are NOT seeing a bug - you are seeing expected behaviour.

  • Stefan wrote:"Have you actually tried reading any of the answers to your original post?"
    Yes, I read carefully original post and ALL answers. Excuse me for my bad English. But you don't see what exactly happens.

    I have very little main function:

    main()
    {
      int e;
    
      while(1)
      {
        e++;
      }
    }
    

    When I compiling this code (with C51 Optimization level=7 + check 'Linker Code Packing' + LX51) and start debugging I see on 'Local' Tab of 'Watch & Call Stack Window':
    'e ????????'

    When I re-compiling this code with C51 Optimization level=7 + no check 'Linker Code Packing' + LX51, in debugger I see real value of variable.

    Is it "expected behaviour"?

    In Disassembly window I see that code is correct - variable 'e' placed in internal RAM at address: 0x08 - high byte & 0x09 - low byte. So, generated code is correct. Debugger simply did not show variable.

  • Well I'm sorry, but I read "ever I use this variable in my program" as "never I use this variable in my program".

    It works fine on v7.01.

    Stefan