Microprocessor - Nubacad.com

feastcanadianSoftware and s/w Development

Dec 14, 2013 (3 years and 3 months ago)

110 views

Page
1

of
20


Northern University
Bangladesh,
Dhaka

Class schedule

Course Code: 3124/3129; Course Title
-
Microprocessor & Assembly

Language Programming. Summer

Semester
-
201
2


Course Teacher:

Prof. Dr. Md. Nurul Islam


Course Objective
: Microprocessor is the main building

block of the microcomputer/P.C. So the internal
structure of this is to be known along with its language

(Assembly language). Internal structure with
various components and their functions will be presented for students


assimilation. Instructions of the
processor will be used for
programming

with some ideas on data manipulation and communication to
outside pheriperial devices.

C
ourse contents:


Chapter

Contents

No. of Lectures for 1.5
hr duration

1

Microprocessor and microcomputer: Evolution, application,
architecture, common instruction sets, addressing modes.

1
-
4

2

Brief study of Intel 8085,8086 microprocessor, overview of Intel
80186,80386,80486 and Pentium processor.

5
-
10

3

Memory management in

microprocessor. Interrupt in Intel
processor.

11
-
12

4

Micro controllers: Architecture & applications; Overview of Alpha
processor

1
3
-
14

5

Design and operation of Interface between computer and the
outside world. (I/O operations)

15
-
17

6

Machine &
Assembly instruction types and their formats,
Character representation instructions, Instruction execution.
Machine language programming.

18
-
20

7

Instruction set and their implementations. Assembly process,
Addressing methods, Subroutines, macro and its I
/O
programming, Interrupt and concurrent processing

22
-
24

Total

24


Total Marks= 100


Distribution
: Class test +assignment+
Class performance

=
20

; Mid
-
term =
3
5
; Final =
4
5

Class Test shall be conducted on completion of some chapters and the schedule
will be announced during the
progress of the class lectures.

● Mid term and final examina
tion will be held as per package

schedule.

Books recommended:


1. Microprocessor and Microprocessor



M. Rafiquzzaman

based system design

2. Microprocessor and Microc
omputer



T. Hanley

3. Microcomputer architecture and programming

John F. wakerley.

4. The INTEL Microprocessors 8086/8088/……..

Bray B. Bray.

5. Internet

Page
2

of
20



Coures#CSE3124
/EEE3129
:
Microprocessor

and Assembly



Language programm
ing.


Lecturer: Prof.Dr.M.N Islam
;

Dean , Faculty of Science & Engineering ,NUB,

Dhaka

,Bangladesh

Lecture
-
01:


M
icroprocessor:



It is a special type of Integrated Circuit(I.C)



A general purpose device which may be programmed and applied to wide
range
of applications.



It is the brain/
heart of the microcomputer and microprocessor based
system.



Two chief functions are processing and control. Processes data according to
the program of instructions stored in the memory of the system.



Arithmetic Logic Unit(A
LU) process data and Control Unit(C
U) keeps parts
of the system working together and in right time sequences during the
execution of the program.



Processor is also known as Microprocessor Unit(MPU) and very often it is
referred to as Central processing Uni
t(CPU)
.But CPU is slightly different
from MPU, being consists of ALU,CU and main memory.



Many types of microprocessors from 8 bit,16 bit,32bit,64 bit,etc are
available in the market now a days.









Page
3

of
20








Computers and Microcomputers:



A
Computer

is a programmable machine.




The two principal characteristics of a computer are:



It responds to a specific set of instructions in a well
-
defined manner.



It can execute a prerecorded list of instructions (a program ).



Modern computers are electronic an
d digital.



The actual machinery wires, transistors, and circuits is called
hardware. the instructions and data are called software.



































All general
-
purpose computers require the following hardware components:




Memory
: Enables a computer to store, at least temporarily, data and
programs.



Mass storage device
: Allows a computer to permanently retain large
amounts of

data. Common mass storage

devices include disk drives and
tape drives.



Input device
: Usually a keyboard and mouse are the input device through
which

data and instructions enter a computer.

Page
4

of
20




Output device
: A display screen, printer, or other device that lets you see
what

