Assembly language

HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

Assembly is a human-readable rendition of 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 short commands, called mnemonics, and their arguments.

So, while a computer will recognize what

 10110000 01100001

does, for programmers it is easier to remember the semantics of the equivalent

 mov $0x61, %al

(it means to move the hexadecimal value 61 (97 decimal) into the register 'al'.)

Unlike in high-level languages, there is a 1-to-1 mapping from simple assembly to machine language, so that computers can translate in both directions without losing information. Transforming assembly into machine languages is accomplished by an assembler, the other direction by a disassembler. When real programming is done in assembly, it is usually in a bit more complex variant, and the convenient mapping is gone.

Every computer architecture has its own machine language, and henceforth its own assembly language (the example above is from the i386). These languages differ by the number and type of operations that they support; while all general-purpose computers are able carry out the same functionality, the way they do it differs.

Nevertheless, some basic operations are available in almost all assembly languages:

  • moving
    • load a value into a register
    • move data from a memory location to a register, or vice versa
  • 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 languages will often have single, or a few instructions for operations which would otherwise take many instructions. Examples:

  • moving big blocks of memory
  • higher arithmetic (sine, cosine, square root, etc.)
  • applying a simple operation (for example, addition) to a vector of values