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

Submission Details

Submitted by Muhammad Usama Saghar

Roll No. 2019-CPE-27

2019-CPE-27 usama saghar


LAB Manual 06
Objective:

Addition of Number Using Memory Variables (direct Addressing)

Direct Addressing:
Direct addressing. is So-named because the value to be stored in memory is obtained by
directly
retrieving it from another memory location. For example:
mov A,30h (mov ax, num)

This instruction will read the data out of Internal RAM address 30 (hexadecimal) and store it in
the
Accumulator.

Direct addressing is generally fast since, although the value to be loaded is not included in the
instruction, it is quickly accessible since It is; stored in the Internal RAM. It is also much more
flexible than Immediate Addressing the value to be loaded is whatever is found at the given
address - which
may be variable.
Now we write the program such that the numbers 5, 10, and 15 are stored as memory variables
instead
of constants and we access them from there.

001 ; a program to add three numbers using memory variables

002 org 100h

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

004 mov bx, [num21 ; load second number in

005 add ax, bx ; accumulate sum in ax

006 mov bx, [num3] ; load third number in bx

007 add ax, bx ; accumulate sum in ax

008 mov [num4], ax ; store sum in num4

009 ret

2019-CPE-27 usama saghar


010 num1 dw 5
011 num2 dw 10

012 num3 dw 15

013 num4 dw 0

In above program, source Is changed from constant 5 to num1. It is signaling that the
operand Is placed in memory address num1. The value 5 will be loaded In ax even though we
did not
specified It in our code, rather the value will be picked from memory. The instruction should be
read as "read the 21 location num1 in the ax label num1 is a symbol for
us but an address for the processor while the conversion is done by the assembler. The label
num1 is
defined as a word the assembler, requested to place 5 In that memory location.

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 00112 -1 LABEL (NOSEG)
2 00114 -1 LABEL (NOSEG)
3 00116 -1 LABEL (NOSEG)
4 00118 -1 LABEL (NOSEG)
5
6
7
8
9
10

2019-CPE-27 usama saghar


Com List File
Instruction Location Machine code Source Code
1 0100 BB 12 01 Org loop
2 0103 BB 14 01 Mov ax[num1];
3 0106 03 C3 Mov bx[num2];
4 1108 89 06 18 01 Add ax, bx;
5 0101 C3 Mov bx,[num3];
6 0111 05 00 Add ax, bx;
7 0112 0A 00 Mov [num4] ,ax;
8 0114 0F 00 Ret
9 0116 00 00 Num1 : dw5
10 0118 00 00 Num2 : dw10

2019-CPE-27 usama saghar

You might also like