16

Microprocessors GATE PSUs - content.kopykitab.com

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microprocessors GATE PSUs - content.kopykitab.com
Page 2: Microprocessors GATE PSUs - content.kopykitab.com

Microprocessors

GATE PSUs

and ES Examination

Satish K Karna

VIKAS® PUBLISHING HOUSE PVT LTD

A01_MP_FM.indd 1 8/5/2015 11:55:07 AM

Page 3: Microprocessors GATE PSUs - content.kopykitab.com

Vikas® Publishing house PVt ltde-28, sector-8, Noida-201301 (uP) india

Phone: +91-120-4078900 • Fax: +91-120-4078999

Registered office: 576, Masjid Road, Jangpura, New Delhi-110014. indiae-mail: [email protected] • Website: www.vikaspublishing.com

• Ahmedabad : 305, grand Monarch, 100 ft, shyamal Road, near seema hall, ahmedabad-380 051 • Ph. 079-65254204

• Bengaluru : First Floor, n.s. bhawan, 4th Cross, 4th Main, gandhi nagar, bengaluru-560009 • Ph. +91-80-22204639, 22281254

• Chennai : e-12, nelson Chambers, 115, nelson Manickam Road, aminjikarai Chennai -600029 • Ph. +91-44-23744547, 23746090

• Hyderabad : aashray Mansion, Flat-g (g.F.), 3-6-361/8, street no. 20, himayath nagar, hyderabad-500029 • Ph. +91-40-23269992 • Fax. +91-40-23269993

• Kolkata : 6b, Rameshwar shaw Road, kolkata-700014 • Ph. 033-22897888

• Mumbai : 67/68, 3rd Floor, aditya industrial estate, Chincholi bunder, Malad (West), Mumbai-400064 • Ph. +91-022-42662545

• Patna : Flat no. 101, sri Ram tower, besides Chiraiyatand over bridge, kankarbagh Main Road, kankarbagh, Patna - 800 020, (bihar)

Printed in India.

all rights reserved. no part of this publication which is material protected by this copyright notice may be reproduced or transmitted or utilized or stored in any form or by any means now known or hereinafter invented, electronic, digital or mechanical, including photocopying, scanning, recording or by any information storage or retrieval system, without prior written permission from the publisher.

information contained in this book has been published by Vikas® Publishing house Pvt ltd and has been obtained by its authors from sources believed to be reliable and are correct to the best of their knowledge. however, the Publisher and its authors shall in no event be liable for any errors, omissions or damages arising out of use of this information and specifically disclaim any implied warranties or merchantability or fitness for any particular use. disputes if any are subject to delhi Jurisdiction only.

Microprocessors—gate, Psus and es examination

isbn: 978-93259-9226-9

First edition 2015

Vikas® is the registered trademark of Vikas Publishing house Pvt ltd

Copyright © author, 2015

A01_MP_FM.indd 2 8/5/2015 11:55:07 AM

Page 4: Microprocessors GATE PSUs - content.kopykitab.com

Table of ContentsPreface vSyllabus vi

Chapter 1 8085 Microprocessors 1.1-1.661.1 Microprocessor 1.1

1.2 Computer Language 1.5 1.3 Operating System 1.6 1.4 The 8085 Programming Model 1.7 1.5 InstructionSetClassification 1.8 1.6 Instruction Data Format and Storage 1.9 1.7 Data Formats 1.12 1.8 Execution of a Program 1.12 1.9 An Overview of 8085 Instruction Set 1.12 1.10 Microprocessor Architecture and Its Operations 1.14 1.11 MemoryClassification 1.15 1.12 Input and Output Devices 1.21 1.13 Logic Devices 1.21 1.14 Architecture of 8085 Microprocessor 1.21 1.15 8085 Pins and Description 1.33 1.16 Pin Description 1.35 1.17 Control and Status Pin 1.35 1.18 External Signal 1.35 1.19 Power Supply and Clock Frequency 1.36 1.20 Serial I/O Port 1.36 1.21 8085 Functional Description 1.36 Multiple-Choice Questions 1.45

Chapter 2 Programming the 8085 2.1-2.872.1 Introduction to 8085 Instructions 2.1

