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

code reduce

Hi All

I'm writing a software for 8 bit architecture using uvision 2. But when I try to compile my project using uvision2 it gives the following error

*** ERROR L107: ADDRESS SPACE OVERFLOW
.
.
.
Program Size: data=171.7 xdata=15942 code=65617
 

my target system has only 64KB code space it seems overflow.

How can I reduce code size for this application.

I'm using Code Optimisation Level 9 from uvision2.

any idea

Parents
  • does this mean that if I have a single source file project with a main and two functions, only one of which is called, the uncalled function will not be linked and non-overlayed data space will not be allocated for that function?

    Yes. That's the idea. To exemplify, I create a single-file project with 3 functions: main, func1 (which is used), and unusedfunc (which is unused).

    Both func1 and unusedfunc return an int and are passed 3 arguments. Additionally, they have a local 16-byte buffer.

    Following is the memory map from the LX51 linker with the REMOVEUNUSED directive specified.


    START     STOP      LENGTH    ALIGN  RELOC    MEMORY CLASS   SEGMENT NAME
    =========================================================================
    
    * * * * * * * * * * *   D A T A   M E M O R Y   * * * * * * * * * * * * *
    000000H   000007H   000008H   ---    AT..     DATA           "REG BANK 0"
    000008H   000011H   00000AH   BYTE   UNIT     DATA           _DATA_GROUP_
    000012H   000012H   000001H   BYTE   UNIT     IDATA          ?STACK
    
    * * * * * * * * * * *   C O D E   M E M O R Y   * * * * * * * * * * * * *
    000000H   000002H   000003H   ---    OFFS..   CODE           ?CO??C_STARTUP?0
    000003H   000022H   000020H   BYTE   UNIT     CODE           ?PR?_FUNC1?MAIN
    000023H   00002EH   00000CH   BYTE   UNIT     CODE           ?C_C51STARTUP
    00002FH   000039H   00000BH   BYTE   UNIT     CODE           ?PR?MAIN?MAIN
    
    * * * * * * * * *   R E M O V E D     S E G M E N T S   * * * * * * * *
       *DEL*:           000020H   BYTE   UNIT     CODE           ?PR?_UNUSEDFUNC?MAIN
       *DEL*:           00000AH   BYTE   UNIT     DATA           ?DT?_UNUSEDFUNC?MAIN
    

    The segments that the linker has determined are unused are listed in a new REMOVED SEGMENTS section along with the size, name and memory space they were allocated to.

    Hopefully, this directive will help some developers shrink program size and avoid warnings about unused code/data.

    Jon

Reply
  • does this mean that if I have a single source file project with a main and two functions, only one of which is called, the uncalled function will not be linked and non-overlayed data space will not be allocated for that function?

    Yes. That's the idea. To exemplify, I create a single-file project with 3 functions: main, func1 (which is used), and unusedfunc (which is unused).

    Both func1 and unusedfunc return an int and are passed 3 arguments. Additionally, they have a local 16-byte buffer.

    Following is the memory map from the LX51 linker with the REMOVEUNUSED directive specified.


    START     STOP      LENGTH    ALIGN  RELOC    MEMORY CLASS   SEGMENT NAME
    =========================================================================
    
    * * * * * * * * * * *   D A T A   M E M O R Y   * * * * * * * * * * * * *
    000000H   000007H   000008H   ---    AT..     DATA           "REG BANK 0"
    000008H   000011H   00000AH   BYTE   UNIT     DATA           _DATA_GROUP_
    000012H   000012H   000001H   BYTE   UNIT     IDATA          ?STACK
    
    * * * * * * * * * * *   C O D E   M E M O R Y   * * * * * * * * * * * * *
    000000H   000002H   000003H   ---    OFFS..   CODE           ?CO??C_STARTUP?0
    000003H   000022H   000020H   BYTE   UNIT     CODE           ?PR?_FUNC1?MAIN
    000023H   00002EH   00000CH   BYTE   UNIT     CODE           ?C_C51STARTUP
    00002FH   000039H   00000BH   BYTE   UNIT     CODE           ?PR?MAIN?MAIN
    
    * * * * * * * * *   R E M O V E D     S E G M E N T S   * * * * * * * *
       *DEL*:           000020H   BYTE   UNIT     CODE           ?PR?_UNUSEDFUNC?MAIN
       *DEL*:           00000AH   BYTE   UNIT     DATA           ?DT?_UNUSEDFUNC?MAIN
    

    The segments that the linker has determined are unused are listed in a new REMOVED SEGMENTS section along with the size, name and memory space they were allocated to.

    Hopefully, this directive will help some developers shrink program size and avoid warnings about unused code/data.

    Jon

Children
  • more correctly:
    Hopefully, this directive will help some sloppy developers shrink program size and avoid warnings about unused code/data.

    If you need to have "delete of unused" to shrink program size, you do not work in a professional way.

    "unused segments" are quite common during development and OK at that time, but when the need to shrink program size comes up you either a) have some unused that should not be there in the first place or shrinking will not help you since the unused is to be used.

    I abhor ANY suppression of warnings.

    Erik

  • Sounds good. Perhaps this feature will motivate me to update my tools (at least once we make it past the next milestone so I can risk breaking things!)

  • "this directive will help some sloppy developers"

    Ouch!

    ""unused segments" are quite common during development and OK at that time"

    This is exactly when I need this new directive. My projects often fly close to the wire in terms of 'data' space. During development I often have quite a number of test/debugging functions in the source and it often happens that I comment out all calls to one or more of them during some test. I then get the infamous L107 warning, the linker therefore doesn't overlay locals in those functions and suddenly I have an address space overflow error. Then I have to comment out the uncalled functions, then later I have to uncomment them again, and so on.

    This feature is something quite a few of us have been waiting a long time for. Don't go telling Keil it's a bad idea now!

    "I abhor ANY suppression of warnings"

    I wouldn't be surprised if the new directive issues a warning when it removes code?

  • I wouldn't be surprised if the new directive issues a warning when it removes code?

    Nope - no warning. IF you specify this directive, the linker assumes you know what you're doing.

    You do, however, get a nice listing of all the memory you just saved.

    * * * * * * * * *   R E M O V E D     S E G M E N T S   * * * * * * * *
       *DEL*:           000020H   BYTE   UNIT     CODE           ?PR?_UNUSEDFUNC?MAIN
       *DEL*:           00000AH   BYTE   UNIT     DATA           ?DT?_UNUSEDFUNC?MAIN
    

    Jon