0% found this document useful (0 votes)
12 views18 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 concepts. It covers the use of assemblers like MASM, TASM, and NASM, as well as emulators and linkers, providing installation instructions for DOSBox and EMU 8086. Additionally, it includes a lab task for executing assembly code using the mentioned tools.

Uploaded by

nextgenapparelpk
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)
12 views18 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 concepts. It covers the use of assemblers like MASM, TASM, and NASM, as well as emulators and linkers, providing installation instructions for DOSBox and EMU 8086. Additionally, it includes a lab task for executing assembly code using the mentioned tools.

Uploaded by

nextgenapparelpk
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/ 18

Computer Organization and Assembly Language

Lab Manual (Lab 1)

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


Linker, Turbo Assembler

Instructor: Zohaib Ashraf

Session: Fall 2021

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 exe-
cuting 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 dur-
ing operations.

Memory

The Memory Dimension in computer architecture refers to how memory is organized and de-
scribed. 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 capac-
ity.

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.

Uses of Assembly Language:


System Programming:
Writing low-level system software like operating systems, device drivers, and embedded
systems.
Direct hardware manipulation, critical in systems with limited resources.
Performance-Critical Applications:
Applications requiring maximum speed and efficiency.
Real-time systems where every microsecond matters.
Hardware Control:
Precise control over hardware components.
Implementing communication protocols for hardware devices.
Educational Purposes:
Teaching fundamentals of computer architecture and operation.
Understanding how high-level languages translate to machine code.
Optimization:
Optimizing critical sections of code that require the utmost performance.
Reducing the footprint of applications on memory-limited devices.

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 or 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 Sys-


tem) environment, enabling users to run old DOS-based software, including games and
programs, on modern operating systems like Windows, macOS, and Linux. It is com-
monly used to revive legacy applications that were originally designed for the DOS plat-
form, 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 archi-
tecture 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

Basic Steps to install and run DosBox, TASM and


Compile x86 Assembly Program in Windows 7 64 bit
Version
Step 1:
1. Go to Start, and My Computer. Click on (C:) Local Disk C (or any desired
location you want).
Step 2:

2. On the directory, create a folder and name it TASM ( or any name you want).

Step 3:
3. Download this file.

Step 4:

5. Extract the contents of the .zip file.

Step 5:
5. Copy the extracted files to the folder TASM (or to the folder you've made awhile
ago). Also, don't forget to extract the DEBUG125.zip to the same folder.

Step 6:

7. Download DOSBOX here.

Step 7:
8. After installing the DOSBox, run it and type the following lines:

MOUNT E C:\TASM
E:

If you chose a while ago a custom drive besides the directory of C:

LET X be your drive letter:

MOUNT E X:\TASM
E:

Step 8:
9. Put your assembly code (e.g <your filename>.asm) in the same directory where
you installed TASM and TLINK and run it by typing:

TASM <yourfilename>
TLINK <yourfilename>

Step 9:
10. The executable file is located in the folder TASM or your chosen directory. You
can run it as it is or via CMD by typing <yourfilename>.exe

Step 10:

Extra (Optional):
11. The debug command was deleted in Windows 7 64 bit machines. The file that
you've downloaded and installed has the 'debug' executable files. Now, you can run
it via DOSBox by typing in DEBUG or DEBUG <your+executable+file>.exe.

Step 11:
Prerequisite For EMU 8086:
You must have

1. A PC
2. An active internet Connection
3. Administrative rights for Windows XP/Vista/7 users.
4. 10 Mb of hard disk space
5. 1024x768 or greater screen resolution.

Installation Process:
You can get Emu8086 from google by searching emu8086 download.
 Click it and you will get a Website.
 Click "Download for PC" button. This opens a new tab and the downloading

starts.

Observe that the zip file of 3Mb in your folders .

 Click on the small arrow, open the folder. A folder will be pop up.

 Double click at "Setup". It will ask for the permission. Allow it by clicking "yes".

The Window will appear that will start the setup process
 Click "Next" to continue the process.

A new will be appear like this:

 Close All the Application running applications and click "Next".

 Now, You have to give the path for the folder .By default the path is given for

the C directory but you can change it by clicking Browse.


 Read all the tabs appeared after it and then Click "Next".

In the last window, it will ask does we want to launch the Emu8086 or Does we
wish to read the instruction.
 Choose the action you want to be launched or mere remove the tick mark and the

setup is finished.

The Emu8086 icon will appear on your desktop. You can use it whenever you
want.
Lab Task

Task # 1:

 Copy the above code in notepad and save the file in c:\temp folder or c:\
turbo assembler folder with extension .asm i.e. First_program.asm
 Then go to the command prompt by writing cmd or go to the Dosbox
 Execute the .asm file saved above by writing the instruction tasm ,tlink
 Observe the output
OR
Task # 1:

 Download and Install Emu8086 and run it.


 Select EXE file type.
 Place the sample code in editor and run it.
Sample Code:
.model small
.stack 100h
.data
num1 db 5 ; First number
num2 db 3 ; Second number
result db 0 ; To store the result

.code
main proc
mov ax, @data
mov ds, ax ; Initialize the data segment

; Load the first number into the AL register


mov al, num1

; Add the second number to the AL register


add al, num2

; Store the result


mov result, al
; Exit the program (DOS interrupt 21h)
mov ah, 4Ch ; DOS function: Exit
int 21h ; Call interrupt

main endp
end main

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

You might also like