Adding Two 16 Bit Numbers Using 8086 Processor
Adding Two 16 Bit Numbers Using 8086 Processor
This document provides a detailed program for adding two 16-bit numbers using the Intel 8086 microprocessor assembly
language. It includes the program's objective, the complete assembly code, and the expected output. The guide is designed
for enthusiasts and learners interested in low-level programming and understanding arithmetic operations on early
microprocessors.
DB by Dipankar Bala
Objective
The primary objective of this program is to demonstrate how to add two 16-bit numbers using assembly language
instructions specific to the 8086 processor. This will help learners understand the process of handling multi-byte
arithmetic operations in a processor architecture that naturally works with 16-bit registers.
This exercise illustrates fundamental concepts such as register usage, arithmetic operations, and basic assembly
programming techniques on the 8086 microprocessor.
Assembly Program to Add Two 16-bit Numbers on 8086
The following is a complete assembly program that adds two 16-bit numbers and stores the result in a register. It
assumes the use of standard 8086 registers and syntax compatible with common assemblers such as MASM or TASM.
.MODEL SMALL
.STACK 100H
.DATA
num1 DW 1234H ; First 16-bit number (4660 decimal)
num2 DW 5678H ; Second 16-bit number (22136 decimal)
result DW 0 ; To store the result
.CODE
MAIN PROC
MOV AX, @DATA ; Initialize data segment
MOV DS, AX
This program starts by defining two 16-bit data words, num1 and num2, with example hexadecimal values. The code
segment initializes the data segment register DS to access the data variables properly.
The actual addition is done by moving the first number into register AX, then using the ADD instruction to add the second
number. The sum is then moved to the memory location 'result'. Finally, the program terminates gracefully by calling
DOS interrupt 21h, function 4Ch.
This program can be assembled and run in an 8086 emulator or real hardware for practical demonstration.
Expected Output
When this program executes, the sum of the two 16-bit numbers 0x1234 and 0x5678 will be calculated and stored in the
variable 'result'. Specifically:
The hexadecimal representation of the result is 0x68AC. This value is stored in the 'result' variable in memory.
To verify the output, you can use a debugger or emulator to inspect the memory address of 'result' after program
execution or modify the program to output the value to a display or port.
This simple yet fundamental program serves as a foundation for understanding arithmetic operations in assembly
language and provides practical insight into 16-bit computations on the 8086 microprocessor.