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 optimization

hai,
what are the ways to reduse code.

Parents
  • and remember: "Optimum" means different things in different contexts; eg, one application might require minimum code size (possibly at the cost of execution speed); another application might require maximum execution speed (possibly at the cost of code size); another might be concerned with minimum data size, etc, etc,...

Reply
  • and remember: "Optimum" means different things in different contexts; eg, one application might require minimum code size (possibly at the cost of execution speed); another application might require maximum execution speed (possibly at the cost of code size); another might be concerned with minimum data size, etc, etc,...

Children
  • i am facing a problem regarding code size.
    I am using the ARM RealView Development Tool together with Keil µVision working on STR912FW42 Microcontroller.
    i have follows according to manual instructions like use thum mode, increase optimization level etc. my code size is gradually increases even though it is a small program. when i deleting some variables from the code, size will reduses. all variables are stored in RAM, i think it should not effect the code size. but why it behaves like that.
    pleasse help me how to reduse the code size.

  • "my code size is gradually increases"

    Of course, as you write more code the code size will obviously increase!

    "even though it is a small program"

    That's a prety meaningless statement!
    What do you mean by "small"?

    Are you using lots of large libraries - like printf and/or floating point?

    "when i deleting some variables from the code, size will reduses. all variables are stored in RAM, i think it should not effect the code size. but why it behaves like that."

    Well, if you don't have the variables, you presumably also remove any code that would use them - and that will obviously reduce the code size!

    Were the variables initialised? That takes code.

    "pleasse help me how to reduse the code size."

    Have you read the article yet?

    user.it.uu.se/.../engblom-esc-sf-2001.pdf

  • Note :
    The size shown by the uV compiler during compilation at bottom
    (Specifically if you are using the limited free version !) in output window includes all the ROM code + ZIdata + RW data .
    So even the RAM is included in this size.

    If using the free version the limited 16K include all type of data

    Suvidh

  • hi,
    Andy Neil and Suvidh,
    Thanks for u'r reply.
    regards
    raj.