Professional Documents
Culture Documents
EQUIPMENT:
SOFTWARE:
• Turbo Assembler (TASM)
DISCUSSION:
When an application program needs to write characters on the screen in text mode, it can choose
among three types of output:
• MS-DOS-level access: Any computer running or emulating MS-DOS can use INT 21h to write
text to the video display. Input/output can easily be redirected to other devices such as a printer or
disk. Output is quite slow, and you cannot control the text color.
• BIOS-level access: Characters are output using INT 10h function, known as BIOS services. They
execute more quickly than INT 21h and let you specify the text color. When filling large screen
areas, a slight delay can usually be detected. Output cannot be redirected.
• Direct video memory access: Characters are moved directly to video RAM, so execution is
instantaneous. Output cannot be redirected. During the MS-DOS era, word processors and
electronic spreadsheet programs all used this method. (Use of this method is restricted to full-
screen mode under Windows NT, 2000, XP, and beyond.)
In this lab we will be focusing on the BIOS-level access particularly learning to use INT10h for
video/graphics programing.
ATTRIBUTES:
As illustrated in the following diagrams, each screen character is assigned an attribute byte that
controls both the color of the character (called the foreground) and the screen color behind the
character (called the background) as shown in fig 1.
Each position on the video display holds a single character, along with its own attribute (color).
The attribute is stored in a separate byte, following the character in memory. In the following
figure, three positions on the screen contain the letters ABC:
BLINKING:
Blinking Characters on the video display can blink. The video controller does this by reversing the
foreground and background colors of a character at a predetermined rate. By default, when a PC
boots into MS-DOS mode, blinking is enabled. It is possible to turn blinking off using a video
BIOS function. Also, blinking is off by default when you open up an MS-DOS emulation window
under MS-Windows.
CONTROLLING THE COLOR:
MIXING PRIMARY COLORS:
Each color pixel on a CRT video display is generated using three separate electron beams: red,
green, and blue. A fourth channel controls the overall intensity, or brightness of the pixel. All
available text colors can therefore be represented by 4-bit binary values, in the following form
(I = intensity, R = red, G = green, B = blue). The following diagram shows the composition of a
white pixel:
By mixing three primary colors (Table 1), new colors can be generated. Furthermore, by turning
on the intensity bit, you can make the mixed colors brighter.
Figure 5:Shows attribute byte for background and foreground for blinking enabled.
From the above attribute byte structure MS-DOS–style primary colors and mixed colors are
compiled into a list of all possible 4-bit colors as shown in Table 2. Each color in the right-hand
column has its intensity bit set.
Table 2: Shows four bit color text encoding.
When blinking is enabled, only the low-intensity colors in the left-hand column of Table 2 are
available as background colors (black, blue, green, cyan, red, magenta, brown, and light gray)
The default color when MS-DOS boots is 00000111 binary (light gray on black background).
INTERUPT 10h VIDEO FUNCTIONS
Table 3 lists the most frequently used INT 10h functions.
Table 3: Shows the functions of INT 10h
To set a particular function we need to move that function number into AH register.
INT 10h Function 00h:
Set video mode AH=00h AL = video mode
Following are the video modes that are used in INT 10h
AL = 00h 40x25 B/W text
AL = 01h 40x25 16 color text
AL = 02h 80x25 16 shades of gray text
AL = 03h 80x25 16 color text
AL = 04h, 05h 320x200 4 color graphics
AL = 06h 640x200 B/W graphics
AL = 07h 80x25 Monochrome text
AL = 08h 160x200 16 color graphics
AL = 09h,0Dh,0Eh 320x200 16 color graphics
AL = 0Ah 640x200 4 color graphics
AL = 0Fh 640x350 Monochrome graphics
AL = 10h 640x350 16 color graphics
AL = 11h 640x480 B/W graphics
AL = 12h 640x480 16 color graphics
AL = 13h 320x200 256 color graphics
SAMPLE CODE 1 (SETING VIDEO MODE: FUNCTION 00h)
.model small
.stack 100h
.data
.code
main proc
mov ah,00h ; set the configuration to video mode by using function number
mov al,13h ; choose the video mode 320x200 256 color graphics
int 10h ; executes the configuration
mov ah,4ch
int 21h
main endp
end main
Observe the output in the command window
The Colour of the text on the console is “Brighter” and the resolution/quality is improved.
mov ah,6 ; set the configuration to scroll window up by using function number
mov al,10 ; scrolling up by 10 line. If “0” is used then entire window
mov bh, 01000011b ; choosing background “red” and foreground “cyan”
mov ch,5 ; upper left row
mov cl,5 ; upper left column
mov dh,15 ; lower right row
mov dl,15 ; lower right column
int 10h ; executes the configuration
mov ah,4ch
int 21h
main endp
end main
Output:
• A Red background is moved up by 10 lines and 5 units from upper left row and column. The
background is also moved 15 units from lower right row and column
.
mov ah,09h ; set configuration to write character and attribute at cursor position
mov al,'A' ; moving ASCII of A into al register
mov bh, 0h ; video page 0
mov bl, 71h ; attribute (blue on light gray)
mov cx, 5 ; repetition
int 10h ; executes the configuration
mov ah,4ch
int 21h
main endp
end main
mov ah,09h ; set configuration to write character and attribute at cursor position
mov al,'A' ; moving ASCII of A into al register
mov bh, 0h ; video page 0
mov bl, 11110001b ; attribute (blue on light gray)
mov cx, 5 ; repetition
int 10h ; executes the configuration
mov ah,4ch
int 21h
main endp
end main
Answer:
What need to be replaced in above code to lower the intensity of the foreground text? Show
your code and result
Answer:
The color of blue is made lighter by the intensity bit.
mov bl,11111001b instruction is added
CODE:
.model small
.stack 100h
.data
.code
main proc
mov ah,09h
mov al,'A'
mov bh, 0h
mov bl,11111001b ;prints blue on light gray color(lower background)
mov cx, 5
int 10h
mov ah,4ch
int 21h
main endp
end main
Output:
EXRERCISES:
1. Write a code to display a graphics as shown below the area of outer most rectangle is
150x250
12
9 3
TASM Code
.model small
.stack 100h
.data
.code
main proc
mov ah,7
mov al,00h
mov bh, 00011111b
mov ch,5
mov cl,0
mov dh,20
mov dl,40
int 10h
mov ah,6
mov al,00h
mov bh, 01110000b
mov ch,7
mov cl,5
mov dh,18
mov dl,35
int 10h
mov ah, 2
mov bh, 0
mov dh, 7
mov dl, 20
int 10h
mov ah, 2
mov dl, '1'
int 21h
mov dl, '2'
int 21h
mov ah, 2
mov bh, 0
mov dh, 12
mov dl, 33
int 10h
mov ah, 2
mov dl, '3'
int 21h
mov ah, 2
mov bh, 0
mov dh, 18
mov dl, 20
int 10h
mov ah, 2
mov dl, '6'
int 21h
mov ah, 2
mov bh, 0
mov dh, 12
mov dl, 7
int 10h
mov ah, 2
mov dl, '9'
int 21h
mov ah, 2
mov bh, 0
mov dh, 2
mov dl, 0
int 10h
mov ah,4ch
int 21h
main endp
end main
Screenshot:
Conclusion:
• In this lab we learned how to change the resolution, make text on the console brighter and
bigger.
• We learnt the displacement of outputs by units in rows ,coloums left and right.