Lab Report
Lab Report
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
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
MOV AL, BL
SUB AL, BH
ADD AL, 30H
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
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:
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
Conclusion:
The program correctly converts uppercase letters to lowercase. This experiment demonstrates character
manipulation in the 8086 microprocessor.
Experiment No: 03
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:
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
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
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
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:
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
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:
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
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:
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
Conclusion:
Objective:
Procedure:
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
Conclusion
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:
Assembly Code:
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.