Introduction to Assembly Language

What is Assembly Language?

Assembly language offers a user-friendly alternative to machine language by using familiar symbolic representations for instructions and memory locations. While computers understand only binary code, assembly language bridges the gap between human-readable code and machine instructions.

Program Structure

An assembly language program consists of lines of code, each containing three fields:

Label Field

Optional symbolic address (1-3 alphanumeric characters)

Instruction Field

Machine instruction or pseudoinstruction

Comment Field

Optional explanatory remarks

Pseudoinstructions

ORG N

Sets the origin of the program to memory location N

END

Marks the end of the symbolic program

DEC N

Converts decimal number N to binary

HEX N

Converts hexadecimal number N to binary

Machine Language

16-Bit Instruction Format

Each machine instruction in the basic computer is 16 bits long, divided into:

Bit 15 | Bits 14-12 | Bits 11-0
I | Opcode | Address
1 | 3 bits | 12 bits
I (Bit 15)

Addressing mode: 0=Direct, 1=Indirect

Opcode (3 bits)

Specifies the operation (ADD, LDA, etc.)

Address (12 bits)

Memory address or operand data

Interactive Example: LDA Instruction

Load AC from address 005: 2005 (hexadecimal)

Arithmetic and Logic Operations

Arithmetic Operations

ADD

Adds memory content to AC, carry goes to E flip-flop

LDA

Loads memory word into AC

STA

Stores AC content into memory

INC

Increments AC by one

CLA

Clears AC to zero

CMA

Complements AC (1's complement)

Logic Operations

AND

Bit-wise logical AND with memory and AC

CME

Complements the E flip-flop

CIR

Circular shift right (AC and E)

CIL

Circular shift left (AC and E)

Programming Constructs

Looping Constructs

Program loops execute instruction sequences multiple times using conditional branch and skip instructions:

ISZ

Increment and Skip if Zero - crucial for loop control

SPA

Skip if AC positive

SNA

Skip if AC negative

SZA

Skip if AC zero

Subroutines

Reusable code blocks for specific tasks:

BSA

Branch and Save Return Address - calls subroutine

BUN

Branch Unconditionally - returns from subroutine

I/O Programming

Managing communication with external devices:

INP

Input character from INPR to AC

OUT

Output character from AC to OUTR

SKI

Skip if Input Flag is ON

SKO

Skip if Output Flag is ON

ION

Turn Interrupt ON

IOF

Turn Interrupt OFF

Interactive I/O Demo

Experience how interrupt-driven I/O works