Professional Documents
Culture Documents
MP-19CS407 Lab Manual 2020 - 21
MP-19CS407 Lab Manual 2020 - 21
LAB MANUAL
Semester: IV Year: 2020-21
Course Objectives:
This Course will enable students to:
1. Develop assembly level language program for 8086 using arithmetic, logical shifts and
rotate instructions.
2. Develop assembly level language program for 8086 using macro, interrupts, String
handling and flag set/reset instructions.
3. Analyze the working of miscellaneous instructions like XLAT.
4. Interface 8086 microprocessor to external I/O devices logic controller, seven segment
display.
5. Interface 8086 microprocessor to external I/O devices stepper motor, keypad.
Course Outcomes:
At the end of the course the student will be able to:
1. Develop assembly level language program for 8086 using arithmetic, logical shifts and
rotate instructions.
2. Develop assembly level language program for 8086 using macro, interrupts, String
handling and flag set/reset instructions.
3. Analyze the working of miscellaneous instructions like XLAT.
4. Interface 8086 microprocessor to external I/O devices logic controller, seven segment
display.
5. Interface 8086 microprocessor to external I/O devices stepper motor, keypad.
Page 1 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
1. Search a key element in a list of ‘n’ 16-bit numbers using the Linear search
algorithm. (Display only Success or Unsuccessful message)
i. To read a character from the keyboard in the module (1) (different file).
iii. Use the above two modules to read a string of characters from the
keyboard terminated by the carriage return and print the string on the
display in the next line.
3. Read an alphanumeric character and display its equivalent ASCII code at the
center of the screen.
5. Read your name from the keyboard and display it at a specified location on
the screen in front of the message “What is your name?” You must clear the
entire screen before display.
Page 2 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
8. Read the current time from the system and display it in the standard format
on the screen.
9. Create and open a file named myfile.txt, and write a text 'Welcome to
MICROPROCESSOR LAB' in this file & close. Next, the reads from the file
myfile.txt and it display the text on to the screen.
PART B:
1. Search a key element in a list of ‘n’ 16-bit numbers using the Binary search
algorithm
2. Sort a given set of ‘n’ numbers in ascending and descending orders using the
Bubble Sort algorithm.
3. Sort a given set of ‘n’ numbers in ascending and descending orders using the
Selection Sort algorithm.
5. Read two strings, store them in locations STR1 and STR2. Check whether they
are equal or not and display appropriated messages. Also display the length
of the stored strings.
7. Read a pair of input co-ordinates in BCD and move the cursor to the specified
location on the screen.
Page 3 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
PART A:
1. Search a key element in a list of ‘n’ 16-bit numbers using the Linear search
algorithm
DATA SEGMENT
ARR DW 1000H,3402H,3501H,2234H,4567H
LEN DB $-ARR
KEY DW 2234H
SUCC DB 10,13, "SEARCH SUCCESSFUL $"
NOTSUCC DB 10,13,"UNSUCCESSFUL$"
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
SHR LEN,01
MOV CL,0
LEA SI, ARR
UP:
CMP CL, LEN
JE NOTFOUND
MOV AX,[SI]
CMP KEY,AX
JE FOUND
ADD SI,02
INC CL
JMP UP
FOUND:
LEA DX,SUCC
MOV AH,09
INT 21H
JMP EXIT
Page 4 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
NOTFOUND:
LEA DX,NOTSUCC
MOV AH,09
INT 21H
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
ENS START
READCHAR MACRO
MOV AH, 01H
INT 21H
ENDM
DISPCHAR MACRO
MOV AH, 02H
INT 21H
ENDM
INCLUDE F1.MAC
INCLUDE F2.MAC
DATA SEGMENT
msg1 db 10, 13, 'ENTER STRING : $'
Page 5 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
LEA DX, msg1
MOV AH, 09H
INT 21H
LEA SI, str
CALL READSTRING
MOV n, CL
LEA DX, msg2
MOV AH, 09H
INT 21H
LEA SI, str
MOV CL, n
CALL DISPSTRING
MOV AH, 4CH
INT 21H
Page 6 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
INC SI
INC CL
JMP UP
L1: RET
READSTRING ENDP
3. Read an alphanumeric character and display its equivalent ASCII code at the
center of the screen.
CLRSCR MACRO
MOV AH, 00H
MOV AL, 02H
INT 10H
ENDM
Page 7 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DATA SEGMENT
msg1 DB 10, 13, 'ENTER THE CHARACTER : $'
n DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
LEA DX, msg1
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV n, AL
CLRSCR
MOV AL, 02H
SETCURSOR 12, 40
MOV BL, n
CALL DISPHEXA
MOV AH, 01H
INT 21H
MOV AH, 4CH
INT 21H
DISPHEXA PROC NEAR
MOV DL, BL
MOV CL, 04H
SHR DL, CL
CMP DL, 09H
JBE L1
ADD DL, 07H
L1:
ADD DL, 30H
Page 8 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, str1
LEA DI, str2
LEA DX, M1
Page 9 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
Page 10 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
PAL:
LEA DX, M2
MOV AH, 09H
INT 21H
EXIT:
MOV AH, 4CH
INT 21H
5.Read your name from the keyboard and display it at a specified location on the
screen in front of the message “What is your name?” You must clear the entire
screen before display.
CLRSCR MACRO
MOV AH, 00H
MOV AL, 02H
INT 10H
ENDM
Page 11 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DATA SEGMENT
msg1 DB 'ENTER YOUR NAME:$'
msg2 DB 'What is your name?$'
str DB 30 dup(?)
n DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,msg1
MOV AH,09H
INT 21H
LEA SI, str
CALL READSTRING
MOV n,CL
CLRSCR
MOV AH, 02H
SETCURSOR 10,30
LEA DX,msg2
MOV AH,09H
INT 21H
LEA SI, str
MOV CL, n
Page 12 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CALL DISPSTRING
MOV AH,01H
INT 21H
MOV AH,4CH
INT 21H
READSTRING PROC NEAR
MOV CL, 00H
UP: CMP CL,30
JZ L1
MOV AH,01H
INT 21H
CMP AL,0DH
JZ L1
MOV [SI],AL
INC SI
INC CL
JMP UP
L1: RET
READSTRING ENDP
Page 13 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DATA SEGMENT
n DB 06H
fact DW ?
msg DB 'FACTORIAL(6)=$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
MOV AX,1
MOV BL,n
MOV BH,00
CALL FACTORIAL
MOV fact,AX
MOV BL, AH
LEA DX,msg
MOV AH,09H
INT 21H
CALL DISPHEXA
MOV BX,fact
CALL DISPHEXA
MOV AH,4CH
INT 21H
FACTORIAL PROC
CMP BX,1
JE L1
PUSH BX
DEC BX
CALL FACTORIAL
POP BX
Page 14 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MUL BX
L1: RET
FACTORIAL ENDP
DISPHEXA PROC
MOV DL,BL
MOV CL,04
SHR DL,CL
CMP DL,09H
JBE L2
ADD DL,07H
L2:
ADD DL,30H
MOV AH,02H
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,09H
JBE L3
ADD DL,07H
L3:
ADD DL,30H
MOV AH,02H
INT 21H
RET
DISPHEXA ENDP
CODE ENDS
END START
DATA SEGMENT
f1 DB 00H
f2 DB 01H
Page 15 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
f3 DB ?
msg DB 'THE FIBONACCI SERIES IS:',10,13,'$'
N DB 10
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,msg
MOV AH,09H
INT 21H
MOV BL,f1
CALL DISPHEXA
MOV DL,' '
MOV AH,02H
INT 21H
MOV BL,f2
CALL DISPHEXA
MOV DL,' '
MOV AH,02H
INT 21H
MOV CL,00
SUB N, 02H
UP:
CMP CL,N
JZ EXIT
MOV AL,f1
ADD AL,f2
MOV f3,AL
MOV BL,f3
CALL DISPHEXA
MOV DL,' '
Page 16 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV AH,02H
INT 21H
MOV AL,f2
MOV f1,AL
MOV AL,f3
MOV f2,AL
INC CL
JMP UP
EXIT:
MOV AH,4CH
INT 21H
DISPHEXA PROC
PUSH CX
MOV DL,BL
MOV CL,04
SHR DL,CL
CMP DL,09H
JBE L1
ADD DL,07H
L1:
ADD DL,30H
MOV AH,02H
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,09H
JBE L2
ADD DL,07H
L2:
ADD DL,30H
MOV AH,02H
INT 21H
POP CX
RET
Page 17 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DISPHEXA ENDP
CODE ENDS
END START
8. Read the current time from the system and display it in the standard format on
the screen.
DATA SEGMENT
HR DB ?
MIN DB ?
SEC DB ?
MSEC DB ?
msg DB 'THE CURRENT TIME IS:',10,13,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,msg
MOV AH,09H
INT 21H
MOV AH,2CH
INT 21H
MOV HR,CH
MOV MIN,CL
MOV SEC,DH
MOV MSEC,DL
MOV AL,HR
AAM
MOV BX,AX
CALL DISPUNPACKDBCD
Page 18 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV DL,':'
MOV AH,02H
INT 21H
MOV AL,MIN
AAM
MOV BX,AX
CALL DISPUNPACKDBCD
MOV DL,':'
MOV AH,02H
INT 21H
MOV AL,SEC
AAM
MOV BX,AX
CALL DISPUNPACKDBCD
MOV DL,':'
MOV AH,02H
INT 21H
MOV AL,MSEC
AAM
MOV BX,AX
CALL DISPUNPACKDBCD
MOV AH,4CH
INT 21H
Page 19 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DISPUNPACKDBCD ENDP
CODE ENDS
END START
9. Create and open a file named myfile.txt, and write a text 'Welcome to
MICROPROCESSOR LAB' in this file & close it. Next, read from the file myfile.txt
and display the text on to the screen.
DATA SEGMENT
FILE DB 'MYFILE.TXT',0
MSG DB "WELCOME TO MICROPROCESSOR LAB$"
BUF DB 30 DUP (?)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS:DATA
START: MOV AX,DATA
MOV DS, AX
Page 20 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV AH,3EH
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
Page 21 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
PART B
1. Search a key element in a list of ‘n’ 16-bit numbers using the Binary search
algorithm
DATA SEGMENT
arr DW 0012H, 0015H, 0063H, 0078H, 0156H, 0206H, 0558H len DB $-ARR
mid db ?
key dw 0079H
msg1 db 10, 13, 'KEY NOT FOUND', 10, 13, '$'
msg2 db 10, 13, 'KEY FOUND AT POSITION $'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
SHR len, 01H
DEC len
MOV DL,00H
MOV DH, len
MOV CX, key
UP:
CMP DL, DH
JG NOTFOUND
MOV AL, DL
ADD AL, DH
SHR AL, 01H
MOV mid, AL
MOV BL, 02H
MUL BL
MOV BX, AX
Page 22 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
Page 23 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
INT 21H
MOV DL, BL
AND DL, 0FH
CMP DL, 09H
JBE L2
ADD DL, 07H
L2:
ADD DL, 30H
MOV AH, 02H
INT 21H
RET
DISPHEXA ENDP
CODE ENDS
END START
2. Sort a given set of ‘n’ numbers in ascending/ descending order using the
Bubble Sort algorithm.
DATA SEGMENT
a DB 61H, 38H, 05H, 91H, 82H, 03H
len DB $-a
NL DB 10, 13, '$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
DEC len
MOV CL, 00H
UP2:
CMP CL, len
JZ DISPLAY
MOV BX, 0000H
Page 24 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
Page 25 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
3. Sort a given set of ‘n’ numbers in ascending / descending orders using the
Selection Sort algorithm.
DATA SEGMENT
a DB 91H, 82H,61H, 38H,0ABH, 05H, 03H
Page 26 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
n DB $-a
POS DB ?
NL DB 10,13,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
DEC N
MOV DX, 00H
MOV BX,0
UP2:
CMP DL, N
JZ DISPLAY
MOV BL, DL
MOV CX,DX
INC CL
UP1:
CMP CL, N
JA SWAP
LEA SI,A
ADD SI,CX
MOV AL, [SI]
CMP A[BX], AL
JBE SKIP
MOV BX, SI
SKIP:
INC CL
JMP UP1
SWAP:
LEA SI,A
Page 27 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
ADD SI,DX
MOV AL,[SI]
XCHG AL, A[BX]
MOV [SI], AL
INC DL
JMP UP2
DISPLAY:
MOV CL, 00
LEA SI, a
UP3:
CMP CL, N
JA EXIT
MOV BL, [SI]
CALL DISPHEXA
CALL NEWLINE
INC CL
INC SI
JMP UP3
EXIT:
MOV AH, 4CH
INT 21H
DISPHEXA PROC NEAR
PUSH CX
PUSH DX
MOV DL, BL
MOV CL, 04H
SHR DL, CL
CMP DL, 09H
JBE L1
ADD DL, 07H
L1:
ADD DL, 30H
MOV AH, 02H
INT 21H
Page 28 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV DL, BL
AND DL, 0FH
CMP DL, 09H
JBE L2
ADD DL, 07H
L2:
ADD DL, 30H
MOV AH, 02H
INT 21H
POP DX
POP CX
RET
DISPHEXA ENDP
NEWLINE PROC NEAR
LEA DX, NL
MOV AH, 09H
INT 21H
RET
NEWLINE ENDP
CODE ENDS
END START
Page 29 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CALL READHEXA
MOV BYTE PTR NUM1+1, BL
CALL READHEXA
MOV BYTE PTR NUM1, BL
CALL READHEXA
MOV BYTE PTR NUM2+1, BL
CALL READHEXA
MOV BYTE PTR NUM2, BL
Page 30 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV AH,01H
INT 21H
CMP AL,39H
JBE SKIP1
ADD AL, 09H
SKIP1:
AND AL,0FH
ADD BL, AL
MOV AH,01H
INT 21H
CMP AL,39H
JBE SKIP2
ADD AL, 09H
SKIP2:
AND AL,0FH
MOV CL,04
SHL BL, CL
ADD BL,AL
RET
READHEXA ENDP
DISPHEXA PROC NEAR
MOV DL, BL
MOV CL, 04H
SHR DL, CL
CMP DL, 09H
JBE L1
ADD DL, 07H
L1:
ADD DL, 30H
MOV AH, 02H
INT 21H
MOV DL, BL
AND DL, 0FH
CMP DL, 09H
Page 31 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
JBE L2
ADD DL, 07H
L2:
ADD DL, 30H
MOV AH, 02H
INT 21H
RET
DISPHEXA ENDP
CODE ENDS
END START
5. Read two strings, store them in locations STR1 and STR2. Check whether they
are equal or not and display appropriated messages. Also display the length of
the stored strings.
DATA SEGMENT
STR1 DB 20 DUP(?)
STR2 DB 20 DUP(?)
N1 DB ?
N2 DB ?
M1 DB 10, 13, 'STRINGS ARE EQUAL$'
M2 DB 10, 13, 'STRINGS ARE NOT EQUAL$'
M3 DB 10, 13, 'ENTER STRING 1 : $'
M4 DB 10, 13, 'ENTER STRING 2 : $'
M5 DB 10, 13, 'STRING 1 LENGTH : $'
M6 DB 10, 13, 'STRING 2 LENGTH : $'
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START:
MOV AX, DATA
MOV DS, AX
LEA DX, M3
Page 32 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
Page 33 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DISPLEN:
LEA DX, M5
MOV AH, 09H
INT 21H
MOV BL, N1
CALL DISPHEXA
LEA DX, M6
MOV AH, 09H
INT 21H
MOV BL, N2
CALL DISPHEXA
MOV AH, 4CH
INT 21H
Page 34 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
JBE L1
ADD DL, 07H
L1:
ADD DL, 30H
MOV AH, 02H
INT 21H
MOV DL, BL
AND DL, 0FH
CMP DL, 09H
JBE L2
ADD DL, 07H
L2:
ADD DL, 30H
MOV AH, 02H
INT 21H
POP DX
POP CX
RET
DISPHEXA ENDP
CODE ENDS
END START
Page 35 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
Page 36 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
INC DX
JMP UP2
L1:
CMP DL, M
JZ MATCH
INC CX
JMP UP1
MATCH:
LEA DX, MSG1
MOV AH, 09H
INT 21H
JMP EXIT
NOMATCH:
LEA DX, MSG2
MOV AH, 09H
INT 21H
EXIT:
MOV AH, 4CH
INT 21H
CODE ENDS
END START
7. Read a pair of input co-ordinates in BCD and move the cursor to the
specified location on the screen.
CLRSCR MACRO
MOV AH,00
MOV AL,02
INT 10H
ENDM
Page 37 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,msg1
MOV AH,09H
INT 21H
CALL READBCD
MOV BCD_X,BL
LEA DX,msg2
MOV AH,09H
INT 21H
CALL READBCD
MOV BCD_Y,BL
MOV BL,BCD_X
CALL BCD_TO_BIN
Page 38 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
MOV BIN_X,BL
MOV BL,BCD_Y
CALL BCD_TO_BIN
MOV BIN_Y,BL
CLRSCR
SETCURSOR BIN_Y,BIN_X
MOV AH,01H
INT 21H
MOV AH,4CH
INT 21H
READBCD PROC NEAR
MOV AH,01H
INT 21H
MOV BL, AL
MOV CL,04H
SHL BL,CL
MOV AH,01H
INT 21H
AND AL,0FH
ADD BL,AL
RET
READBCD ENDP
Page 39 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
BCD_TO_BIN ENDP
CODE ENDS
END START
CLRSCR MACRO
MOV AH, 00H
MOV AL, 02H
INT 10H
ENDM
CODE SEGMENT
ASSUME CS:CODE
START:
CLRSCR
MOV AL, 00H
UP:
CMP AL, 99H
JZ DISP99
CALL CENTER
MOV BL, AL
CALL DISPLAY
CALL DELAY
ADD AL, 01H
DAA
JMP UP
DISP99:
CALL CENTER
MOV BL, AL
CALL DISPLAY
CALL DELAY
MOV AH, 4CH
INT 21H
Page 40 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
CENTER PROC
PUSH AX
MOV DL, 39
MOV DH, 12
MOV BH,0
MOV AH,02h
INT 10h
POP AX
RET
CENTER ENDP
DISPLAY PROC
PUSH AX
MOV DL, BL
MOV CL,04
SHR DL, CL
CMP DL,09
JBE DOWN1
ADD DL,07h
DOWN1:
ADD DL,30h
MOV AH,02h
INT 21h
MOV DL, BL
AND DL,0Fh
CMP DL,09H
JBE DOWN2
ADD DL,07h
DOWN2:
ADD DL,30h
MOV AH,02h
INT 21h
POP AX
RET
Page 41 of 42
(ISO 9001:2015 Certified), Accredited with ‘A’ Grade by NAAC
: 08258 - 281039 – 281263, Fax: 08258 – 281265
Department of Computer Science and Engineering
B.E. CSE Program Accredited by NBA, New Delhi from 1-7-2018 to 30-6-2021
DISPLAY ENDP
DELAY PROC
PUSH AX
PUSH BX
PUSH CX
MOV CX,100h
L1:
MOV BX,0FFFh
L2:
DEC BX
JNZ L2
LOOP L1
POP CX
POP BX
POP AX
RET
DELAY ENDP
CODE ENDS
END START
Page 42 of 42