I am working on a project with an 8k code space limit (Only using the internal flash of the analog devices ADuC824). I have had some success decreasing the code size by eliminating library routines such as memmove(). And I was wondering if there is any documenation that specifies what the library routine are in the output listing file (*.m51). Below is the list of library rountines currently used in my project. Some are obvious like (?C?COPY) and (?C?MEMCMP). If I know what the others are I may be able to restructure my code to eliminate them and save some space. I currently have about 300 bytes of code space left and I still have some functionality to add! Thank you. C:\KEIL\C51\LIB\C51S.LIB (?C_STARTUP) C:\KEIL\C51\LIB\C51S.LIB (?C?COPY) C:\KEIL\C51\LIB\C51S.LIB (?C?CLDPTR) C:\KEIL\C51\LIB\C51S.LIB (?C?CLDOPTR) C:\KEIL\C51\LIB\C51S.LIB (?C?CSTPTR) C:\KEIL\C51\LIB\C51S.LIB (?C?CSTOPTR) C:\KEIL\C51\LIB\C51S.LIB (?C?LMUL) C:\KEIL\C51\LIB\C51S.LIB (?C?ULDIV) C:\KEIL\C51\LIB\C51S.LIB (?C?SLDIV) C:\KEIL\C51\LIB\C51S.LIB (?C?LNEG) C:\KEIL\C51\LIB\C51S.LIB (?C?SLCMP) C:\KEIL\C51\LIB\C51S.LIB (?C?ULCMP) C:\KEIL\C51\LIB\C51S.LIB (?C?ULSHR) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDPTR) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDCODE0) C:\KEIL\C51\LIB\C51S.LIB (?C?LSTIDATA) C:\KEIL\C51\LIB\C51S.LIB (?C?LSTKIDATA) C:\KEIL\C51\LIB\C51S.LIB (?C?MEMCMP) C:\KEIL\C51\LIB\C51S.LIB (?C_INIT) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDIDATA) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDXDATA) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDPDATA) C:\KEIL\C51\LIB\C51S.LIB (?C?LLDCODE)
The whole point of a Library is that the Linker only includes those functions which are actually used; so your focus should be on optimising your own code, rather than trying to pick the Libraries apart. Have you read the section in the C51 manual on writing optimum code? Paying careful attention to where your variables are placed (DATA, XDATA, etc) can have a significant impact on code size: accessing XDATA requires more code PDATA and significantly more than DATA - so make sure your most frequently-used variables are in DATA. I recently had a Project where one variable was used a "key" to index all sorts of other data all over the place; simply moving this from XDATA to DATA saved over 1K of code! You can easily identify your most frequently-used variables with the uVision Browser: just double-click the 'Uses' column heading, and the listing will be sorted by the number of times each symbol is used. Unfortunately, you can't print the info from the Browser :-( As bemoaned here: http://www.keil.com/forum/docs/thread1260.asp
Thanks for the advice, but I AM optimizing my code and I don't have XDATA memory space. Identifing the library routines and restructuring my code to avoid using them has produced significant savings so far. For example, I was using memcpy() to put small strings into an output buffer. I found that it was more efficient to assign literals to each array element rather using the memcpy(). For example: Rather than:
memcpy(outputBuff, "ACK", 3);
outputBuff[0] = 'A'; outputBuff[1] = 'C'; outputBuff[2] = 'K';