Page No:1
Page No:2
INDEX
SL Experiment Name Page No
1
Convert Lowercase to Uppercase and Vice Versa 3
2 Odd or Even Number Check 5
3 Compare Two Numbers and Display Smaller 7
4 ind Largest Element of an Array 9
5 Reverse a String 11
Page No:3
Assignment 1: Convert Lowercase to Uppercase and Vice Versa
Objective
To write an assembly language program to convert a lowercase letter to uppercase or vice
versa.
Algorithm
1. Start the program.
2. Read a character from the keyboard.
3. If it is lowercase, subtract 32 to make it uppercase.
4. If it is uppercase, add 32 to make it lowercase.
5. Display the result.
6. End the program.
Assembly Code (8086 - emu8086)
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB "Enter a character: $"
MSG2 DB 0DH,0AH,"Converted character: $"
CHAR DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
MOV CHAR, AL
CMP AL, 'a'
JL CHECK_UPPER
CMP AL, 'z'
JG CHECK_UPPER
SUB AL, 32
JMP DISPLAY
CHECK_UPPER:
CMP AL, 'A'
JL DISPLAY
CMP AL, 'Z'
JG DISPLAY
Page No:4
ADD AL, 32
DISPLAY:
LEA DX, MSG2
MOV AH, 9
INT 21H
MOV DL, AL
MOV AH, 2
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Sample Output
Enter a character: a
Converted character: A
Conclusion
This program successfully converts a lowercase letter to uppercase and vice versa using
ASCII value manipulation.
Page No:5
Assignment 2: Odd or Even Number Check
Objective
To write an assembly language program to determine whether a number is odd or even.
Algorithm
7. Start the program.
8. Input a number from the user.
9. Divide the number by 2.
10. Check the remainder.
11. If remainder is 0, number is even; else, it is odd.
12. End the program.
Assembly Code (8086 - emu8086)
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB "Enter a number: $"
EVEN_MSG DB 0DH,0AH,"Number is Even.$"
ODD_MSG DB 0DH,0AH,"Number is Odd.$"
NUM DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
SUB AL, 30H
MOV NUM, AL
MOV AH, 0
MOV AL, NUM
MOV BL, 2
DIV BL
CMP AH, 0
JZ EVEN_LABEL
LEA DX, ODD_MSG
MOV AH, 9
INT 21H
Page No:6
JMP EXIT
EVEN_LABEL:
LEA DX, EVEN_MSG
MOV AH, 9
INT 21H
EXIT:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Sample Output
Enter a number: 5
Number is Odd.
Conclusion
This program determines whether a given single-digit number is odd or even by checking
the remainder after division by 2.
Page No:7
Assignment 3: Compare Two Numbers and Display Smaller
Objective
To write an assembly language program to input two numbers, compare them and display
the smaller one.
Algorithm
13. Start the program.
14. Input the first number.
15. Input the second number.
16. Compare the two numbers.
17. If the first number is smaller, display it.
18. Else display the second number.
19. End the program.
Assembly Code (8086 - emu8086)
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB "Enter first number: $"
MSG2 DB 0DH,0AH,"Enter second number: $"
MSG_SM DB 0DH,0AH,"Smaller number is: $"
NUM1 DB ?
NUM2 DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
SUB AL, 30H
MOV NUM1, AL
LEA DX, MSG2
MOV AH, 9
INT 21H
MOV AH, 1
INT 21H
SUB AL, 30H
MOV NUM2, AL
Page No:8
MOV AL, NUM1
CMP AL, NUM2
JL FIRST_SMALLER
MOV AL, NUM2
JMP DISPLAY
FIRST_SMALLER:
MOV AL, NUM1
DISPLAY:
ADD AL, 30H
LEA DX, MSG_SM
MOV AH, 9
INT 21H
MOV DL, AL
MOV AH, 2
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Sample Output
Enter first number: 5
Enter second number: 8
Smaller number is: 5
Conclusion
This program compares two single-digit numbers and displays the smaller one.
Page No:9
Assignment 4: Find Largest Element of an Array
Objective
To write an assembly language program to find the largest element of an array.
Algorithm
20. Start the program.
21. Initialize an array of numbers.
22. Assume the first element as the largest.
23. Compare each element with the current largest.
24. If a larger element is found, update the largest.
25. Display the largest element.
26. End the program.
Assembly Code (8086 - emu8086)
.MODEL SMALL
.STACK 100H
.DATA
ARR DB 5, 9, 3, 7, 1
LEN DB 5
MSG DB "Largest element is: $"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV CX, LEN
MOV SI, 0
MOV AL, ARR[SI]
NEXT:
INC SI
CMP ARR[SI], AL
JLE SKIP
MOV AL, ARR[SI]
SKIP:
LOOP NEXT
LEA DX, MSG
MOV AH, 9
INT 21H
ADD AL, 30H
MOV DL, AL
MOV AH, 2
INT 21H
Page No:10
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Sample Output
Largest element is: 9
Conclusion
This program scans through an array of numbers and finds the largest element.
Page No:11
Assignment 5: Reverse a String
Objective
To write an assembly language program to accept a string from keyboard and display the
string in reverse order.
Algorithm
27. Start the program.
28. Prompt the user to enter a string.
29. Store the string in memory.
30. Find the length of the string.
31. Reverse the string by printing from the last character to the first.
32. End the program.
Assembly Code (8086 - emu8086)
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB "Enter a string: $"
MSG2 DB 0DH,0AH,"Reversed string: $"
STR DB 20 DUP('$')
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 9
INT 21H
MOV SI, 0
READ_LOOP:
MOV AH, 1
INT 21H
CMP AL, 0DH
JE DONE_READ
MOV STR[SI], AL
INC SI
JMP READ_LOOP
DONE_READ:
MOV CX, SI
DEC SI
LEA DX, MSG2
MOV AH, 9
Page No:12
INT 21H
PRINT_LOOP:
MOV DL, STR[SI]
MOV AH, 2
INT 21H
DEC SI
LOOP PRINT_LOOP
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Sample Output
Enter a string: HELLO
Reversed string: OLLEH
Conclusion
This program reads a string from the user and prints it in reverse order.