Ex 02
Ex 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:
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. 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, 32-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.
Source Code:
For Addition:
For Subtraction:
SUB BX, DX
SBB AX, CX
Original Source & Output for ADDITION:
Figure-2.1(a) Original source code for Addition and Output for Addition.
Figure-2.1(b) Original source code for Subtraction and Output for Subtraction.
Result Table:
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
Result and Discussion:
The experimental study successfully demonstrated 32-bit addition and subtraction using emulator
software. The results obtained from the emulator matched the expected theoretical values. No carry or
overflow was observed in normal cases, but special conditions like adding the maximum signed integer
resulted in an overflow flag (OF = 1), and subtracting a larger number from a smaller one triggered the
carry flag (CF = 1). This confirms that the emulator accurately simulates arithmetic operations at the
processor level, providing insights into how modern CPUs handle data.
Conclusion:
This experiment effectively illustrated the execution of 32-bit addition and subtraction at the assembly
language level. By analyzing the results, we observed how carry, borrow, and overflow flags behave
during arithmetic operations. Understanding these concepts is crucial for low-level programming,
microprocessor design, and embedded system development, making emulator software a valuable tool for
learning computer architecture assembly and language.