The Assembler

Experience the magic of translating symbolic code into machine language through an interactive two-pass process

What is an Assembler?

An assembler is a crucial program that bridges the gap between human-readable assembly language and machine-executable binary code. It transforms symbolic representations into precise binary instructions that computer hardware can understand and execute.

📝 Source Program

Symbolic assembly code written by programmer

→

⚙️ Assembler

Two-pass translation process

→

🎯 Object Program

Binary machine language code

Memory Representation

Before assembly begins, the symbolic program must be loaded into memory using specific encoding rules:

Character Encoding
8-bit ASCII
Storage Format
2 chars/location
Symbol Separator
Space (20h)
Line Terminator
CR (0Dh)
Label Terminator
Comma (2Ch)

The Two-Pass Assembly Process

The assembler uses a sophisticated two-pass approach to ensure accurate translation of symbolic code:

1

First Pass: Symbol Resolution

  • 🎯 Initialize Location Counter (LC) to 0
  • 🔍 Scan for Labels in each line
  • 📊 Build Symbol Table with addresses
  • ➕ Increment LC for each instruction
  • 🏁 Stop at END pseudoinstruction
2

Second Pass: Code Generation

  • 🔄 Reset LC to 0
  • 📋 Use Lookup Tables for translation
  • 🔢 Convert Instructions to binary
  • 🎯 Resolve Addresses from symbol table
  • 💾 Generate Object Code

Flowchart for Assembler

1

First Pass: Flow Chart

first pass
2

Second Pass: Flow Chart

second pass

Interactive Assembly Demonstration

Assembly Source Code Example
100
ORG 100
/ Origin at location 100
101
LDA SUB
/ Load subtrahend
102
CMA
/ Complement AC
103
INC
/ Increment AC
104
ADD MIN
/ Add minuend
105
STA DIF
/ Store result
106
MIN,
DEC 83
/ Minuend value
107
SUB,
DEC -23
/ Subtrahend value
108
DIF,
HEX 0
/ Result storage
109
END
/ End program

Lookup Tables Used by Assembler

The assembler uses four essential tables during the second pass for accurate code translation:

📋 Pseudoinstruction Table

ORG, END, DEC, HEX

🎯 MRI Table

AND(0), ADD(1), LDA(2), STA(3)
BUN(4), BSA(5), ISZ(6)

⚙️ Non-MRI Table

CLA, CLE, CMA, CME, CIR, CIL
INC, SPA, SNA, SZA, SZE, HLT

🏷️ Address Symbol Table

User-defined labels
Generated in First Pass

Error Detection & Diagnostics

A robust assembler identifies and reports various types of errors to help programmers debug their code:

🚫 Undefined Symbol Error
LDA UNKNOWN / Symbol 'UNKNOWN' not defined in program
❓ Unrecognized Instruction
INVALID 100 / 'INVALID' is not a valid instruction
🔤 Illegal Symbolic Address
123ABC, / Symbol cannot start with a number
Start Learning Programming Loops