the compu
ter has accomplished.



Central processing unit (CPU):
The heart of the computer, this is the
component

that actually executes instructions.



In addition to these components, many others make it possible for the
basic components to work together efficiently
.



For example, every computer requires a bus that transmits data from one
part of the computer to another.


Computers

can be generally classified by size and power as follows, though there
is considerable overlap:

Personal computer
: A small, single
-
user

computer based on a microprocessor.



In addition to the microprocessor, a personal computer has a keyboard
for entering data, a monitor for displaying information, and a storage
device for saving data.



Working station
: A powerful, single
-
user computer. A
workstation is
like a

personal computer, but it has a more powerful microprocessor
and a higher
-
quality monitor.



Minicomputer
: A multi
-
user computer capable of supporting from
10 to

hundreds of users simultaneously.



Mainframe
: A powerful multi
-
user
computer capable of supporting
many

hundreds or thousands of users simultaneously.



Supercomputer:
An extremely fast computer that can perform
hundreds of

millions of instructions per second.

Minicomputer
:



A midsized computer. In size and power, minicomputers lie between
workstations and mainframes.



A minicomputer, a term no longer much used, is a computer of a size
intermediate between a microcomputer and a mainframe.



Typically, minicomputers have been st
and
-
alone computers (computer
systems with attached terminals and other devices) sold to small and mid
-
size businesses for general business applications and to large enterprises
for department
-
level operations.



In recent years, the minicomputer has evolve
d into the "mid
-
range server"
and is part of a network. IBM's AS/400e is a good example.




The AS/400
-

formally renamed the "IBM iSeries," but still commonly
known as AS/400
-

is a midrange server designed for small businesses and
departments in large ent
erprises and now redesigned so that it will work
Page
5

of
20


well in distributed networks with Web applications.



The AS/400 uses the PowerPC microprocessor with its reduced
instruction set computer technology. Its operating system is called the
OS/400.



With multi
-
terabytes of disk storage and a Java virtual memory closely tied
into the operating system, IBM hopes to make the AS/400 a kind of
versatile all
-
purpose server that can replace PC servers and Web servers in
the world's businesses, competing with

both Wintel and Unix servers, while
giving its present enormous customer base an immediate leap into the
Internet.

Workstation:

1)

A type of computer used for engineering applications (CAD/CAM),
desktop publishing, software development, and other types of a
pplications
that require a moderate amount of computing power and relatively high
quality graphics capabilities.



Workstations generally come with a large, high
-

resolution graphics screen,
at least 64 MB (mega bytes) of RAM, built
-
in network support, and
a
graphical user interface.



Most workstations also have a mass storage device such as a disk drive,
but a special type of workstation, called a diskless workstation, comes
without a disk drive.




The most common operating systems for workstations are UNIX and
Windows NT.



In terms of computing power, workstations lie between personal
computers and minicomputers, although the line is fuzzy on both ends.



High
-
end personal computers are equivalent to

low
-
end workstations. And
high
-
end workstations are equivalent to minicomputers.



Like personal computers, most workstations are single
-
user computers.
However, workstations are typically linked together to form a local
-
area
network, although they can als
o be used as stand
-
alone systems.

2)

In networking,
workstation

refers to any computer connected to a
local
-
area network. It could be a workstation or a personal computer.



Mainframe:
A very large and expensive computer capable of supporting

hundreds, or eve
n thousands, of users simultaneously. In the hierarchy that
starts with a simple microprocessors (in watches, for example) at the bottom
and moves to supercomputer at the top, mainframes are just below
supercomputers.



In some ways, mainframes are more powerful than supercomputers
because they support more simultaneous programs.



But supercomputers can execute a single program faster than a
Page
6

of
20


mainframe. The distinction between small mainframes and minicomputers
is vague, d
epending really on how the manufacturer wants to market its
machines.



Microcomputer:
The term

microcomputer

is generally synonymous
with

personal computer, or a computer that depends on a
microprocessor.



Microcomputers are designed to be used by individu
als, whether in the
form of PCs, workstations or notebook computers.




