Encyclopedia > Assembly language

  Article Content

Assembly language

Assembly is a human-readable[?] notation for the machine language that a specific computer architecture uses. Machine language, a mere pattern of bits, is made readable by replacing the raw values with symbols called mnemonics.

So, while a computer will recognize what the machine instruction[?]

  10110000 01100001
does, for programmers it is easier to remember the equivalent assembly language representation
  mov  %al,$0x61
(it means to move the hexadecimal value 61 (97 decimal) into the register 'al'.)

Unlike in high-level languages, there is (to a close approximation) a 1-to-1 correspondence between simple assembly to machine language. Transforming assembly into machine languages is accomplished by an assembler, the other direction by a disassembler.

Every computer architecture has its own machine language, and therefore its own assembly language (the example above is from the i386). These languages differ by the number and type of operations that they support. They may also have different sizes and numbers of registers, and different representations of data types in storage. While all general-purpose computers are able to carry out esentially the same functionality, the way they do it differs.

In addition, multiple sets of mnemonics or assembly-language syntax may exist for a single instruction set. In these cases, the most popular one is usually that used by the manufacturer in their documentation.

Table of contents

Machine instructions

Similar basic operations are available in almost all instruction sets.

  • moving
    • load a value into a register
    • move data from a memory location to a register, or vice versa
    • read and write data from hardware devices
  • computing
    • add, subtract, multiply, or divide the values of two registers, placing the result in a register
    • combine two register values with logical and/or
    • negate a register value arithmetically or by logical NOT
  • affecting program flow
    • jump to another location in the program (normally, instructions are processed sequentially)
    • jump to another location, but save the next instruction as a point to return to
    • go back to the last return point

Specific instruction sets will often have single, or a few instructions for operations which would otherwise take many instructions. Examples:

  • moving big blocks of memory
  • complex and/or floating-point arithmetic (sine, cosine, square root, etc.)
  • applying a simple operation (for example, addition) to a vector of values

Assembly language directives

In addition to codes for machine instructions, assembly languages have extra directives for assembling blocks of data, and assigning address locations for instructions or code.

They usually have a simple symbolic capability for defining values as symbolic expressions which are evaluated at assembly time, making it possible to write code that is easier to read and understand.

Like most computer languages, textual comments can be added to the source code which are ignored by the computer.

They also usually have an embedded macro language[?] to make it easier to generate complex pieces of code or data.

In practice, the absence of comments and the replacement of symbols with actual numbers makes the human interpretation of disassembled code considerably more difficult than the original source would be.

Usage of assembly language

There is some debate over the usefulness of assembly language. In many cases, modern compilers can render higher-level languages into code as that runs as fast as hand-written assembler.

However, some discrete calculations can still be rendered into faster running code in assembler, and some low-level programming is simply easier to do in assembler. Some system-dependent tasks performed by operating systems simply cannot be expressed in high-level languages. Many compilers also render high-level languages into assembler first before fully compiling, allowing the assembler code to be viewed for debugging and optimization purposes.

Many embedded devices[?] are also programmed in assembly to squeeze the absolute maximum functionality out of what is often very limited computational resources, though this is gradually changing in some areas as more powerful chips become available for the same minimal cost.

See also:

All Wikipedia text is available under the terms of the GNU Free Documentation License

  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article
Thomas a Kempis

... possible to a mortal. His teachings far excel all the teachings of the saints. The book gives counsels to read the Scriptures, statements about the uses of adversity, ...

This page was created in 37.3 ms