Computer Architectutre Manual 8 2019-Cpe-27 Muhammad Usama Saghar

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

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

Submission Detail

Submitted by Muhammad Usama Saghar

Roll no 2019-cpe-27

2019-CPE-27 usama saghar


Lab Manual 08
Objective:

Addition of Number directly in Memory (direct Addressing)

Theory:
A last variation using direct addressing shows that we can directly add a memory variable and a
register Instead of adding a register into another that we were doing till now.

Now we write the program such that the numbers 5, 10, and 15 ate stored directly in memory.

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+6], ax; , store first number in result

005 mov ax [num1+2] ; load second number in ax

006 add [num1+6]; , add second number in result

007 mov ax [num1+4] ; load third number in ax

008 mov [num1+6], ax add third number to result

009 ret

010 num1 dw 5,10,15,0

During execution we observe that the word data as it is read into a register is read in correct
orders-The change in this example is that the destination of addition is memory. Method
memory is direct addressing, whether it is the MOV instruction or the ADD instruction.

The first two instructions of the above program read a number into AX and placed it at another
memory location. A quick thought reveals that the following a possible single instruction to
replace the couple:

num1+6, num1 ; ILLEGAL

2019-CPE-27 usama saghar


However this form is illegal and not allowed an the Intel architecture. None of the general
operations of mov add, sub etc. allow moving data from memory to memory. Only register to
register, register to memory, memory to register, constant to memory, and constant to register
operations are allowed. The other register to constant, memory to constant, and memory to
memory are all disallowed. Only string instructions allow moving data from memory to
memory.

EXERCISE
1. Write the above program code for addition of numbers directly in memory 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 2 VRP (NDSEG)
2 00115 2 VRP (NDSEG)
3
4

Com list file

Instruction Location Machine code Source Code


1 0100 A1 15 01 Org loop
2 0103 A1 1B 01 Mov ax[num1];
3 0106 A1 17 01 Mov bx[num1+6];
4 1109 01 06 18 0 Add ax, bx;
5 010D C3 Mov bx,[num1+6];
6 0110 05 00 Add ax, bx;
7 0114 0A 00 Mov [num1+6] ,ax;
8 0115 0F 00 Ret
9 0117 00 00 Num1 : dw5
10 0119 00 00 Num2 : dw10

2019-CPE-27 usama saghar

You might also like