The Intel Microprocessors
Total Page:16
File Type:pdf, Size:1020Kb
THE INTEL MICROPROCESSORS 8086/8088, 80186/80188, 80286, 80386, 80486, Pentium, Pentium Pro Processor, Pentium II, Pentium III, Pentium 4, and Core2 with 64-Bit Extensions Architecture, Programming, and Interfacing Eighth Edition BARRY B. BREY Upper Saddle River, New Jersey Columbus, Ohio Library of Congress Cataloging in Publication Data Brey, Barry B. The Intel microprocessors 8086/8088, 80186/80188, 80286, 80386, 80486, Pentium, Pentium Pro processor, Pentium II, Pentium III, Pentium 4, and Core2 with 64-bit extensions: architecture, programming, and interfacing / Barry B. Brey—8th ed. p. cm. Includes index. ISBN 0-13-502645-8 1. Intel 80xxx series microprocessors. 2. Pentium (Microprocessor) 3. Computer interfaces. I. Title. QA76.8.I292B75 2009 004.165—dc22 2008009338 Editor in Chief: Vernon Anthony Acquisitions Editor: Wyatt Morris Editorial Assistant: Christopher Reed Production Coordination: GGS Book Services Project Manager: Jessica Sykes Operations Specialist: Laura Weaver Design Coordinator: Mike Fruhbeis Cover Designer: Ilze Lemesis Cover image: iStockphoto Director of Marketing: David Gesell Marketing Manager: Jimmy Stephens Marketing Assistant: Les Roberts This book was set in Times by GGS Book Services. It was printed and bound by Hamilton Printing. The cover was printed by Phoenix Color Corp. Copyright © 2009, 2006, 2003, 2000, 1997, 1994, 1991, 1987 by Pearson Education, Inc., Upper Saddle River, New Jersey 07458. Pearson Prentice Hall. All rights reserved. Printed in the United States of America. This publication is protected by Copyright and per- mission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permission(s), write to: Rights and Permissions Department. Pearson Prentice Hall™ is a trademark of Pearson Education, Inc. Pearson® is a registered trademark of Pearson plc Prentice Hall® is a registered trademark of Pearson Education, Inc. Pearson Education Ltd., London Pearson Education Australia Pty. Limited Pearson Education Singapore Pte. Ltd. Pearson Education North Asia Ltd., Hong Kong Pearson Education Canada, Inc. Pearson Educación de Mexico, S.A. de C.V. Pearson Education—Japan Pearson Education Malaysia Pte. Ltd. 10987654321 ISBN–13: 978–0–13–502645–8 ISBN–10: 0–13–502645–8 This text is dedicated to my progenies, Brenda (the programmer) and Gary (the veterinarian technician), and to my constant four-legged companions: Romy, Sassy, Sir Elton, Eye Envy, and Baby Hooter. iii This page intentionally left blank PREFACE This practical reference text is written for students who require a thorough knowledge of pro- gramming and interfacing of the Intel family of microprocessors. Today, anyone functioning or striving to function in a field of study that uses computers must understand assembly language programming, a version of C language, and interfacing. Intel microprocessors have gained wide, and at times exclusive, application in many areas of electronics, communications, and control systems, particularly in desktop computer systems. A major addition to this eighth edition explains how to interface C/C++ using Visual C++ Express, which is a free download from Microsoft, with assembly language for both the older DOS and the Windows environments. Many applications include Visual C++ as a basis for learning assembly language using the inline assembler. Updated sections that detail new events in the fields of microprocessors and micro- processor interfacing have been added. ORGANIZATION AND COVERAGE To cultivate a comprehensive approach to learning, each chapter begins with a set of objectives that briefly define its content. Chapters contain many programming applications and examples that illustrate the main topics. Each chapter ends with a numerical summary, which doubles as a study guide, and reviews the information just presented. Questions and problems are provided for reinforcement and practice, including research paper suggestions. This text contains many example programs using the Microsoft Macro Assembler program and the inline assembler in the Visual C++ environment, which provide a learning opportunity to program the Intel family of microprocessors. Operation of the programming environment includes the linker, library, macros, DOS function, BIOS functions, and Visual C/C++ program development. The inline assembler (C/C++) is illustrated for both the 16- and 32-bit program- ming environments of various versions of Visual C++. The text is written to use Visual C++ Express 2005 or 2008 as a development environment, but any version of Visual Studio can also be used with almost no change. This text also provides a thorough description of family members, memory systems, and various I/O systems that include disk memory, ADC and DAC, 16550 UART, PIAs, timers, key- board/display controllers, arithmetic coprocessors, and video display systems. Also discussed are v vi PREFACE the personal computer system buses (AGP, ISA, PCI, PCI Express, USB, serial ports, and parallel port). Through these systems, a practical approach to microprocessor interfacing can be learned. APPROACH Because the Intel family of microprocessors is quite diverse, this text initially concentrates on real mode programming, which is compatible with all versions of the Intel family of micro- processors. Instructions for each family member, which include the 80386, 80486, Pentium, Pentium Pro, Pentium II, Pentium III, and Pentium 4 processors, are compared and contrasted with those for the 8086/8088 microprocessors. This entire series of microprocessors is very sim- ilar, which allows more advanced versions and their instructions to be learned with the basic 8086/8088. Please note that the 8086/8088 are still used in embedded systems along with their updated counterparts, the 80186/80188 and 80386EX embedded microprocessor. This text also explains the programming and operation of the numeric coprocessor, MMX extension, and the SIMD extension, which function in a system to provide access to floating- point calculations that are important in control systems, video graphics, and computer-aided design (CAD) applications. The numeric coprocessor allows a program to access complex arithmetic operations that are otherwise difficult to achieve with normal microprocessor pro- gramming. The MMX and SIMD instructions allow both integer and floating-point data to be manipulated in parallel at very high speed. This text also describes the pin-outs and function of the 8086–80486 and all versions of the Pentium microprocessor. First, interfacing is explained using the 8086/8088 with some of the more common peripheral components. After explaining the basics, a more advanced emphasis is placed on the 80186/80188, 80386, 80486, and Pentium through Pentium 4 microprocessors. Coverage of the 80286, because of its similarity to the 8086 and 80386, is minimized so the 80386, 80486, and Pentium versions can be covered in complete detail. Through this approach, the operation of the microprocessor and programming with the advanced family members, along with interfacing all family members, provides a working and practical background of the Intel family of microprocessors. Upon completing a course using this text, you will be able to: 1. Develop software to control an application interface microprocessor. Generally, the software developed will also function on all versions of the microprocessor. This software also includes DOS-based and Windows-based applications. The main emphasis is on developing inline assembly and C++ mixed language programs in the Windows environment. 2. Program using MFC controls, handlers, and functions to use the keyboard, video display system, and disk memory in assembly language and C++. 3. Develop software that uses macro sequences, procedures, conditional assembly, and flow control assembler directives that are linked to a Visual C++ program. 4. Develop software for code conversions using lookup tables and algorithms. 5. Program the numeric coprocessor to solve complex equations. 6. Develop software for the MMX and SIMD extensions. 7. Explain the differences between the family members and highlight the features of each member. 8. Describe and use real and protected mode operation of the microprocessor. 9. Interface memory and I/O systems to the microprocessor. 10. Provide a detailed and comprehensive comparison of all family members and their software and hardware interfaces. 11. Explain the function of the real-time operating system in an embedded application. 12. Explain the operation of disk and video systems. 13. Interface small systems to the ISA, PCI, serial ports, parallel port, and USB bus in a personal computer system. PREFACE vii CONTENT OVERVIEW Chapter 1 introduces the Intel family of microprocessors with an emphasis on the microprocessor- based computer system: its history, operation, and the methods used to store data in a microprocessor-based system. Number systems and conversions are also included. Chapter 2 explores the programming model of the microprocessor and system architecture. Both real and protected mode operations are explained. Once an understanding of the basic machine is grasped, Chapters 3 through 6 explain 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