Basic Input Output System-Microprocessor and Assembly Language Programming-Lecture Notes, Study notes of Microprocessor and Assembly Language Programming

This lecture handout was provided at Quaid-i-Azam University for Microprocessor and Assembly Language Programming course by Prof. Saleem Raza. Its main points are: Bios, Services, Video, Int, Graphics, Ascii, Cursor, Write, Position, String, Altering, Attributes

Typology: Study notes

2011/2012

Uploaded on 08/04/2012

saqqi
saqqi ๐Ÿ‡ต๐Ÿ‡ฐ

4

(33)

40 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The Basic Input Output System (BIOS) provides services for video,
keyboard, serial port, parallel port, time etc. The video services are exported
via INT 10. We will discuss some very simple services. Video services are
classified into two broad categories; graphics mode services and text mode
services. In graphics mode a location in video memory corresponds to a dot
on the screen. In text mode this relation is not straightforward. The video
memory holds the ASCII of the character to be shown and the actual shape is
read from a font definition stored elsewhere in memory. We first present a list
of common video services used in text mode.
INT 10 - VIDEO - SET VIDEO MODE
AH = 00h
AL = desired video mode
Some common video modes include 40x25 text mode (mode 0), 80x25 text
mode (mode 2), 80x50 text mode (mode 3), and 320x200 graphics mode
(mode D).
INT 10 - VIDEO - SET TEXT-MODE CURSOR SHAPE
AH = 01h
CH = cursor start and options
CL = bottom scan line containing cursor (bits 0-4)
INT 10 - VIDEO - SET CURSOR POSITION
AH = 02h
BH = page number
0-3 in modes 2&3
0-7 in modes 0&1
0 in graphics modes
DH = row (00h is top)
DL = column (00h is left)
INT 10 - VIDEO - SCROLL UP WINDOW
AH = 06h
AL = number of lines by which to scroll up (00h = clear entire window)
BH = attribute used to write blank lines at bottom of window
CH, CL = row, column of window's upper left corner
DH, DL = row, column of window's lower right corner
INT 10 - VIDEO - SCROLL DOWN WINDOW
AH = 07h
AL = number of lines by which to scroll down (00h=clear entire window)
BH = attribute used to write blank lines at top of window
CH, CL = row, column of window's upper left corner
DH, DL = row, column of window's lower right corner
INT 10 - VIDEO - WRITE CHARACTER AND ATTRIBUTE AT CURSOR POSITION
AH = 09h
AL = character to display
BH = page number
pf3
pf4
pf5

Partial preview of the text

Download Basic Input Output System-Microprocessor and Assembly Language Programming-Lecture Notes and more Study notes Microprocessor and Assembly Language Programming in PDF only on Docsity!

The Basic Input Output System (BIOS) provides services for video,

keyboard, serial port, parallel port, time etc. The video services are exported

via INT 10. We will discuss some very simple services. Video services are

classified into two broad categories; graphics mode services and text mode

services. In graphics mode a location in video memory corresponds to a dot

on the screen. In text mode this relation is not straightforward. The video

memory holds the ASCII of the character to be shown and the actual shape is

read from a font definition stored elsewhere in memory. We first present a list

of common video services used in text mode.

INT 10 - VIDEO - SET VIDEO MODE

AH = 00h AL = desired video mode

Some common video modes include 40x25 text mode (mode 0), 80x25 text

mode (mode 2), 80x50 text mode (mode 3), and 320x200 graphics mode

(mode D).

INT 10 - VIDEO - SET TEXT-MODE CURSOR SHAPE

AH = 01h CH = cursor start and options CL = bottom scan line containing cursor (bits 0-4) INT 10 - VIDEO - SET CURSOR POSITION AH = 02h BH = page number 0-3 in modes 2& 0-7 in modes 0& 0 in graphics modes DH = row (00h is top) DL = column (00h is left) INT 10 - VIDEO - SCROLL UP WINDOW AH = 06h AL = number of lines by which to scroll up (00h = clear entire window) BH = attribute used to write blank lines at bottom of window CH, CL = row, column of window's upper left corner DH, DL = row, column of window's lower right corner INT 10 - VIDEO - SCROLL DOWN WINDOW AH = 07h AL = number of lines by which to scroll down (00h=clear entire window) BH = attribute used to write blank lines at top of window CH, CL = row, column of window's upper left corner DH, DL = row, column of window's lower right corner INT 10 - VIDEO - WRITE CHARACTER AND ATTRIBUTE AT CURSOR POSITION AH = 09h AL = character to display BH = page number

BL = attribute (text mode) or color (graphics mode) CX = number of times to write character INT 10 - VIDEO - WRITE CHARACTER ONLY AT CURSOR POSITION AH = 0Ah AL = character to display BH = page number BL = attribute (text mode) or color (graphics mode) CX = number of times to write character INT 10 - VIDEO - WRITE STRING AH = 13h AL = write mode bit 0: update cursor after writing bit 1: string contains alternating characters and attributes bits 2-7: reserved (0) BH = page number BL = attribute if string contains only characters CX = number of characters in string DH, DL = row, column at which to start writing ES:BP -> string to write