A microcomputer contains a CPU on a microchip (the microprocessor), a
memory system (typically ROM and RAM), a bus system and I/O ports,
typically housed in a motherboard.



Microprocess
or
: A silicon chip that contains a CPU. In the world of
personal

computers, the terms
microprocessor

and CPU are used
interchangeably.



A
microprocessor

(sometimes abbreviated
µP
) is a digital electronic
component with miniaturized transistors on a single semiconductor
integrated circuit (IC).



One or more microprocessors typically serve as a central processing unit
(CPU) in a computer system or handheld device.



Microprocessors m
ade possible the advent of the microcomputer.



At the heart of all personal computers and most working stations
sits a microprocessor.



Microprocessors also control the logic of almost all digital devices, from
clock radios to fuel
-
injection systems for au
tomobiles.



Three basic characteristics differentiate microprocessors:



Instruction set
: The set of instructions that the microprocessor can execute.



Bandwidth
: The number of bits processed in a single instruction.



Clock speed
: Given in megahertz (MHz),
the clock speed determines how
many

instructions per second the processor can
execute.



In both cases, the higher the value, the more powerful the CPU. For
example, a 32 bit microprocessor that runs at 50MHz is more powerful than
a 16
-
bit microprocessor that runs at 25MHz.




In addition to bandwidth and clock speed, microprocessors are classi
fied as
being either RISC (reduced instruction set computer) or CISC (complex
instruction set computer).



Supercomputer
: A supercomputer is a computer that performs at or
near the

currently highest operational rate for computers.



A supercomputer is typica
lly used for scientific and engineering
applications that must handle very large databases or do a great amount of
computation (or both).

Page
7

of
20




At any given time, there are usually a few well
-
publicized
supercomputers that operate at the very latest and always
incredible
speeds.



The term is also sometimes applied to far slower (but still impressively
fast) computers.



Most supercomputers are really multiple computers that perform
parallel processing.



In general, there are two parallel processing approaches:
symmetric multiprocessing (SMP) and massively parallel
processing (MPP).


Lecture#02


Evolution of Microprocessor:



