Need help on 8051 assembly code optimization

We are developing a product on 8051 microcontroller. We have done coding using assembly language. Right now our code size is very high and is overshooting the allocated ROM size.

We have started code optimization using “code optimizing tips†and by “optimizing the designâ€. But from “assembler and linker†I am unaware of any directive available for code optimization.

Please let me know for any tools/KEIL options which help in "Assembly code optimization" (Eg: Identifying repeated patterns, identifying duplicate expressions, removal of dead code, Suggesting right instruction etc…)

Parents
  • Please let me know for any tools/KEIL options which help in "Assembly code optimization"

    I'm not aware of any such tools.

    Usually, the point of writing code in assembly is to have the processor execute _exactly_ the instructions specified by the programmer, without giving the tools any freedom to make changes to the code.

    Also, "highly optimized" assembly code is usually a nightmare to debug. If the code was produced by a compiler from a high-level language, it's easy to reduce the optimization level and check the un-optimized code for correct function, but it'd be hard to do that with "optimized" assembly.

    However, if you are exceeding the "allocated ROM size" which was deemed enough for the project, then maybe you should start by optimizing the ("high level") program flow and the algorithms first, and _then_ look at the actual code again. Usually, this is easier and can bring more savings and less headaches than painstakingly sifting through already-written assembly and changing it without breaking the program.

Reply
  • Please let me know for any tools/KEIL options which help in "Assembly code optimization"

    I'm not aware of any such tools.

    Usually, the point of writing code in assembly is to have the processor execute _exactly_ the instructions specified by the programmer, without giving the tools any freedom to make changes to the code.

    Also, "highly optimized" assembly code is usually a nightmare to debug. If the code was produced by a compiler from a high-level language, it's easy to reduce the optimization level and check the un-optimized code for correct function, but it'd be hard to do that with "optimized" assembly.

    However, if you are exceeding the "allocated ROM size" which was deemed enough for the project, then maybe you should start by optimizing the ("high level") program flow and the algorithms first, and _then_ look at the actual code again. Usually, this is easier and can bring more savings and less headaches than painstakingly sifting through already-written assembly and changing it without breaking the program.

Children
More questions in this forum