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

2. Addressing Modes Lab

The document is a laboratory manual for a microprocessor course (ENEE 466) focusing on addressing modes and data transfer instructions. It includes objectives, introductions to various addressing modes, lab work instructions using emu8086 software, and exercises for students to practice programming. The manual also covers arithmetic instructions and provides examples and exercises to enhance understanding of assembly language programming.

Uploaded by

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

2. Addressing Modes Lab

The document is a laboratory manual for a microprocessor course (ENEE 466) focusing on addressing modes and data transfer instructions. It includes objectives, introductions to various addressing modes, lab work instructions using emu8086 software, and exercises for students to practice programming. The manual also covers arithmetic instructions and provides examples and exercises to enhance understanding of assembly language programming.

Uploaded by

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

MICROPROCESSOR

(ENEE 466)
LABORATORY MANUAL

Addressing modes and data transfer instructions

LAB # ( )

Lab Instructor : Engr. Younus Talha

Student Name: ___________________________

Student Id : _____________ Section: ___________

Date performed: _____________________,

Report Submission Date: ______________,

_______________________________
LECTURER SIGNATURE & DATE

1
Objective 1

To learn various addressing modes and to verify the actions of data transfer.

1. Introduction

Assembly language program can be thought of as consisting of two logical parts: data and code.
Most of the assembly language instructions require specification of the location of the data to be
operated on. There are a variety of ways to specify and find where the operands required by an
instruction are located. These are called addressing modes. This section is a brief overview of some
of the addressing modes required to do basic assembly language programming.

The operand required by an instruction may be in any one of the following locations

• in a register internal to the CPU

• in the instruction itself

• in main memory (usually in the data segment)

Therefore the basic addressing modes are register, immediate, and memory addressing modes.

1.1. Register Addressing Mode

Specification of an operand that is in a register is called register addressing mode. For example, the
instruction
MOV AX,CX
requires two operands and both are in the CPU registers.

2
1.2. Immediate Addressing Mode
In this addressing mode, data is specified as part of the instruction. For example, in the following
instruction

MOV BX,1000H
the immediate value 1000H is placed into register BX after this instruction is executed.

1.3. Memory Addressing Mode


A variety of modes are available to specify the location of an operand in memory. These are direct,
register-indirect, based, indexed and based-indexed addressing modes.

2. Lab Work:

2.1. Software
We will be using the emu8086 software in this lab.
2.2. Examples
Program 1: Enter the following program. Execute the program step by step. Since the program
does nothing except for transferring the contents from one register to another, view and verify the
action of each statement using emu8086.
Note: You have to create your source file.

# Procedure (To be followed for all programs):


1. Choose “New” and specify “COM template” in emu8086.
2. Enter the code to the editor:
3. Start emulation by clicking the “emulate” button on the toolbar. A new emulator window will
appear.
4. Single-step the program codes by pressing the “single step” button on the toolbar of the emulator
window.
5. Each time after pressing the “single step” button, check and record down the contents of registers.

3
In assembler we have to explicitly perform many functions which are taken for granted in high level
languages. The most important of these is exiting from a program. The last two lines

MOV AX,4C00H

INT 21H
in the code segment are used to exit the program and transfer the control back to the operating
system.

4
Program 2: Write a program that stores the hex numbers 20, 30, 40, and 50 in the memory and
transfers them to AL, AH, BL, and BH registers. Verify the program by identifying the memory
location where the data is stored.

5
The directive DB ‘Define Byte’ is used to store data in a memory location. Each data has a length of
byte. (Another directive is DW ‘Define Word’ whose data length is of two bytes) The label ‘num’ is
used to identify the location of data. The two instructions

MOV AX,@DATA

MOV DS,AX
together with LEA SI,num
are used to find the segment and offset address of the memory location ‘num’. Notice that memory
addressing modes are used to transfer the data.

Program 3: Write a program that allows a user to enter characters from the keyboard using the
character input function. This program should also store the characters entered into a memory location.
Run the program and specially identify the location where the data will be stored.

6
7
The directive DB when used with DUP allows a sequence of storage locations to be defined or
reserved. For example

DB 20 DUP(?)
Reserves 20 bytes of memory space without initialization. To fill the memory locations with some
initial value, write the initial value with DUP instead of using ‘question mark’. For example DB 20
DUP(10) will reserve 20 bytes of memory space and will fill it with the numbers 10.

The Keyboard input function waits until a character is typed from the keyboard. When the
following two lines

MOV AH,01

INT 21H
are encountered in a program, the program will wait for a keyboard input. The ASCII value of the
typed character is stored in the AL register. For example if ‘carriage return’ key is pressed then AL
will contain the ASCII value of carriage return i.e. 0DH.

2.3. EXERCISE
# Write a program in emu8086 that reserves a memory space ‘num1’ of 10 bytes and initializes
them with the hex number ‘AA’. The program should copy the 10 bytes of data of ‘num1’ into
another memory location ‘num2’ using memory addressing mode.

Hint: Use DB instruction with DUP to reserve the space for ‘num1’ of 10 bytes with the initialized
value of ‘AA’. Again use DB with DUP to reserve another space for ‘num2’, but without initialization.
Use memory content transfer instructions to copy the data of ‘num1’ to ‘num2’.

8
Objective 2
The objective of this experiment is to learn the arithmetic instructions and write simple programs
using emu8086.

1. Introduction
Arithmetic instructions provide the microprocessor with its basic integer math skills. The 80x86
family provides several instructions to perform addition, subtraction, multiplication, and division on
different sizes and types of numbers. The basic set of assembly language instructions is as follows

Addition: ADD, ADC, INC, DAA


Subtraction: SUB, SBB, DEC, DAS, NEG
Multiplication: MUL, IMUL
Division: DIV, IDIV
Sign Extension: CBW, CWD
Examples:
ADD AX,BX
adds the content of BX with AX and stores the result in AX register.

ADC AX,BX

adds the content of BX, AX and the carry flag and store it in the AX register. It is commonly used to
add multibyte operands together (such as 128-bit numbers)

DEC BX

decreases the content of BX register by one

MUL CL

multiplies the content of CL with AL and stores the result in AX register

MUL CX

multiplies the content of CX with AX and stores the 16-bit upper word in DX and 16-bit lower word
in the AX register

IMUL CL

is same as MUL except that the source operand is assumed to be a signed binary number

9
1. Pre-lab:

1. Write a program that performs the addition of two byte sized numbers that are initially stored in
memory locations ‘num1’ and ‘num2’. The addition result should be stored in another memory
location ‘total’. Verify the result using emu8086.

[Hint: Use DB directive to initially store the two byte sized numbers in memory locations called
‘num1’ and ‘num2’. Also reserve a location for the addition result and call it ‘total’]

2. Write a program that multiplies two unsigned byte sized numbers that are initially stored in
memory locations ‘num1’ and ‘num2’. Store the multiplication result in another memory
location called ‘multiply’. Notice that the size of memory location ‘multiply’ must be of word
size to be able to store the result. Verify the result using emu8086.

String output function is used in this program to print a string on screen. The effective address of
string must first be loaded in the DX register and then the following two lines are executed

MOV AH,09

INT 21H

 Exercise 1: Write a program so that it asks for entering an uppercase letter and converts it
to lowercase.

10
2. Lab Work:

Example Program 1: Write a program that asks to type a letter in lowercase and then converts that
letter to uppercase and also prints it on screen.

11
Example Program 2: The objective of this program is to enter 3 positive numbers from the keyboard
(0-9), find the average and store the result in a memory location called ‘AVG’. Run the program in
emu8086 and verify the result

12
13
14

You might also like