2.2 Data Transfer Operations 2.1 2.3 LDAX Rp (Load Accumulator Extended) 2.2 2.4 8-Bit Data Transfer Instruction 2.2 2.5 Machine Control 2.4 2.6 8-Bit Arithmetic Instructions 2.4 2.7 8-Bit Logical Operation Logic 2.7 2.8 Various 8085 Operations/Cycle/Timing 2.10 2.9 Branch Operation 2.12 2.10 16-Bit Data Transfer Instructions 2.14 2.11 16-Bit Arithmetic Instruction 2.16 2.12 8-Bit Logical Rotational Instruction 2.17 2.13 Bit Logical Compare Instructions 2.18 2.14 Subroutine 2.24 2.15 Instruction Related to HL Pair 2.30 2.16 Counters and Time Delays 2.33

A01_MP_FM.indd 3 8/5/2015 11:55:07 AM

Page 5: Microprocessors GATE PSUs - content.kopykitab.com

iv Table of Contents

2.17 Timing Diagram 2.35 2.18 Software Development System 2.40 Multiple-Choice Questions 2.51

Chapter 3 Peripheral Devices and Their Interfacing 3.1-3.713.1 Memory and I/O Interfacing 3.1

3.2 Address Space Partitioning 3.2 3.3 General Steps of Interfacing 3.2 3.4 Memory Interfacing 3.2 3.5 Chip Selection Logic by Gates 3.3 3.6 Chip Selection Logic or Decoder Circuit 3.5 3.7 I/O Interfacing 3.6 3.8 Data Communication with 8085 3.7 3.9 Data Transfer Schemes 3.10 3.10 ClassificationofDataTransferSchemes 3.10 3.11 Interrupts 3.12 3.12 The 8085 Interrupts 3.12 3.13 Restarts as Software Interrupts 3.13 3.14 Multiple Interrupts and Priorities 3.14 3.15 The 8085 Maskable/Vectored Interrupt 3.15 3.16 Maskable and Non-Maskable Interrupt 3.15 3.17 Triggering Levels 3.18 3.18 8254: Programmable Interval Timer 3.21 3.19 8259: A Programmable Interrupt Controller 3.23 3.20 Direct Memory Access 3.24 3.21 8255: Programmable Peripheral Interface (PPI) 3.24 Multiple-Choice Questions 3.41

Chapter 4 Advanced Microprocessors 4.1-4.604.1 Introduction 4.1

4.2 Advanced Microprocessors 4.2 4.3 8086 Microprocessor 4.2 4.4 8086 Architecture 4.10

4.5 Flag Register 4.124.6 8086 Programmer’s Model 4.13

4.7 Memory Segmentation 4.13 4.8 Segments 4.15 4.9 8086 Memory Organization 4.17 4.10 Instruction Types 4.18 4.11 Loops and Conditional Jumps 4.21 4.12 Addressing Modes 4.22 4.13 Comparison of 8086 and 8088 4.23 4.14 8284 Clock Generator 4.28 4.15 Clock Logic 4.28 4.16 8087 Numeric Co-Processor 4.30 4.17 80286 Microprocessor 4.36 4.18 80486 Microprocessor 4.36 4.19 Conclusion 4.50 Multiple-Choice Questions 4.53

Appendix A.1-A.4

A01_MP_FM.indd 4 8/5/2015 11:55:07 AM

Page 6: Microprocessors GATE PSUs - content.kopykitab.com

PrefaceThe book Microprocessors—GATE, PSUs and ES Examination has been designed after much consultation with the students preparing for these competitive examination. A must buy for students preparing for GATE, PSUs and ES examination, the book will be a good resource for students of BE/BTech programmes in the electronics engineering, electrical engineering, electrical and electronics engineering, and instrumentation engineering branches too. It will also be useful for the undergraduate students of sciences.

Every part of the book has been examined carefully with the dual goals of keeping topics current and improving clarity of text. Those familiar with the preparation from guides for competitive examination will note that a structured effort has been put in place to develop this resource as a textbook as well as a practice book. The theory in the book has been written and presented in simple and lucid manner in order to meet the requirements of students who prepare for competitive examination. Further, there has been a conscious effort in bringing out a healthy mix of classical and freshly constructed MCQs to give students ample practice opportunities. Finally, precisely segregated questions from relevant examination have been provided.