First microprocessor 4004(4
-
bit was introduced by INTEL,1971 and was
used in calc
ulator
.



Soon after came


Rockwell International 4
-
bit,pps
-
4,INTEL 8
-
bit 8008 and
National semiconductor 16
-
bit IMP
-
16.



In 1971
-
73,
First Generation microprocessor

using PMOS technology were
designed.These were low cost,low price
,

low speed and low output current
and were not compatible with TTL(Tr
a
nsistor Transistor Logic).These serial
processors Fetch and execute each instruction before going to the next,

e.g
INTE
L 4004.



Aft
er 1973,Second generation microprocessor such as Motorol
a 6800 and
6808, INTEL 8085 and Zilog Z 80 were evolved.

These 8
-
bit processors were
fabricated using NMOS(N type MOS) technology. These offers faster speed
and higher density of circuit than PMOS and also TTL compatible.



After 1978 the third generation mi
croprocessors with 16
-
bit word length
and ALU(Arithmetic Logic Unit) were introduced.

These includes INTEL
8086/80186/80286 and Motorola 68000/68010. Being designed by
HMOS(High density MOS) technology, these provides SSP(Speed power
Product) four times b
etter than that of NMOS processors. Circuit density
Page
8

of
20


also approximately twice than

those of NMOS,HMOS=4128gates/sq.

µ
meter and

N
MOS=

1852.5
gates/sq.

µ
meter



In 1980 fourth generation microprocessor using HMOS evolved. INTEL 32
bit processor,

INTEL 432 an
d by 1985 more microprocessor like M
otoro
L
a
MC68020/68030/68040 power PC , INTEL

80386/80486 and INTEL P
entium
using low power version of HMOS technology(called HCMOS) came in the
market.



INTEL and Motorola introduced

RISC (Reduced Instruction Set
Computer),INTEL 80960 and MC 88100 power PC with simplified instruction
sets to maximize the speed by reducing clock cycles per instruction

by using
super scalar and multiple super scalar pipelines.



Evolution is going on with the latest high speed processo
rs like
---
core 2
du
o, core quad, etc


Table 1: Evolution of Intel's Microprocessors


Product

8080

8085

8086

8088

80286

80386

80486


Year Introduced

1974

1976

1978

1979

1982

1985

1989




Clock rate
(MHz)

2
-
3

3
-
8

5
-
10

5
-
8

6
-
16

16
-
33

25
-
50




No. transistors

4500

6500

29,000

29,000

130,000

275,000

1.2
million




Physical
memory

64K

64K

1M

1M

16M

4G

4G




Internal data
bus

8

8

16

16

16

32

32




External data
bus

8

8

16

8

16

32

32




Address bus

16

16

20

20

24

32

32




Data type (bits)

8

8

8,16

8,16

8,16

8,16,32

8,16,32





Application of microprocessor
:

The main application of microprocessors are in microcomputers and in
embedded systems, may be in the form of microcontrollers.

A

block
diagram of a typical microcomputer is given below to show the
application of the microprocessor in the microcomputer system.







Page
9

of
20

























Here MPU is the

Micro
processor Unit

Microprocessor architecture:

It refers to the internal
structure or organization of a microprocessor.

The following factors are important for selecting a microprocessor for a particular
action:



Word length of a microprocessor ,i .e data word.



Directly addressable memory.



Speed of executing instructions.



Regis
ters available for the programmers,



Other useful registers for the microprocessors.



Range of instructions that are supported by the microprocessor.




The addressing modes available.


Page
10

of
20


Word lengths; May be 8 bits,16 bits ,32
-
bits, 64

bits,e

tc. and

may be
indicated as follows:



M
SB


LSB




8 bit byte










15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

0


-----------------------------------------------

16
-
bit word
---------------------------------

3
1






















9


8

7

6

5

4

3

2

1

0


------------------------------------------------

32
-
bit word
---------------------------------


Directly
addressable memory:



The address bus is used for the data transaction from the microprocessor to
the devices ,memory or input/output ports.



The following table shows the number of memory locations that can be
addressed by by using different number of addres
s lines.



No .of address lines No. of directly addressable memory locations

01

02

02

04

03

08

04

16

05

32

06

64

07




08




09




10

1024(1K)












16




65536











20




1024(KB)=1MB


N

2
N

7

6

5

4

3

2

1

0

Page
11

of
20


An example of memory addressing for a hypothetical 4
-
bit microprocessor with
three bit address lines ar
e shown below:


Data bus Address bus

Hypothetical

4
-
bit

microprocessor



Binary
address

Memory location


Memory contents

4
-
bit long


000


00


0010


001


01


1000


010


02


0100


011


03


1100


100


04


0110


101


05


0001


110


06


1111


111


07


1110


Each location is identified by a number called location/address.

For example if the processor wants to read data in location 2,it

must
send address 010 along the address bus to the memory. The data
0100 is then read from location 2 onto the data bus and then taken
into the microprocessor.

Speed of operation of microprocessor:



Competitions are going on in architecture for improvement

of
speed.



Speed are measured in two ways: 1)C
onsidering the clock
frequency w
hich is express in
M
egahertz(Mhz)/Gigahertz.
Page
12

of
20


2)Execution of instructions per second and expresses in
MIPS(Millions of instructions per second).



The clock speed of recent
processors are in Gigahertz.

Microprocessor’s block diagram:

The block diagram of a simple microprocessor showing the internal
elements interconnected.


8
-
bit data bus

External Data bus






Outside the

µ
P



Microproces








IN IN








ALU


ext
e
rnal

Ad
-------


Internal ad
----------


-----------

cont
rol signals




--------------








Internal control bus





External Control



i
--------------------------------------------------------------------------------------
-------------------------------



Clock


Control Signal to external elements




Fig: Block di
agram of a simple Microprocessor.

Lecture #03


B

C

D

E

H

L

Stack Pointer

Program
Counter

Instructi
on Reg.



Instructi
on

Decoder

&

Timing

&

Control

Logic

SR

Accumula
tor


A

Page
13

of
20


Some internal elements of the microprocessors are introduced below:

Registers:
a) General purpose registers
--

B


C


D


E



H


L


b) Accumulator
----------------------

A


C) Status register
-------------------

