Assembly Language

Master the art of low-level programming with interactive examples and visualizations

What is Assembly Language?

Assembly language is a programming language that uses symbolic representations instead of binary machine code. It provides a human-readable way to write programs that are then translated into binary code by an assembler. Each line of code follows a structured format with three distinct fields.

Assembly Language Structure

Each line in assembly language is organized into three fields:

1. Label Field
  • Purpose: Contains symbolic addresses
  • Format: 1-3 alphanumeric characters
  • Rule: First character must be a letter
  • Example: MIN, SUB, DIF
2. Instruction Field
  • Memory Reference: LDA, ADD, STA
  • Register Reference: CMA, INC, HLT
  • Pseudoinstructions: ORG, END, DEC, HEX
3. Comment Field
  • Purpose: Documentation and explanation
  • Format: Preceded by / symbol
  • Ignored: During binary translation
  • Example: / Load subtrahend to AC

Interactive Example: Subtraction Program

Click on any row to see detailed explanations of each instruction:

Assembly Code: Subtracting Two Numbers
Label Instruction Comment
ORG 100 / Origin of program is location 100
LDA SUB / Load subtrahend to AC
CMA / Complement AC
INC / Increment AC
ADD MIN / Add minuend to AC
STA DIF / Store difference
HLT / Halt computer
MIN, DEC 83 / Minuend
SUB, DEC -23 / Subtrahend
DIF, HEX 0 / Stored difference here
END / End of symbolic program

Step-by-Step Execution:

Memory Visualization

This shows how data is stored in memory during program execution:

100
2107
LDA SUB
101
7200
CMA
102
7020
INC
103
1106
ADD MIN
104
3108
STA DIF
105
7001
HLT
106
0053
MIN (83)
107
FFE9
SUB (-23)
108
0000
DIF (Result)

Translation Process

The assembler performs a two-pass translation process:

1
First Pass: The assembler scans the program to identify all symbolic addresses and assign them memory locations. For example, MIN gets location 106, SUB gets 107, and DIF gets 108.
2
Second Pass: The assembler translates each instruction into binary/hexadecimal machine code using the address assignments from the first pass. LDA SUB becomes 2107 (hex).
Start Learning Assembler