The salient features of the book are as follows:

1. Interweaving of numerous solved examples to provide a 360 degree grip on concepts.2. A variety of MCQs such as matching type, assertion-reason, and statement type questions.3. Precisely segregated and accurately solved problems from previous examination for hands-on

experience of the students.

Suggestions and inputs from several colleagues, librarians, and individuals, both in government institutions and private sector, have gone into building this book. We wish to thank them for their thoughtful suggestions. The editorial and production teams at Vikas Publishing House has been a pleasure to work with and has exhibited unfailing professionalism. My special thanks to Bhupesh Sharma who has coordinated the entire editorial and production work.

As for me, it has always been a great pleasure to work on the books related to the core subjects of electronics, electrical and instrumentation engineering. Any comments and suggestions for the further improvement of the book are welcome.

Satish K Karna

A01_MP_FM.indd 5 8/5/2015 11:55:07 AM

Page 7: Microprocessors GATE PSUs - content.kopykitab.com

SyllabusGate electronics and Communication engineeringMicroprocessor: Microprocessor (8085): Architecture, Programming, Memory and I/O Interfacing.

Gate electrical engineeringMicroprocessor: 8-Bit Microprocessor Basics, Architecture, Programming and Interfacing.

Gate Instrumentation engineeringMicroprocessor: Basics of Number System, Microprocessor Applications, Memory and Input-Output Interfacing, Microcontrollers.

IeS electronics and telecommunication engineeringComputer engineering: Number Systems, Data Representation; Programming; Elements of a High Level Programming Language PASCAL/C; Use of Basic Data Structures; Fundamentals of Computer Architecture; Processor Design; Control Unit Design; Memory Organisation, I/O System Organisation. Microprocessors: Architecture and Instruction Set of Microprocessors 8085 and 8086, Assembly Language Programming; Microprocessor Based System Design: Typical Examples; Personal Computers and Their Typical Uses.

Civil Services (IaS) electrical engineeringMicroprocessor and Microcomputers: PC Organization: CUP, Instruction Set; Register Set, Timing Diagram; Programming; Interrupts; Memory Interfacing; I/O Interfacing; Programmable Peripheral Devices.

DRDO electronicsDigital Circuits: Boolean Algebra, Minimization of Boolean Functions; Logic Gates; Digital IC Families (DTL, TTL, ECL, MOS, CMOS). Combinatorial Circuits: Arithmetic Circuits, Code Converters, Multiplexers, Decoders, PROMs and PLAs. Sequential Circuits: Latches and Flip-Flops, Counters and Shift-Registers. Sample and Hold Circuits, ADCs, DACs, Semiconductor Memories, Microprocessor (8085): Architecture, Programming, Memory and I/O Interfacing.

JtO electronicsMicroprocessor: Microprocessor Architecture – Instruction Set and Simple Assembly Language Programming, Interfacing for Memory and I/O, Applications of Microprocessors in Telecommunications and Power System

JtO electricalMicroprocessor: Microprocessor Architecture–Instruction Set and Simple Assembly Language Programming; Interfacing for Memory and I/O; Applications of Micro-processors in Power System.

A01_MP_FM.indd 6 8/5/2015 11:55:07 AM

Page 8: Microprocessors GATE PSUs - content.kopykitab.com

1.1 MicroprocessorThe microchip was invented in the early 1970s. All the components that make up the processor are placed on to a single piece of silicon so as to make the size of the processor several thousand times smaller and the speed several hundred

times faster. This is how the microprocessor came into existence.

• The microprocessor is a programmable device that takes in numbers and performs arithmetic or logical operations on them according to the program stored in the

» CHAPTER OUTLINE

1.1 Microprocessor1.2 Computer Language1.3 Operating System1.4 The 8085 Programming

Model1.5 Instruction Set Classification1.6 Instruction Data Format and

Storage1.7 Data Formats1.8 Execution of a Program1.9 An Overview of 8085

Instruction Set1.10 Microprocessor Architecture

