SCREEN
PROCESSING
JULIUS BANCUD
THE MONITOR
A typical video screen has eighty (80) columns
numbered from 0 to 79 and twenty five (25) rows
numbered from 0 to 24. The columns and rows
provide a grid of addressable locations at any one of
which cursor can be set. The table below shows the
examples of cursor locations.
SCREEN COLUMN ROW NO. COLUMN NO. Row no.
LOCATION NO.
In Decimal Value In Hexadecimal Value
Upper Left 0 0 00h 00h
Corner
Upper Right 79 0 4Fh 00h
corner
Center of 40 12 28h 0Ch
Screen
Lower Left 0 24 00h 18h
Corner
Lower Right 79 24 4Fh 18h
Corner
Clearing the Screen in
Assembly Approach
Interrupt 10h function 06h handles the process of
clearing the screen and scrolling. You can clear all or
part of display beginning at any screen location and
ending at any higher-numbered location. The
following sample code shows how to create the clear
screen code in assembly.
MOV AX, 0600H ; AH=06h(scroll), AL=00h(full screen)
MOV BH, 07H ; 0 (black background), 7(white text color)
MOV CX, 0000H ; CH=00h(Row), CL = 00h(Column)
MOV DX, 184Fh ; DH = 18H (Row), DL = 4Fh
(Column)
INT 10H ; call interrupt service
Setting the Cursor Position
In the text mode, setting the cursor position is a
common requirement, because its position determines
where the text character is to be displayed. Again,
interrupt 10h is the BIOS operation for screen
handling and function 02h in the AH tells the
operation to set the cursor.
MOV AH, 02h ; request to set the cursor position
MOV BH, 00h ; page number 0
MOV DH, 0Ah ; Row = 10 in decimal
MOV DL, 08h ; Column= 8 in decimal
INT 10h ; call interrupt service
Displaying the character ‘x’ at
the center of the screen
Output
Displaying the string “MERLIONS”
at the center of the screen
Output
Displaying ASCII character set
Among the extended ASCII characters 128d to 255d
(80h – FFh) are a number of special symbols that are
useful for displaying prompts, menus and logos. Here
are some of the them:
CHARACT SINGLE HEX CODE DOUBLE HEX CODE
ER LINE LINE
Straight C4 CD
lines:
Horizontal
Line
Vertical Line B3 BA
Corners: DA C9
Top Left
Bottom D9 BC
Right
Top Right BF BB
Bottom Left C0 C8
COLOR CHART
For the colored monitor, the background can display
one out of eight colors and text can display one out of
sixteen colors.
COLOR HEX CODE INTENSITY RED GREEN BLUE
Black 0 0 0 0 0
Blue 1 0 0 0 1
Green 2 0 0 1 0
Cyan 3 0 0 1 1
Red 4 0 1 0 0
Magenta 5 0 1 0 1
Brown 6 0 1 1 0
White 7 0 1 1 1
Gray 8 1 0 0 0
Light Blue 9 1 0 0 1
Light Green A 1 0 1 0
Light Cyan B 1 0 1 1
Light Red C 1 1 0 0
Light Magenta D 1 1 0 1
Yellow E 1 1 1 0
High-intensity White F 1 1 1 2
Text and Background Color
Here is an example how to set the text and
background colors and how to make them blink,
where BL below means blinking.
BACKGROUND TEXT COLOR HEX MEANING
COLOR CODE
BL R G B I R G B
0 0 1 0 1 0 0 0 28 Green background
color gray text color
1 0 1 0 1 0 0 0 A8 Green background
color gray text color
blinking
0 1 1 0 0 0 0 1 61 Brown background
color blue text color
1 1 1 0 0 0 0 1 E1 Green background
color blue text color
blinking
Displaying character ‘x’ with
attributes
Output
Displaying string “
MERLIONS“ with attribute
output
INT 10H
AH =00H SETS THE DISPLAY MODE
• TEXT MODE
AL = 00H 40 COLUMNS X 25 ROWS, BLACK AND WHITE
AL = 01H 40 COLUMNS X 25 ROWS, COLOR
AL = 02H 80 COLUMNS X 25 ROWS, BLACK AND WHITE
AL = 03H 80 COLUMNS X 25 ROWS, COLOR
• GRAPHICS MODE
AL = 04H 320 X 200 PIXELS, COLOR
AL =05H 320 X 200 PIXELS, BLACK AND WHITE
AL = 06H 640 X 200 PIXELS, BLACK AND WHITE
AH = 01H SETS THE CURSOR SIZE
CH STARTING SCAN LINE OF THE CURSOR.
- the top line is 00h on both the monochrome and color graphics display
- the bottom lines is 13h for monochrome and 07h for color graphics adapter.
- Valid range: 00h – 31h
CL Last scan line of the cursor
The power-on setting for the color graphics adapter is CH = 06h and CL =07h. For
monochrome display: CH = 11h and CL = 12h
INT 10H
AH = 02H SETS THE CURSOR POSITION
DH ROW NUMBER
DL COLUMN NUMBER
The upper left corner of the screen is (0,0)
BH PAGE NUMBER
- this is the number of the display page, but most
programs use page zero (0)
AH = 03H READS THE CURSOR POSITION
BH PAGE NUMBER
ON EXIT:
DH ROW NUMBER OF THE CURSOR
DL COLUMN NUMBER OF THE CURSOR
CH AND CL SIZE OF THE CURSOR
INT 10H
AH= 04H READS THE LIGHT PEN POSITION
AH = 05H SELECTS ACTIVE DISPLAY PAGE
AL NEW PAGE NUMBER
- FROM 0 TO 7 FOR MODES 0 AND 1
- FROM 0 TO 3 FOR MODES 2 AND 3
AH = 05H SCROLLS UP
AL NUMBER OF LINES TO BLANK AT THE BOTTOM OF THE
WINDOW
- normal scrolling blanks one (1) line.
- set to zero (0) to blank the entire window.
BH DISPLAY ATTRIBUTE TO USE BLANK LINES
CH, CL row and column number of upper-left corner of the screen
DH, DL row and column number of lower-right corner of the screen
AH = 07H SCROLLS DOWN
The same with the scroll up (AH = 06h), but lines are left blank at the top of
the screen instead of the bottom
INT 10H
AH = 08H READS ATTRIBUTE AND CHARACTER UNDER THE
CURSOR
AH ATTRIBUTE OF CHARACTER READ (TEXT
MODE ONLY0
AL CHARACTER READ
BH DISPLAY PAGE ( TEXT MODE ONLY)
AH = 09H DISPLAYS CHARACTER WITH ATTRIBUTES
AL CHARACTER TO DISPLAY
BH PAGE NUMBER (TEXT MODE ONLY)
BL BACKGROUND AND TEXT COLOR
CX NUMBER OF TIMES TO WRITE CHARACTER AND
ATTRIBUTE ON SCREEN
AH =10H WRITES CHARACTER UNDER CURSOR
AL CHARACTER TO DISPLAY
BH DISPLAY PAGE
CX NUMBER OF TIMES TO WRITE CHARACTER
INT 10H
AH = 11H VARIOUS GRAPHICS FUNCTIONS
AH = 13H DISPLAYS STRING WITH ATTRIBUTES
AL = 00H
display attribute and string without advancing the cursor.
BH PAGE NUMBER
BL BACKGROUND AND TEXT COLOR
BP ADDRESS OF STRING IN BASE POINTER OF EXTRA
SEGMENT
CX LENGTH OF STRING
DH ROW NUMBER
DL COLUMN NUMBER
INT 10H
AH = WRITE TELETYPE. WRITES ON CHARACTER TO THE
14H SCREEN AND MOVE THE CURSOR TO THE NEXT
POSITION
AL CHARACTER TO WRITE
BH DISPLAY PAGE
BL COLOR OF CHARACTER
AH=15 RETURN CURRENT VIDEO STATE
H AH NUMBER OF CHARACTER PER LINE
AL DISPLAY MODE CURRENTLY SET
BH ACTIVE DISPLAY PAGES