0% found this document useful (0 votes)
32 views4 pages

MP (CS3005-1) Lab Manual 2023-24-6-9

The document contains assembly language programs for various tasks including displaying hexadecimal values, reading and displaying strings, and checking for palindromes. It defines macros for reading characters and displaying them, and includes procedures for handling string input and output. Additionally, it provides functionality to clear the screen and position the cursor for displaying ASCII codes.

Uploaded by

darshankotian99
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)
32 views4 pages

MP (CS3005-1) Lab Manual 2023-24-6-9

The document contains assembly language programs for various tasks including displaying hexadecimal values, reading and displaying strings, and checking for palindromes. It defines macros for reading characters and displaying them, and includes procedures for handling string input and output. Additionally, it provides functionality to clear the screen and position the cursor for displaying ASCII codes.

Uploaded by

darshankotian99
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/ 4

FOUND:

LEA DX, msg2


MOV AH, 09H
INT 21H
MOV BL, mid
CALL
DISPHEXA
EXIT:
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
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
RET
DISPHEXA ENDP
CODE ENDS
END START

2. Write ALP macros:


i. To read a character from the keyboard in the module (1) (in a
different file).
ii. To display a character in module(2) (from 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.
Page No. 6
READCHAR MACRO
MOV AH, 01H
INT 21H
ENDM

DISPCHAR MACRO
MOV AH, 02H
INT 21H
ENDM

INCLUDE F1.MAC
INCLUDE F2.MAC

DATA SEGMENT
str db 50 DUP(?)
n db ?
msg1 db 10, 13, 'ENTER STRING : $'
msg2 db 10, 13, 'ENTERED STRING IS : $'
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
LEA DX, msg2
MOV AH, 09H
INT 21H
LEA SI, str
MOV CL, n
CALL DISPSTRING
MOV AH, 4CH
INT 21H

READSTRING PROC NEAR


MOV CL, 00H
UP:
CMP CL, 50
JZ L1
READCHAR
CMP AL, 0DH
JZ L1

Page No. 7
MOV [SI], AL
INC SI
INC CL
JMP UP
L1:
RET
READSTRING ENDP

DISPSTRING PROC NEAR


UP2:
CMP CL, 00
JZ L2
MOV DL, [SI]
DISPCHAR
INC SI
DEC CL
JMP UP2
L2:
RET
DISPSTRING ENDP
CODE ENDS
END START

3. Write an ALP to 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

SETCURSOR MACRO row, col


MOV DL, col
MOV DH, row
MOV BH, 00H
MOV AH, 02H
INT 10H
ENDM

DATA SEGMENT
n DB ?
msg1 DB 10, 13, 'ENTER THE CHARACTER : $'
DATA ENDS

CODE SEGMENT
ASSUME CS: CODE, DS: DATA

Page No. 8
START:
MOV AX, DATA
MOV DS, AX
LEA DX, msg1
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
MOV n, AL
CLRSCR
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
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
RET
DISPHEXA ENDP
CODE ENDS
END START

4. Write an ALP to reverse a given string and check whether it is a


palindrome or not.
DATA SEGMENT
str1 DB 20 DUP(?)
str2 DB 20 DUP(?)
n DB ?
M1 DB 10, 13, 'ENTER THE STRING: $'
M2 DB 10, 13, 'STRING IS PALINDROME $'

Page No. 9

You might also like