You are on page 1of 3

DEPARTMENT OF COMPUTER ENGINEERING

University College of Engineering & Technology


Bahauddin Zakariya University, Multan.

Manuax Details

Subject Computer Architecture

Session 2019 -2023

Pr. Hrs. per Week 3Hrs. (Pr)

Lab Instructor Engr. Abdul Rehman

Submission Detail

Submitted by Muhammad Usama Saghar

Roll no 2019-cpe-27
MANUAL 10

2019-CPE-27 usama saghar


Lab Manual 10
Objective
Addition of Numbers Using Register Indirect Addressing Method

Theory:
we have done very elementary data access till now. Assume that the numbers we had were 100
and not just three. This way of adding them will cost us 200 Instructions. There must be some
method to do a task repeatedly on data placed in consecutive memory cells. The key to this is
the need for some register that can hold the address of data. So that we can change the
address to access some other cell of memory using the same Instruction.
In direct addressing mode the memory cell accessed was fixed Inside the instruction. There is
another method in which the address can be placed in a register so that it can be changed. For
the following example we will take 10 instead of 100 numbers but the axgorithm is extensibxe
to any size.
There are four registers that can hold address of data and they are BX, BP, SI, and DI, For the
current example, we will use the BX register and we will take just three numbers and extend
the concept with more numbers in later examples.
001 org 100h ; a program to add three numbers using indirect addressing
p02 mov bx, [num1] ; point bx to first number
004 mov ax, [bx] ; load first number in ax
005 add bx, 2 advance bx to second number
006 add ax, [bx] ; add second number to ax
007 add bx, 2 ; advance bx to third number
008 add ax, (bx] ; add third number to ax
009 add bx, 2 ; advance bx to result
010 mov [bx], ax store sum at num1+6
011 ret
012 num1: dw 5, 10, 15, 0

2019-CPE-27 usama saghar


Observe that colon (:) is used after num1 this time. The address is loaded in bx and not the
contents.
In next instruction, brackets are now used around BX. Brackets can be used around BX, B, SI,
and DI only. The instruction will be read as "move into ax the contents of the memory location
whose address is in bx." Now since bx contains the address of num1 the contents of num1 are
transferred to the ax register. Without square brackets the meaning of the instruction would
have been totaxly different.
The next instruction is changing the address. Since we have words not bytes, we add two to bx
so that it points to the next word in memory. This was the mechanism to change addresses that
we needed.

EXERCISE
1. Write the above program code for addition of numbers using register Indirect addressing in
emu8086 and give the information about "Com Symbol" & "Com list" files for each instruction.

Com Symbol File


Instruction OFFSET Size Type Segment
1 00115 -1 LABEL (NDSEG)
2 00115 -1 LABEL (NDSEG)
3
4

COM LIST FILE

Instruction Location Machine code Source Code


1 0100 BB 15 01 Org loop
2 0103 8B 07 Mov bx[num3];
3 0105 83 C3 02 Mov ax[bx];
4 1108 03 07 Add bx 2;
5 010D 83 C3 02 add ax,[bx
6 011F 81 07 Add bx,2;
7 0112 C3 add ax [bx];
8 0113 05 0A 00 Add, b1, 2
9 0114 00 00 ret
10 0115 00 00 Num1 : dw 5,10,15

2019-CPE-27 usama saghar

You might also like