0% found this document useful (0 votes)
15 views

Lab Report

Uploaded by

umor2026
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)
15 views

Lab Report

Uploaded by

umor2026
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/ 16

Experiment No: 01

Name of the Experiment: Subtraction of Two Single Digits Using 8086 Microprocessor

Objective:

To write an assembly program for the 8086 microprocessor to take two single-digit inputs, subtract them,
and display the result.

Theory:

In the ASCII table, digits ('0' to '9') have values ranging from 48 to 57. To perform arithmetic operations,
the ASCII values need to be converted to their decimal equivalents by subtracting 48. After the
subtraction, the result is converted back to ASCII by adding 48. DOS interrupts are used for input and
output.

Equipment/Software:

 Software: Emulator

Procedure

 Read two single-digit inputs using INT 21H.


 Convert ASCII values to decimal.
 Perform subtraction on the two digits.
 Convert the result to ASCII for display.
 Display the result using INT 21H.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
PROMPT1 DB 'Enter first digit: $'
PROMPT2 DB 'Enter second digit: $'
RESULT_PROMPT DB 'The result is: $'
NEWLINE DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT1


MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
SUB AL, 30H
MOV BL, AL

LEA DX, NEWLINE


MOV AH, 09H
INT 21H
LEA DX, PROMPT2
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
SUB AL, 30H
MOV BH, AL

MOV AL, BL
SUB AL, BH
ADD AL, 30H

LEA DX, NEWLINE


MOV AH, 09H
INT 21H
LEA DX, RESULT_PROMPT
MOV AH, 09H
INT 21H
MOV DL, AL
MOV AH, 02H
INT 21H

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program successfully takes two single-digit inputs, subtracts them, and displays the result. This
experiment demonstrates the ability to handle arithmetic operations and input/output using the 8086
microprocessor.
Experiment No: 02

Name of the Experiment: Convert Uppercase to Lowercase Using 8086 Microprocessor

Objective:

To develop an assembly program for the 8086 microprocessor to accept an uppercase letter as input and
print its corresponding lowercase letter.

Theory:

In the ASCII table, uppercase letters ('A' to 'Z') have values from 65 to 90, while lowercase letters ('a' to
'z') have values from 97 to 122. Adding 32 to the ASCII value of an uppercase letter converts it to its
corresponding lowercase letter.

Equipment/Software:

 Software: Emulator

Procedure:

 Accept an uppercase letter using INT 21H.


 Check if the input is within the uppercase range ('A'-'Z').
 Add 32 to the ASCII value for conversion.
 Display the resulting lowercase letter.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
PROMPT1 DB 'Enter an uppercase letter: $'
RESULT_PROMPT DB 'The lowercase letter is: $'
NEWLINE DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT1


MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV BL, AL
ADD BL, 20H

LEA DX, NEWLINE


MOV AH, 09H
INT 21H
LEA DX, RESULT_PROMPT
MOV AH, 09H
INT 21H
MOV DL, BL
MOV AH, 02H
INT 21H

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program correctly converts uppercase letters to lowercase. This experiment demonstrates character
manipulation in the 8086 microprocessor.
Experiment No: 03

Name of the Experiment: Convert Hexadecimal to Decimal Using 8086 Microprocessor

Objective:

To write an assembly program for the 8086 microprocessor to accept a hexadecimal digit ('A'-'F') as input
and print its corresponding decimal value.

Theory:

Hexadecimal digits ('A'-'F') represent decimal values 10 to 15. To convert a hex character to decimal:

 If the input is a letter ('A'-'F'), subtract 55 from its ASCII value (since 'A' = 65 and 65 - 55 = 10).

Equipment/Software:

 Software: Emulator

Procedure:

 Accept a hex character ('A'-'F') using INT 21H.


 Convert the hex character to its decimal equivalent using subtraction.
 Display the decimal value as a character string.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Enter a hex digit (A-F): $'
RESULT_PROMPT DB 'Decimal value is: $'
NEWLINE DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT


MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV BL, AL
SUB BL, 37H

LEA DX, NEWLINE


