Lab Manual for
Microprocessor Assembly Programming Lab
CSE0613210
Program 01: Write an assembly program to print a String declared
under the data segment.
Code:
.MODEL SMALL
.STACK 100h
.DATA
MSG DB "THIS IS A MESSAGE$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH, 9
LEA DX, MSG
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Program 02: Write an assembly program to take input from user
and print it on the console.
Code:
.MODEL SMALL
.STACK 100h
.DATA
.CODE
MAIN PROC
MOV AH, 1
INT 21H
MOV BL, AL
MOV AH, 2
MOV DL, 0AH
INT 21H
MOV DL, 0DH
INT 21H
MOV DL, BL
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Program 03: Write an assembly program so that if AL contains 2 or
4, the output shows even. If AL contains 3 or 5, the output shows
odd.
Code:
.MODEL SMALL
.STACK 100H
.DATA
EVEN DB "EVEN$"
ODD DB "ODD$"
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AL, 2
MOV AH, 9
CMP AL, 3
JE PRINT_ODD
CMP AL, 5
JE PRINT_ODD
CMP AL, 2
JE PRINT_EVEN
CMP AL, 4
JE PRINT_EVEN
PRINT_EVEN:
LEA DX, EVEN
INT 21H
JMP EXIT
PRINT_ODD:
LEA DX, ODD
INT 21H
JMP EXIT
EXIT:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Program 02: Write an assembly program to read a character. If it is
in uppercase, convert it to lowercase, and if it is in lowercase,
convert it to uppercase.
Code:
.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
MOV AH, 1
INT 21H
CMP AL, 65
JL EXIT
CMP AL, 90
JG CHECK_LOWER
JMP CONVERT_LOWER
CHECK_LOWER:
CMP AL, 97
JL EXIT
CMP AL, 122
JG EXIT
JMP CONVERT_UPPER
CONVERT_LOWER:
ADD AL, 32
MOV AH, 2
MOV DL, AL
INT 21H
JMP EXIT
CONVERT_UPPER:
SUB AL, 32
MOV AH, 2
MOV DL, AL
INT 21H
EXIT:
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN