0% found this document useful (0 votes)
18 views8 pages

Lab 1

The document is a lab manual for a course on Computer Organization and Assembly Language, detailing objectives, basic computer architecture, memory organization, and assembly language fundamentals. It introduces various assemblers like MASM, TASM, and NASM, along with emulators such as EMU8086 and DOSBox, and explains the roles of linkers and debuggers. Additionally, it provides step-by-step instructions for writing and executing assembly programs using Emu8086, along with a lab assignment focused on basic arithmetic operations.

Uploaded by

s2024266134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views8 pages

Lab 1

The document is a lab manual for a course on Computer Organization and Assembly Language, detailing objectives, basic computer architecture, memory organization, and assembly language fundamentals. It introduces various assemblers like MASM, TASM, and NASM, along with emulators such as EMU8086 and DOSBox, and explains the roles of linkers and debuggers. Additionally, it provides step-by-step instructions for writing and executing assembly programs using Emu8086, along with a lab assignment focused on basic arithmetic operations.

Uploaded by

s2024266134
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Computer Organization and Assembly Language

Lab Manual (Lab 1)

Topic: To study assembler, MASM, NASM, TASM, Emulator, Linker, Turbo


Assembler

Course Instructor:

Lab Instructor: Muhammad Rizwan

Session: Fall 2024

School of Systems and Technology


UMT Lahore Pakistan
Objectives:
● Basic Computer Organization
● Memory
● Introduction to Assembly Language
● Installation

Basic Computer Organization

Basic Computer Architecture refers to the fundamental structure of a computer system, which
includes several key components:

● Processor (CPU): The core component responsible for performing operations and
executing instructions.
● Memory: Stores data and instructions that the processor accesses and manipulates.
● I/O Devices: Facilitate communication between the computer and the external world,
such as peripherals.
● Buses (Address, Data, and Control): These connect the processor to memory and other
devices:
o Address Bus: Unidirectional, tells memory which data to access.
o Data Bus: Bidirectional, moves data between memory and processor.
o Control Bus: Coordinates read/write operations and synchronizes data flow.
● Registers: Small, fast storage locations within the CPU for temporary data handling
during operations.

Memory

The Memory Dimension in computer architecture refers to how memory is organized and
described. Memory is defined by two key dimensions: the cell width, which indicates how many
bits each memory cell can store (commonly 8 bits or a byte), and the number of cells, which
specifies the total storage capacity. Together, these dimensions determine the overall structure
and capacity of memory, similar to how the width and depth of a well describe its total volume.

● Memory is divided into cells, each storing a fixed number of bits (e.g., 8-bit or 16-bit
cells).
● The data bus width typically matches the cell width for efficient operations.
● Memory is described by the number of cells and their size, determining the total
capacity.

Introduction to Assembly Language


An assembly language is a low-level programming language for computers,
microprocessors, Microcontrollers, and other integrated circuits. It implements a symbolic
representation of the binary machine codes and other constants needed to program a given CPU
architecture. This representation is usually defined by the hardware manufacturer, and is based
on mnemonics that symbolize processing steps (instructions), processor registers, memory
locations, and other language features. An assembly language is thus specific to certain physical
(or virtual) computer architecture.
Machine Language

Machine language is a pattern of bits that represent the OPCODE and operands, directly
executable by the CPU. The following is a short machine language program of the IBM PC.

Assembly Language Machine Language Operations


MOV AX,A 10100001 00000000 Fetch the contents of memory
00000000 word 0 and put it in register AX.
ADD AX,4 00000101 0000100 00000000 Add 4 to AX
MOV A,AX 10100011 0000000 00000000 Store the contents of AX in
memory word 0.

Introduction to Assembler, Linker and Debugger

Assembler
It is a system program which converts the assembly language program instructions into
machine executable instructions. For example: Microsoft Macro Assembler (MASM), Borland
Turbo Assembler (TASM), Open Source Netwide Assembler (NASM) etc.

MASM
The Microsoft Macro Assembler (MASM) is an x86 assembler for MS-DOS and
Microsoft
Windows. It supports a wide variety of macro facilities and structured programming idioms,
Including high-level functions for looping and procedures. Later versions added the capability of
producing programs for Windows.

TASM
Turbo Assembler (TASM) is an x86 assembler package developed by Borland. It is used
with
Borland's high-level language compilers, such as Turbo Pascal, Turbo Basic and Turbo C. The
Turbo Assembler package is bundled with the linker, Turbo Linker, and is interoperable with the
Turbo Debugger.

NASM
The Net wide Assembler (NASM) is an assembler and disassemble for the Intel x86
architecture. It can be used to write 16-bit, 32-bit (IA-32) and 64-bit (x86-64) programs. NASM
is considered to be one of the most popular assemblers for Linux and is the second most popular
assembler overall, behind MASM.
NASM was originally written by Simon Tatham with assistance from Julian Hall, and is
currently maintained by a small team led by H. Peter Anvin.
Emulators
EMU 8086
Emulator allows computer program to run on a platform (computer architecture
and/or operating system) other than for which they were originally developed unlike the
simulation which only attempts to reproduce a program's behavior, emulation attempts to
model to various degrees the state of device being emulated.
EMU8086 is emulator which emulates the behavior of 8086 machine. Emu8086 IDE contains
built in assembler which is compatible with syntax of MASAM, TASAM and few other
assemblers.
It also contains debugger which can be used to debug executable program. In emu8086 one can
emulate each instruction of program one by one and can views the value of registers, flags and
variable changed by instruction.

Dos Box