SR


d) Instruction Register
-------------

IR



e) Program counter
-----------------
PC


f) Stack pointer
----------------------
SP

Functions of different Registers:

a)

General purpose registers:



Each one stores one byte of data and may be connected to the
bidirectional data bu
s.



Can transfer data to or from the data bus.



For adding two data ,one of them could be kept in one of these
registers.



Pair of registers may be used for storing two bytes(16
-
bits)



This may be 16
-
bit data or address.

b)

The Accumulator
:



It is an 8
-
bit
register connected to internal bidirectional data bus.



It works closely with the ALU.



For adding two data one is hold by A while one of the general
registers manipulates other.



The results of operations appear at the output of ALU.



The results may be kep
t either in A or general register before
transfering to the memory.


Page
14

of
20


C)
Status Register:



It is sometimes referred to as the Flag Register(FR) Or condition codr
Register(CCR).



Flag is an indicator that can be set

or reset .A Flip=Flop is an example of
this device which may be set to 1 or zero.



This is an 8
-

bit Register and set or reset some or all the bit during
execution of the program.



ALU and some Register operation may set to 1 or 0 one or more status bits
i
n SR.



Some of the bits may be tested by instructions in the program and decision
may be taken.



These bits may be used as conditions for jump, call and return
instructions.
The

Z80 flag Register is shown below:

D7

D0






Sign
Flag Zero Flag

Pa
rity/over flow Carry flag




H and N are used for BCD arithmetic and can not be tested.



X means that the flag goes to indeterminate state’



S,Z,N and C are the four testable bits



Example; use two’s

complement notation and the two 8
-
bit numbers
11110000 and 01110101,use in MSB=1 represents


and 0 for + .

c)

Instruction Register(IR):



It is 8
-
bit wide and is connected to the internal data bus. It can only
receive data,



It holds part of the current instru
ction known as the operation (OP)
code and dictate the processor for next cycle.



The output from the IR is the input to the Instruction decoder.




S


Z


X


H


X


P/V


N


C

Page
15

of
20


d)

Program Counter(PC):



It is most essential part of the microprocessor.



It hold the 16
-
bit address of the next

instruction to be
executed.



If the processor is to deal with the next instruction, it must
bring that instruction into itself from the memory.



In doing this PC output the address of the next instruction to
the external address bus.



When the address infor
mation reaches the memory, it
releases the contents of that particular location to the data
bus and eventually enters into the IR.

Stack Pointer(SP
):



For structure program, this 16
-
bit SP is used.



PC holds the address of next instruction while executing a program but for
procedure or subroutine it becomes necessary to load the PC with new
value.



Example may be seen below:




Address Main program Address

Subprogram






0100H

Ins 1


0102

Ins.2

0104

Ins
-
3

0106

Call 0500H

0108

Ins
-
5

010a

Ins
-
6











When main program starts running it executes Ins
-
1 to Ins
-
3 and Instruction
4

is a Call 0500H which transfer the control to 0500H location outside the
main program in the subprogram.

0500H

Ins
-
1

0502

Ins
-
2











0600H

Return

Page
16

of
20




The subprogram is then executed until the return Instruction is reached and
now the control is transferred to address 0108H in the main program.



The s
tack pointer works in conjunction with a read/write memory called
the stack which works as last in and first out(LIFO) structure.



Two software instruction PUSH for storing the contents of the Register on
the stack before execution of the subroutine and POP

restore the values to
the Register after completion of the subroutine .In the example the
content of 0108H is stored in the stack by the PUSH instruction as indicated
below
:






PUSH

Part of RAM

Microprocessor



PC 0108


SP 0237





PUSH starts at address 02390H. The steps for putting the address
0108H on the stack are: !) Decrement SP by 01 i.e

to 0238FH 2) save
the high order PC byte,01 at this address,3) Decrement the SP again
by 01,store the byte 08 with SP pointing at 237EH



The PC is now loaded with the address of the subprogram, 0500.



On completion of subprogram at RETURN, the POP instruct
ion does
the operation in opposite direction to restore the address to the PC
for completion of the remaining instructions in the main program.



Lecture #04


Content

