Video BIOS Functions
Contents:
- Video functions provided by BIOS
- Video Modes with their respective Codes
- An example in assembly to print a character on the screen using the BIOS(Real Mode)
- Terms (BIOS,VGA)
The following are the functions provided by the BIOS.
NOTE:
- The 'H' in the every value below stands for Hexadecimal Code.
- The values which come after the word 'Returns:' are the values returned by the BIOS after the execution of the particular function.
Function AH(H=Hex) Other Registers
Set Video Mode 00H AL = video mode*
Set Cursor type 01H CH= starting line
CL =ending line
Set Cursor position 02H BH=Page
DH=row DL=column
Get cursor position 03H BH=page
Returns: CH=start line CL=endline DH=row DL=column
Set display page 05H AL=page
Initialize or scroll window up 06H AL=no of lines
BH=attribute byte
CH,CL/DH, DL=x and y of coordinates of upper-left and
lower-right corner
Initialize or scroll window down 07H Same as above
Read character and attribute 08H BH=page
Returns:AH=attribute AL=character
Write character and attribute 09H AL=char BH=page BL=colour
CX=count of characters
Write character on the screen 0AH Same as above but CX =count of characters to write
Set the palette, background or 0BH BH=00 BL=colour
border
Write grapics pixel 0CH AL=value BH=page CX=x DX=y
Read grapics pixel 0DH BH=page CX=x DX=y RETURNS:AL= Value
Get video mode 0FH
Returns:AL number of columns in the screen AL=mode BH=page
Set palette register 10H AL=00 BH=colour BL=palette
Set bordor colour 10H AL=01 BH=colour value
Set palette and boarder 10H AL=02 ES:DX=seg:off of colour bit
Toggle intensity bit 10H AL=03 BL=blink/intensity toggle
Get palette register 10H AL=07 BL=palette register
Returns:BH =colour
Get border colour 10H AL=08
Returns: BH=colour
Get palette and border 10H AL=09 ES:DX =segment:offset of 17byte buffer
Returns:ES:DX =segment:offset of buffer
Set colour register 10H AL=10 BH=colour register CH,CL=green/blue value
DH=red value
Set block of colour registers 10H AL=13 BH=page BL=00
Get values of the colour registers 10H AL=15 BX =colour register
Returns:CH,CL,DH =green/blue/red
Get block of colour registers 10H AL=17 BX=first colour register CX=no. of colour register
ES:DX =segment:offset of buffer
Retruns: ES:DX segment:offset of buffer
Get the colour page state 10H AL=1AH
Returns: BH=colour page BL=mode
Set gray scale values 10H AL=1BH BX=first colour register CX=no. colour register
Load user font 11H AL=00 BH=points BL=block CX=number of character defined
by table DX=first char in the code in table ES:BP=
segment:offset of font table
Load 8 x 14 font 11H AL=01 BL=block
Set scan lines 12H AL=scan line code BL=30H
Returns: AL=12H/00(If VGA active/non-active)
Enable/disable video 12H AL=00/01 (Enable/Disable) BL=32H
Returns: AL=12H if supported
Enable/Disable gray code summing 12H AL=00/01 (Enable/Disable) BL=33H
Returns: AL=12H if supported
Enable/Disable cursor emulation 12H AL=00/01 (Enable/Disable) BL=34H
Returns: AL=12H if supported
Enable/Disable Screen refresh 12H AL=00/01 (Enable/Disable) BL=36H
Returns: AL=12H if supprted
Set or restore video mode 1CH AL=00/01/02 (Get/save/restore) CX=requested states
ES: BX =segment:offset of buffer
Returns:AL=1CH if suported
=====================================================================
List of common Video Modes:
- 00H 40x25 16Colours Text
- 01H 40x25 16Colours Text
- 02H 80x25 16Colours Text
- 03H 80x25 16Colours Text
- 04H 320x200 16Colours Graphics
- 05H 320x200 4Colours Graphics
- 06H 640x200 16Colours Graphics
- 07H 80x25 2 Colours Text
- 08H 160x200 16Colours Graphics
- 09H 320x200 16Colours Graphics
- 0AH 640x200 4Colours Graphics
- 0BH Reserved-Reserved-Reserved-Reserved
- 0CH Reserved-Reserved-Reserved-Reserved
- 0DH 320x200 16Colours Graphics
- 0EH 640x200 16Colours Graphics
- 0FH 640x350 4Colours Graphics
- 010H 640x350 4/16Colours Graphics
- 011H 640x480 2Colours Graphics
- 012H 640x480 16Colours Graphics
- 013H 320x200 256Colours Graphics
=====================================================================
Example Code in Assembly (Real Mode only):
mov AH, 00H ;Video Mode number
mov AL, 02H ;Mode Number, refer the BIOS Function List above
int 10H ;Call the function
mov AH, 02H ;Load function number to display the cursor
mov DX, 0C28H ;Load the coordinate (12,40) of the cursor into DX
mov BH, 00H ;Load page number
int 10H ;Call the BIOS function
mov AH, 09H ;Load the function to display the character
mov AL, 65H ;Loads the ASCII Code for a letter in AL (65=a) (Change the number if you wish)
mov BH, 00H ;Load page number
mov BL, 0FH ;Load attribute byte,normal-video, non-blinking character
mov CX, 01H ;Load the number of characters to send to the monitor
int 01H ;Calls the BIOS function
=====================================================================
Troubleshooting:
Faults:
A fault will take place if you try to access BIOS function when your kernel is running in protected mode.These BIOS function are available in Real Mode only.You can also use BIOS functions on V86 Mode(Virtual Real Mode).
Terms:
BIOS Basic input/output service(or system)
VGA Video Graphics Array
Links:
Text based Console (Protected mode)
Detecting Video Cards