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

How to know lib function code size

Hi,
After compiling my project, following library functions are listed in the m51 file.
C:\KEIL\C51\LIB\C51L.LIB (?C_INIT)
C:\KEIL\C51\LIB\C51L.LIB (?C?COPY)
C:\KEIL\C51\LIB\C51L.LIB (?C?CLDPTR)
C:\KEIL\C51\LIB\C51L.LIB (?C?CLDOPTR)
C:\KEIL\C51\LIB\C51L.LIB (?C?CSTPTR)
C:\KEIL\C51\LIB\C51L.LIB (?C?CSTOPTR)

Where can I get the sizes of these functions?.

with regards
Rajesh

  • Why do you want to know?

    I'm sure you could get at least a good estimate from the Map file; eg, this is from the MEasure example project:

    LINK MAP OF MODULE:  measure (MEASURE)
    
                TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
                -----------------------------------------------------
    
                * * * * * * *   D A T A   M E M O R Y   * * * * * * *
                REG     0000H     0008H     ABSOLUTE     "REG BANK 0"
                REG     0008H     0008H     ABSOLUTE     "REG BANK 1"
                DATA    0010H     0001H     UNIT         ?DT?GETCHAR
                IDATA   0011H     000FH     UNIT         _IDATA_GROUP_
                BIT     0020H.0   0001H.3   UNIT         _BIT_GROUP_
                BIT     0021H.3   0000H.3   UNIT         ?BI?MEASURE
                BIT     0021H.6   0000H.1   UNIT         ?BI?GETCHAR
                        0021H.7   0000H.1                *** GAP ***
                DATA    0022H     002CH     UNIT         _DATA_GROUP_
                DATA    004EH     0014H     UNIT         ?DT?MEASURE
                IDATA   0062H     0001H     UNIT         ?STACK
    
                * * * * * * *  X D A T A   M E M O R Y  * * * * * * *
                XDATA   0000H     01FFH     UNIT         ?XD?MEASURE
    
                * * * * * * *   C O D E   M E M O R Y   * * * * * * *
                CODE    0000H     0003H     ABSOLUTE
                CODE    0003H     0005H     UNIT         ?PR?GETCHAR?UNGETCHAR
                        0008H     0003H                  *** GAP ***
                CODE    000BH     0003H     ABSOLUTE
                CODE    000EH     07A3H     UNIT         ?C?LIB_CODE
                CODE    07B1H     046FH     UNIT         ?PR?PRINTF?PRINTF
    and
    SYMBOL TABLE OF MODULE:  measure (MEASURE)
    
      VALUE           TYPE          NAME
      ----------------------------------
      -------         MODULE        ?C?FPADD
      C:0015H         PUBLIC        ?C?FPADD
      C:0011H         PUBLIC        ?C?FPSUB
      -------         ENDMOD        ?C?FPADD
    
      -------         MODULE        ?C?FPMUL
      C:0106H         PUBLIC        ?C?FPMUL
      -------         ENDMOD        ?C?FPMUL
    
      -------         MODULE        ?C?FPCMP
      C:020EH         PUBLIC        ?C?FPCMP
      C:020CH         PUBLIC        ?C?FPCMP3
      -------         ENDMOD        ?C?FPCMP
    
      -------         MODULE        ?C?FCAST
      C:0283H         PUBLIC        ?C?FCASTC
      C:027EH         PUBLIC        ?C?FCASTI
      C:0279H         PUBLIC        ?C?FCASTL
      -------         ENDMOD        ?C?FCAST
    
      -------         MODULE        ?C?CASTF
      C:02B7H         PUBLIC        ?C?CASTF
      -------         ENDMOD        ?C?CASTF
    
      -------         MODULE        PRINTF
      D:002EH         PUBLIC        ?_PRINTF?BYTE
      D:002EH         PUBLIC        ?_SPRINTF?BYTE
      C:0813H         PUBLIC        _PRINTF
      C:080DH         PUBLIC        _SPRINTF
      -------         ENDMOD        PRINTF
    Surely you can find similar information in your map file for the functions you require?

  • Thanks Neil..

    "Why do you want to know?"
    I would like to analyze how much memory is taking each individual module. If library function accupies more memory, I am planning to implement in assembly.

    In your example, ?C?LIB_CODE size is 07A3H. But, what is the code sixe of ?C?FPMUL?. Value (C:0106H) means what ?.


    Thanks in advance
    Rajesh

  • "If library function accupies more memory, I am planning to implement in assembly."

    These functions are used internally by the compiler - I don't think they're documented at all for use by developers - let alone custom re-implementation!
    Also, you might be being a bit optimistic in assuming that you can do a better job than Keil - especially without all the necessary support & information...! :-0

    " ... ?C?FPMUL?. Value (C:0106H) means what ?"

    The Linker deals with Addresses - so the "value" of any symbol as far as the Linker is concerned is always an Address.

    In the case of a function, the "value" is the entry point address of the function.

    You can estimate that code size of a function by looking at its start address, and the start address of the next object in code space...

  • The runtime library is implemented in assembler. I would be really surprised if you could shrink down the size any further.

  • You certainly can shrink the code. For example, the Keil ?C?COPY routine always links all the code required to copy from any type of memory to any other, whether or not all possibilities are used. Typically, they wouldn't be.