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

not used functions linked and declares XDATA for local vars

Hello,

I have detected that some functions like this one are using their own XDATA space instead of using the XDATA_GROUP for local purposes:

for example this one:

void zmemcpy2(UINT8 *dst,const UINT8 *src, UINT32 len)
{

      --dst;   --src;
       while (len--)
       {
          *(++dst) = *(++src);
   }
}

then this is the line in the m51 file:

XDATA   82C2H     000AH     UNIT         ?XD?_ZMEMCPY2?LIB


so then Im wasting ten bytes of global data space for just a memcopy. Why is this happening?

And here it is another weird thing: this function is never used by the rest of the program. It is compiled, but should not be linked.
any idea?

thanks in advance...

Parents
  • Just a note about your copy. Note that the C standard specifies that you are always allowed to step the pointer one step past the last element of an array. However, you are not guaranteed to be able to step one step before the first entry.

    On a different architecture, the processor could generate an underflow exception - even if you never try to use the decremented pointer. Even for a '51 it may be dangerous, depending on what "magic" the compiler vendor performs to implement generic pointers.

Reply
  • Just a note about your copy. Note that the C standard specifies that you are always allowed to step the pointer one step past the last element of an array. However, you are not guaranteed to be able to step one step before the first entry.

    On a different architecture, the processor could generate an underflow exception - even if you never try to use the decremented pointer. Even for a '51 it may be dangerous, depending on what "magic" the compiler vendor performs to implement generic pointers.

Children
No data