and Its Operations

1.11 Memory Classification1.12 Input and Output Devices1.13 Logic Devices1.14 Architecture of 8085

Microprocessor1.15 8085 Pins and Description1.16 Pin Description1.17 Control and Status Pin1.18 External Signal1.19 Power Supply and Clock

Frequency1.20 Serial I/O Port1.21 8085 Functional Description

8085 Microprocessors

1

M01_MP_CH01.indd 1 8/4/2015 12:45:53 PM

Page 9: Microprocessors GATE PSUs - content.kopykitab.com

1.2 8085 Microprocessors

memory so as to produce the result. The microprocessor communicates and operates through the binary numbers 0 and 1 which are called bits. Each microprocessor has a fixedsetofinstructionsgivenintheformofbinary patterns called a machine language.

• Instructions are given in the form of abbreviated names called mnemonics, which form the assembly language.

• The physical components of this system are called hardware. A set of instructions written for the microprocessor to perform a task is called a program and a group of programs is called software.

The microprocessor is a programmable device that can perform different sets of operations on the data it receives depending on the sequence of instructions supplied in the given program.

By changing the program, the microprocessor can manipulate the data in different ways.

InstructionsEach microprocessor is designed to execute a specific group of operations. This group ofoperations is called an instruction set. The instruction setdefineswhat themicroprocessorcan do and what it cannot do.

Input Devices: The data that the microprocessor manipulates must come from

“input devices” such as a keyboard, a mouse, switches, and the like.

Numbers: It can understand only binary numbers.

• A binary digit is called a bit.• The microprocessor recognizes and processes

a group of bits together. The group of bits is called a “word”.

• The number of bits in a microprocessor word determines the measure of its “abilities”.

The earliest microprocessor (the Intel 8088 and Motorola’s 6800) recognized eight-bit words. They processed information of eight-bits at a time and hence were called “eight-bit processors”. They could handle large numbers, but in order to process these numbers, they broke them into eight-bit pieces and processed each group of eight-bits separately. Later, microprocessors

(8086 and 68000) were designed with 16-bit words.

1. A group of eight-bits were referred to as a “half-word” or “byte”.

2. A group of four-bits is called a “nibble”.3. Also, 32-bit groups were given the name

“long word”.

Now a days, the processors are capable of manipulating at least 32 bits at a time. There are microprocessors that are capable of processing 64, 80, 128 bits at at time.

Arithmetic and Logic OperationsA microprocessor can perform arithmetic operations such as addion and subtraction as a part of its instruction set.

Most microprocessors can perform operations such as multiplication and division. Some of the newer ones are capable of performing complex operations such as square root.

In addition, microprocessors have logic operations as well, such as AND, OR, XOR, shift left, shift right, etc.

Again, the number and the types of operations definethemicroprocessor’sinstructionsetanditdependsuponthespecificmicroprocessor.

MemoryMemory is the location where information is kept while not in current use. It is a collection of storage devices. Usually, each storage device holds one bit. Also, in most kinds of memory, these storage devices are grouped into groups of eight. These eight storage locations can be accessed only together. So, one can only read or write in terms of bytes to and from memory.

Memory is usually measured by the number of bytes it can hold. It is measured in kilos, megas, and lately gigas.

A kilo in a computer language is 210 = 1024. So, a KB (kilobyte) is 1024 bytes. A Mega is 1024 kilos and a giga is 1024 megas.

When a program is entered into a computer, it is stored in the memory. As the microprocessor starts to execute the instructions, it brings out the instructions from the memory one at a time.

Memory is also used to hold the data. The microprocessor reads (brings in) the data from

M01_MP_CH01.indd 2 8/4/2015 12:45:53 PM

Page 10: Microprocessors GATE PSUs - content.kopykitab.com

8085 Microprocessors 1.3

the memory at the time of execution and writes (stores) the results into the memory when it is done.

Output DevicesFor the user to see the result of the execution of the program, the results are presented in a human readable form on an output device that can be a monitor, a paper from the printer or a simple LED program.

To sum up, a microprocessor is an electronic integrated chip that has computing and decision making capability.

