0% found this document useful (0 votes)
2 views

assembly language summary

The document provides an introduction to assembly language, covering its concepts, historical background, and features compared to machine and high-level languages. It details the structure of assembly programs, instruction formats, registers, addressing modes, and the assembly process, including linking and error handling. Additionally, it discusses the differences between one-pass and two-pass assemblers and outlines the steps to run an assembly program.

Uploaded by

hafsahakilu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

assembly language summary

The document provides an introduction to assembly language, covering its concepts, historical background, and features compared to machine and high-level languages. It details the structure of assembly programs, instruction formats, registers, addressing modes, and the assembly process, including linking and error handling. Additionally, it discusses the differences between one-pass and two-pass assemblers and outlines the steps to run an assembly program.

Uploaded by

hafsahakilu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Week 1: Introduction to Assembly Language

1.1 Concept of Assembly Language

Assembly language is a low-level programming language specific to a processor.

It uses mnemonics (symbols) instead of binary instructions.

Requires an assembler to convert code into machine language.

Benefits: Speed, Space efficiency, Capability, and Deeper Knowledge of hardware.

1.2 Historical Background

Early computers used machine code (binary).

EDSAC (1949) introduced an assembler.

IBM 650 (1955) had SOAP (Symbolic Optimal Assembly Program).

High-level languages reduced assembly use but it is still relevant in system programming.

1.3 Features and Differences from Machine & High-Level Languages

Machine Language: Binary, fastest but hard to understand.

Assembly Language: Mnemonics, more readable than machine language.

High-Level Language: Human-like syntax (e.g., C, Python), requires compilers/interpreters.

Week 2: Assembly Language Features & Basic Terms

2.1 Features of Assembly Language

Uses mnemonics for operations (e.g., MOV, ADD).

CPU-specific and interacts directly with registers.

Allows symbolic representation of memory locations.

2.2 Comparison of Machine, Assembly, and High-Level Languages

2.3 Basic Assembly Language Terms

Opcode: Specifies the operation (e.g., ADD, MOV).

Operand: Data to be processed (e.g., registers, memory locations).

Instruction: A command to the CPU (e.g., MOV AX, BX).


Register: A small storage unit in the CPU.

Week 3: Assembly Program Layout & Machine Instructions

3.1 Relationship Between Opcode, Operand, and Instruction

Opcode: The command (e.g., MOV).

Operand: The data being processed.

Instruction: The complete command given to the CPU.

3.2 Machine Instruction

Written in binary and directly executed by the CPU.

Example:

MOV R5, #25H ; Loads 25H into register R5

Instruction Format: [Label:] Mnemonic [Operand, Operand] [; Comment]

3.3 Assembly Language Program Layout

Example Assembly Code:

[org 0x0100]

mov ax, 5 ; Load 5 into AX

mov bx, 10 ; Load 10 into BX

add ax, bx ; AX = AX + BX

Key Sections:

.model → Defines memory model.

.stack → Defines stack.

.data → Data section.

.code → Program instructions.

Week 4: Labels, Functions & Comments

4.1 Labels in Assembly

Data Label: Marks a memory location.


count DWORD 100 ; Variable named count

Code Label: Marks a location in code (used for jumps).

target:

mov ax, bx

jmp target ; Loops back to target

4.2 Functions in Assembly

A reusable block of code.

Functions help modularize programs and can return values.

4.3 Comments in Assembly

Documentation within code.

Example:

MOV DL, 0AH ; Move one line down

Here’s a summarized version of the key topics from Weeks 5 to 8 for your exams:

Week 5: Instruction Formats & Registers

1. Instruction Formats

Defines how instructions are structured in memory.

Consist of opcode (operation) and operand addresses (data location).

Types:

Zero-address (stack-based)

One-address (uses accumulator)

Two-address (direct data movement)

Three-address (efficient but requires more bits)

2. Registers & Their Functions

General Purpose Registers: Store temporary data.

Special Purpose Registers: Includes Program Counter (PC), Instruction Register (IR), Memory Address Register (MAR),
and Accumulator (AC).
Stack Pointer (SP): Manages the function call stack.

Week 6: Assembly Linking & Addressing Modes

1. Assembly Linking

Combines multiple object files into an executable.

Types:

Static Linking (libraries included in final program, more memory usage).

Dynamic Linking (shared libraries loaded at runtime, saves memory).

2. Addressing Modes (Ways to locate data in memory)

Immediate: Value is directly in instruction.

Direct: Address of operand is given explicitly.

Indirect: Address points to another address storing the data.

Register: Data stored in a register.

Register Indirect: Register holds memory address of data.

Displacement (Base + Offset, Indexed): Effective address computed dynamically.

Stack Addressing: Uses stack for operand storage.

Week 7: Addressing Modes & Assembler Directives

1. More on Addressing Modes

Covers Relative Addressing (jump instructions), Base Register Addressing, and Indexing for efficient data retrieval.

2. Assembler Directives

ASSUME: Specifies logical segments.

DB, DW, DD, DQ, DT: Define data storage sizes.

EQU: Assigns a name to a value.

ORG: Sets program starting address.

PROC/ENDP: Define subroutines.

END: Marks the end of a program.


Week 8: Instruction Sets & Assembly Instructions

1. Instruction Sets

Data Transfer Instructions (MOV, LOAD, STORE).

Arithmetic & Logical Instructions (ADD, SUB, AND, OR).

Control Transfer Instructions (JUMP, CALL, RET).

I/O Instructions (IN, OUT).

Special Instructions (CLI, STI for interrupts).

2. Assembly Language Instructions

Arithmetic Operations (Addition, Subtraction, Multiplication, Division).

Bit Manipulation (Shift, Rotate, AND, OR, XOR).

Program Flow Control (Conditional Jumps, Looping).

Interrupts (Handling system-level events).

Processor Control (Set/clear flags, enable/disable interrupts).

Week 9: Testing Assembly Language Programs & Assembly Process

Study Session 8.1: Running an Assembly Language Program

Steps to run an assembly program using NASM:

1. Create a source file (e.g., hello.asm).

2. Assemble using: nasm -f elf hello.asm.

3. If no errors, an object file (hello.o) is created.

4. Link using: ld -m elf_i386 -s -o hello hello.o.

5. Run the executable: ./hello.

Assembly Output Layout:

The output includes an executable (.COM) and a listing file (.LST).

Uses little-endian byte order (least significant byte stored first).

Debugging involves stepping through instructions and observing register changes.


Study Session 9.1: Assembly Process & Passes

Steps in Assembly Process:

1. Assembling: Converts source code into an object file (.OBJ).

2. Linking: Combines object files into an executable (.EXE).

3. Loading & Execution: The program is loaded into memory and executed.

Passes in Assembly Process:

First Pass:

Checks for syntax errors.

Allocates space and builds a symbol table.

Second Pass:

Resolves symbolic references.

Converts instructions into machine code.

Week 10: Assembly Errors & One/Two Pass Assemblers

Study Session 9.2: Assembly Program Errors

Types of Errors & Solutions:

1. Undefined Symbol: Check spelling of labels.

2. Undefined Opcode: Verify instruction availability.

3. Invalid Addressing Mode: Ensure correct mode is used.

4. Expression Error: Check parentheses and simplify.

5. Phasing Error: Remove undefined symbols.

6. Address Error: Use ORG to match memory availability.

Syntax Errors vs Logical Errors:

Syntax Errors: Incorrect spelling, punctuation, invalid labels.

Logical Errors: Program runs but produces incorrect results.

Study Session 9.3: One Pass & Two Pass Assemblers


One Pass Assembler:

Converts code in one go.

Handles forward references with corrections after execution.

Less efficient.

Two Pass Assembler:

Pass 1: Creates a symbol table.

Pass 2: Resolves addresses and generates object code.

More efficient and commonly used.

You might also like