Download presentation
Presentation is loading. Please wait.
1
DOS and BIOS Interrupts
DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from keyboard, etc. They are used by identifying the interrupt option type, which is the value stored in register AH and providing, whatever extra information that the specific option requires.
2
Video Programming When an application program needs to write characters on the screen in text mode, it can choose between three types of video output: MS-DOS-level access: Any computer running or emulating MS-DOS can use INT 21h to write text to video display. BIOS-level access: Characters are output using INT 10h function, known as BIOS services. This executes more quickly than int 21h, and permits the control of text color. Direct video access: Characters are moved directly to video RAM (screen buffer), so the execution is instantaneous.
3
Screen Buffer The screen buffer begins at B800:0000 and it has some rows and columns. Number of columns is usually 80. Number of rows can be 25 or 40 in most cases. Each line on screen takes 160 bytes (80 x 2 byte for CHARACTER + ATTRIBUTE).
4
Display Modes Monitors can display both text and graphics and have different techniques and memory requirements for each. Consequently, video adapters have two display modes: text and graphics. In text mode, the screen is divided into columns and rows, typically 80 columns by 25 rows, and a character is displayed at each screen position (character cell). In graphics mode, the screen is again divided into columns and rows, and each screen position is called a pixel (short for picture element). A picture can be displayed by specifying the color of each pixel on the screen. Text Modes Mode Description Adapters 3 80 x 25 16-color text VGA (most frequently used mode for text display) Graphics Modes Mode(hex) Description Adapters 12 640 x 480 4 color VGA 13 320 x 200 256 color VGA Video Display Addresses B800:0000h Standard display address for text mode
5
BIOS Interrupt 10H Option 0H – Sets video mode. Registers used: Ex:
AH = 0H AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex: MOV AH,0 MOV AL,7 INT 10H
6
BIOS Interrupt 10H Option 2H – Sets the cursor to a specific location.
Registers used: AH = 2H BH = 0H selects Page 0. DH = Row position. DL = Column position.
7
BIOS Interrupt 10H Ex: MOV AH,2 MOV BH,0 MOV DH,12 MOV DL,39 INT 10H
8
BIOS Interrupt 10H Option 6H – Scroll window up. This interrupt is also used to clear the screen when you set AL = 0. Registers used: AH = 6H AL = number of lines to scroll. BH = display attribute. CH = y coordinate of top left. CL = x coordinate of top left. DH = y coordinate of lower right. DL = x coordinate of lower right.
9
BIOS Interrupt 10H Clear Screen Example:
MOV AH,6 MOV AL,0 MOV BH,7 MOV CH,0 MOV CL,0 MOV DH,24 MOV DL,79 INT 10H The code above may be shortened by using AX, BX and DX registers to move word size data instead of byte size data.
10
BIOS Interrupt 10H Option 7H – Scroll window down. This interrupt is also used to clear the screen when you set AL = 0. Registers used: AH = 7H AL = number of lines to scroll. BH = display attribute. CH = y coordinate of top left. CL = x coordinate of top left. DH = y coordinate of lower right. DL = x coordinate of lower right.
11
Practice/Lab 4. Modify your code so that it performs the following tasks: - Clear screen - Set cursor to the middle of screen Display the characters (5) in: CHAR_TBL DB ‘A’ ,’B’, ’C’, ’D’, ’E’ on the middle of the screen 5. Compile and run your code
15
BIOS Interrupt 10H Option 8H – Read a character and its attribute at the cursor position. Registers used: AH = 8H and returned attribute value. AL = Returned ASCII value. BH = display page.
16
BIOS Interrupt 10H Option 9H – Write a character and its attribute at the cursor position. Registers used: AH = 9H. AL = ASCII value. BH = display page. BL = attribute. CX = number of characters to write.
17
Attribute Definition Monochrome display attributes Blinking Intensity
D7 = 0 - Non-blinking D7 = 1 - Blinking Intensity D3=0 - Normal intensity D3=1 - Highlighted intensity Background and foreground D6 D5 D4 and D2 D1 D0 White = 0 0 0 Black = 1 1 1
18
Attribute Definition Color display attributes Blinking Intensity
D7 = 0 - Non-blinking D7 = 1 - Blinking Intensity D3=0 - Normal intensity D3=1 - Highlighted intensity Background and foreground D6 D5 D4 and D2 D1 D0 RGB values defined by the table to the right.
20
DOS Interrupt 21H Option 1 – Inputs a single character from keyboard and echoes it to the monitor. Registers used: AH = 1 AL = the character inputted from keyboard. Ex: MOV AH,1 INT 21H
21
DOS Interrupt 21H Option 2 – Outputs a single character to the monitor. Registers used: AH = 2 DL = the character to be displayed. Ex: MOV AH,2 MOV DL,’A’ INT 21H
22
INT 21h/ 01H and 02H Input a character
Step 1: Set AH =01H Step 2: : Call INT 21H to display the character Step 3: The input character is saved in AL To display the entered character Step 1: Set AH=02H Step 2: Load the character from AL to DL – Step 3 Call INT 21H to display the character
23
Int 21h/1h 2h
24
Example Prompt reading a character
26
DOS Interrupt 21H Option 9 – Outputs a string of data, terminated by a $ to the monitor. Registers used: AH = 9 DX = the offset address of the data to be displayed. Ex: MOV AH,09 MOV DX,OFFSET MESS1 INT 21H
27
DOS Interrupt 21H Option 0AH – Inputs a string of data from the keyboard. Registers used: AH = 0AH DX = the offset address of the location where string will be stored. DOS requires that a buffer be defined in the data segment. It should be defined as follows: 1st byte contains the size of the buffer. 2nd byte is used by DOS to store the number of bytes stored.
28
DOS Interrupt 21H Ex: Assume “Go Tigers!” was entered on the keyboard.
.DATA BUFFER1 DB 15,?,15 DUP (FF) . MOV AH,0AH MOV DX,OFFSET BUFFER1 INT 21H Assume “Go Tigers!” was entered on the keyboard. BUFFER1 = 10,10,’Go Tigers!’,CR,255,255,255,255
29
DOS Interrupt 21H Option 4CH – Terminates a process, by returning control to a parent process or to DOS. Registers used: AH = 4CH AL = binary return code. Ex: MOV AH,4CH INT 21H
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.