DOSBox is an open-source emulator that simulates a DOS (Disk Operating


System) environment, enabling users to run old DOS-based software, including games
and programs, on modern operating systems like Windows, macOS, and Linux. It is
commonly used to revive legacy applications that were originally designed for the DOS
platform, offering compatibility and support for older hardware features like sound cards
and graphics.

● Emulates DOS environment, allowing old software to run on modern systems.


● Supports legacy hardware, including sound cards, joystick, and VGA graphics.
● Cross-platform compatibility with Windows, macOS, and Linux.
● Widely used for running retro games and educational purposes in computer
architecture courses.

Linker
Linker or link editor is a program that takes one or more objects generated by a
compiler and combines them into a single executable program. When a program
comprises multiple object files, the linker combines these files into a unified executable
program.

Linkers can take objects from a collection called a library. Some linkers do not include
the whole library in the output; they only include its symbols that are referenced from
other object files or libraries.
Turbo Assembler
The basic steps required to create, assemble, link and debug programs using MS Notepad
and the Borland Turbo C tools TASM, TLINK and TDEBUG, respectively. Each step requires
certain command parameters and programs to be run in order to accomplish on-line debugging.

Installation

● NASM
https://genrica.com/html5CSS3/Assembler_NASM_Installation_Usage_Guide.aspx
● Youtube
https://www.youtube.com/watch?v=91Vv-GKe57g

Activity:
Draw the following diagram on page or chart and bring to next class

Video of information flow:


https://youtu.be/OvLRBSQ0Ja0

This part of the manual introduces the basics of writing, saving, and running 8086 assembly
language code using the Emu8086 software. It will guide you through setting up Emu8086,
viewing registers, writing simple assembly code, and running it. The manual also includes an
initial lab assignment for hands-on practice.

1. Download and Install Emu8086:


you can view the above link but UMT IPC and UMT IT department has helped us doing it

2- Overview of the Emu8086 Interface


Once you have installed and opened Emu8086, familiarize yourself with the following sections
of the interface:
1. Code Editor:
This is where you will write your assembly code.
2. Registers Panel:
Displays the current values in the processor’s registers (AX, BX, CX, DX, SP, BP, SI, DI)
3. Memory Viewer:
Shows the contents of memory, including the data and code segments.
4. Flags:
Displays the status of various flags (zero, sign, carry, etc.) affected by arithmetic and logic
operations.
5. Controls:
Assemble: Compiles the written assembly code.
Run: Executes the program.
Step-by-Step: Executes the program one instruction at a time, allowing you to observe changes
in registers and memory.

Writing and Running Your First Program

Step 1: Write Your First Assembly Program

1. Open Emu8086 and start a new file by clicking on `File > New`.
2. Enter the following simple assembly code to add two numbers:

```asm
; Simple program to add two numbers

MOV AX, 5 ; Load 5 into register AX


MOV BX, 3 ; Load 3 into register BX
ADD AX, BX ; Add BX to AX, result in AX
```
Step 2: Save Your Program
1. Save the program by clicking on `File > Save`.
2. Give the program a suitable name (e.g., `AddNumbers.asm`) and save it.

Step 3: Assemble the Program


1. Click on the Assemble button (or go to `File > Assemble`).
2. If there are no errors, the program will be assembled and you will see a success message.

Step 4: Run the Program


1. Click on the Run button to execute the program.
2. You can also run the program step-by-step by clicking on the Step button. This will execute
one instruction at a time, allowing you to observe how the values in the registers change.

Step 5: View the Registers and Flags


1. As the program runs, observe the changes in the Registers Panel. You should see the values
in AX and BX update as the instructions execute.
2. Pay attention to the Flags section. If an instruction affects any of the flags (e.g., zero flag,
carry flag), they will change accordingly.

Understanding Registers and Memory

Viewing Registers:
AX, BX, CX, DX are general-purpose registers used for various operations (e.g., arithmetic, data
storage).
SP, BP, SI, DI are special-purpose registers, commonly used for stack operations and memory
indexing.

Viewing Memory:
The memory panel allows you to see what values are stored in specific memory addresses.
You can toggle between different memory segments (code, data, stack).

Lab Observation: Write down the values in the registers after each step of program execution,
especially after the `ADD AX, BX` instruction. You should observe that the sum of 5 and 3 is
stored in the AX register.

Lab Assignment 1: Practice with Basic Arithmetic Operations

Objective:
Write and execute an assembly program to perform addition, subtraction, multiplication, and
division of two numbers.

Assignment Description:
1. Open Emu8086 and create a new program.
2. Write a program to perform the following tasks:
- Load the value 10 into register AX.
- Load the value 2 into register BX.
- Perform the following arithmetic operations:
- Addition: Add AX and BX, store the result in AX.
- Subtraction:Subtract BX from AX, store the result in AX.
- Multiplication: Multiply AX by BX, store the result in AX.
- Division: Divide AX by BX, store the quotient in AX and remainder in DX.

3. Save your program with an appropriate name (e.g., `ArithmeticOperations.asm`).

4. Assemble and run the program step-by-step, noting down the changes in registers after each
operation.

Sample Code:
```asm
; Assembly program for arithmetic operations

MOV AX, 10 ; Load 10 into AX


MOV BX, 2 ; Load 2 into BX

ADD AX, BX ; Add AX and BX, result in AX


SUB AX, BX ; Subtract BX from AX, result in AX
MUL BX ; Multiply AX by BX, result in AX
DIV BX ; Divide AX by BX, quotient in AX, remainder in DX
```

Write a brief report noting the values of the registers after each operation.
Make sure to practice using the Step-by-Step execution mode in Emu8086. This will help you
observe how each instruction affects the registers and flags.

You might also like