Reasons for using assembly code

Assembly coding is not used as much today as previously. However, there are still reasons
for learning and using assembly code. The main reasons are:

1. Educational reasons : It is important to know how microprocessors and compilers
work at the instruction level in order to be able to predict which coding techniques
are most efficient, to understand how various constructs in high level languages
work, and to track hard-to-find errors.

2. 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.

3. Making compilers : Understanding assembly coding techniques is necessary for
making compilers, debuggers and other development tools.

4. Embedded systems : Small embedded systems have fewer resources than PC’s and
mainframes. Assembly programming can be necessary for optimizing code for speed
or size in small embedded systems.

5. Hardware drivers and system code : Accessing hardware, system control registers
etc. may sometimes be difficult or impossible with high level code.

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

7. Self-modifying code : Self-modifying code is generally not profitable because it
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.

8. Optimizing code for size : Storage space and memory is so cheap nowadays that it 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
optimize a critical piece of code for size in order to make it fit into the code cache.

9. 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 assembly programming.

10. Function libraries : The total benefit of optimizing code is higher in function libraries
that are used by many programmers.

11. 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 requires assembly
programming.
Advertisements

, , , , , , , ,

  1. #1 by Linda Thema on November 7, 2011 - 9:25 pm

    It’s a very creative one. I like it very much.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: