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

Lab Tasks 2

The document provides instructions for several assembly language labs focused on using basic instructions like MOV, ADD, SUB, INC, DEC, and NEG. The labs introduce students to EMU8086, an emulator for writing and executing assembly code. Students will explore the emulator interface, execute sample assembly code instructions to observe register values, and write and run short programs displaying text on screen. The labs guide students through tasks like loading sample code, single-stepping instruction execution, observing register changes, writing code to perform math operations, and coding simple text output programs using DOS interrupts. The goal is for students to learn how to use basic assembly language instructions and debug code using the emulator.

Uploaded by

CompuTerics
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)
110 views

Lab Tasks 2

The document provides instructions for several assembly language labs focused on using basic instructions like MOV, ADD, SUB, INC, DEC, and NEG. The labs introduce students to EMU8086, an emulator for writing and executing assembly code. Students will explore the emulator interface, execute sample assembly code instructions to observe register values, and write and run short programs displaying text on screen. The labs guide students through tasks like loading sample code, single-stepping instruction execution, observing register changes, writing code to perform math operations, and coding simple text output programs using DOS interrupts. The goal is for students to learn how to use basic assembly language instructions and debug code using the emulator.

Uploaded by

CompuTerics
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/ 10

DEPARTMENT OF COMPUTER SCIENCE

LAB ASSEMBLY LANGUAGE

LAB MANUAL

INSTRUCTOR: M USMAN MALIK


Contents
Lab 1 – An Introduction............................................................................................................3
Lab 2 – An Introduction to EMU8086......................................................................................4
Lab 3, 4 & 5 – Using Basic Instructions....................................................................................6
Lab 6 & 7 – Using Variables.....................................................................................................8
Lab 8 – Sample Programs..........................................................................................................9
Lab 9 – Using Basic Instructions: A Programming Exercise I................................................11

2
Lab 1 – An Introduction
Objectives
The lab objective is to explore some basic concepts related to computer organization,
computer architecture and microprocessors.

Instructions
You are suppose to provide precise answers of following questions after reading related
topics from recommended books and consulting material available on internet. Font size
should be Times New Roman, 12 pt, and justified text with 1.15 line spaces.

Reading
1. http://windows.microsoft.com/en-us/windows/computer-parts#1TC=windows-7
2. http://www.laptopparts101.com/main-laptop-notebook-parts-explained/#more-348
3. http://education-portal.com/academy/lesson/what-is-a-motherboard-definition-function-
diagram.html
4. http://patkay.hubpages.com/hub/the-motherboard-components
5. http://www.engineersgarage.com/tutorials/difference-between-microprocessor-and-
microcontroller
6. Ch#2, “Computer Evolution & Performance”, Book: Computer Organization &
Architecture by William Stallings (8th or 9th Edition)

Questions
1. What is the purpose of RAM (Main Memory) and ROM?
2. Differentiate among Microprocessor, Microcontroller and Embedded Systems. Also give
examples.
3. Summarize major changes in 1st, 2nd, 3rd and 4th generations in the history of Computers.
4. Summarize the evolution of Intel x86 architecture.
5. Discuss general structure of Von Neumann machine.
6. Why an operating system is used? Name few operating systems.
Lab 2 – An Introduction to EMU8086
Objectives
In this lab, students will learn how to use EMU8086 to write and assemble programs in
assembly language.

Introduction
Emu8086 is a program that compiles the source code (assembly language) and executes it.
You can watch registers, flags and memory while your program executes. Arithmetic &
Logical Unit (ALU) shows the internal work of the central processor unit (CPU). Emulator
runs programs on a Virtual PC; this completely blocks your program from accessing real
hardware, such as hard-drives and memory, 8086 machine code is fully compatible with all
next generations of Intel's microprocessors.
Where to start?
1. Start Emu8086 by selecting its icon from the start menu, or by running Emu8086.exe.
2. Select "Samples" from "File" menu.
3. Click [Compile and Emulate] button (or press F5 hot key).
4. Click [Single Step] button (or press F8 hot key), and watch how the code is being
executed.
5. Try opening other samples, all sample programs are heavily commented, so it's a great
learning tool.
TASKS
1. Familiarize yourself with EMU8086 GUI. Explore different menu options. Learn how to
use calculator and base converter. Also explore the ASCII table.
2. Press F1, to open the tutorial in browser. Read the following sections:
a. Where to Start?
b. Working with the Editor
c. How to Compile the Code
d. Assembly Language Tutorials (Numbering System, Part 1: What is Assembly
Language)
3. Registers are high-speed storage locations inside the microprocessor. They are classified
according to the function they performed. Each register has a name. One of the general
types of register is Data Registers (that can hold data). AX (accumulator register) is a
data register. Find out what other data registers can be used.
4. MOV is an instruction used in assembly language to the copy contents of source operand
to destination operand. As a result, destination operands are modified but source contents
remain unchanged. For example, if you execute following instruction in EMU8086, the
contents will be copied in AX register.
MOV AX, 41h
Where MOV is an assembly language instruction, AX is a data register (destination
operand) and 41h is the source operand you want to copy.

