Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version nyu B notes v1.5 12/10/84; site acf4.UUCP Path: utzoo!linus!philabs!cmcl2!acf4!tsc2597 From: tsc2597@acf4.UUCP (Sam Chin) Newsgroups: net.micro.pc Subject: Re: Questions on Interrupts and DOS Message-ID: <1050029@acf4.UUCP> Date: Sun, 5-May-85 21:56:00 EDT Article-I.D.: acf4.1050029 Posted: Sun May 5 21:56:00 1985 Date-Received: Tue, 7-May-85 21:11:15 EDT References: <79@tekig5.UUCP> Organization: New York University Lines: 89 <> In response to the queries about how to use the interrupt capabilities on the PC and the conversion of PC specific programs to generic MS-DOS programs, I am writing a few lines which I hope will be of help. On the PC or any other 8086/88 based machine, the interrupt vectors are stored in the first 1K of low memory. Each address is a 16 bit segment and a 16 bit offset giving 4 bytes in total. You can therefore have 256 interrupt vectors. If you want to examine memory, just use the D option in DEBUG. When the PC starts up, a program in the ROM BIOS initializes the interrupt vectors 2,5,8,9,E, 10-1A, 1C-1F. They are: 2 - Non-Maskable 5 - Print Screen 8 - 8253 System timer 9 - Keyboard (Raw keyboard interrupt - when a key is pressed this goes off) E - Diskette (Raw diskette interrupt) 10 - Video control for monochrome and CG adapters 11 - Reads Switches on Motherboard 12 - Gets memory size from switches 13 - Diskette I/O (Most people use this one as E is a system interrupt) 14 - Communications - Serial I/O 15 - Cassette I/O 16 - Keyboard I/O (This too is used rather than interrupt 9) 17 - Printer 18 - Cassette BASIC 19 - Power on reset 1A - Time of Day 1C - Timer Tick 1D - Video Init 1E - Diskette Parameters 1F - Graphics character extension Interrupts 0 to 7 are 8088 Interrupt Vectors, Interrupts 8 to F are multiplexed to the 8088 through the 8259 interrupt controller which prioritzes the interrupts, Interrupts 10 to 1A are entry points into the BIOS, 1B and 1C user supplied routines and 1D to 1F BIOS parameters. After the BIOS initializes all the interrupt vectors, it reads the boot track on the floppy or hard disk and the boot program takes over, loading MS-DOS and its associated higher level device drivers. A program is not a generic MS-DOS program if it uses any of the above interrupts or attempts to control various chips in the PC through the 8088 ports or attempts to access/modify video memory. Most PC Clones such as COMPAQ, Corona etc are completely bios compatible (the above interrupts are implemented) but may not be totally hardware compatible (the chips used to build it are different or at different locations) On machines such as the DEC Rainbow, Zenith Z-100 or my Lomas S-100 system, interrupts 0 through 1F are used for totally different things and none of the hardware is at the same locations as the PC. Therefore, only generic MS-DOS programs will run on it. A program is generic MS-DOS if and only if it uses only interrupts 20H through 3FH. MS-DOS reserves interrupt types 20H to 3FH of which only 20H to 27H are implemented (as of DOS 2.0). The rest are reserved for future use. Of the interrupts 20H to 27H, the one of most interest is interrupt 21H. This interrupt controls I/O to various devices, the file system, memory allocation etc. The particular function is controled by putting a function number in the AH register prior to issuing the interrupt. Programs which use BIOS interrupts are much easier to convert to generic MS-DOS than programs which access the hardware directly. To convert programs, replace the interrupts 0 to 1F that you find in your program with the same actions using interrupt 21H and the appropriate function. As a simple example, the video interrupt (10H) on the PC will clear the screen if you put 6 in register AH and 0 in register AL. To simulate this on a Z-100, you would invoke interrupt 21H with function 2 (display a character) twice. The first time you would put 1BH in DL and the second time put 'E' in DL. This outputs the escape sequence E to the Z-100 which causes the firmware in the terminal to clear the screen. It may not be easy to simulate some of the interrupts but certainly, the video interrupt (10H) and the keyboard interrupt (16H) etc can be simulated. Finally, the following references will be useful. (1) IBM PC Technical Reference Manual (2) MS-DOS Programmers Manual (I'm not sure of the exact title but this is not the DOS 2.0 manual) (3) Assembly Language Programming for the IBM PC by David Bradley (talks a lot about the hardware on the PC) (4) IBM PC & XT Assembly Language by Leo Scanlon (Has a nice section which completely details the interrupts) Good Luck! Sam Chin UUCP: allegra!cmcl2!acf4!tsc2597 ARPA: tsc2597.acf4@nyu