It is an electronic integrated chip that fetches (read) instruction from memory, executes them and provides the result. A microprocessor cannot perform any task on its own. The pictorial representation below denotes the naming convention of the 8085 microprocessors.

1972 or 1973(80’s decade)

80 8

8 bit

55 V power supply

→ no logic for its name

The advanced version of 8085 is 8086.

Computer—The Programmable MachineThe following block diagram represents a microprocessor-based system (Figure 1.1)

Inside the MicroprocessorInternally, the microprocessor is made up of the following three main units:

1. The Arithmetic Logic Unit (ALU)2. The Control Unit3. An array of registers for holding data

while it is being manipulated.The microprocessor is a silicon chip which includes ALU, register circuits, and control circuits.

Arithmetic Logic UnitThis is the area of the microprocessor where various computing functions are performed on the data. The ALU unit performs arithmetic operations such as addition and subtraction and logic operations such as AND, OR, and exclusive OR.

Register ArrayThis area of the microprocessor consists of variousregistersidentifiedbyletterssuchasB,C,D, E, H and L. These registers are primarily used to store data temporarily during the execution of a program and are accessible to the user through instruction.

Control UnitThe control unit provides the necessary timing and control signals to all the operations in the microcomputer. It controls the flow of databetween the microprocessor and the memory and peripherals.

The 8085 Machine LanguageThe 8085 is an eight-bit microprocessor. It uses a total of 246 bit patterns to form its instruction set. These 246 bit patterns represent only 74 instructions.

Organization of a Microprocessor-Based SystemFigure 1.2 depicts a microprocessor-based system with bus architecture.

MemoryMemory stores information such as instructions and data in the binary format (0 and 1). It provides the information to the microprocessor whenever it is needed.

Input Output

Memory

Micr

opro

cess

or

Figure 1.1 Block Diagram of a Computer with CPU, the Microprocessor

However, there is no logic behind the naming convention.

M01_MP_CH01.indd 3 8/4/2015 12:45:54 PM

Page 11: Microprocessors GATE PSUs - content.kopykitab.com

1.4 8085 Microprocessors

chip which includes microprocessor, memory and I/O in a single package.

Memory Map and AddressesMemory map is a pictorial representation of the address range of the memory. It shows the

Normally, there is a memory “sub-system” in a microprocessor-based system.

This sub-system includes:

• The registers inside the microprocessor.• Read Only Memory (ROM) that is used to

store information that does not change.• Random Access Memory (RAM) (also

known as Read/Write Memory). It is used to store information supplied by the useruch as programs and data.

ROMIt is the integral part of microprocessor. All system related information stored in it comes into picture at the time of power switch “on” condition.

m P = H / W of m p + S / W of m p (on ROM )

RAMIt is externally interfaced with microprocessors. The instructions or commands are always feed into it.

Main Memory = Memory.

BUSIt is a group of wires (or parallel combination of wire) that is used as an interface between two devices. Microcontroller is the example of ASIC design,whereASICmeansapplicationspecificintegrated chip.

MicrocomputerIt is a combination of microprocessor, memory, input and output (See Figure 1.3). If the task of a CPU is performed by a microprocessor, then such a type of computer is known as a microcomputer.

Figure 1.3 Block Diagram of a Microcomputer

Micro-processor

Memory

Input

Output

Figure 1.4 Block Diagram of a Microcontroller

Micro-processor

Memory

OutputInput

Microcomputer is a computer with a microprocessor as its CPU. Includes memory, I/O etc.

MicrocontrollerThe Microcomputer mounted on a single platform or on a single chip is known as a microcontroller (See Figure 1.4). It is a silicon

Figure 1.5 Memory Mapping

EPROM

0000 0000Address Range of EPROM Chip

Address Range 1st RAM Chip

Address Range 2nd RAM Chip

Address Range 3rd RAM Chip

Address Range 4th RAM Chip

3FFF

5FFF

4400

6000

8FFF9000

A3FFA400

F7FFFFFF

RAM 1

RAM 2

RAM 3

RAM 4

Add

ress

Ran

ge

Figure 1.2 Microprocessor-Based System with Bus Architecture

Microprocessor

Control

Memory

Rom R/WM

[Input/Output]

BusSystem