MOV AH, 09H
INT 21H
LEA DX, RESULT_PROMPT
MOV AH, 09H
INT 21H
ADD BL, 30H
MOV DL, BL
MOV AH, 02H
INT 21H

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program successfully converts a hex digit ('A'-'F') into its corresponding decimal value and displays it.
This experiment demonstrates handling and conversion of hexadecimal input in the 8086 microprocessor.
Experiment No: 04

Name of the Experiment: Find the Largest Value Among Three Numbers Using 8086
Microprocessor

Objective:

To develop an assembly program for the 8086 microprocessor to accept three inputs and determine the
largest value.

Theory:

Comparison of numerical values in the 8086 microprocessor is done using the CMP instruction. The
larger value can be identified and stored based on the result of the comparison, using conditional jumps
like JG (Jump if Greater) or JL (Jump if Less).

Equipment/Software:

 Software: Emulator

Procedure:

 Accept three single-digit inputs from the user using INT 21H.
 Convert ASCII values to decimal by subtracting 48.
 Compare the three numbers using CMP and conditional jumps to find the largest.
 Display the largest value on the screen.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
PROMPT1 DB 'Enter first value: $'
PROMPT2 DB 'Enter second value: $'
PROMPT3 DB 'Enter third value: $'
RESULT_PROMPT DB 'The largest value is: $'
NEWLINE DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT1


MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
SUB AL, 30H
MOV BL, AL
LEA DX, NEWLINE
MOV AH, 09H
INT 21H
LEA DX, PROMPT2
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
SUB AL, 30H
CMP BL, AL
JG NEXT1
MOV BL, AL

NEXT1:
LEA DX, NEWLINE
MOV AH, 09H
INT 21H
LEA DX, PROMPT3
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
SUB AL, 30H
CMP BL, AL
JG NEXT2
MOV BL, AL

NEXT2:
LEA DX, NEWLINE
MOV AH, 09H
INT 21H
LEA DX, RESULT_PROMPT
MOV AH, 09H
INT 21H
ADD BL, 30H
MOV DL, BL
MOV AH, 02H
INT 21H

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion

The program successfully identifies and displays the largest value among three inputs. It demonstrates comparison
and conditional branching using the 8086 microprocessor.
Experiment No: 05

Name of the Experiment: Identify Odd or Even Digits in User Input Using 8086 Microprocessor

Objective:

To write an assembly program for the 8086 microprocessor to check if the user's input is odd or even and display the
result.

Theory:

Odd numbers end with digits 1, 3, 5, 7, 9, while even numbers end with digits 0, 2, 4, 6, 8. In assembly, conditional
branching is used to compare the input with these ranges and determine the result.

Equipment/Software:

 Software: Emulator

Procedure:

 Accept a single-digit input using INT 21H.


 Compare the input with ASCII values of odd digits (1, 3, 5, 7, 9) and even digits (0, 2, 4, 6, 8) using the
CMP instruction.
 Display "odd" or "even" accordingly.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Enter a digit: $'
ODD_MSG DB 'odd$', EVEN_MSG DB 'even$'
NEWLINE DB 13, 10, '$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX

LEA DX, PROMPT


MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV BL, AL

CMP BL, '1'


JE ODD
CMP BL, '3'
JE ODD
CMP BL, '5'
JE ODD
CMP BL, '7'
JE ODD
CMP BL, '9'
JE ODD

LEA DX, NEWLINE


MOV AH, 09H
INT 21H
LEA DX, EVEN_MSG
MOV AH, 09H
INT 21H
JMP EXIT

ODD:
LEA DX, NEWLINE
MOV AH, 09H
INT 21H
LEA DX, ODD_MSG
MOV AH, 09H
INT 21H

EXIT:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program successfully identifies whether the input is odd or even, demonstrating input evaluation and
conditional branching in the 8086 microprocessor.
Experiment No: 06

Name of the Experiment: Compute the Sum 1+4+7+…+148 Using 8086 Microprocessor

Objective:

To write an assembly program for the 8086 microprocessor to calculate the sum of an arithmetic sequence with a
common difference of 3, starting from 1 up to 148, and store the result in the AX register.

Theory:

