Está en la página 1de 527
Digital Computer Electronics Third Edition Albert Paul Malvino, Ph.D. Jerald A. Brown eel GLENCOE McGraw-Hill us, Ohio. Woodland New York, New York Columbu Hills, California Peoria, illinois “This textbook was prepared withthe assistance of Publishing Advisory Service. LSI ict photo: Manfred Kage’Peter Arnold lnc To my wife, Joanna, who encourages me to write ‘And to my daughters, Joanna, Antonia, Lucinds, Patricia, and Miriam, who keep me young APM to my wile Vickie dearest friend fellow adventurer love of my life LAB. Library of Congress Cataloging.n-Publiction Data Maino, Albert Paul Digital comauter electronics / Albert Paul Malvino, Jerald A. Brown. — 3d e6 poem Incudes index ISBN 0-02-800594-5 (nardcover) 1 Electronic egal computers. 2. Microcomputers. 3, Ito £8085 (Microprocessor) |. Brown, Jerald AI. Tile TK7856.3M337_ 1993 621.39'16—6c20 92-5895, cP Digital Computer Electronics, Third Eaton limpet 1900 Copyright© 1999, 1963 by Glencoe MeGraw-Hl Al ight osarved, Copjigh © 1989, 1977 by ‘MeGraw-til, nc, Al righ reserved, Prntd inthe Uniod Stats of Amora Except as ‘ermitlod undor tho Unite States Copyright Act, no part ofthis pubbeation may be reproduced ‘ralstrbuted in any form o by any moans, or sored in a Gatabasa or retrovl syst, witout prior rien pormssion othe pubtiser ISBN 0-02-800504-5, Printed in the United States of Ameria 486789101112 c0Wo43 03.0201 0009, es Contents PREFACE vi PART 1 Digital Principles 1 CHAPTER 1, NUMBER SYSTEMS AND CODES 1 J-1. Decimal Odometer 1-2. Binary Odometer 1-3. Number Codes 1-4. Why Binary Numbers Are Used 1-5. Binary-to-Decimal Conversion 1-6, Microprocessors 1-7. Decimal-to-Binary Conversion 1-8, Hexadecimal Numbers. 1-9. Hexadecimal-Binary Conversions 1-10. Hexadecimal-to-Decimal Conversion I-11, Decimal-to-Hexadecimal Conversion 1-12, BCD Numbers 1-13. The ASCII Code CHAPTER 2. GATES 19 2-1. Inverters 2-2, OR Gates 2-3, aNb Gates 24. Boolean Algebra CHAPTER 3. MORE LOGIC GATES 32 3-1. Nok Gates 3-2. De Morgan's First Theorem 3-3. Nanp Gates 3-4. De Morgan's Second Theorem 3.5. EXCLUSIVEOR Gates 3-6, The Controlled Inverter 3-7. EXCLUSIVENOR Gates CHAPTER 4. TTL CIRCUITS 48 4-1, Digital Integrated Circuits 4-2, 7400 Devices 4-3. TTL Characteristics 4-4. TTL Overview 45. AND ORINVERT Gates 4-6, Open-Collector Gates 4-7. Multiplexers CHAPTER 5. BOOLEAN ALGEBRA AND KARNAUGH MAPS 64 5-1. Boolean Relations ‘Sum-of-Products Method 5-3. Algebraic Simplification 5-4, Karnaugh Maps 5-5. Pairs. Quads. and Ovtels 5-6. Kamaugh Simplifications 5-7. Don’t-Care Conditions CHAPTER 6. ARITHMETIC-LOGIC UNITS 9 6-1. Binary Addition 6-2, Binary Subtraction 6-3, Half Adders 6-4, Full Adders 6-5, Binary Adders 6-6. Signed Binary Numbers 6-7, 2's Complement 6-8. 2°s-Complement Adler-Subtracter CHAPTER 7, FLIP-FLOPS 90 7-1. RS Latches 7-2. Level Clocking 7-3. D Latches 7-4. Edge-Triggered D Flip-Flops 7-5, Edge-Triggered JK Flip-Flops 7-6. JK Master-Slave Flip-Flop CHAPTER 8. REGISTERS AND COUNTERS 106 Buller Registers 8-2, Shift Registers Controlled Shift Registers 8-4. Ripple Counters Synchronous Counters 8-6, Ring Counters Other Counters 8-8, Three-State Registers Bus-Organized Computers CHAPTER 9. MEMORIES — 130 9-1. ROMs 9.2. PROMS and EPROMs 9-4. A Small TTL Memory Addresses 9.3. RAMs 9-5. Hexadecimal SAP (Simple-as Computers 140 CHAPTER 10. SAP-1 140 10-1, Architecture 10-2, Instruction Set 10-3. Programming SAP-1 10-4. Fetch Cycle 10-5. Execution Cycle 10:6. The SAP-1 Microprogram 10-7. ‘The SAP-1 Schematic Diagram 10-8. Microprogrammiing CHAPTER 11. SAP-2__ 173 1-1, Bidirectional Registers 11-2. 11-3, Memory-Reference Instructions Architecture 11-4, Register 11-5. Jump and Call Instructions 11-6. Logic Instructions 11-7 11-8. SAP-2 Summary Instructions Other Instructions CHAPTER 12. SAP-3 195 12-1, Programming Model 12-2. MOV and MVL 12.3. Arithmetic Instructions 12-4. Increments, Decrements, and Rotates 12-5. Logic Instructions 12-6, Arithmetic and Logic Immediates 12-7. Jump Instructions 12-8. Extended-Register Instructions 12-9, Indirect Instructions 12-10. Stack Instructions Programming Popular Microprocessors 213 CHAPTER 13, INTRODUCTION TO MICROPROCESSORS | 213 13-1. Computer Hardware Definition of a Microprocessor Some Common Uses for Microprocessors Microprocessors Featured in This Text [Access to Microprocessors CHAPTER 14. PROGRAMMING AND LANGUAGES 216 14-1. Relationship between Electronics and Programming. 14-2. Programming 14-3, Fundamental Premise M4. Floweharts 14-5. Programming Languages 14.6, Assembly Language 14-7. Worksheets CHAPTER 15. SYSTEM OVERVIEW 224 New Concepts 15-1. Computer Architecture 15-2. Microprocessor Architecture Microprocessor Families S02 Family 15-4. 6800/6808 Family 15-5, 8080/8085/280 Family 15-6. 8086/8088 Family CHAPTER 16, DATA TRANSFER INSTRUCTIONS 240 New Concepts 16-1, CPU Control Instructions 16-2. Data Transfer Instructions Specific Microprocessor Families 16-3. 6502 Family 16-4. 6800/6808 Family 16-5. 8080/8085/280 Family 16-6. 8086/8088 Family CHAPTER 17. ADDRESSING MODES—I 263 New Concepts 17-1. What Is an Addressing Mode? 17-2. The Paging Concept 17-3. Basic Addressing Modes Specific Microprocessor Families 17-4. 6502 Family 17-5, 6800/6808 Family 17-6, 8080/8085/280 Family 8086:8088 Family iv Contents CHAPTER 18. ARITHMETIC AND FLAGS. 270 New Concepts 18-1. Microprocessors and Numbers 18.2. Arithmetic Instructions 18-3, Flag Instructions Specific Microprocessor Families 18.4 6502 Family 18-5. 6800/6808 Family 18-6. SO80:8085/Z80 Family 18-7. 8086/8088 Family CHAPTER 19. LO 305 New Concepts 19-1. The Anb Instruction 19.2. The ok Instruction 19.3. The EXCLUSIVE-OR (EOR, NOR) Instruction 19-4. ‘The Nor Instruction 19-5. The NEG (NEGate) Instruction Specific Microprocessor Families 19-6. 6502 Family 19-7. 6800/6808 Family 19-8. 8080:8085/Z80 Family 19.9, 8086/8088 Family ‘AL INSTRUCTIONS, CHAPTER 20. SHI INSTRUCTIONS 319 New Concepts 20-1. Rotating 20-3. An Example Specific Microprocessor Families 20-4. 6502 Family 20-5, 6800/6808 Family 20-6, 8080/8085/Z80 Family 20-7, 8086i8088 Family AND ROTATE 20-2. Shifting CHAPTER 21. ADDRESSING MODES—II 329 New Concepts 21-1, Advanced Addressing Modes Specific Microprocessor Far 6502 Family 3, 6800/6808 Family 21-4, 8080/8085/Z80 Family 1-5. 8086/8088 Family CHAPTER 22. BRANCHING AND LOOPS 342 New Concepts 22-1, Unconditional Jumps 22-2. Conditional Branching 22-3. Compare and Test Instructions 22-4, Increment and Decrement Instructions 22-5, Nested Loops Specific Microprocessor Families 22-6. 6502 Family 22-7. 68006808 Family 22-8, 8080/8085/Z80 Family 22-9, $086:8088 Family CHAPTER 23. SUBROUTINE AND STACK, INSTRUCTIONS | 363 New Concepts 23-1. Stack and Stack Pointer 23-2. Branching versus Subroutines 23.3, How Do Subroutines Return? 23-4. Pushing and Popping Registers Specific Microprocessor Families 23-. 6502 Family 23-6, 6800/6808 Family 23-7. 8080/8085/Z80 Family 24-8, 8086/8088 Family Microprocessor Instruction Set Tables 379 A, Expanded Table of 8085/8080 and 780 (8080 Subset) Instructions Listed by Category 381 Mini Table of 8085/8080 and 280 (8080 Subset) Instructions Listed by Category 410 Condensed Table of 8085/8080 and Z80 (8080) Instructions Listed by Category 415 Condensed Table of 8085/8080 and Z80 (8080 Subset) Instructions Listed by Op Code 417 Condensed Table of 8085/8080 and 280 (8080 Subset) Instructions Listed Alphabetically by 8085/8080 Mnemonic 419 Condensed Table of 8085/8080 and Z80 (8080 Subset) Instructions Listed Alphabetically by Z80 Mnemonic 421 B. Expanded Table of 6800 Instructions Listed by Category 22 Short Table of 6800 Instructions Listed Alphabetically 434 Short Table of 6800 Instructions Listed by Category 437 Condensed Table of 6800 Instructions Listed by Category 441 Condensed Table of 6800 Instructions Listed Alphabetically 443 Condensed Table of 6800 Instructions Listed by Op Code 44a ic Expanded Table of 8086/8088 Instructions Listed by Category 445 Condensed Table of 8086/8088 Instructions Listed by Category 465 Condensed Table of 8086/8088 Instructions Listed Alphabetically 469 D. Expanded Table of 6502 Instructions Listed by Category 471 Short Table of 6502 Instructions Listed by Category 478. Condensed Table of 6502 Instructions Listed by Category 480 Condensed Table of 6502 Instructions Listed Alphabetically 481 Condensed Table of 6502 Instructions Listed by Op Code 482 APPENDIXES | 485, 1, The Analog Interface 2, Binary-Hexadecimal- Decimal Equivalents 3, 7400 Series TTL. 4. Pinouts and Function Tables 5. SAP-I Parts List 6. 8085 Instructions 7, Memory Locations: Powers of 2 8. Memory Locations: 16K and 8K Intervals 9. Memory Locations: 4K Intervals 10, Memory Locations: 2K Intervals 11, Memory Locations: 1K Intervals 12. Programming Models ANSWERS TO ODD-NUMBERED PROBLEMS. 513 INDEX 519 Contents Preface Textbooks on microprocessors are sometimes hard £0 un= derstand. This text attempts to present the various aspects ‘of microprocessors in ways that are understandable and interesting. The only prerequisite 0 using this textbook is an understanding of diodes and transistors A unique aspect of this text is its wide range. Whether you are interested in the student-constructed SAP (simple: as:possible) microprocessor, the 6502, the 6800/6808, the '8080/8085/Z80, or the 8086/8088, this textbook can meet your needs ‘The text is divided into four parts. These parts can be used in different ways to meet the needs of a wide Variety of students, classrooms, and instructors. Part 1, Digital Principles, is composed of Chapters | to 9. Featured topics include number systems, gates, boolean algebra, flip-lops, registers, counters, and memory. This information prepares the student for the microprocessor sections which follow art 2, which consists of Chapters 10 to 12, presents the SAP (simple-as-possible) microprocessor. The student con- structs this processor using digital components. The SAP processor contains the most common microprocessor func: tions. It features an instruction set which is a subset of that ‘of the Intel 8085—leading naturally to a study of that microprocessor. Part 3, Programming Popular Microprocessors (Chapters 13 to 23), simultaneously treats the MOS/Rockwell 6502, the Motorola 6800/6808, the Intel 8080/8085 and Zilog £280, and the 16-bit Intel 8086/8088. Fach chapter is divided into two sections, The first section presents new concepts; second section applies the new concepts (0 each micropro- cessor family. Discussion, programming examples, and problems are provided. The potential for comparative study is excellent. This part ofthe text takes a strong programming approach to the study of microprocessors. Study is centered around the mieroprocessor's instruction set and programming mode! The 8-bit examples and homework problems can be per- formed by using either hand assembly or cross-assemblers. The 16-bit 8086/8088 examples and problems can be per- formed by using either an assembler or the DOS DEBUG. utility Part 4 is devoted to the presentation of the instruction sets of each microprocessor family in table form. Several tables are provided for each microprocessor family, per- rmitting instructions to be looked up alphabetically, by op code, or by functional category, with varying levels of detail. The same functional categories are correspondingly used in the chapters in Part 3. This coordination between parts makes the learning process easier and more enjoyable. Additional reference lables are provided in the appen- dlixes. Answers 10 odd-numbered problems for Chapters | 10 16 follow the appendixes. A correlated laboratory manual, Experiments for Digital Computer Electronics by Michael A. Miller, is available for use with this textbook. It contains experiments for every part of the text. It also includes programming problems for ich of the Featured microprocessors, ‘A teacher's manual is available which contains answers ‘0 all of the problems and programs for every micropro: cessor, In addition, a diskette (MS-DOS 360K 54-inch diskette) containing cross-assemblers is included in the teacher's manual Special thanks to Brian Mackin for being such a patient and supportive editor. To Olive Collen for her editorial work, To Michael Miller for his work on the laby manual And to Thomas Anderson of Speech ‘Technologies Inc. for the use of his cross-assemblers. Thanks also (© reviewers Lawrence Fryda, Illinois State University: Malachi Me- Ginnis, ITT Technical Institute, Garland Texas; and Ben- jamin Suntag. Albert Paul Malvino Jerald A, Brown A man of irue science uses but few hard words, ‘and those only when none other will answer his purpose; whereas the smatterer in science thinks that by mouthing hard words he understands hard things, Herman Melville Pea DIGITAL PRINCIPLES =D- 1 p> NUMBER SYSTEMS AND CODES Modern computers don’t work with decimal numbers Instead, they process binary numbers, groups of Os and Is. Why binary numbers? Because electronic de reliable when designed for two-state (binary) operation. This chapter discusses binary numbers and other concepts needed to understand computer operation ices are most 1-1 DECIMAL ODOMETER René Descartes (1596-1650) said that the way to learn a new subject is to go from the known to the unknown, from the simple to the complex. Let's ty it ‘The Known Everyone has seen an odometer (miles indicator) in action ‘When a car is new, its odometer stars with ‘00000 After 1 mile the reading becomes 0001 Successive miles produce 00002, ‘00009 (00003, and so on, up to AA familiar thing happens at the end of the tenth mile When the units wheel turns from 9 back fo 0, a tab on this wheel forces the tens wheel to advance by I. This is why the numbers change to 0010 Reset-and-Carry ‘The units wheel has reset to O and sent a carry to the tens wheel, Let's call this fumiliar action reset-and-carry The other wheels also reset and carry. After 999 miles the odometer shows 00999 What does the next mile do? The units wheel resets and carvies, the tens wheel resets and carries, the hundreds whee! resets and carries, and the thousands wheel advances by 1, to get 01000 Digits and Strings ‘The numbers on each odometer wheel are called digits The decimal number system uses ten digits, 0 through 9. In a decimal odometer, each time the units wheel runs out of digits, it resets to 0 and sends a carry to the tens wheel When the tens wheel runs out of digits, it resets to 0 and sends a carry to the hundreds wheel. And so on with the remaining wheels, One more point. A siring is a group of characters (either letters o digits) written one after another. For instan 74 is a string of 7, 3, and 4. Similarly, 2CBA is a string of 2, C, 8, and A 1-2 BINARY ODOMETER Binary means two. The binary number system uses only two digits, 0 and 1. All other digits (2 through 9) are thrown away, In other words, binary numbers are strings of Os and Is, ‘An Unusual Odometer Visualize an odometer whose wheels have only two digits, and I. When each whee! turns, it displays 0, then 1, then 1 back to 0, and the cycle repeats. Because each wheel has only two digits, we call this device a binary odometer In a car a binary odometer starts with (0000. (zero) After 1 mile, it indicates 0001 (one) The next mile forces the units wheel to reset and carry; so the numbers change to 0010 (two) ‘The third mile results in oo1t (three) What happens after 4 miles? The units wheel resets and carries, the second wheel resets and carries, and the third wheel advances by 1. This gives 0100. four) Successive miles produce o1ol (five) O10 (six) OIL (seven) After 8 miles, the units wheel resets and caries, the second wheel resets and carries, the third wheel resets and carries, and the fourth wheel advances by 1, The result is 1000 (eight) The ninth mile gives 1001 (niney and the tenth mile produces 1010 (ten) (Try working out a few more readings on your own.) You should have the idea by now. Each mile advances the units wheel by 1, Whenever the units wheel runs out of digits, it resets and carries. Whenever the second wheel runs out of digits, i resets and carries. And so for the other wheels. Binary Numbers A binary odometer displays binary numbers, strings of Os and Is. The number 0001 stands for {, O00 for 2, 0011 2 Digital Computer Etectronics for 3, and so forth. Binary numbers are long when large amounts are involved. For instance, 101010 represents decimal 42, As another example, 111100001111 stands for decimal 3,855, ‘Computer circuits are like binary odometers: they count and work with binary numbers. Therefore, you have 0 learn to count with binary numbers, to convert them to decimal numbers, and to do binary arithmetic. Then you will be ready to understand how computers operate ‘A final point. When # decimal odometer shows 0036, we can drop the leading Os and read the number as 36. Similarly, when a binary odometer indicates OO11, we can drop the leading 0s and read the number as 11. With the leading Os omitted, the binary numbers are 0, 1, 10, 11, 100, 101, and so on, To avoid confusion with decimal numbers, read the binary numbers like this: zero, one, one- zero, one-one, one-Zer-7eF0, One-Z2F0-0Ne, ele 1-3 NUMBER CODES People used to count with pebbles. The numbers 1, 2, 3 looked like @, @@, @@@. Larger numbers were worse: seven appeared «5 @@@O@OO. Codes From the earliest times, people have been creating codes that allow us to think, calculate, and communicate. The decimal numbers are an example of a code (See Table IL-1. Ie's an old idea now, but at the time it revolutionary; 1 stands for @, 2 for @@, 3 for and so forth Table 1-1 also shows the binary code. | stands for @, 10 for @@, 11 for @@®, and soon. A binary number and a decimal number are equivalent if each represents the same amount of pebbles. Binary 10 and decimal 2 are equivalent because each represents @@. Binary 101 and decimal 5 are equivalent because each stands for TABLE 1-1, NUMBER CODES Decimal Pebbles Binary 0 None 0 1 1 2 10 3 u 4 100 5 lol 6 10 1 ML 8 1000 9 1001

También podría gustarte