What are the advantages and disadvantages of using assembly language?






Advantages


  1. Debugging and verifying. Looking at compiler-generated assembly code or the disassembly window in a debugger is useful for finding errors and for checking how well a compiler optimizes a particular piece of code.

  2. Makingcompilers.Understandingassemblycodingtechniquesisnecessaryfor making compilers, debuggers and other development tools.

  3. Embedded systems. Small embedded systems have fewer resources than PCs and mainframes. Assembly programming can be necessary for optimizing code for speed or size in small embedded systems.

  4. Hardware drivers and system code. Accessing hardware, system control regis- ters etc. may sometimes be difficult or impossible with high level code.

  5. Accessing instructions that are not accessible from high-level language. Certain assembly instructions have no high-level language equivalent.

  6. Self-modifyingcode.Self-modifyingcodeisgenerallynotprofitablebecauseit interferes with efficient code caching. It may, however, be advantageous, for example, to include a small compiler in math programs where a user-defined function has to be calculated many times.

  7. Optimizingcodeforsize.Storagespaceandmemoryissocheapnowadaysthatit is not worth the effort to use assembly language for reducing code size. However, cache size is still such a critical resource that it may be useful in some cases to op- timize a critical piece of code for size in order to make it fit into the code cache.









8. Optimizing code for speed. Modern C++ compilers generally optimize code quite well in most cases. But there are still cases where compilers perform poorly and where dramatic increases in speed can be achieved by careful as- sembly programming.

9. Function libraries. The total benefit of optimizing code is higher in function li- braries that are used by many programmers.

10. Making function libraries compatible with multiple compilers and operating systems. It is possible to make library functions with multiple entries that are compatible with different compilers and different operating systems. This re- quires assembly programming.


DISADVANTAGES

The disadvantages of using an assembly language rather than an HLL include the following





1. Development time. Writing code in assembly language takes much longer than writing in a high-level language. 


2. Reliability and security. It is easy to make errors in assembly code. The assembler is not checking if the calling conventions and register save conventions are obeyed. Nobody is checking for you if the number of PUSH and POP instructions





is the same in all possible branches and paths. There are so many possibilities for hidden errors in assembly code that it affects the reliability and security of the pro- ject unless you have a very systematic approach to testing and verifying.

  1. Debugging and verifying. Assembly code is more difficult to debug and verify because there are more possibilities for errors than in high-level code.

  2. Maintainability. Assembly code is more difficult to modify and maintain be- cause the language allows unstructured spaghetti code and all kinds of tricks that are difficult for others to understand. Thorough documentation and a consistent programming style are needed.

  3. Portability. Assembly code is platform-specific. Porting to a different platform is difficult.

  4. System code can use intrinsic functions instead of assembly. The best modern C++ compilers have intrinsic functions for accessing system control registers and other system instructions. Assembly code is no longer needed for device drivers and other system code when intrinsic functions are available.

0 comments:

Feel free to contact the admin for any suggestions and help.