University Name: [University of Bisha]
Faculty: College of Computer Science and Information Technology
Department: Computer Science
Project Title:
Addition of Two Numbers and Displaying the Result in Decimal using 8086 Assembly
Language
Supervisor: Dr. [Omnia Babkr]
Student(s):
Jumana Al-Ghamdi
Ghala Al-Qarni
Presentation Date: April 17, 2025
Table of Contents
1. Input
2. Description
3. Code
4. Output (Print Screen)
1. Input
The program accepts two single-digit numbers as input from the user
via the keyboard. This input process is handled using interrupt `INT
21h` with function `01h`, which reads a single character from standard
input (keyboard).
When a character is entered, it is returned in the `AL` register as an
ASCII value. To convert this ASCII character to its corresponding
numerical digit, the program subtracts the ASCII code of `'0'` (which is
48 in decimal) from the character.
For example, if the user enters the character '6', the ASCII value of '6' is
54. Subtracting '0' (48) gives 6, which is the actual integer value used in
the calculation.
The program performs this input process twice to read two digits. These
digits are then added together to produce the final result, which is
printed in decimal format.
Example Inputs:
- First Digit: 6
- Second Digit: 7
2. Description
This project demonstrates how to perform basic input, arithmetic, and
output operations in 8086 Assembly Language using DOS interrupts.
The key operations include:
- Prompting the user to enter two digits.
- Reading and converting ASCII input into integer values.
- Performing the addition operation.
- Converting the result back to a string in decimal format.
- Displaying the result on the screen.
The result is shown in human-readable decimal format, not hexadecimal
or raw binary.
To achieve this, the program uses:
- INT 21h for input and output operations.
- ASCII conversion via addition and subtraction of '0'.
- Stack-based technique to convert multi-digit numbers into decimal
format using division by 10.
This code can serve as a foundation for more complex arithmetic or
input/output logic in Assembly language.
3. Code
.model small
.stack 100h
.data
msg1 db 'Enter first digit: $'
msg2 db 0Dh,0Ah,'Enter second digit: $'
msg3 db 0Dh,0Ah,'Sum is: $'
.code
main:
mov ax, @data
mov ds, ax
lea dx, msg1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, '0'
mov bl, al
lea dx, msg2
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, '0'
add bl, al
lea dx, msg3
mov ah, 09h
int 21h
mov ax, 0
mov al, bl
call PrintDecimal
mov ah, 4Ch
int 21h
PrintDecimal:
mov cx, 0
mov bx, 10
next_digit:
xor dx, dx
div bx
push dx
inc cx
cmp ax, 0
jne next_digit
print_loop:
pop dx
add dl, '0'
mov ah, 02h
int 21h
loop print_loop
ret
end main
4. Output (Print Screen)
Enter first digit: 6
Enter second digit: 7
Sum is: 13