Chargen Services

In our first example we will read the font definition in memory and change

it to include a set of all on pixels in the last line showing an effect of

underline on all character including space. An 8x16 font is stored in 16

bytes. A sample character and the corresponding 16 values stored in the font

information are shown for the character โ€˜Aโ€™. We

start with two services from the chargen subset

of video services that we are going to use.

INT 10 - VIDEO - GET FONT INFORMATION

AX = 1130h BH = pointer specifier Return: ES:BP = specified pointer CX = bytes/character of on-screen font DL = highest character row on screen INT 10 - TEXT-MODE CHARGEN AX = 1110h ES:BP -> user table CX = count of patterns to store DX = character offset into map 2 block BL = block to load in map 2 BH = number of bytes per character pattern

We will use 6 as the pointer specifier which means the 8x16 font stored in

ROM.

Example

; put underlines on screen font [org 0x0100] jmp start

font: times 256*16 db 0 ; space for font

start: mov ax, 0x1130 ; service 11/30 โ€“ get font info mov bx, 0x0600 ; ROM 8x16 font int 0x10 ; bios video services

mov si, bp ; point si to rom font data mov di, font ; point di to space for font

mov ax, 0x4c00 ; terminate program int 0x

Graphics Mode Services

We will take an example of using graphics mode video services as well. We

will draw a line across the screen using the following service.

INT 10 - VIDEO - WRITE GRAPHICS PIXEL

AH = 0Ch BH = page number AL = pixel color CX = column DX = row

Example

; draw line in graphics mode [org 0x0100] mov ax, 0x000D ; set 320x200 graphics mode int 0x10 ; bios video services

mov ax, 0x0C07 ; put pixel in white color xor bx, bx ; page number 0 mov cx, 200 ; x position 200 mov dx, 200 ; y position 200

l1: int 0x10 ; bios video services dec dx ; decrease y position loop l1 ; decrease x position and repeat

mov ah, 0 ; service 0 โ€“ get keystroke int 0x16 ; bios keyboard services

mov ax, 0x0003 ; 80x25 text mode int 0x10 ; bios video services

mov ax, 0x4c00 ; terminate program int 0x

DOS VIDEO SERVICES

Services of DOS are more cooked and at a higher level than BIOS. They

provide less control but make routine tasks much easier. Some important

DOS services are listed below.

INT 21 - READ CHARACTER FROM STANDARD INPUT, WITH ECHO

AH = 01h Return: AL = character read INT 21 - WRITE STRING TO STANDARD OUTPUT AH = 09h DS:DX -> $ terminated string INT 21 - BUFFERED INPUT AH = 0Ah DS:DX -> dos input buffer

The DOS input buffer has a special format where the first byte stores the

maximum characters buffer can hold, the second byte holds the number of

characters actually read on return, and the following space is used for the

actual characters read. We start will an example of reading a string with

service 1 and displaying it with service 9.

Example

; character input using dos services [org 0x0100] jmp start

maxlength: dw 80 ; maximum length of input message: db 10, 13, 'hello $' ; greetings message buffer: times 81 db 0 ; space for input string

start: mov cx, [maxlength] ; load maximum length in cx mov si, buffer ; point si to start of buffer

nextchar: mov ah, 1 ; service 1 โ€“ read character int 0x21 ; dos services

cmp al, 13 ; is enter pressed je exit ; yes, leave input mov [si], al ; no, save this character inc si ; increment buffer pointer loop nextchar ; repeat for next input char

exit: mov byte [si], '$' ; append $ to user input

mov dx, message ; greetings message mov ah, 9 ; service 9 โ€“ write string int 0x21 ; dos services

mov dx, buffer ; user input buffer mov ah, 9 ; service 9 โ€“ write string int 0x21 ; dos services

mov ax, 0x4c00 ; terminate program int 0x

Our next example uses the more cooked buffered input service of DOS and

using the same service 9 to print the string.

Example

; buffer input using dos services [org 0x0100] jmp start

message: db 10,13,'hello ', 10, 13, '$' buffer: db 80 ; length of buffer db 0 ; number of character on return times 80 db 0 ; actual buffer space

start: mov dx, buffer ; input buffer mov ah, 0x0A ; service A โ€“ buffered input int 0x21 ; dos services

mov bh, 0 mov bl, [buffer+1] ; read actual size in bx mov byte [buffer+2+bx], '$' ; append $ to user input

mov dx, message ; greetings message mov ah, 9 ; service 9 โ€“ write string int 0x21 ; dos services

mov dx, buffer+2 ; user input buffer mov ah, 9 ; service 9 โ€“ write string int 0x21 ; dos services

mov ax, 0x4c00 ; terminate program int 0x

More detail of DOS and BIOS interrupts is available in the Ralf Brown

Interrupt List.