Chapter 1: Developing Efficient Program Code

 Download CD Content

Using assembly language is one of the most efficient methods for optimizing programs. The techniques here are quite similar to those used in high-level languages; however, assembly language provides the developer with a number of additional options. Without repeating the optimization issues that are similar to ones in high-level languages, we will focus on the techniques specific to the assembler.

Optimization Potentials

Using assembly language is, in many respects, a good way to eliminate the problem of redundant program code. The assembly code is more compact than its analog in a high-level language. This is apparent by comparing the disassembled listings of the same program written in assembly language to those written in a high-level language. The assembly code generated by a high-level language compiler, even with the optimization options applied, does not solve the problem of redundant program code, whereas assembly language lets you develop the code, which is brief and efficient.

As a rule, an assembly program module has a higher performance than a program in a high-level language, because a smaller number of commands is needed for implementing the code fragment. It takes the processor less time to execute a smaller set of commands, therefore improved is the application performance.

You can develop complete separate modules in assembly language and then link them to the high-level language programs. It is also possible to make use of the built-in tools of the high-level languages to write assembly procedures in the body of your program directly. This feature is supported in all the high-level languages. By using the built-in assembly language, you can obtain high efficiency. The maximum effect is reached when you use it to optimize mathematical expressions, program loops , and the data arrays processing blocks in the main program.

Assembly language is widely used as a tool for optimizing the performance of high-level language applications. By combining the assembly and the high-level language modules in a logical way, you can achieve a high performance and reduce the size of the executable code. Such a combination is now used so frequently that the interface of the high-level language programs with included assembly modules has become a special concern for compiler producers . As a rule, the modern compilers come with the built-in assembly language.

Despite the evident optimization advantages offered by assembly language, there are indeed very few developers who apply it widely in practical work. One of the main reasons is that it seems somewhat complicated and requires a thorough understanding of the processor architecture. Assembly language is certainly more complicated than the high-level languages. However, it is well worth your time to learn assembly language, since it will greatly improve performance of the programs you create.

Visual C++ Optimization with Assembly Code
Visual C++ Optimization with Assembly Code
ISBN: 193176932X
EAN: 2147483647
Year: 2003
Pages: 50
Authors: Yury Magda © 2008-2017.
If you may any questions please contact us: