0% found this document useful (0 votes)
87 views5 pages

COAL Lab 1

The document provides information about assembler, linker, emulator and gives instructions to install and run an assembly program on Emulator 8086. It includes objectives, concepts of assembly language, machine language, introduction to assembler, linker, debugger and emulator. It also provides a sample assembly code to add two numbers and output the result in a register along with instructions to run the code on Emulator 8086 and observe the results.

Uploaded by

Usama Yousaf
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)
87 views5 pages

COAL Lab 1

The document provides information about assembler, linker, emulator and gives instructions to install and run an assembly program on Emulator 8086. It includes objectives, concepts of assembly language, machine language, introduction to assembler, linker, debugger and emulator. It also provides a sample assembly code to add two numbers and output the result in a register along with instructions to run the code on Emulator 8086 and observe the results.

Uploaded by

Usama Yousaf
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/ 5

Computer Organization and Assembly Lan-

guage
Lab Manual (Lab 01)

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


Assembler and execute an assembly program using Emulator 8086.

Lab Instructor: HAFSA RAFIQUE

Session: Spring 2024


School of Systems and Technology
UMT Lahore Pakistan
Objectives:

Introduction of assembler.

Some concepts and assembler setting snapshot:

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

All the information is just to provide an idea about different assembler, linker and
debuggers. However, emulator 8086 has been preferred and will be used.

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
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.
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.
Instructions to install and run the assembly code on Emulator 8086

1. Download using the given link,

https://drive.google.com/file/d/1qsEOBefozRrqi04zKhE-IhjDqvSxFkFB/view?usp=sharing

2. After installing the emulator 8086, the shortcut(emu8086) will be created on desktop or
somewhere else

3. Open the software (emu8086)

4. Click on new

5. Choose empty work space, and press ok

6. A blank window will appear, either you can type/paste your assembly code over here or
you can click on open to open an assembly file (e.g., add.asm)

7. Optional: Afterwards you can save your code, by default it's going into the directory of
the emulator, however you can change the location to save this file. As mentioned above,
these saving techniques are optional

8. Click on emulate (Run sign, button)

9. Two windows (original source code and emulator add.exe) will popup, if there is no er-
ror.

10. Use emulator add.exe (e.g., filename.exe), either run it step by step (single step), or run
(whole program once).

11. Step by step (single step) will give you an idea, how instructions are going to be executed
and how registers are going to be updated.

12. Analyze the values of registers which are showing on the left side of the window.
Lab Task

Run a program using emu8086 by using the above mentioned instructions and analyze the
result in relevant registers.
Might be some of the comments are placed on two lines, make sure comments should be
mentioned with; by doing this, assembler will ignore it and it will not affect the code.

.model small

.stack 100h ; Reserves size bytes of memory for the run-time stack, for temporary
storage of addresses and data.

.data
a db 09h ; db stands for define byte, it reserves one byte – with a name a and
initialize the byte to value of 09 in hexadecimal
b db 02h ; db stands for define byte, it reserves one byte – with a name a and
initialize the byte to value of 09 in hexadecimal

.code
mov ax,@data ;loading starting address of data segment in AX
mov ds,ax ;data segment gets initialized
mov al,a ; value 9 has been moved to AL register (Register Size 8 bits)
mov bl,b ; value 2 has been moved to BL register (Register Size 8 bits)
add al,bl ; data/values of AL and BL register has been added and result (11=B)
stored in AL register (Reg Size 8 bits)
mov cl,al
mov ah,4ch ; DOS Function call to exit (Preparing to exit)
int 21h ; Interept command (used in combination with ah, 4ch command. Later on
you will learn more.)
end ; End, Shifting control from DOS to the Operating system

Results and Observations.

You might also like