Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

DEPARTMENT OF COMPUTER ENGINEERING

University College of Engineering & Technology


Bahauddin Zakariya University, Multan.

Manual Details

Subject Computer Architecture


Session 2019 -2023
Pr. Hrs. per Week 3Hrs. (Pr)
Lab Instructor Engr. Abdul Rehman
Lab #07

Submission Details

Submitted by Muhammad Usama Saghar

2019-cpe-27

2019-CPE-27 usama saghar


Lab Manual 07
Objective:

Addition of Numbers Using a Single Label Method (Direct Addressing)

Theory:
Given the fact that the assembler knows only numbers We can write the same program using a
single
label. As we know that num? is two ahead of num1, we' can use num1+2 Instead of num2 and
let the
assembler calculate 'he sum during assembly process.

Now we write the program with that the numbers 5, 10, and 15 are stored as single label
instead of
three different labels.

001 ; a program to add three numbers using single label

002 org 100h;

003 mov ax [num1]; , load first number in ax

004 mov bx [num1+2]; , load second number in bx

005 add ax, bx ; accumulate sum ax

006 mov bx [num1+4]; , load third number in bx

007 add ax, bx ; accumulate sum in ax

008 mov [num1+6], ax store sum at 1+6

009 ret

010 num1 dw
011 dw 10
012 dw15
013 dw0

The second number" is read from num1+2.Similarly the third number is read from num1+4. And

2019-CPE-27 usama saghar


finally result is accessed at num1+6. The labels num2, num3, and num4 are removed and the
data there Will be accessed the reference to num1.
Another way to declare the above data and produce exactly same is shown in below example;
001 ; a program to add three numbers using single label

002 org 100h;

003 mov ax [num1]; , load first number in ax

004 mov bx [num1+2]; , load second number in bx

005 add ax, bx ; accumulate sum ax

006 mov bx [num1+4]; , load third number in bx

007 add ax, bx ; accumulate sum in ax

008 mov [num1+6], ax store sum at 1+6

009 ret

010 num1 dw 5,10,15,0

Exercise
Write the above program code for addition of numbers using memory variables in emu8086
and give the information about "Com Symbol" & "Com list" files for each Instruction.

COM SYMBOL FILE


Instruction OFFSET Size Type Segment
1 00113 2 VRP (NDSEG)
2 00113 2 VRP (NDSEG)
3
4

2019-CPE-27 usama saghar


COM LIST FILE
Instruction Location Machine code Source Code
1 0100 A1 13 01 Org loop
2 0103 BB 1E 15 Mov ax[num1];
3 0107 03 C3 Mov bx[num2];
4 1109 88 0E 17 D Add ax, bx;
5 010D 03 C3 Mov bx,[num3];
6 011F 05 00 Add ax, bx;
7 0112 0A 00 Mov [num4] ,ax;
8 0113 0F 00 Ret
9 0115 00 00 Num1 : dw5
10 0117 00 00 Num2 : dw10

2019-CPE-27 usama saghar

You might also like