bios1 basic input output system bios bios refers to a set of procedures or functions that enable the...

10
BIOS 1 Basic Input Output System BIOS • BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer. • A BIOS function is invoked using the INT instruction. The actual function is specified by the contents of AH. • ROM BIOS refers to BIOS procedures that are stored in a ROM placed on the motherboard. Some typical ROM BIOS are: INT 10H Video Driver INT 13H Disk Driver INT 14H Serial Port Driver INT 16H Keyboard Driver • DOS BIOS refers to BIOS that are loaded from a disk after the computer is booted up. Most DOS BIOS are

Upload: millicent-wade

Post on 28-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 1

Basic Input Output SystemBIOS

• BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.

• A BIOS function is invoked using the INT instruction. The actual function is specified by the contents of AH.

• ROM BIOS refers to BIOS procedures that are stored in a ROM placed on the motherboard. Some typical ROM BIOS are:

– INT 10H Video Driver

– INT 13H Disk Driver

– INT 14H Serial Port Driver

– INT 16H Keyboard Driver

• DOS BIOS refers to BIOS that are loaded from a disk after the computer is booted up. Most DOS BIOS are invoked using the INT 21H instruction.

Page 2: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 2

Character Input from keyboard with Echo

• INT 21H Function 01H: – Call With: AH = 01H– Returns: AL = ASCII character pressed. – Note: If AL is zero, then a function key

is pressed.– Example: The following macro reads a one digit number

from the keyboard and returns the corresponding binary value in AL.

GET1 MACRO

MOV AH,01 ;Specify function 01

INT 21H ;Call DOS BIOS

AND AL,0FH ;Convert from ASCII to binary

GET1 ENDM

Page 3: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 3

Display Character on Standard Output Device

• INT 21H Function 02H: – Call With: AH = 02H

DL = ASCII code of character to be displayed – Returns: AL = ASCII code of character displayed – Note: Standard output device is normally the

monitor.– Example: The following macro displays a one digit number

on the screen. The number is passed in DL as a binary number.

DSP1 MACRO

OR DL,30H ;Convert from binary to ASCII

MOV AH,02 ;Specify function 02

INT 21H ;Call DOS BIOS

DSP1 ENDM

Page 4: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 4

Display a Character String

• INT 21H Function 09H: – Call With: AH = 09H

DS:DX = Segment:Offset address of the string.

– Returns: All registers unchanged. – Note: Displays a character string up to the

first occurrence of the dollar sign "$".– Example: The following macro displays the character

string MSG on the screen.

DMSG MACRO MSG

MOV DX, Offset MSG ;Point to MSG

MOV AH,09 ;Specify function 09

INT 21H ;Call DOS BIOS

DMSG ENDM

Page 5: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 5

Buffered Keyboard Input

• INT 21H Function 0AH: – Call With: AH = 0AH

DS:DX = Segment:Offset address of the buffer

The first byte in the buffer should be loaded with the size of the buffer, i.e. the maximum number of characters to be input.

– Returns: All registers unchanged.

The second byte in the buffer is equal to the number of characters entered.

The characters entered are stored in the buffer starting from the third byte.

– Note: The functions ends if the user has typed in a number of characters equal to the first value in the buffer, or if the user has pressed the “Enter” key.

Page 6: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 6

Buffered Keyboard Input:- Example

The following procedure prompts the user to type in a text up to 30 characters long. The text entered is stored in the buffer BUF1. The procedure uses the DSPM macro of the previous example.

ORG 100H

MSG1 DB ‘Type in a text up to 30 characters long’, 0AH, 0DH,’$’

BUF1 DB 30, 00, 30 DUP(?)

MAIN PROC NEAR

DSPM MSG1 ;Display MSG1

MOV DX, Offset BUF1 ;Point to BUF1

MOV AH,0AH ;Specify function 0A

INT 21H ;Call DOS BIOS

RET

MAIN ENDP

Page 7: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 7

ASCII Codes

00 NUL01 SOH02 STX03 ETX04 EOT05 ENQ06 ACK07 BEL

• ASCII code is a standard 8-bit binary code for alphanumeric characters.• It defines:

– a group of control characters (00H to 20H and 7FH for Delete)– a group of printable characters (21H to 7EH)– a group of special graphics or multilingual characters (80H to FFH)

08 BS09 HT0A LF0B VT0C FF0D CR0E SO0F SI

ASCII Control Characters

10 DLE 11 DC112 DC2 13 DC3 14 DC4 15 NAK 16 SYN 17 ETB

18 CAN19 EM1A SUB1B ESC1C FS1D GS1E RS1F US

Page 8: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 8

ASCII Codes - Printable Characters

20 Space21 !22 ”23 #24 $25 %26 &27 ’28 (29 )2A *2B +2C ,2D -2E .2F /

30 031 132 233 334 435 536 637 738 839 93A :3B ;3C <3D =3E >3F ?

40 @41 A42 B43 C44 D45 E46 F47 G48 H49 I4A J4B K4C L4D M4E N4F O

60 `61 a62 b63 c64 d65 e66 f67 g68 h69 i6A j6B k6C l6D m6E n6F o

70 p 71 q72 r73 s74 t75 u76 v77 w78 x79 y7A z7B {7C |7D }7E ~ 7F Del

50 P51 Q52 R53 S54 T55 U56 V57 W58 X59 Y5A Z5B [5C \5D ]5E ^5F _

Page 9: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 9

EXAMPLE(1/2)• x86 Assembly program that asks for two numbers and prints their sumTITLE printsum.data ;data segment

ORG 100H ;only if com programMSG1 DB ‘Please enter a number’, 10, 13, ‘$’MSG2 DB ‘sum = ’, 10, 13, ‘$’

.code ;code segmentStart: mov ax,@data

mov ds,axLEA DX,MSG1 ;OR MOV DX, OFFSET MSG1 MOV AH,09H ; Printing MSG1INT 21HMOV AH,01HINT 21H ;reading number 1 from keyboardMOV BL,AL ;moving number 1 to BLSUB BL, 30h ;Subtracting ascii offsetLEA DX,MSG1 MOV AH,09H ; Printing MSG1INT 21HMOV AH,01HINT 21H ;reading number 2 from keyboardSUB AL, 30h ;Subtracting ascii

Page 10: BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer

BIOS 10

EXAMPLE(2/2)

ADD AL,BL ;Adding the two numbers

MOV AH, 0 ;clearing AH for division

MOV BL, 10

DIV BL ;dividing with 10 to obtain decimal digits

MOV BH, AH ;moving remainder to use AH for interrupts

LEA DX,MSG2

MOV AH, 09 ;printing MSG2

INT 21H ;could corrupt registers, need to PUSH-POP!

MOV DL, AL ;printing digit 1

ADD DL, 30H

MOV AH, 02

INT 21H ;could corrupt registers, need to PUSH-POP!

MOV DL, BH ;printing digit 2

ADD DL, 30H

MOV AH, 02

INT 21H

MOV AH,4CH ; exit to operating system

INT 21H

end start