RegisterArray

ALU

location of the different memory chips placed within the address range (See Figure 1.5).

M01_MP_CH01.indd 4 8/4/2015 12:45:54 PM

Page 12: Microprocessors GATE PSUs - content.kopykitab.com

8085 Microprocessors 1.5

Assembler is a translator that converts assembly language to machine language. It is a software.

If a translation task is performed manually, then it is known as hand assembly. Look at the following examples to know in detail about the hand assembly.

Example 1:• 00111100 is translated to 3C in hexadecimal

(OPCODE).• Its mnemonic is: “INR A”.• INR stands for “increment register” and A is

the short form for an accumulator.

Example 2:• 1000 0000 is translated to 80 in hexadecimal.• Its mnemonic is “ADD B”.• It stands for “Add register B to the accumulator

and keep the result in the accumulator”.It is important to remember that a machine

language and its associated assembly language are completely machine dependent. In other words, they are not transferable from one microprocessor to the other. For example, Motorolla has an eight-bit microprocessor called the 6800. The 8085 machine language is very different from that of the 6800. So is the assembly language. A program written for the 8085 cannot be executed on the 6800 and vice versa.

“Assembling” the ProgramAn Assembly Language can get translated into machine language in two ways: The firstpossibility is done by “hand assembly,” where

Execution of a ProgramThe user enters instructions in the binary format into the memory. The microprocessor reads these instructions and the required data from the memory, executes the instructions and stores the results either in the memory or produces it on an output device.

The Three-Cycle Instruction Execution ModelTo execute a program, the microprocessor reads each instruction from memory, interprets it, and then executes it.

To use the right names for the cycles, the microprocessor fetches each instruction, decodes it, and then executes it.

This sequence is continued until all instructions are performed.

1.2 Computer LanguageMachine LanguageThe number of bits that form the “word” of a microprocessor is fixed for that particularprocessor. These bits define the maximumnumber of combinations. For example, an eight-bit microprocessor can have a maximum of 28 = 256 different combinations.

However, in most microprocessors, not all of these combinations are used. Certain patterns arechosenandassignedspecificmeanings.Eachof these patterns forms an instruction to the microprocessor. The complete set of patterns make up the machine language of the microprocessor.

The reason for the difference is that some (actually most) instructions have multiple different formats.Sinceitisverydifficulttoenterthebitpatterns correctly, they are usually entered in hexadecimal instead of the binary format.

If commands or instructions written in the binary pattern, then such a type of language is known as the machine language which is platformdependentormachinespecificlanguage.

Assembly LanguageEntering the instructions using hexadecimal is quite easier than entering in the binary combinations.

However, it still is difficult to understandwhat a program written in hexadecimal does. So, each companydefines a symbolic code for theinstructions. These codes are called mnemonics.

The mnemonic for each instruction is usually a group of letters that suggest the operation performed.

If a binary pattern is replaced by words, written in language such as English, it is known as “mnemonics.” Such a type of language is known as the assembly language.

The assembly language is also a platform- dependentoramachine-specificlanguage.

Figure 1.6 Block Diagram of an Assembler Converting an Assembly Language to Machine Language

AssemblyLanguage

AssemblerMachine

Language

M01_MP_CH01.indd 5 8/4/2015 12:45:55 PM

Page 13: Microprocessors GATE PSUs - content.kopykitab.com

1.6 8085 Microprocessors

The programmer translates each assembly language instruction into its equivalent hexadecimal code (machine language). Then the hexadecimal code is entered into the memory.

The other possibility is done through a program called an “assembler”, which does the translation automatically.

Low Level LanguageAll platformormachine-specific languages areknown as low level languages such as machine language and assembly language. Machine languages are in binary format and the assembly language is in English like word format i.e. in the form of mnemonics.

The AssemblerIt is a program that translates the mnemonics entered by the ASCII keyboard into the corresponding binary machine codes of the microprocessor.

Each microprocessor has its own assembler because the mnemonics and machine codes are specific to themicroprocessor being used, andeach assembler has rules that must be followed by the programmer.

