Copyright 1984 by ABComputing ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º PC DOS and Firmware º º º º by º º º º Don Buresh º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Introduction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ This column treats the IBM PC Disk Operating System (PC DOS ) and firmware. I will discuss the technical features (and undocumented bugs) in PC DOS using the PC DOS manual as our functional specification. I would like to thank Bill Salkin, the editor of PCFL, for permitting me to write this column ( EDITOR'S NOTE: Actually, I couldn't stop him.) With each article appearing in PCFL I will attempt to provide coding examples that illustrate the topic. These examples are the functional equivalents of the PC DOS commands. They will be distributed to PC user groups and electronic bulletin boards across the country on a FREEWARE(tm) basis. Ten years in data processing has convinced me that there are relatively few good coding examples in the public domain. I intend to provide structured assembly language code for the benefit of all. The schedule given below is tentative but indicates the direction of this column. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Second Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ My next article is concerned with three topics. The first topic is a summary of the birth and growth of PC DOS. The second is a review of the commands of PC DOS and how they have grown in function since their introduction two years ago. Third, we investigate IBMBIO.COM (or its MS-DOS equivalent IO.SYS) and COMMAND.COM, describing their intimate relationship to IBMDOS.COM (Did you know that IBM wrote IBMBIO.COM and COMMAND.COM and that Microsoft, Inc., is only responsible for DOS?) ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Third Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In the third article, we examine the PC DOS interrupts listed in Appendix A of the DOS manual. The Program Segment Prefix and the File Control Blocks (FCB) created by PC DOS when executing a .COM or .EXE file are discussed. In particular, we learn how assembly language programs can gain access to the command line. Third, we consider how PC DOS creates and maintains the disk directory file and the File Allocation Table (FAT) of a disk. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Fourth Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The fourth article concentrates on the PC DOS utility DISKCOPY. This utility has the ability to access all the available memory of your IBM Personal Computer. This is extremely important because the micro code of the Intel 8088 processor chip divides memory into 64K segments ( areas ). An assembly language program demonstrating how to access all memory in your system (subject to the constraint that you do not write over Video RAM ) will be presented. The assembly language program FREECOPY, provided on a FREEWARE(tm) basis, will further illustrate the concept. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Fifth Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The fifth article is centered around the FORMAT utility. I would like to develop a program that formats either a diskette or a hard disk, but may settle on formatting a diskette only. In the process we will analyze the implications of writing the bit pattern 0F6H to a diskette.(Did you know that this bit pattern does not stress a diskette so that a defective formatted diskette will slip through FORMAT.COM? What is the best bit pattern???? TRS-80 users know that 6DB6H is the most stressful bit pattern that can be written on a diskette.) I intend to write the program FREEFRMT, serving the same functions as FORMAT, but also writing a 6DB6H bit pattern on a diskette. FREEFRMT will be offered on a FREEWARE(tm) basis. After the fifth article it may be an appropriate time to discuss DISKCOMP and MODE. The interesting feature of DISKCOMP is that the NEC 765 (or the Intel 8272 for owners of the older versions of the IBM PC) floppy disk controller chip can be programmed to SCAN the contents of memory against the bit patterns on a diskette indicating any differences. This program is straightforward and a real gem. The program FREEMODE demonstrates how to parse a complicated command line and redirect the parallel printer interrupt (INT 17H) to a serial line (INT 14H). The implications to the operating system, in particular, Ctrl PrtSc or INT 05H of the ROM, are discussed. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Change of Direction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ We could continue to rewrite the various functions of PC DOS, but it would be more useful to re-investigate IBMDOS.COM, IBMBIO.COM, and COMMAND.COM and provide a thorough analysis of the relationships among these programs. They form a chain directly to the firmware. Before discussing the firmware in the ROM, the subject of device drivers and how they can be used with PC DOS 2.0 and 2.1 is explored. I am going to write a sample device driver and invite you to submit assembly language device drivers for public examination. Please place your source in the public domain so that we can all learn from it. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Sixth Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ We are finally prepared to discuss the firmware. My favorite ROM interrupt is the video interrupt or INT 10H ( I have done considerable work with the display driver ). Topics to be discussed are 1) why the IBM PC INT 10H is so slow; 2) how to scroll up, down, and sideways; 3)how to create graphic characters; etc. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Seventh Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In this article we interrupt drive the RS-232-C ports so a program can collect data over the serial port while a concurrent process is executing in another part of the program. In the process, we redirect INTerrupts 09H and 0CH so characters can be sent and received concurrently. Modified versions of these two interrupts, and INT 14H, are provided. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Eighth Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ This article concentrates on the disk driver interrupt, otherwise known as INT 13H. The three (3) chips that must be programmed for INT 13H are the Intel 8237 Dynamic Memory Access (DMA) chip, the Intel 8259 hardware interrupt chip and the NEC 765 (or Intel 8272). INT 13H is one of the most powerful and little understood software interrupts. We demonstrate how companies use this interrupt to copy protect their programs. The information given in this article is published in the Intel Data Catalog which is sold over the counter. Companies use the information contained in this book to create proprietary copy-protection schemes. Actually, software companies are merely specifying the parameters to these three chips. As an example, I will show how to format a diskette with odd sector sizes, such as 189 bytes per sector. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Ninth & Tenth articles ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The next two articles consider the remaining interrupts in the PC firmware and show how to use them effectively in programs. Use of INTerrupts 1BH through 1FH are demonstrated. (Interrupt 1B is used for "Ctrl Break" processing; 1C points to code executed with every tick of the clock; 1D is used for video initialization; 1E is used to adjust the disk parameter table; and 1F offers programmers the opportunity to create unique graphic characters.) ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Eleventh Article ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ With these tasks behind us, we return to PC DOS and explain the file-handling interrupts. The reason for this change in direction is that by this time I hope to release (in the public domain) an assembly language terminal program with the XMODEM file-transfer protocol. I also want the program to contain a terminal routine with an ANSI parser as well as an interrupt-driven conversational routine. This program demonstrates how to use the PC DOS and ROM interrupts in a significant manner. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Conclusion ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In closing, I invite all of my readers to suggest other topics to cover in this column. You are further encouraged to send me assembly language coding examples to discuss, and then be placed in the public domain. Please do not send proprietary code which you have written as an employee of a company. I will neither release nor discuss proprietary code! I hope your interest has been whetted by this introductory article. Good programming!!!! *XENIX(tm) is a trademark of Microsoft, Inc. **FREEWARE(tm) is a trademark of Headlands Press, Inc. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Name: ÛÛ dos1.txt ÛÛ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ IGDEAL used above is regarded as a reference to BIGDEAL.ASM.) Assuming that BIGDEAL