Address

--


08

0237EH

01

0238FH

xx

02390H



Page
17

of
20


Arithmetic Logic Unit (ALU):



Arithmetic and logical operations are done here in ALU using the reg
isters.



Addition circuit is available for addition and subtraction by taking
complements of binary data.



Binary multiplication and division are done by using the shift and add and
shift and subtract operations respectively



Hence the arithmetic operations

can be reduced to a series of complement
and addition operations.



For logic operation such as Oring of two bytes ALU has in
-
built logic net
works constructed around registers and logic elements.



The type of functions performed by the ALU of most micropro
cessors ,
include:
Add, Subtract, Logical AND ,Logical OR, Logical EOR, Shift left ,
shift right, Increment, Decrement, Complement, etc



ALU has two inputs, both labelled ‘IN’ and a single output identified as
‘OUT’


Microprocessor’s Control circuit:



It
consists of Instruction decoder, Timing and control logic .Decoder receive
input from IR and control circuitry direct the fetching of instruction from
the memory for execution in ALU by providing timing and control signals.



The external clock signal acts a
s the reference for all timing operations in
the microprocessor.



A set of signals emanate from the control unit for synchronising the entire
system(see
the block d
iagram).

Execution of Instruction:


To understand how the CPU operates, let’s look at how an instruction is
executed. The machine instruction has two major parts: an
opcode

and
operands.

The opcode specifics the type of operation and operands are
often given as memory address to the data to
be manipulated. The
Fetch


Decode
-
Execute cycle

of the microprocessor are:


Page
18

of
20


Fetch:




Fetch an instruction from memory and take the opcode for the
instruction and then put it in the IR.

Decode:



Decode the instruction ;

the instruction decoder determines which
operation from the instruction set of the microprocessor is to be
carried out.

Execute:




Perform the operation on the data as requested by programmer.



Store the result in memory if needed.

For each instruction is
repeated until the whole program is finished.













No



Yes


Fig ,Flowchart for Fetch
-
Decode
-
Execute cycle.


Start

Fetch opcode

Decode
instruction

Execute

Last
instructi
o

End

Page
19

of
20


Problem:

How a microprocessor execute an instruction ,say LDA 6cH ; load
accumulator with 6cH?

Common instr
uction Set
:


It consists of the following instructions:



Data moving instructions.

e.g

MOVE,

PUSH,

etc



Arithmetic
-

add, subtract, increment and decrement.

e.
g

ADD,SUB,

etc



Logic
al

-

AND, OR, XOR and rotate

(ROR,ROL)
.



Control transfer
-

conditional, unconditional, call subroutine,
return from subroutine and restarts.
E.g JUMP,CALL etc



Input/Output

instructions.

e.g IN,OUT ,etc



Other
-

setting/clearing flag
bits, enabling/disabling interrupts,
stack operations, etc.



There may be other instructions depending on the microprocessors.


Addressing mode
:


It refers to the data flow from the memory to the processor and vice versa.
There may be number of addressing modes depending on the microprocessor
type and model. A few of these are mentioned below:




Register

-

references the data in a register or in a r
egister pair.
e.g M
OVE
CL ,DL ; Move 8
-
bit content of DL into CL



Register indirect
-

instruction specifies register pair containing address,
wherethe data is located.



Direct addressing


for 8
-
bit or 16 bit to the effective address.



Immediate
addressing
-

moves 8
-
bit or 16bit content into a register.



Questions.

1.What is a microprocessor ? What are its characteristics ?

2. What are CPU and MPU.?

3. Give the block diagram of a microcomputer.Explain briefly the
different components of it.

4.Desc
ribe different types of computers briefly.

5. Give the history of the evolution of the microprocessors.

6. Draw the block diagram of a typical microprocessor with names
of the components.

7. Describe the function of General registers,
Accumulator,Instructi
on Register, Status register and ALU.

Page
20

of
20


8. How the PC and SP work ?

9. What do you understand by addressable memory ?

Show with diagram how a 3 bit address bus can address 8 locations
?

10. How the fetch
-
decode
-
execution cycle works in a program?

11.Name the

different type of instruction sets and addressing
modes.