Now execute the following instructions (single-step) in EMU8086 and observe the
changes in contents of AX register.

a. MOV AX, ‘B’


b. MOV AX, 42h
c. MOV AX, 42
d. MOV AX, 42d
e. MOV AX, 0100 0010b
f. MOV AX, 123Ah
g. MOV AX, 0FE44h

5
Lab 3, 4 & 5 – Using Basic Instructions
Objectives
In this lab, students will learn how to use instructions MOV, ADD, SUB, INC, DEC, and
NEG in an assembly language program.

Lab Tasks
Task 1: Read the syntax of assembly language instructions MOV, ADD, SUB, INC, DEC,
and NEG (purpose, no. of operands required, and legal/illegal operands) from textbook ch#4.
Also, find out all valid combinations of MOV instructions using data register and immediate
values or both operands as data register.

Task 2: Now execute the following instructions (single-step) in EMU8086 and observe the
changes in contents of destination operand. If any instruction gives error, correct that error.
a. MOV AL, 256
b. MOV AX, F1ABh
c. MOV AX, -123
d. MOV BX, 123
e. MOV AH, 010010001b
f. MOV 1234h, BX
g. MOV DX, 33h
h. MOV CX, ‘AB’
i. MOV CH, AL
j. MOV DL, BL
k. MOV AH, BL
l. MOV AX, CL
Task 3: For each of the following assembly language instructions, what will be the possible
register value (in hex)? Assume all statements are being executed in a sequence and initially
all registers contain zero.

No. Instructions AX BX CX DX
AH AL BH BL CH CL DH DL
1. MOV AX, 0110b
2. MOV BH, 90H
3. MOV CX, 10
4. MOV DX, 1234H
5. ADD DH, DL
6. ADD AX, BX
7. SUB CX, BX
8. SUB AH, DL
9. INC AX
10. INC BL
11. DEC DX
12. DEC CH
13. NEG CX
14. NEG BL

Task 4: Execute following statements (single-step) in EMU8086. Observe changes in the


contents of destination operand.
No Code Snippet Result
.
A. MOV AX, 4D12h
MOV BX, 1C21h
ADD AX, BX
B. MOV AX, 4D12h
MOV BX, 1C21h
SUB AX, BX
C. MOV AL, 25
MOV BH, 1Ch
ADD AL, BH
D. MOV CL, 10000011b
MOV CH, 10010010b
SUB CH, CL
E. MOV AX, 80h
ADD AX, 01
F. MOV AL, 80h
ADD AL, 01
G. MOV AL, 0A5h
MOV BL, 12h
ADD AL, BL
MOV DH, BL
SUB DH, 10

7
Lab 8 – Sample Programs
Objectives
In this lab, students will execute given sample programs to understand their working and
observe their output.

Lab Tasks
Practice the following code in EMU8086 and write their output:

Code Output
1. .MODEL SMALL
.STACK 100H
.CODE
; input a character
MOV AH, 1 ; read character function
INT 21H ; character in AL

2. .MODEL SMALL
.STACK 100H
.CODE
; display character
MOV AH, 2
MOV DL, ‘A’
INT 21H

3. .MODEL SMALL
.STACK 100H
.DATA
MSG DB "Hello","$"
.CODE
MOV AH, 9
MOV DX, Offset MSG
INT 21H

4. .MODEL SMALL
.STACK 100H
.DATA
MSG DB "Hello",0AH, "Assembly",0Dh, "LAB""$"
.CODE
MOV AH, 9
MOV DX, Offset MSG
INT 21H

5. .MODEL SMALL
.STACK 100H
.DATA
MSG DB "Hello",0AH, "Assembly",0Dh, "LAB","$"
.CODE
MOV AH, 2
MOV DL, MSG+2
INT 21H

6. .MODEL SMALL
.STACK 100H
.DATA
MSG DB "Hello",0AH, "Assembly",0Dh, "LAB","$"
.CODE
MOV AH, 9
LEA DX,MSG
INT 21H

You might also like