Interupts --------- BIOS is based in ROM and handles all interrupts for the system. This handout describes various BIOS interrupts, and lists the DOS interrupts as a reference. An interrupt is an operation that interrupts the execution of a program so that the system can take special action. There are two main reasons for an inter- rupt: 1) An intentional request for such action as input from a device and output to a device, and 2) An unintentional serious error such as a divide overflow. External devices signal for attention via an INTR pin on the processor. The processor always responds to a request if the IF (Interrupt Flag) is en- abled (i.e., contains 1). Under most circumstances, the processor ignores an interrupt if the IF flag is disabled (i.e., contains 0). The instruction for setting an interrupt is STI and for clearing an interrupt is CLI. DOS supplies two modules, IBMBIO.COM and IBMDOS.COM, to facilitate the use of BIOS. Since the DOS modules provide much of the additional required testing, the DOS operations are generally easier to use than their BIOS counterparts. The IBMBIO.COM and IBMDOS.COM are on the DOS diskette, but are not displayed when you request DIR. IBMBIO.COM provides a "low-level" interface to BIOS. This is an I/O handler program that facilitates reading data from external devices into memory and writing data from memory onto external devices. IBMDOS.COM contains a file manager and a number of service functions such as blocking and deblocking disk records. When a user program requests an I/O operation, the operation delivers to IBMDOS "high-level" information via the contents of registers and control blocks. To complete the request, IBMDOS.COM translates the information into one or more calls to IBMBIO.COM. The following diagram shows the logical relationship: ------------- -------------- ------------- ------ ---------- |I/O Request| |"High-Level"| |"Loe-Level"| |ROM | |External| | by User | <--> | DOS | <--> | DOS | <--> | | <--> | | | Program | | IBMDOS.COM | |IBMBIO.COM | |BIOS| | Device | ------------- -------------- ------------- ------ ---------- TABLE OF INTERRUPT ADDRESSES ---------------------------- Address Interrupt Function (Hex) (Hex) -------------------------------------------------------------------- 00-03 00 Divide by zero 04-07 01 Single step (trace) 08-0B 02 Non-Maskable Interrupt (NMI) 0C-0F 03 Break-point instruction ('CC'x) 10-13 04 Overflow 14-17 05 Print Screen 18-1F 06,07 Reserved 20-23 08 Timer 24-27 09 Keyboard Interrupt 28-37 A,B,C,D Reserved 38-3B 0E Diskette Interrupt 3C-3F 0F Reserved 40-43 10 Video Screen I/O BIOS 44-47 11 Equipment Check 48-4B 12 Memory Size Check 4C-4F 13 Diskette I/O 50-53 14 Communications I/O 54-57 15 Cassette I/O 58-5B 16 Keyboard Input 5C-5F 17 Printer Output 60-63 18 ROM Basic Entry Code 64-67 19 Bootstrap Loader 68-6B 1A Time of Day 6C-6F 1B Get Control on Keyboard Break 70-73 1C Get Control on Timer Interrupt 74-77 1D Pointer to Video Initialization Table 78-7B 1E Pointer to Diskette Parameter Table 7C-7F 1F Pointer to Table for Graphics ASCII -------------------------------------------------------------------- 80-83 20 DOS Program Terminate 84-87 21 DOS Function Call 88-8B 22 DOS Terminate Address 8C-8F 23 DOS Ctrl/Break Exit Address DOS 90-93 24 DOS Fatal Error Vector 94-97 25 DOS Absolute Disk Read 98-9B 26 DOS Absolute Disk Write 9C-9F 27 DOS Terminate, Fix in Storage A0-FF 28-3F Reserved for DOS -------------------------------------------------------------------- 100-1FF 40-7F Not used BASIC 200-217 80-85 Reserved for BASIC 218-3C3 86-F0 Used by BASIC Interpreter 3C4-3FF F1-FF Not used -------------------------------------------------------------------- Interrupt 21h ------------- Interrupt 21h is the DOS function on interrupt. This interrupt gives access to the DOS/IO structure. The following table shows the possible functions using this interrupt. A program selects the function by setting the AH register to the correct value prior to issuing the Interrupt 21h. 00 Program end -> 01 Keyboard input -> 02 Display output 03 Auxiliary input (asynchronous communications) 04 Auxiliary output -> 05 Printer output 06 Direct console I/O 07 Direct console input without echo 08 Console input without echo -> 09 Print string -> 0A Buffered keyboard input 0B Check keyboard status 0C Clear keyboard buffer and do function # in AL 0D Disk reset 0E Select Disk -> 0F Open file -> 10 Close file 11 Search for first entry 12 Search for next entry -> 13 Delete file 14 Sequential read 15 Sequential write -> 16 Create file 17 Rename file 19 Current disk 1A Set disk transfer address 1B Allocation table address 21 Random read 22 Random write -> 23 File size 24 Set random record field 25 Set interrupt vector 26 Create a new program segment 27 Random block read 28 Random block write 29 Parse filename 2A Get date 2B Set date 2C Get time 2D Set time -> 40 Print string Input Functions --------------- 1) mov ah,01 Returns Character (entered from Keyboard) in AL int 21h 2) lea dx,InBuff InBuff+0 must have Maximum Number of Characters mov ah,0ah that can be entered from Keyboard int 21h InBuff+1 will show the Number of Characters actually entered from Keyboard InBuff+² Firsô Characteò entereä froí Keyboard Output Functions ---------------- 1) mov ah,02 Prints Character in DL to Standard Ouput (Screen) int 21h 2) lea dx,OutBuff Prints String pointed to by DX to Standard Output mov ah,09 The end of the String must be marked by '$' int 21h 3) lea dx,OutBuff Prints String pointed to by DX to Standard Output mov cx,Length CX determines the Number of Characters to print mov ah,40h Hence, the end of a String marker '$' is not needed int 21h