An arithmetic sequence has the formula: [S = n/2×(a+l)]Where n is the number of terms, a is the first term, and l is
the last term. Here, the program iteratively computes the sum using a loop.

Equipment/Software:

 Software: Emulator

Procedure:

 Initialize AX to 0 for storing the sum.


 Use CX to store the current term, starting from 1.
 Add each term to AX and increment by 3 until the term exceeds 148

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV AX, 0
MOV CX, 1
NEXT_TERM:
ADD AX, CX
ADD CX, 3
CMP CX, 149
JL NEXT_TERM

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion: The program successfully calculates the sum of the arithmetic sequence 1+4+7+…+148, demonstrating
iteration and accumulation in the 8086 microprocessor.
Experiment No: 07

Name of the Experiment: Print Characters A-Z, a-z, 0-9 Using a For Loop.

Objective:

To display the characters 'A-Z', 'a-z', and '0-9' sequentially using a for loop in the 8086 microprocessor.

Theory:

Each character has a specific ASCII value. A loop can be used to iterate through these values and print each
character using INT 21H.

Equipment/Software:

 Software: Emulator

Procedure:

 Use three loops: one for uppercase letters, one for lowercase letters, and one for digits.
 Use MOV DL and INT 21H for printing each character.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV CX, 26
MOV DL, 'A'
PRINT_UPPER:
MOV AH, 02H
INT 21H
INC DL
LOOP PRINT_UPPER

MOV CX, 26
MOV DL, 'a'
PRINT_LOWER:
MOV AH, 02H
INT 21H
INC DL
LOOP PRINT_LOWER

MOV CX, 10
MOV DL, '0'
PRINT_DIGITS:
MOV AH, 02H
INT 21H
INC DL
LOOP PRINT_DIGITS

; End program
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program successfully displays characters 'A-Z', 'a-z', and '0-9' sequentially using loops.
Experiment No: 08

Name of the Experiment: Compute the Sum 100+95+90+…+5 Using 8086 Microprocessor.

Objective:

To calculate the sum of an arithmetic sequence with a common difference of (−5), starting at 100 and
ending at 5.

Theory:

This sequence can also be calculated iteratively by decrementing the term by 5 in each iteration until it
reaches 5.

Procedure:

 Initialize AX to 0 for storing the sum.


 Use CX to store the current term, starting from 100.
 Add each term to AX and decrement by 5 until the term is less than 5.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV AX, 0
MOV CX, 100
NEXT_TERM:
ADD AX, CX
SUB CX, 5
CMP CX, 5
JGE NEXT_TERM

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion:

The program successfully calculates the sum 100+95+90+…+5.


Experiment No: 09

Name of the Experiment: Display a Character 80 Times

Objective:

To display a user-input character 80 times on the next line.

Procedure:

 Accept a character input using INT 21H.

 Use a loop to print the character 80 times using MOV DL and INT 21H.

Assembly Code:

.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV AH, 01H
INT 21H
MOV BL, AL

MOV CX, 80
MOV DL, BL
MOV AH, 02H
INT 21H
LOOP PRINT_CHAR

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion

The program correctly displays a character 80 times.


Experiment No: 10

Name of the Experiment: Compute the Sum of the First 50 Terms of the Sequence 1,5,9,13,…
Using 8086 Microprocessor.

Objective:

To compute the sum of the first 50 terms of an arithmetic sequence with a common difference of
4, starting at 1.

Theory:

The sum of an arithmetic sequence can be iteratively computed by adding the next term until the
required count is reached.

Procedure:

1. Initialize AX to 0 for storing the sum.


2. Use CX to count the terms, starting from 1 to 50.
3. Add each term to AX, incrementing by 4.

Assembly Code:

.MODEL SMALL.STACK 100H.DATA.CODE


MAIN PROC
MOV AX, 0
MOV CX, 50
ADD AX, BX
ADD BX, 4
LOOP NEXT_TERM

MOV AH, 4CH


INT 21H
MAIN ENDP
END MAIN

Conclusion

The program successfully computes the sum of the first 50 terms of the sequence 1,5,9,13,…1, 5,
9, 13, \ldots1,5,9,13,…, showcasing effective use of loops in arithmetic operations.

You might also like