Assembler

Introduction to Assembler

  • Assembler is a type of program used to convert assembly language into machine language (binary code).
  • Computer processors can only understand binary, which is why this conversion is necessary for the execution of assembly language programs.
  • It allows the programmer to write in a language that is easier to understand and use than binary.

How Assemblers Work

  • An assembler converts each assembly language instruction into a corresponding machine code instruction.
  • Associated with each assembly language instruction is an equivalent machine language opcode.
  • Through a process called assembling, the assembler replaces each assembly opcode with its corresponding binary version.

Types of Assemblers

  • There are two types of assemblers: one-pass assemblers and two-pass assemblers.
  • One-pass assemblers read the source code once and generate the machine code in one pass, but they have some limitations, especially where forward references are concerned.
  • Two-pass assemblers read the source code twice. The first pass is to establish symbol references, and the second pass is to generate the actual machine code.

Symbolic Assembly Language vs Machine Language

  • A symbolic assembly language is easier to read and understand compared to machine language.
  • This is because it uses mnemonics to represent each operation code, and symbolic names instead of explicit addresses.
  • Examples of mnemonics include ADD (for addition), SUB (for subtraction), and MOV (for moving data).
  • This form of language is easier on the human eye, which aids in the debugging process and dropping the barriers to low-level programming.

Application of Assemblers

  • Assembly language is used in real-world applications where direct hardware manipulation and high efficiency are crucial, e.g., system software like device drivers or embedded systems.
  • It gives programmers a high degree of control and a way to write highly optimized code.

Key Terms

  • Opcode: An instruction for what operation the CPU should perform.
  • Mnemonics: A symbolic name for a single executable machine language instruction.
  • Debugging: The process of finding and resolving defects or problems within a computer program.
  • Forward References: When a symbol is referenced before it is declared.
  • Assembling: The process of converting assembly language into machine code.