High Level LanguageProgramming languages that are intended to be machine independent are called high level languages. These include languages such as BASIC, PASCAL, C, C++ and Java, all of which have certain sets of rules and drawn on symbols and conventions.

Instructions written in English in languages such as C, C++, JAVA are known as statements rather than mnemonics.

Compiler or an InterpreterThese programs accept English like statements as their input called the source code. The compiler or interpreter then translates the source code into the machine language compatible with the microprocessor being used in the system. This translation in the machine language is called the object code. Each microprocessor needs its own compiler or an interpreter for each high level language (See Figure 1.7).

CompilerIt is a software that reads the entire program from the source code and then translates it into

the object code which in turn will be executed by the microprocessor in languages such as C, C++.

InterpreterIt is a software that reads one instruction at a time from source code to produce its object code that in turn will be executed by processor (See Figure 1.8). Then, it proceeds with the next instruction from the source code. This involves a sequence of machine actions. This kind of execution is done in languages such as Basic.

Figure 1.8 Translation of High Level Language Program into Machine Code

SourceCode

Compiler orInterpreter

Object Code

The primary advantage of high level languages lies in its ability to troubleshoot (debugging) programs.

Note:Machine Assembly High level

> >Language Language Language

Faster Execution

Machine Assembly High level< <

Language Language LanguageRequire Large Memory to Store

Machine Assembly High level< <

Language Language LanguageDebugging or Trouble Shooting is Faster to Find Error

1.3 Operating SystemThe interaction between the hardware and the software is managed by a set of programs called an operating system of a computer; it oversees all the operations of the computer. The

Figure 1.7 Conversion Diagram from Source Code to Object Code

SourceCode

Compiler orInterpreter

UserUnderstandable

MachineUnderstandable

Object Code

M01_MP_CH01.indd 6 8/4/2015 12:45:55 PM

Page 14: Microprocessors GATE PSUs - content.kopykitab.com

8085 Microprocessors 1.7

RegistersThe 8085 has six general-purpose registers to storeeight-bitdata;theseareidentifiedasB,C,D,E, H, and L as shown in Figure 1.9. They can be combined as register pairs such as BC, DE, and HL to perform some 16-bit operations. The programmer can use these registers to store or copy data into the registers by using data copy instructions.

AccumulatorThe accumulator is an eight-bit register that is a part of the arithmetic/logic unit (ALU). This register is used to store eight-bit data and to perform arithmetic and logical operations. The result of the operation is stored in the accumulator. TheaccumulatorisalsoidentifiedasregisterA.

FlagsTheALUincludesfiveflip-flops,whicharesetor reset after an operation according to the data conditions of the result stored in the accumulator and in other registers. They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC)flags; theirbitpositions in theflagregister are shown in Figure 1.10. The most commonlyusedflagsareZero,Carry,andSign.Themicroprocessor uses theseflags to test thedata conditions. They are listed in the Table and theirbitpositionsintheflagregisterareshownin the Figure below.

operating system is primarily responsible for storing information on the disk and for enabling communication between the computer and its peripherals.

The Floppy DiskThefloppydisk isamagneticmediumsimilarto a disk that can be accessed randomly using disk drives.

WorkstationThese are high-performance cousins of the personal computers. They are used in engineering and scientific applications suchas computer-aided design (CAD), computer-aided engineering (CAE), and computer-aided manufacturing (CAM). They generally include system memory and storage (hard disk) memory in gigabytes, and a high-resolution screen.

The work stations are designed around RISC (reduced instruction set computing) processors. The RISC processors tend to be faster and more efficient than the processors used in personalcomputers. Some of the workstations have better performance than that of the low-end large computers.

1.4 The 8085 Programming Model

The 8085 programming model includes six registers,oneaccumulator,andoneflagregister,as shown in Figure 1.9. In addition, it has two 16-bit registers: the stack pointer and the program counter.Theyaredescribedbrieflybelow.

D7

S

D6

Z

D5 D4

AC

D3 D2

P

D1 D0

CY

Figure 1.10 Flags of 8085 Microprocessors

Figure 1.9 8085 Programming Model

Accumulator A

B

D

H

(8)

(8)

(8)

(8)

C

E

L

(8)

Flag Register

(8)

(8)

(16)

(16)

