Lab 9
Lab 9
Write an assembly language program to scroll a window from row 5, column 20 to row 20,
column 60 with a reverse video attributes. Then locate the cursor at row 12, column 30. And
display a string as “Programming in Assembly Language is Fun”.
TITLE 20*20 WINDOW SCROLLING
.MODEL SMALL
.DATA
STRLEN DB 50
STRSZ DB ?
STR DB 14 DUP('$')
STRTRM DB '$'
.STACK
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
LEA DX, STRLEN
MOV AH, 0AH
INT 21H
MOV AH, 00
MOV AL, 03H
INT 10H
MOV AL, 00H
MOV CH, 00H
MOV CL, 30
MOV DH, 20
MOV DL, 50
MOV BH, 71H
MOV AH, 06H
INT 10H
MOV BH, 00
MOV DH, 10
MOV AX, 80
SUB AL, STRSZ
MOV DL, 02H
DIV DL
MOV DL, AL
MOV AX, 0200H
INT 10H
LEA DX, STR
MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
2. Write an assembly language program that takes a string (having 60 characters at max.) as input
from user, and display the string at the center of the clear screen.
TITLE DISPLAYING AT THE CENTER
.MODEL SMALL
.DATA
STRLEN DB 60
STRSZ DB ?
STR DB 60 DUP('$')
STRTRM DB '$'
.STACK
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
LEA DX, STRLEN
MOV AH, 0AH
INT 21H
MOV AH, 00
MOV AL, 03H
INT 10H
MOV BH, 00
MOV DH, 00
MOV AL, 80
MOV DL, STRSZ
SUB AL, DL
MOV DL, 02H
DIV DL
MOV DL, AL
MOV AH, 02H
INT 10H
LEA DX, STR
MOV AH, 09H
INT 21H
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
3. Write an assembly language program that takes a string (having 24 characters at max.) from
the user and display each character at the center of each line.
.MODEL SMALL
.DATA
STRLEN DB 24
STRSZ DB ?
STR DB 24 DUP('$')
STRTRM DB '$'
.STACK
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
LEA DX, STRLEN
MOV AH, 0AH
INT 21H
MOV AH, 00H
MOV AL, 03H
INT 10H
LEA SI, STR
MOV CH, 00
MOV CL, STRSZ
MOV DX, 00H
L1:
MOV BH, 00H
MOV DL, 40
MOV AH, 02H
INT 10H
MOV DL, [SI]
MOV AH, 02H
INT 21H
INC DH
INC SI
LOOP L1
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
4. Write an assembly language program that takes a string (having 14 characters at max.) input
from user and scroll a window of size 20×20 at the center of screen. Then display the string at
the center of scrolled window. (You can choose the color attribute yourself).
TITLE SCROLL
.MODEL SMALL
.DATA
STR DB "PROGRAMMING IN ASSEMBLY LANGUAGE IS FUN",'$'
STRLEN DB $-STR
.STACK
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV AH, 00
MOV AL, 03H
INT 10H
MOV CH, 05
MOV CL, 20
MOV DH, 20
MOV DL, 60
MOV AH, 07H
MOV BH, 71H
MOV AL, 00
INT 10H
MOV BH,00
MOV DH, 12
MOV DL, 30
MOV AH, 02H
INT 10H
LEA DX, STR
MOV AH, 09H
INT 21H
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
5. Write a program that a string from the user and display each word in new line diagonally from
upper left towards bottom right in a clear screen. If the string is “Programming in Assembly
Language is Fun”, it shoud be displayed as
Programming
in
Assembly
Language
is
Fun
TITLE TO SHOW DIAGONAL TEXT
.MODEL SMALL
.STACK 32
.DATA
STRING DB 20 DUP(?)
.CODE
MAIN PROC FAR
MOV AX, @DATA
MOV DS, AX
MOV CL, 00H
MOV AH, 0AH
LEA DX, STRING
INT 21H
MOV AX, 0003H
LEA DI, STRING
MOV AH, 00H
MOV AL, 03H
INT 10H
REPEAT:
MOV AH, 02H
MOV DL, [DI+2]
CMP DL, 20H
JE CASE2
CASE1:MOV DL, [DI+2]
INT 21H
INC CL
JMP CONTINUE
CASE2:
MOV DL, 0AH
INT 21H
INC DH
MOV BH, 00H
MOV DL, CL
INT 10H
CONTINUE:
INC DI
MOV AH, [DI+2]
CMP AH, 0DH
JNE REPEAT
MOV AX, 4C00H
INT 21H
MAIN ENDP
END MAIN
DISCUSSION:
The lab focused on familiarizing with BIOS Service INT 10H in Assembly Language Programming,
specifically for video display control. The lab introduced various functions under INT 10H, allowing
students to control video modes, cursor settings, scrolling, and color attributes. Understanding these
functions is crucial for creating interactive and visually appealing assembly language programs.
Set video mode (00H): Clearing the screen and setting the video mode.
Set cursor size (01H): Adjusting the cursor size vertically.
Set cursor position (02H): Placing the cursor at a specified row and column.
Return cursor status (03H): Retrieving information about the cursor position and size.
Select the page (05H): Displaying different pages to create alternations.
Scrolling (06H and 07H): Scroll upward and downward in specified areas of the screen.
Read character and its attribute (08H): Reading character and attribute at the cursor.
Display characters (09H and 0AH): Displaying specified characters with given attributes.
Set color palette (0BH): Setting background color or graphics palette.
Display selected color (0CH): Displaying a selected color in graphics mode.
Read pixel dot (0DH): Reading the color value of a pixel.
Monitor display (0EH): Displaying characters with foreground color in test and graphics modes.
Get current video mode (0FH): Retrieving information about the current video mode and screen
columns.
The lab assignments provided practical scenarios for us to apply their knowledge. These assignments
involved scrolling windows, displaying strings at specific locations, taking user input, and manipulating
text and color attributes to create visually interesting displays.
CONCLUSION:
By completing the assignments, we can gain proficiency in using BIOS services to enhance the visual
aspects of their programs. This lab equips us with the skills needed to create interactive and visually
appealing assembly language applications, laying the foundation for more advanced graphics
programming in future studies.