DOS and BIOS Interrupts n n DOS and
DOS and BIOS Interrupts n n 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. 1
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: n MS-DOS-level access: Any computer running or emulating MS-DOS can use INT 21 h to write text to video display. n BIOS-level access: Characters are output using INT 10 h function, known as BIOS services. This executes more quickly than int 21 h, and permits the control of text color. n Direct video access: Characters are moved directly to video RAM (screen buffer), so the execution is instantaneous. 2
Screen Buffer The screen buffer begins at B 800: 0000 and it has some rows and columns. n Number of columns is usually 80. n Number of rows can be 25 or 40 in most cases. n Each line on screen takes 160 bytes (80 x 2 byte for CHARACTER + ATTRIBUTE). n 3
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). n 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 n Mode Description Adapters 3 80 x 25 16 -color text VGA (most frequently used mode for text display) Graphics Modes n Mode(hex) Description Adapters 12 640 x 480 4 color VGA 13 320 x 200 256 color VGA Video Display Addresses B 800: 0000 h Standard display address for text mode n 4
BIOS Interrupt 10 H n n Option 0 H – Sets video mode. Registers used: ¨ AH = 0 H ¨ AL = Video Mode. n n n 3 H - CGA Color text of 80 X 25 7 H - Monochrome text of 80 X 25 Ex: ¨ MOV AH, 0 ¨ MOV AL, 7 ¨ INT 10 H 5
BIOS Interrupt 10 H n n Option 2 H – Sets the cursor to a specific location. Registers used: ¨ AH = 2 H ¨ BH = 0 H selects Page 0. ¨ DH = Row position. ¨ DL = Column position. 6
BIOS Interrupt 10 H n Ex: ¨ MOV AH, 2 ¨ MOV BH, 0 ¨ MOV DH, 12 ¨ MOV DL, 39 ¨ INT 10 H 7
BIOS Interrupt 10 H n n Option 6 H – Scroll window up. This interrupt is also used to clear the screen when you set AL = 0. Registers used: ¨ AH = 6 H ¨ 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. 8
BIOS Interrupt 10 H n 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 10 H n The code above may be shortened by using AX, BX and DX registers to move word size data instead of byte size data. 9
BIOS Interrupt 10 H n n Option 7 H – Scroll window down. This interrupt is also used to clear the screen when you set AL = 0. Registers used: ¨ AH = 7 H ¨ 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. 10
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 11
12
13
14
BIOS Interrupt 10 H n n Option 8 H – Read a character and its attribute at the cursor position. Registers used: ¨ AH = 8 H and returned attribute value. ¨ AL = Returned ASCII value. ¨ BH = display page. 15
BIOS Interrupt 10 H n n Option 9 H – Write a character and its attribute at the cursor position. Registers used: ¨ AH = 9 H. ¨ AL = ASCII value. ¨ BH = display page. ¨ BL = attribute. ¨ CX = number of characters to write. 16
Attribute Definition n Monochrome display attributes ¨ Blinking n D 7 = 0 - Non-blinking n D 7 = 1 - Blinking ¨ Intensity n D 3=0 - Normal intensity n D 3=1 - Highlighted intensity ¨ Background and foreground n D 6 D 5 D 4 and D 2 D 1 D 0 ¨ ¨ White = 0 0 0 Black = 1 17
Attribute Definition n Color display attributes ¨ Blinking n n ¨ Intensity n n ¨ D 7 = 0 - Non-blinking D 7 = 1 - Blinking D 3=0 - Normal intensity D 3=1 - Highlighted intensity Background and foreground n D 6 D 5 D 4 and D 2 D 1 D 0 ¨ RGB values defined by the table to the right. 18
19
DOS Interrupt 21 H n n Option 1 – Inputs a single character from keyboard and echoes it to the monitor. Registers used: ¨ AH = 1 ¨ AL = the character inputted from keyboard. n Ex: ¨ MOV AH, 1 ¨ INT 21 H 20
DOS Interrupt 21 H n n Option 2 – Outputs a single character to the monitor. Registers used: ¨ AH = 2 ¨ DL = the character to be displayed. n Ex: ¨ MOV AH, 2 ¨ MOV DL, ’A’ ¨ INT 21 H 21
INT 21 h/ 01 H and 02 H • Input a character – Step 1: Set AH =01 H – Step 2: : Call INT 21 H to display the character – Step 3: The input character is saved in AL • To display the entered character – Step 1: Set AH=02 H – Step 2: Load the character from AL to DL – Step 3 Call INT 21 H to display the character 22
Int 21 h/1 h 2 h 23
Example Promptreading a character • 24
25
DOS Interrupt 21 H n n 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. n Ex: ¨ MOV AH, 09 ¨ MOV DX, OFFSET MESS 1 ¨ INT 21 H 26
DOS Interrupt 21 H n n Option 0 AH – Inputs a string of data from the keyboard. Registers used: ¨ AH = 0 AH ¨ DX = the offset address of the location where string will be stored. n DOS requires that a buffer be defined in the data segment. It should be defined as follows: ¨ 1 st byte contains the size of the buffer. ¨ 2 nd byte is used by DOS to store the number of bytes stored. 27
DOS Interrupt 21 H n Ex: ¨. DATA ¨ BUFFER 1 DB 15, ? , 15 DUP (FF) ¨. ¨. ¨ MOV AH, 0 AH ¨ MOV DX, OFFSET BUFFER 1 ¨ INT 21 H n Assume “Go Tigers!” was entered on the keyboard. ¨ BUFFER 1 = 10, ’Go Tigers!’, CR, 255, 255 28
DOS Interrupt 21 H n n Option 4 CH – Terminates a process, by returning control to a parent process or to DOS. Registers used: ¨ AH = 4 CH ¨ AL = binary return code. n Ex: ¨ MOV AH, 4 CH ¨ INT 21 H 29
- Slides: 29