Stack Pointer (SP)

Program Counter (PC)

Data Bus

8 Lines Bidirectional 16 Lines Bidirectional

Address Bus

For example, after an addition of two numbers, if the sum in the accumulator is larger than eight bits, theflip-flop that isused to indicateacarry,calledtheCarryflag(CY),issettoone.Whenanarithmeticoperation results inzero, theflip-flopcalledtheZero(Z)flagissettoone.Figure1.10showsaneight-bitregister,calledtheflagregisterthat is seen adjacent to the accumulator. However, itisnotusedasaregister;fivebitpositionsoutofeightareusedtostoretheoutputsofthefiveflip-flops.Theflagsarestoredintheeight-bitregisterso that theprogrammercanexamine theseflags(data conditions) by accessing the register through an instruction.

M01_MP_CH01.indd 7 8/4/2015 12:45:56 PM

Page 15: Microprocessors GATE PSUs - content.kopykitab.com

1.8 8085 Microprocessors

a destination, without modifying the contents of the source. In technical manuals, the term data transfer is used for this copying function. However, the term transfer is misleading; it creates the impression that the contents of the source are destroyed when, in fact, the contents are retained without any modification. Thevarious types of data transfer (copy) are listed in Table 1.1 along with examples for each type:

Table 1.1 Type of Data Transfer

Types Examples1. Between registers. 1. Copy the contents

of the register B into register D.

2. Specificdatabyteto a register or a memory location.

2. Load register B with the data byte 32H.

3. Between a memory location and a register.

3. From a memory location 2000H to register B.

4. Between and I/O device and the accumulator.

4. From an input keyboard to the accumlator.

Arithmetic OperationsThese instructions perform arithmetic operations such as addition, subtraction, increment, and decrement.

Addition Any eight-bit number, the contents of a register or the contents of a memory location can be added to the contents of the accumulator and the sum is stored in the accumulator. No two other 8-bit registers can be added directly (e.g., the contents of Register B cannot be added directly to the contents of Register C). The instruction DAD is an exception; it adds 16-bit data directly in register pairs.

Subtraction Any eight-bit number, the contents of a register, or the contents of a memory location can be subtracted from the contents of the accumulator and the results are stored in the accumulator. The subtraction is performed in 2’s complement, and the results, if negative, are expressed in 2’s complement. No two other registers can be subtracted directly.

Theseflagshave critical importance in thedecision-making process of the microprocessor. The conditions (set or reset) of the flags aretested through the software instructions. For example, the instruction JC (Jump on Carry) is implemented to change the sequence of a program when CY flag is set. A thoroughunderstandingofflagsisessentialwhilewritingprograms for an assembly language.

Program Counter (PC)This 16-bit register deals with sequencing the execution of instructions. This register is a memory pointer. Memory locations have 16-bit addresses, and that is why this is calles a 16-bit register.

The microprocessor uses this register to sequence the execution of the instructions. The function of the program counter is to point the memory address from which the next byte is to be fetched. When a byte (machine code) is being fetched, the program counter is incremented by one to point the next memory location.

Stack Pointer (SP)The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory location in R/W memory, called the stack. The beginning ofthestackisdefinedbyloading16-bitaddressin the stack pointer.

This programming model will be used in subsequent tutorials to examine how these registers are affected after the execution of an instruction.

1.5 Instruction Set Classification

An instruction is a binary pattern designed inside a microprocessortoperformaspecificfunction.Theentire group of instructions, called the instruction set, determines what functions the microprocessor canperform.Theseinstructionscanbeclassifiedintothefollowingfivefunctionalcategories:datatransfer (copy) operations, arithmetic operations, logical operations, branching operations, and machine-control operations.

Data Transfer (Copy) OperationsThis group of instructions copy data from a location called a source to another location called

M01_MP_CH01.indd 8 8/4/2015 12:45:56 PM

Page 16: Microprocessors GATE PSUs - content.kopykitab.com

Microprocessors - GATE, PSUS And ESExamination

Publisher : SChand Publications ISBN : 9789325992269 Author : Satish K Karna

Type the URL : http://www.kopykitab.com/product/18095

Get this eBook

20%OFF