Preface

Programming the 80286, 80386, 80486, and Pentium-Based Personal Computer

© 1995 by Barry B. Brey

This text is written for the student in any course of study that requires a thorough knowledge of the configuration and programming of the Intel-based personal computer. These curricula include: computer science, engineering, and engineering technology. It is a very practical reference text for anyone interested in the programming and other aspects of this important microprocessor family and the personal computer system. Today, anyone functioning or striving to function in a field of study that uses computers must understand assembly language programming and the personal computer. This is especially true even when using high-level languages such as C/C++ for software development. Even though C/C++ can perform most machine functions, assembly language software is used to improve the performance of a program and to control hardware aspects of a system. Because machine control is addressed with assembly language, the intimate details of assembly language must be understood. Assembly language is also the only choice for video gaming applications and virtual reality because of the efficiency demanded.

It is suggested that the student has a foundation in number systems. If not, section 1-3 is provided as a primer on number systems and may be included as part of a course if needed. No other requirements should be necessary for a course based on this text, except for the Microsoft MASM assembler package, version 5.10 or hopefully version 6.X. Intel microprocessors have gained wide application and acceptance in many areas of electronics, communications, control systems, and particularly in desktop computer systems. The personal computer is often a launching point for system development and is even available in integrated form as the 80386EX--a PC on a chip.

ORGANIZATION AND COVERAGE

In order to cultivate a comprehensive approach to learning, each chapter of the text begins with a set of objectives that briefly define the contents of the chapter. This is followed by the body of the chapter, which includes many programming applications that illustrate the main topics of the chapter. At the end of each chapter, a numerical summary, which doubles as a study guide, reviews the information presented in the chapter. Finally, questions and problems are provided to promote practice and mental exercise with the concepts presented in the chapter.

This text contains hundreds of complete programming examples, using the Microsoft Macro Assembler program, provide an opportunity to learn how to program the Intel family of microprocessors and the personal computer. Operation of the programming environment includes the, linker, library, macros, DOS function, and BIOS functions. Also included is a study of batch programs, and how to configure the personal computer.

APPROACH

Because the Intel family of microprocessors is quite diverse, this text initially concentrates on real-mode assembly language programming, which is compatible with all versions of the Intel family of microprocessors and all personal computers based on them. Instructions for each family member, which includes the 80286, 80386, 80486 and Pentium, are compared and contrasted with the 8086/8088 microprocessor. This entire series of microprocessors is very similar, which allows more advanced versions to be learned once the basics are understood.

The text also develops an understanding of the CONFIG.SYS file, the AUTOEXEC.BAT file as they apply to DOS and the configuration of the personal computer. Configuration is fostered through a study of batch programs that illustrate the customization of the DOS system and also utility programs. The configuration of WINDOWS and the structure of its WIN.INI and SYSTEM.INI files are developed and discussed.

In addition to fully explaining the programming and operation of the microprocessor, this text also explains the programming and operation of the numeric coprocessor (8087/80287/80387/80486/7 and Pentium). The numeric coprocessor functions in a system to provide access to floating-point calculations that are important in applications such as control systems, video graphics, and computer aided design (CAD). The numeric coprocessor allows a program to access complex arithmetic operations that are otherwise difficult to achieve with normal microprocessor programming.

