An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions. Each assembly language is specific to a particular computer architecture, in contrast to most high-level programming languages, which are generally portable across multiple architectures, but require interpreting or compiling.
Assembly language is converted into executable machine code by a utility program referred to as an assembler; the conversion process is referred to as assembly, or assembling the code.
Assembly language uses a mnemonic to represent each low-level machine instruction or operation. Typical operations require one or more operands in order to form a complete instruction, and most assemblers can therefore take labels, symbols and expressions as operands to represent addresses and other constants, freeing the programmer from tedious manual calculations.
Macro assemblers include a macroinstruction facility so that (parameterized) assembly language text can be represented by a name, and that name can be used to insert the expanded text into other code. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.
Macro assemblers include a macroinstruction facility so that (parameterized) assembly language text can be represented by a name, and that name can be used to insert the expanded text into other code. Many assemblers offer additional mechanisms to facilitate program development, to control the assembly process, and to aid debugging.
Assembly language is the most basic programming language available for any processor. With assembly language, a programmer works only with operations implemented directly on the physical CPU.
Every computer has at its heart exactly two things: a CPU and some memory. Together,
these two things are what make it possible for your computer to run programs.
On the
most basic level, a computer program is nothing more than a collection of
numbers stored in memory. Different numbers tell the CPU to do different
things. The CPU reads the numbers one at a time, decodes them, and does what
the numbers say.
For example, if the CPU reads the number 64 as part of a
program, it will add 1 to the number stored in a special location called AX. If
the CPU reads the number 146, it will swap the number stored in AX with the
number stored in another location called BX.
By combining many simple
operations such these into a program, a programmer can make the computer
perform many incredible things.
computer programs could be written using words instead of numbers. A
special program called an assembler would then take the programmer's
words and convert them to numbers that the computer could understand. This new
method, called writing a program in assembly language, saved programmers
thousands of hours, since they no longer had to look up hard-to-remember
numbers in the backs of programming books, but could use simple words instead.
The
program above, written in assembly language, looks like this:
MOV AX, 47104
MOV DS, AX
MOV [3998], 36
INT 32
When an assembler reads this sample program, it converts each line
of code into one CPU-level instruction. This program uses two types of
instructions, MOV and INT. On Intel processors, the MOV instruction moves data around,
while the INT instruction
transfers processor control to the device drivers or operating system.
The first instruction, MOV AX, 47104, tells the computer to copy the number
47104 into the location AX. The next instruction, MOV DS, AX, tells the computer to copy the number
in AX into the location DS. The next instruction, MOV [3998], 36 tells the computer to put the
number 36 into memory location 3998. Finally, INT 32 exits the program by returning to
the operating system.
No comments:
Post a Comment