文档介绍:1. Assembly Language: The True Language Of Programmers
Assembly
PC Language: The
PCunderground True Language
Of Programmers
Chapter 1
There are many high-level, structured languages for programming today's PCs. Two popular examples are
C++ and Pascal. However, assembly language still has its place in today's programming world. Since it
mimics the operations of the CPU at the machine level, assembly language lets you get right to the "heart"
of your PC.
In fact, there are some tasks that you can do only by using assembly language. While it's true that the Pascal
language is capable enough to handle interrupts, it can't be used to pass keyboard input to DOS, for
example. Since Pascal has no native way to do this, you must still insert an assembler module routine to
perform the function. Likewise, you can't easily remove a high-level resident program from memory. Once
again, you have to write the routine in assembly language to do this.
For many applications, programming code must still be pact as possible. For example, in programming
resident programs, each kilobyte of RAM below the 640K boundary is vital. Programs written in high-level
languages usually require a runtime library which may add several additional kilobytes to the size.
Assembly language programs don't need these bulky library routines.
However, the most important advantage of assembly language is speed. Although high-level languages
can be optimized for speed of execution, even the best optimization cannot replace the experience of a
programmer. Here's a simple example. Let's say that you want to initialize two variables in Pascal to a zero
value. piler will generate the following assembly code:
xor ax,ax
mov var1,ax
xor ax,ax
mov var2,ax
Here, the piler optimized the execution speed by using the XOR instruction to zero the ax register
(the fastest way to do this) and storing this value as var1. However, due piler's limitations, the AX
register was again zeroed