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

C51, Linker, list of variables as pile up in memory

Hi

I found a bug in my code, a for was out of range and overwriting the variables after the wanted one.

i.e.
uint8_t xdata globalMyVar[4];

for ( ii = 0; ii < 20; ii++ )
{ globalMyVar[ii] = 0;
}

So I wanted to look which were these overwritten variables.
For that I checked the file generated by the linker (.M51) with the symbols information
My application has several modules.
The symbol(s) table(s) produced is not well adapted for a quick look on how variables are piled up in memory.

What I did was to cut and paste all the modules symbols information in excel, with fixed columns for the address value, type and name then sort by address value.

I couldn't find a switch for the linker to obtain this kind of sorted list.
Btw I noted that the memory pile-up is not as declared in the source code, nor alphabetic (some internal hash used for optimization?).

Is there a better way to get the sorted list of variables as they are defined in memory? (than sorting via excel)

Regards
Daniel

Parents
  • oh, how wondeefulit is to use plain numbers

    uint8_t xdata globalMyVar[4];
    
    for ( ii = 0; ii < 20; ii++ )
    { globalMyVar[ii] = 0;
    }
    
    using correct methodology would never have let this pass
    
    
    #define SIZE_OF RALPH 4
    uint8_t xdata globalMyVar[SIZE_OF RALPH];
    
    for ( ii = 0; ii < SIZE_OF RALPH; ii++ )
    { globalMyVar[ii] = 0;
    }
    


    and, of course, crappy little variable names such as 'i' and 'ii' makes it even more error prone

Reply
  • oh, how wondeefulit is to use plain numbers

    uint8_t xdata globalMyVar[4];
    
    for ( ii = 0; ii < 20; ii++ )
    { globalMyVar[ii] = 0;
    }
    
    using correct methodology would never have let this pass
    
    
    #define SIZE_OF RALPH 4
    uint8_t xdata globalMyVar[SIZE_OF RALPH];
    
    for ( ii = 0; ii < SIZE_OF RALPH; ii++ )
    { globalMyVar[ii] = 0;
    }
    


    and, of course, crappy little variable names such as 'i' and 'ii' makes it even more error prone

Children
  • Sorry but I'm not in the mood to discuss about C coding today and is a bit off topic of what I asked in 1st place.

    How to get a list of the variables sorted by address with C51 toolset.

    Just let you know that the piece of code posted is not the real code and was a fast 4 line code to show a very simplified even understandable example.

    Regards
    Daniel