Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Outstanding Achiever Lab Report

Uploaded by

malikuzair1242
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)
13 views5 pages

Outstanding Achiever Lab Report

Uploaded by

malikuzair1242
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/ 5

Name Uzair Malik

Class Bcs-4B
Reg.No Sp23-Bcs-065
-----------------------------------------------------------------------------------------------------------

Lab Report
Title:
Arithmetic Operations and Digit Manipulation Using EMU8086

Objective:
The objective of this lab is to perform basic arithmetic operations using the EMU8086
assembler and display the result in a user-readable format by converting it into ASCII.
This includes separating the result into its individual digits and printing them,
demonstrating knowledge of data manipulation and system-level programming.

Equipment & Software:


1. EMU8086 Microprocessor Emulator.
2. Personal Computer with a Windows operating system.
3. Assembly programming knowledge and logical analysis skills.

Introduction:
Assembly language provides a direct means to interface with hardware, offering
unparalleled control over the system. This experiment involves adding two numbers,
separating the resulting sum into its individual digits, and converting these digits into a
human-readable ASCII format. The program also demonstrates effective use of
interrupts, register manipulation, and memory allocation.

Code:

.MODEL SMALL
.STACK 100H
DATA SEGMENT
num1 DW 5
num2 DW 10
result DW ?
newline DB 13, 10, '$'
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA, CS:CODE

MAIN PROC
MOV AX, DATA
MOV DS, AX

CALL sum
CALL separate_digits

; Print the first digit


MOV AL, AH
ADD AL, '0'
MOV DL, AL
MOV AH, 02H
INT 21H
MOV AL, BL
ADD AL, '0'
MOV DL, AL
MOV AH, 02H
INT 21H

; Print a newline
LEA DX, newline
MOV AH, 09H
INT 21H

HLT
MAIN ENDP

sum PROC
MOV AX, num1
ADD AX, num2
MOV result, AX
RET
sum ENDP

separate_digits PROC
MOV AX, result
XOR DX, DX
MOV BX, 10
DIV BX
MOV BL, DL
MOV AH, AL
RET
separate_digits ENDP

CODE ENDS
END MAIN

Procedure:

1. Initialization:
- The `.MODEL SMALL` directive and `.STACK` space were defined for program
structure.
- Data such as `num1`, `num2`, and the `result` variable were defined in the DATA
SEGMENT.
- The ASCII newline was defined to improve readability.

2. Addition:
- The program calculates the sum of `num1` and `num2` using the `sum` procedure.
- The result is stored in the `result` variable.

3. Digit Separation:
- The program separates the two digits of the result using the `separate_digits` procedure.
- Division by `10` is used to extract the quotient (tens place) and remainder (units place).

4. ASCII Conversion:
- Each digit is converted to its ASCII equivalent by adding the character `'0'` (ASCII 48).
- The digits are stored in the `digit_string` array.

5. Output:
- The program uses the interrupt `21H` with function `09H` to display the ASCII digits
on the screen.
- A newline is printed to maintain output clarity.

Output:
The program adds the numbers 5 and 10, giving a result of “15”. The output
displayed on the screen is:

15
Analysis:
- Registers Used:
- `AX`: Accumulator for arithmetic operations and holding the result.
- `BX`: Used as a divisor.
- `DX`: Stores the remainder during division.
- `BL` and `AH`: Hold the separated digits of the result.

- Interrupts:
The program utilizes software interrupt `21H` to display strings. This showcases mastery
of BIOS services for I/O operations.

- Error Handling:
Proper initialization of registers ensures accurate results and avoids division errors.

Conclusion:
The experiment demonstrates effective use of assembly language to perform arithmetic
operations and manipulate data at a low level. By combining arithmetic procedures with
digit manipulation, the program provides a deeper understanding of how computers
process numeric data. The ability to convert numeric results into ASCII output bridges
the gap between machine and user interaction, highlighting the relevance of assembly
programming in system-level applications.

You might also like