Assembly Language: Features, Types, and Machine Code

Assembly Language: Types and Characteristics

Assembly language is a type of low-level programming language used to write programs. It represents the most direct, human-readable form of machine code, specific to each computer architecture.

Key Features of Assembly Language

  • Programming in assembly language is difficult to learn, understand, read, write, debug, and maintain. This complexity led to the development of compiled languages.
  • Despite potential performance loss during compilation, most modern computers are fast enough to handle compiled code efficiently.
  • Assembly language is not portable. Code written for one architecture typically cannot run on another without significant modification.
  • Programming in assembly language is time-consuming.
  • Programs written in assembly language are generally faster. When carefully crafted, assembly programs can be 5 to 100 times faster than their high-level language counterparts.
  • Assembly language programs usually occupy less memory. A well-written assembly program can take up roughly half the space of a comparable high-level language program.
  • Assembly language allows for the creation of code segments that are impossible to form in high-level languages.

Assemblers, generally simpler to write than compilers for high-level languages, have been available since the 1950s. High-level assemblers offer abstraction capabilities, including:

  • Advanced control structures
  • Top-level procedure/function declarations
  • Abstract data types, including structures, records, unions, classes, and sets
  • Sophisticated macro processing

A program written in assembly language consists of a set of instructions corresponding to the flow of executable commands that can be loaded into the computer’s memory.

Machine Code and Assembler Types

The transformation of assembly language into machine code is performed by an assembler program. The reverse translation can be done by a disassembler. Unlike high-level languages, there is usually a one-to-one correspondence between simple assembly instructions and machine language instructions.

Machine code consists of simple instructions that, depending on the processor’s structure, can specify:

  • Specific registers for arithmetic operations, management, or supervisory functions
  • Specific memory locations (offsets)
  • Addressing modes used to interpret operands

Types of Assemblers

  • Cross Assemblers: These leverage the physical media support and programming capabilities of powerful machines to develop programs that will run on specialized systems for specific tasks.
  • Resident Assemblers: These reside in the computer’s main memory and load the produced object program for execution.
  • Macro Assemblers: These assemblers allow the use of macroinstructions (macros).
  • Micro Assemblers: The program that instructs the CPU’s interpreter on how to act is called firmware. The program that helps create this microprogram is called a microassembler. Some processors allow modification of their firmware, which is used for microassemblies.
  • Single-Pass Assemblers: These assemblers read a source program line by line and directly translate it to produce a machine language instruction or execute a pseudoinstruction.
  • Two-Pass Assemblers: These assemblers perform the translation in two stages. In the first pass, they read the source program and build a symbol table. In the second pass, they re-read the source program and translate it completely, utilizing the symbol table to resolve symbols and their assigned positions.