0% found this document useful (0 votes)
12 views8 pages

Micro 2

The document describes an experiment on addition and subtraction of 16-bit and 32-bit numbers using memory locations. It discusses register and memory addressing modes, and how addition and subtraction instructions like ADD, SUB, ADC work. The experiment was conducted using emu8086 software. For 16-bit numbers, addition and subtraction were performed simultaneously, storing results in registers at memory locations 0110H and 0113H. Similarly, 32-bit addition and subtraction were performed, storing results in registers at memory locations 0100:0024 and 0100:0016. The experiment demonstrated successful addition and subtraction of 16-bit and 32-bit numbers using memory locations.

Uploaded by

MD MASUD ALAM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views8 pages

Micro 2

The document describes an experiment on addition and subtraction of 16-bit and 32-bit numbers using memory locations. It discusses register and memory addressing modes, and how addition and subtraction instructions like ADD, SUB, ADC work. The experiment was conducted using emu8086 software. For 16-bit numbers, addition and subtraction were performed simultaneously, storing results in registers at memory locations 0110H and 0113H. Similarly, 32-bit addition and subtraction were performed, storing results in registers at memory locations 0100:0024 and 0100:0016. The experiment demonstrated successful addition and subtraction of 16-bit and 32-bit numbers using memory locations.

Uploaded by

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

Heaven’s Light is Our Guide

Rajshahi University of Engineering & Technology

Lab Report
Department of Electrical & Electronic Engineering

Course No.: EEE 3210

Course Title: Microprocessor, Interfacing and System design


Sessional

Experiment No.: 02

Experiment Name: Addition and Subtraction of 16 bit


Number using Memory location

Submitted by: Submitted to:


Md. Sabbir Hossain Belal Hossain
Roll No.: 1801124 Assistant Professor,
Section : C Dept. of EEE, RUET.
Class: 3rd Year,
Even Semester,
Session :2018-19

Date of Experiment: 19-10-2022


Date of Submission: 26-10-2022
Page |2

Experiment No.: 02
Experiment Name.: Addition and Subtraction of 16bit Number using Memory location

Objectives:
1. To familiarize with register and memory locations.
2. To know about different type of command.
3. To perform addition and subtraction using memory location.

Requirements:
1. Emu-8086 application.
2. PC/Laptop.
Theory: The assembly level programming of the 8086 makes use of memory registers. A register is
a memory-based component that allows data to be captured and stored more quickly in
microprocessors and controllers. The 8086 is the first CPU in the Intel series. All of the registers of
the 8086 are 16 bits. General Purpose, Index, Status & Control, and Segment are the four categories
they fall into.
Using different addressing modes, programmers can choose to reference data differently, as required
by the program. Most assembly instructions that require operands follow this syntax, where inst is
the instruction name, dest denotes the destination, and src denotes the source: inst dest src
However, the operand may reside in memory, a register, or may be a constant. Depending on the
type of operand an instruction is operating on, addressing in assembly language can be performed in
three modes, as shown in below:
Mode Operand Description
Register Addressing Stored in a register.
Memory Addressing Resides in memory
Immediate Addressing Is a constant or expression

Register addressing: The following MOV instruction makes uses of register addressing to move
the data referred to by SP into CX: MOV CX, SP. The addressing mode used here is register
addressing as the destination operand is a register. Another example of register addressing would be
the INC instruction, which increments the value of a specified register.

Memory addressing: In memory addressing, the second operand is a memory location and is
usually represented by a variable name. Subsequently, this addressing mode requires access to
the data segment of the program. Here is an example of a MOV instruction that copies data from the
variable BILL stored in the data segment to the register AX: MOV AX, BILL.

Immediate addressing: In immediate addressing, the second operand of the instruction is a


constant. The first operand may reside in a register or the memory segment. The following snippet of
code demonstrates how immediate addressing may be used to change the value of a register and a
memory location: MOV AX 37; ADD NUM 37.The value of the register AX and the memory
location pointed to by the variable NUM (its previous value was 0) has been set to 37, which is % in
ASCII.
Page |3

Fig. 2.1: Memory map.

We use ADD instruction for addition and SUB instruction for subtraction. ADD instruction adds an
immediate data or contents of a memory location specified in the instruction or a register (source) to
the contents of another register (destination) or memory location. The result is in the destination
operand. However, both the source and destination operands cannot be memory operands. That
means memory to memory addition is not possible. Also the contents of the segment registers cannot
be added using this instruction. All the condition code flags are affected depending upon the result.
Hence one of the operands is initially moved to AL OR AX. Then using the add instruction, 8 bit or
16-bit addition is performed. The next arithmetic primitive is SUB. As discussed in ADD it permits
the same modes of addressing. Hence moving the minuend to a register pair is necessary. Then the
result is moved to a location in memory.

The syntax of ADD and ADC (add with carry) is similar to mov. Like MOV, there are special forms
for the AX/EAX register that are more efficient. Unlike mov, you cannot add a value to a segment
register with these instructions.

The ADD instruction adds the contents of the source operand to the destination operand. For
example, add ax, bx adds bx to ax leaving the sum in
the ax register. Add computes dest :=dest+source while adc computes dest :=dest+source+C where
C represents the value in the carry flag. Therefore, if the carry flag is clear before
execution, adc behaves exactly like the add instruction.

The SUB (subtract), SBB (subtract with borrow), dec (decrement), aas (ASCII adjust for
subtraction), and das (decimal adjust for subtraction) instructions work as expect. Their syntax is
very similar to that of the add instructions. The sub instruction computes the value dest := dest - src.
The sbb instruction computes dest := dest - src - C. Note that subtraction is not commutative. If any
want to compute the result for dest := src - dest then need to use several instructions, assuming need
to preserve the source operand.
Page |4

Program with Command Field:

For 16bit number:

Fig.2.2: Input code for addition and subtraction of 16bit number.


Output:

Fig.2.3: Output for addition and subtraction of 16bit number.


Page |5

Fig.2.4: Memory address for particular segment [0100:0016].

Program with Command Field:

For 32bit number:

Fig.2.5: Input code for addition of 32bit number.


Page |6

Output:

Fig.2.6: Output for addition of 32bit number.

Fig.2.7: Memory address for particular segment [0100:0024].


Page |7

Fig.2.8: Input code for subtraction of 32bit number.

Fig.2.6: Output for subtraction of 32bit number.


Page |8

Fig.2.4: Memory address for particular segment [0100:0016]

Discussion: In this experiment, the addition and subtraction of 16bit number and 32bit number was
studied using memory location. Two Hexadecimal values were added and subtracted simultaneously
for 16bit number in this experiment. This was performed on a computer program that was executed
using the emu8086 software, and then the machine code was shown in Fig.2.4. Here, the resulted
value for addition was stored in CX register with specified memory location [0110H] and for
subtraction was stored in DX register with specified memory location [0113H]. Similarly both the
addition and subtraction of 32bit number was performed successfully in this experiment. After all,
this experiment was performed successfully.

You might also like