0% found this document useful (0 votes)
2 views

lab8

The document outlines a series of assembly language programs that utilize DOS Service INT 21H for various string manipulation tasks, such as displaying strings, reading user input, converting strings to uppercase, and displaying words on separate lines. It emphasizes the importance of understanding interrupts and functions for input/output operations in the Intel 8086 microprocessor. The lab assignments aim to provide practical experience in assembly language programming and enhance comprehension of DOS services.

Uploaded by

quantum physics
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)
2 views

lab8

The document outlines a series of assembly language programs that utilize DOS Service INT 21H for various string manipulation tasks, such as displaying strings, reading user input, converting strings to uppercase, and displaying words on separate lines. It emphasizes the importance of understanding interrupts and functions for input/output operations in the Intel 8086 microprocessor. The lab assignments aim to provide practical experience in assembly language programming and enhance comprehension of DOS services.

Uploaded by

quantum physics
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/ 6

1.

Write a program to display a string "Programming is Fun" in the screen using string
displaying function
TITLE TO DISPLAY THE STRING "Programming is Fun" IN THE SCREEN
.MODEL SMALL
.STACK 64
.DATA
STRING DB "Programming is Fun$"
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 09H
LEA DX, STRING
INT 21H
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN

2. Write a program to display the same string using character reading function (use current
address operator $ to count the no. of characters e.g.
STR DB "String to be displayed"
LEN DW $-STR ;Gives the length of the string STR
TITLE TO DISPLAY THE STRING "Programming is Fun" IN THE SCREEN USING
CHARACTER READING FUNCTION
.MODEL SMALL
.STACK 64
.DATA
STRING DB "Programming is Fun"
LEN DW $-STRING
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
LEA BX, STRING
MOV CX, LEN
DISPLAY:
MOV AH, 02H
MOV DL, [BX]
INT 21H
INC BX
LOOP DISPLAY
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN

3. Write a program to read string from the user (use function that reads string) and display
the string in another line. (To display the character in new line display characters 0DH and
0AH)
TITLE TO READ A STRING FROM USER AND DISPLAY THE STRING IN ANOTHER
LINE
.MODEL SMALL
.STACK 64
.DATA
LEN DB 50
DB ?
STRING DB 51 DUP (?)
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 0AH
MOV DX, OFFSET LEN
INT 21H
MOV BL, LEN[1];
MOV BH, 00H
MOV STRING[BX], '$'
MOV AH, 02H
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
MOV AH, 09H
MOV DX, OFFSET STRING
INT 21H
MOV AX, 4C00H;
INT 21H
MAIN ENDP
END MAIN
4. Write a program to read the string using the character reading function and display the
string using character displaying function.
TITLE TO READ A STRING FROM USER AS WELL AS DISPLAY THE STRING
CHARACTER BY CHARACTER
.MODEL SMALL
.STACK 64
.DATA
STRING DB 51 DUP (?)
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV BX, 0H
INPUT:
MOV AH, 01H
INT 21H
MOV STRING[BX], AL
CMP AL, '$'
JE DISPLAY
INC BX
JMP INPUT
DISPLAY:
MOV AH, 02H
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
MOV BX, 0H
DISPLAY:
MOV AL, STRING[BX]
CMP AL, '$'
JE EXIT
MOV AH, 02H
MOV DL, AL
INT 21H
INC BX
JMP DISPLAY
EXIT:
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
5. Write a program to read the string and convert it into upper case if it is in lower case and
display the resulting string. Process the string in the memory before displaying.
TITLE TO READ A STRING, CONVERT IT TO UPPERCASE AND DISPLAY IT
.MODEL SMALL
.STACK 64
.DATA
LEN DB 50
DB ?
STRING DB 51 DUP (?)
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 0AH
MOV DX, OFFSET LEN
INT 21H
MOV BL, LEN[1];
MOV BH, 00H
MOV STRING[BX], '$'
MOV BX, 0H
MOV CL, LEN[1]
UPPERCASE:
MOV AL, STRING[BX]
CMP AL, 97
JL NEXT
CMP AL, 123
JG NEXT
SUB AL, 32
MOV STRING[BX], AL
NEXT:
INC BX
LOOP UPPERCASE
MOV AH, 02H
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
MOV AH, 09H
MOV DX, OFFSET STRING
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

6. Write a program to read a string and display each word in separate lines.
TITLE TO DISPLAY ENTERED STRING'S WORDS IN DIFFERENT LINES
.MODEL SMALL
.STACK 64
.DATA
LEN DB 50
DB ?
STRING DB 51 DUP (?)
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 0AH
MOV DX, OFFSET LEN
INT 21H
MOV CL, LEN[1]
MOV BX, 00H
MOV AH, 02H
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
DISPLAY:
MOV AH, 02H
MOV AL, STRING[BX]
CMP AL, ' '
JE NEWWORD
MOV DL, AL
INT 21H
JMP CONTINUE
NEWWORD:
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
CONTINUE:
INC BX
LOOP DISPLAY
MOV AX, 4C00H
INT 21H
MAIN ENDP

END MAIN

DISCUSSION:
The lab focused on familiarizing us with DOS Service INT 21H in Assembly Language Programming,
emphasizing the use of interrupts and functions for input/output services. The Intel 8086 microprocessor
recognizes two types of interrupts: hardware and software. Hardware interrupts are generated by
peripheral devices, while software interrupts involve calls to subroutines in the operating system,
specifically DOS for input and output operations.
The key DOS Service INT 21H functions discussed include:

• Terminate program
• Console input with echo
• Character output
• Printer output
• Direct console input-output
• Console input with and without echo
• String output and input
• Check keyboard status
• Clear keyboard buffer and invoke input functions
The lab assignments were designed to reinforce understanding through practical application. We were
tasked with writing assembly language programs to achieve various objectives, such as displaying strings,
reading strings, converting case, and displaying words on separate lines.

CONCLUSION:
In conclusion, this lab provided a hands-on experience with assembly language programming using DOS
services. We learned to interact with the Intel 8086 microprocessor, particularly through the use of
interrupts and functions provided by DOS Service INT 21H. The assignments guided them through
different scenarios, ranging from basic string display to more complex tasks like string manipulation and
case conversion.

You might also like