0% found this document useful (0 votes)
10 views5 pages

Exp 02u

The document outlines an experiment using EMU-8086 software to perform addition and subtraction of two 32-bit numbers. It details the objectives, theory, procedure, and source code for both operations, emphasizing the limitations of performing 32-bit arithmetic on a 16-bit architecture. The conclusion highlights the complexities involved in managing data and flags for accurate results in such operations.

Uploaded by

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

Exp 02u

The document outlines an experiment using EMU-8086 software to perform addition and subtraction of two 32-bit numbers. It details the objectives, theory, procedure, and source code for both operations, emphasizing the limitations of performing 32-bit arithmetic on a 16-bit architecture. The conclusion highlights the complexities involved in managing data and flags for accurate results in such operations.

Uploaded by

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

Experiment No: 02

Experiment Name: Experimental study of 32-bit Addition & Subtraction using EMULATOR
Software.

Objectives:

1. Perform addition and subtraction of two 32-bit numbers stored in memory and save the
results.
2. Explore addition operations using EMU-8086 software.
3. Understand the methods for handling addition and subtraction in this software.

Required Software: EMU-8086

Theory: The 8086 processor uses the ADD and SUB instructions for basic arithmetic. The ADD
command adds an immediate value, memory content, or register content to another register or
memory location, storing the result in the destination. However, it doesn't support memory-to-
memory addition, and segment registers cannot participate. Arithmetic flags are updated based on
the results. Similarly, the SUB instruction operates under the same constraints. For effective
addition or subtraction, one operand must first be moved to a register (e.g., AL or AX), where
operations are performed.

Procedure:

1. Input opcodes starting at memory location 2000 using win862 on the 8086 trainer kit.
2. Execute the program step-by-step with the GO command on the 8086 trainer kit.
3. Run the program in MASM611, using -T for single-step execution. Verify the registers to
confirm proper initialization.

Algorithm for Adding Two 32-bit Numbers:

1) Initialize the data segment.


2) Load the least significant byte (LSB) of the first number into AX.
3) Load the most significant byte (MSB) of the first number into BX.
4) Load the LSB of the second number into CX.
5) Load the MSB of the second number into DX.
6) Add the LSBs of the two numbers.
7) Add the MSBs along with the carry.
8) Display the result.
9) Stop.
Source Code:

For Addition:

MOV AX, 1234H


MOV BX, 5678H
MOV CX, 4687H
MOV DX, 8986H
ADD BX, DX
ADC AX, CX

For Subtraction:

MOV AX, 1234H


MOV BX, 5678H
MOV CX, 4687H
MOV DX, 8986H
SUB BX, DX
SBB AX, CX

Original Source & Output for ADDITION:

(a) (b)

Figure-2.1(a) Original source code for Addition and (b) Output for Addition.
Original Source & Output for SUBTRACTION:

(a) (b)

Figure-2.2(a) Original source code for Subtraction and (b) Output for Subtraction
Result Table:

Assembly Language Machine Code Kit output

MOV AX, 1234H B8 1234


34
12
MOV BX, 5678H BB 5678
78
56
MOV CX, 4687H B9 4687
87
46
MOV DX, 8986H BA 8986
86
89
ADD BX, DX 03 DF FE
DA

ADC AX, CX 13 58 BB
C1
MOV AX, 1234H B8 12324
34
12
MOV BX, 5678H BB 5678
78
56
MOV CX, 4687H B9 4687
87
46
MOV DX, 8986H BA 8986
86
89
SUB BX, DX 2B CC F2
DA
SBB AX, CX 1B CB AC
C1
Results & Discussion:
When performing 32-bit addition and subtraction in EMU8086, it is crucial to understand the
limitations and implications of working with 32-bit integers on a 16-bit architecture. The
EMU8086 processor, being a 16-bit processor, does not have native support for 32-bit operations.
As a result, 32-bit addition and subtraction operations need to be implemented through multiple
16-bit operations.

In this lab experiment we have seen the addition and subtraction of 32 bit numbers using
microprocessor 8086. Here we have given a code in EMU8086 software to perform addition
operation and a separate code to perform subtraction operation after which we can see the result
in the output. Then we have made the result table where assembly language, machine code and
kit output are arranged in separate columns. And this was the work of our lab experiment.

Conclusion:

In conclusion, while it is possible to perform 32-bit addition and subtraction in EMU8086 through
careful management of data and flags, it is important to be aware of the additional complexity and
considerations involved compared to working with native 16-bit operations. Proper handling of
carry flags, sign bits, and memory alignment is essential for accurate results when working with
32-bit arithmetic on a 16-bit processor architecture like EMU8086.

You might also like