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

Removing Code will adjust whole program

When I remove a little piece of code, what has no issue with the working of my program, the program doesn't work at all.

Also
I've got 2 function that aren't used at all, but when I remove them, my program won't work to.

With not working I mean: it will compile and the program also starts but some program parts don't work.

I've got
ADuC842
uVision 3.30a

I first thought it would be that I used up
to much memory, but after removing unused
code it also (doesn't) work(s).
I have no idea where to look to solve this
problem, if you have any ideas I'm happy to
hear them.

Parents
  • When I remove a little piece of code

    it doesn't matter, it could be
    i=i;

    I've got 2 function that aren't used at all

    Well the function aren't used. So what does it matter what the function contain for code?
    but here's one...

    /**
     * Saves settings to flash memory.
     * @param rwmath Pointer to rwmath ADT.
     */
    
    void
    saveSettings(tRWMath *rwmath)
    {
    	flashBytes(0x0, rwmath->VDRatioNominator, rwmath->VDRatioDenominator, 0x0, 0x0);
    }
    

    The warnings/
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: _SAVESETTINGS/RWMATH
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: _FASTDIVIDE/RWMATH
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: ?CO?MAIN
    Program Size: data=23.1 xdata=329 const=13274 code=28314
    creating hex file from "fw1_0"...
    "fw1_0" - 0 Error(s), 3 Warning(s).

Reply
  • When I remove a little piece of code

    it doesn't matter, it could be
    i=i;

    I've got 2 function that aren't used at all

    Well the function aren't used. So what does it matter what the function contain for code?
    but here's one...

    /**
     * Saves settings to flash memory.
     * @param rwmath Pointer to rwmath ADT.
     */
    
    void
    saveSettings(tRWMath *rwmath)
    {
    	flashBytes(0x0, rwmath->VDRatioNominator, rwmath->VDRatioDenominator, 0x0, 0x0);
    }
    

    The warnings/
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: _SAVESETTINGS/RWMATH
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: _FASTDIVIDE/RWMATH
    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: ?CO?MAIN
    Program Size: data=23.1 xdata=329 const=13274 code=28314
    creating hex file from "fw1_0"...
    "fw1_0" - 0 Error(s), 3 Warning(s).

Children
  • it doesn't matter, it could be
    i=i;


    How do you know it does not matter ?

    Even seemlingy innocent code could cause timing issues.

    And even i = i; can matter a lot (if i is volatile or a register).

    Well the function aren't used. So what does it matter what the function contain for code?

    I assume you have read the appropriate chapters in the C51 and BL/LX51 documentation about uncalled functions and data overlaying ?

    The compiler and the linker have no way of knowing that a function is not used. They must assume that it is called somehow (for example by using a function pointer) in the course of the program, with all the implications this has on memory usage and overlaying.

    So what could happen ? Maybe the stack pointer is not initialized correctly and the stack moves into the RAM range used by your functions, but you never found out about it until now because the stack only overwrote the memory that is used by the two "unimportant" functions.

    Of course, you would never make such an obvious mistake, but without more information about the program, this guess is as good as any other.

    *** WARNING L16: UNCALLED FUNCTION, IGNORED FOR OVERLAY PROCESS
    NAME: ?CO?MAIN


    Hm, finally we're getting somewhere.

    The error message does look odd, though - it does not refer to an uncalled function, but to what looks like unused (and constant) data in code memory.