Advanced programming techniques include access to the expanded memory system using the EMS functions provided by EMM386.EXE and also VCPI. Access to the extended memory system programming is provided by a study of the XMS functions provided by HIMEM.SYS and also DPMI. Protected mode programming and applications are provided by DPMI. The structure of the device driver is studied and several device driver programs are illustrated. Other advanced programming techniques include the TSR, hot-key, and mouse driver.

  1. Develop control software to control an application interfaced to the 8086/8088, 80286, 80386, 80486, and Pentium microprocessor. Generally, the software developed will also function on all versions of the microprocessor. This software also includes DOS-based applications.
  2. Program using DOS function calls to control the keyboard, video display system, and disk memory in assembly language.
  3. Use the DOS internal and external commands to control the personal computer system and write batch programs.
  4. Use the BIOS functions to control the keyboard, display, and various other components in the computer system.
  5. Use INT 33H to access the mouse through the mouse driver.
  6. Develop software that uses interrupt hooks, and hot-keys to gain access to terminate and stay resident software.
  7. Program the numeric coprocessor to solve complex equations.
  8. Explain the differences between the family members and highlight the features of each member.
  9. Describe and use real and protected mode operation of the 80286, 80386, 80486, and Pentium microprocessors.
  10. Use the EMS, XMS, VCPI, and DPMI drivers to access protected mode operation, expanded memory, and extended memory.
  11. Write device drivers using the IOCTL functions provided by DOS.
  12. Execute another program using the EXEC function provided by DOS.
  13. Invoke assembly language procedures from high-level languages such as C/C++, PASCAL, BASIC, and FORTRAN.

CONTENT OVERVIEW

Chapters 1 through 3 introduce the Intel family of microprocessors with an emphasis on the microprocessor-based personal computer system. These early chapters serve to introduce the microprocessor, its history, its operation, and the methods used to store data in a microprocessor-based system. The structure of the personal computer, its memory map, its I/O map, disk system, and DOS internal and external commands are introduced. Also explored are the DOS configuration files CONFIG.SYS and AUTOEXEC.BAT as well as the WINDOWS configuration files WIN.INI and SYSTEM.INI. The construction and development of batch programs for controlling the personal computer system are explored. Once an understanding of the basic machine is grasped, Chapters 4--8 explain the basic programming model of the microprocessor, real and protected mode operation, and how each instruction functions with the Intel family of microprocessors. As instructions are explained, simple applications are presented to illustrate the operation of the instructions and develop basic programming concepts.

Once the basis for programming is developed, Chapters 9, 10, and 11 provide applications using the assembler program. These applications include programs that use DOS and BIOS function calls. Disk files are explained as well as keyboard and video operation on a personal computer system. The mouse and video system are explained as well as using them with application software. These chapters provide the tools required to develop virtually any program on a personal computer system.

Chapter 12 presents the operation and construction of TSR (terminate and stay resident) software. This includes the use of the timer within the personal computer and the use of hot-keys to access the TSR. Examples illustrate these techniques by presenting a simple TSR that beeps the speaker once per half hour and twice on the hour. Also illustrated is a screen saver program and other applications.

Chapter 13 details the operation and programming of the 8087--Pentium family of arithmetic coprocessors. Today few applications function efficiently without the power of the arithmetic coprocessor. Examples include the quadratic equation and a program that displays sinusoidal harmonic content.

Chapter 14 presents advanced programming concepts that include the EXEC function, EMS and XMS control, access to the protected mode microprocessor, device drivers, and interface to high-level languages.

Appendices are included to enhance the application of the text. These include:

  1. A complete listing of the DOS INT 21H function calls. This appendix also details the use of the assembler program and many of the BIOS function calls including BIOS function call INT 10H. Also included in this expansive appendix are the INT 33H mouse functions, INT 67H EMS function, XMS functions, VCPI and DPMI functions.
  2. Complete listing of all 8086 through Pentium instructions including many example instructions and machine coding in hexadecimal as well as clock timing information.
  3. Provides a compact listing of all the instructions that change the flag bits.
  4. Answers for the even-numbered questions and problems are provided in this appendix.
  5. A glossary of the many important terms presented throughout the text.

APPENDUM

As an appendum to the text, a disk containing many of the more advanced versions of the example programs is included with the text. This example disk contains the unassembled source files of many of the example programs. These files can be assembled and examined in the laboratory that may be associated with the course based upon this text. Each program is keyed by the example number in the text, for example EXA10-2.ASM. It also contains a macro include file that eases the task of assembly language programming by providing macros that perform most of the I/O tasks associated with assembly language programming.

return to publication list