You are on page 1of 477
(= —— (EC/TC) rd PLA STUNG Letts Dr. D. A. Godse ‘As per Revised Syllabus of VISVESVARAYA TECHNOLOGICAL UNIVERSITY Choice Bosed Credit System (CBCS) Scheme-2015 Semester.V (EC/TC) MICROPROCESSORS Atul P Godse M.S. Software Systems (BITS Plan) BE. Industriol Electronics Formerly Lecturer in Departmen! of Electronics Engg. Vishwokarma Institute of Technology Pune Dr. Mrs. Deepali A. Godse ME. Ph.D. (Computer Engineering) Hood of information Technology Department, Bhoroti Vidyapeeth's College of Engineering for Women, Pune Price : € 360/- 78.93-332-1 Tega il ‘An Up-Thrust for Knowledge MICROPROCESSORS Semester - IV (EC/TC) Fist Edition : February 2017 ‘Second Revised Edition : January 2018 © Copyright with Authors All publishing rights (printed and ebook version) reserved with Technical Publications. No part of this book should be reproduced in ony form, Electronic, Mechanical, Photocopy or any informotion storage ond retrieval system without prior permission in writing, from Technical Publications, Pune. ‘Ghul Indl Este, Nended saseboiises roa ae Pot Price :€ 3600- ISBN 978-93-332-1484-1 WM il 9789333214841 (2) wo PREFACE The importance of Microprocessors is well known in various engineering fields. Overwhelming response to our books on various subjects inspired us to write this book. The book is structured to cover the key aspects of the subject Microprocessors. The book uses plain, lucid language to explain fundamentals of this subject. The book provides logical method of explaining various complicated concepts and stepwise methods to explain the important topics. Each chapter is well supported with necessary illustrations, practical examples and solved problems. All chapters in this book are arranged in a proper sequence that permits each topic to build upon earlier studies. All care has been taken to make students comfortable in understanding the basic concepts of this subject. Representative questions have been added at the end of each section to help the students in picking important points from that section. The book not only covers the entire scope of the subject but explains the philosophy of the subject. This makes the understanding of this subject more clear and makes it more interesting. The book will be very useful not only to the students but also to the subject teachers. The students have to omit nothing and possibly have to cover nothing more. We wish to express our profound thanks to all those who helped in making this book a reality. Much needed moral support and encouragement is provided on numerous occasions by our whole family. We wish to thank the Publisher and the entire team of Technical Publications who have taken immense pain to get this book in time with quality printing Any suggestion for the improvement of the book will be acknowledged and well appreciated. Anthors AP. Gore Dr. D. A, Godse Dedicated to God ain SYLLABUS Microprocessors - 15EC42 Module - 1 8086 Processor : Historical background , 8086 CPU architecture. Addressing modes, Machine language instruction formats, Machine coding the program. Instruction Set of 8086 : Data transfer and arithmetic instructions. Control/Branch instructions, Illustration of these instructions with example programs . (Chapters 1, 2) Module - 2 Logical instructions, String manipulation instructions, Flag manipulation and processor control instruction, Illustration of these instructions with example programs. Assembler directives and operators, Assembly language programming and example programs. (Chapter - 2) Module = 3 Stack and Interrupts : Introduction to stack, Stack structure of 8086, Programming for stack. Interrupts and interrupt service routines, Interrupt cycle of 8086, NMI, INTR, Interrupt programming, Passing parameters to procedures, Macros, Timing and delays, (Chapter+ 3) Module - 4 8086 Bus Configuration and Timings : Physical memory organization, General bus operation cycle, I/O addressing capability, Special processor activities, Minimum mode 8086 system and timing diagrams, Maximum mode 8086 system and timing diagrams. Basic Peripherals and their Interfacing with 8086 (Part 1) : Static RAM interfacing with 8086, Interfacing VO ports, PIO 8255, Modes of operation - Mode-0 and BSR mode, Interfacing keyboard and 7-segment digits using 8255. (Chapters =4, 5) Module =5 Basic Peripherals and their Interfacing with 8086 (Part 2) : Interfacing ADC-0808/0809, DAC-0800, Stepper motor using 8255. Timer 8254- Mode 0, 1, 2, & 5 and interfacing programmes for these modes. INT 21H DOS Function calls - For handling keyboard and display Other Architectures : Architecture of 8088 and architecture of NDP 8087. ‘Von-Neumann and Harvard CPU architecture and CISC & RISC CPU architecture. (Chapters «5,6, 7, 8) ww TABLE OF CONTENTS Chapter-1 8086 Processor (1 - 1) to (1 - 58) 1-2 1.1 Historical Background... 1.1.1 Evolution From 8008 to 8088... . 0.60. sseeseeeeseeeeeeeeeueuee eens 1-2 1.1.2 Microprocessors : 8086 to 80486 1-3 1.1.3 Advanced Microprocessors - Pentium to Pentium 4..........000ee00008+ 1-4 1.2 Features of 8086... 1,3 8086 CPU Architecture .... 1.3.1 Bus Interface Unit (BIU) .... 20... cece eeeeeeeeeeeeeeereeeeeeneeeeneeee 1-7 1.3.2 Execution Unit (EU)... 6.2.66. ce cece cece cece eee e eee eee eee eees 1-9 1.4 Register Organization of 8086 ... . 1.4.1 General Purpose Registers...........000ccceeseeeeesseseeesseeeeess 1.4.2 Segment Registers . 1.4.3 Pointers and Index Registers ..........c0cccseeeeeeesssseeeeeeeeseess 1-12 1.4.4 Flag Register .. -12 1.5 Memory Segmentation... 1.6 Signal Description of 8086 . 1.6.1 Signals with Common Functions in Both Modes ..........-.6.s000s00005 1-22 1.6.2 Signal Definitions (24 to 31) for Minimum Mode ...........00s00ec00e0 1-24 1.6.3 Signal Definitions (24 to 31) for Maximum Mode ...........02s00ee0000 1-24 1.7 Addressing Modes . 1.7.1 Data Addressing Modes .......-.....0sss0eceeeeecsueeseessneseuees 1-26 1.7.1.1 Addressing Modes for Accessing Immediate and Register Data... . . 1-26 1.7.1.2 Addressing Modes for Accessing Data in Memory . 1.7.2 Program Memory Addressing Modes 1.7.3 Stack Memory Addressing Modes. . . 1.8 Machine Language Instruction Formats . ) 1.9 Machine Coding the Program. 1-49 Chapter-2 _ Instruction Set of 8086 (2 - 1) to (2 - 150) .2-2 2.1 Introduction 2.2 Instruction Set of 8086 .. 2.2.1 Data Transfer Group 2.2.1.1 MOVinstruction. . 2... eee ee 2-2 2.2.1.2 PUSH/POP Instructions. ©. eee 2-3 2.2.1.3 Load Effective Address 2-7 2.2.1.4 String Data Transfer Instructions... 2.22. 2.2 ee ee ee 2-8 2.2.1.5 Miscellaneous Data Transfer Instructions . 2-9 2.2.2 Arithmetic Group DBAAMMION. oe ee ee 2.2.2.2 Subtraction 2.2.2.3 Comparison... oe ee eee 2-14 2.2.24Multiplication 2. eee 2-14 2225Division... 2.2... 2.2.3 BCD and ASCII Arithmetic Instructions . 2.2.3.1 BCD Arithmetic. 2.2.3.2 ASCII Arithmetic 2.2.4 Logical Group ... 2.2.5 Shift and Rotate Group. ZDSASHIME eee 2.252Rotate ...... 2.2.6 String Compare Group 2.2.7 Control Transfer Group 2.2.8 Machine Control and Miscellaneous Instruction Group ..........-.....++ 2-34 2.2.9 Interrupt Instruction Group... 66. 66s eee e eee eee cece eee eeeees 2236 2.3 8086 Instruction Set Summary ... 2.4 Assembler Directives .. 2.4.1 Summary of Assembler Directives. . 2.4.2 Variables, Suffix and Operators. . cc) 2.4.3 Accessing a Procedure and Data from another Assembly Module ......... 2-55 2.5 Assembly Language Programming. 2.5.1 Steps Involved in Programming, 2.5.2 Flowchart. 2.5.3 Assembly Language Programs 2.5.4 Assembly Language Programming Tips. ...... 2.5.5 Programming with an Assembler . .. 2.5.5.1 Assembling Process. © 2. 1 ee ee ee ee 25.5.2 Linking Process... 2.2... 25.5.3 Loading Process... . . ne 2-66 2.5.5.4 Debugging Process . . 7 2-67 2.5.6 Structured Programming and Pseudocode Overview . . +. 2-68 2.5.7 Implementation of If-Then, If-Then-Else, and Multiple If-Then-Else Programs 2 - 71 2.5.7.1 Implementation of If-Then Structure... . See 2-71 2.5.7.2 Implementation of If-Then-Else Structure... . . sees 272 2.5.7.3 Implementation of Multiple if-Then-Else Structure... 2 oss 2-72 2.5.8 While-Do Programs. . . 2.5.9 Repeat-Until Programs 2.5.10 For-Loop Programs 2.6 Assembly Language Programming Examples. 2.7 More Programming Examples Program 2.5.1 : Implementation of if then structure. Program 2.5.2 : Implementation of if then structure. Program 2.5.3 : Implementation of if-then-else structure. Program 2.5.4 : Implementation of multiple it-then-else structure.. Program 2.5.5 : Implementation of while~do structure Program 2.6.4 : Search a number in the array.. Program 2.6.5 : Find sum of numbers in the array. Program 2.6.6 : Separate even-Odd annem wid) Program 2.6.7 : Add two data bytes .. Program 2.6.8 : Add the contents of memeory location to accumulator Program 2.6.9 : Find the average of two temperature Program 2.6.10 : Find out the largest number from an unordered array. Program 2.6.11 : Move a byte string.. Program 2.6.12 : Add a profit factor to each element in a COST... Program 2.6.13 : Find out the number of positive numbers and negative numbers Program 2.6.14 : Program that performs the addition, subtraction, multiplication, division of the given operands... Program 2.6.15 : Find out the number of even and odd numbers Program 2.6.16 : Add 5 bytes of data in an array. Program 2.6.17 : Divide a 32-bit number by a 16-bit number. Program 2.6.18 : Add two 8-bytes of data. Program 2.6.19 : Add two 16-bit hexa decimal numbers. Program 2.6.20 : Find the sum of the first ‘n’ integers Program 2.6.21 : Convert 4qdigit BCD number to HEX, Program 2.6.22 : Convert a 4edigit BCD number to its equivalent hex number Program 2.6.23 : Convert a 2edigit HEX Number to BCD Number... Program 2.6.24 : Add two multi byte numbers of length Nw. Program 2.6.26 : Transfer an array of numbers to another location and store reverse order... Program 2.6.26 : Reverse the bits in a 16-bit number and check whether it is a palindrome... Program 2.6.27 : Compute ng, Program 2.6.28 : Count number of Os in a 16-bit binary string Program 2.7.1 : Read keyboard input and display it on monitor Program 2.7.2 : Addition of two 32-bit numbers... Program 2.7.3 : Addition of 3 x3 Matrix sme Program 2.7.4 : Program to read a password and validate user... Program 2.7.5 : Program to calculate factorial of a number .. Program 2.7.6 : Reverse the words in string, Program 2.7.7 : Search numbers, alphabets, special characters .. Program 2.7.8 : Program to find whether string is palindrome or not, 11 Program 2.7.9 : Program to display string in lowercase.. snes 2= 142 Program 2.7.10 : Write an 8086 assembly language program (ALP) to add array of N number NNNNNNN NRNRRNNNNNNNN 888 8 See2ssessae 8822333 y ieeeeeteeea Ol retiree ies 2 = 102, 2-104 eerie Ol 2-108 stored in the memory. seems 2= 143 Program 2.7.11 : Write 8086 ALP to perform non-overlapped and overlapped block transfer.. mene 2= 116 Program 2.7.12 : Write 8086 ALP to find and count negative numbers from the array of signed numbers stored in memory. . 124 Program 2.7.13 : Multiplication of two 8-bit numbers. 124 Program 2.7.14 : Multiplication of BCD numbers -130 Program 2.7.15 : BCD to HEX conversion using AAD instruction.. = 131 (wit) Program 2.7.16 : Read key, if key is pressed, display message. Program 2.7.17 : Compare two 32-bit numbers. Program 2.7.18 : Exchange the contents of two non overlapped memory blocks. Program 2.7.19 : Write a Do-while construct .. Program 2.7.20 : BCD to ASCII using XLAT instruction. Program 2.7.21 : Add two 8-digit BCD numbers.. Program 2.7.22 : Read string of characters from keyboard. Program 2.7.23 : Multiply two 32-bit numbers... Program 2.7.24 : Concatenate two strings... Program 2.7.25 : Add N one byte BCD numbers. Program 2.7.26 : Convert 4-digit ASCII coded Hex number to its binary equivalent. Program 2.7.27 : Data transfer from memory to memory .. Program 2.7.28 : WALP to pack the two unpacked BCD numbers stored in the locations LOC and LOC + 1. Program 2.7.29 : Write an assembly language program segment to perform (OX)

You might also like