Vous êtes sur la page 1sur 35

CE 2423

Microprocessors & Microcontroller

Instructor:ShahidSJan COE, PAFKiet


e-mail:
shahidjan@pafkiet.edu.pk

WEB page: www.groups.yahoo.com/group/kiet-mmbs-fall2009/

Lecture 1
Introduction to Microprocessors
Computer Codes, & Programming

Stored Program Concept

Stored Program Concept

There are three major parts


The CPU (Central Processing Unit) which acts as the brain coordinating all
activities within the computer
The memory unit where the program instructions and data are temporarily stored
The I/O (Input/Output) devices which allow the computer to input information for
processing and then output the result

Today the CPU circuitry has been reduced to ICs called the microprocessor,
the entire computer with the three parts is called a microcomputer
Several registers (e.g., flip-flops wired in series with each other)
Some are general purpose, the accumulator for example is reserved for
performing complex mathematical operations like multiply and divide, and all I/O
data has to go thru the accumulator

The basic timing of the computer is controlled by a square wave oscillator or


a clock generator circuit.
Synchronization
Determines how fast the program can be fetched from memory and executed

Memory Read or Fetch Cycle


IP: Instruction Pointer
8

Stored Program Concept

Memory unit consists of a large number of storage locations each


with its own address
RAM (Random Access Memory) and its volatility
Typically each memory location is 8 bits wide (byte accessible memory)

ROM (Read Only Memory)

The memory units address selector/decoder circuit examines the


binary number on the address line and selects the proper memory
location to be accessed.
In this example, CPU is reading from memory, it activates its MEMORY
READ control signal
This causes the selected data byte in memory to be placed onto the
data lines and routed to the instruction register in the CPU

Once in the CPU, the instruction is decoded and executed


In this example, instruction has the decimal code 64 which for a 8086
microprocessor is decoded to be INC AX
The ALU (Arithmetic Logic Unit) is instructed to add 1 to the contents of
the AX

The cycle repeats itself


9

Stored Program Concept

Memory unit consists of a large number of storage locations each


with its own address. As a Prime Memory it can be observed as:
RAM (Random Access Memory) and its volatility. Typically 8 bit wide
ROM (Read Only Memory)

10

Internal Working Of Computers


1- the CPU program counter can have any value between
0000 FFFF H. This one is set to start with 1400
2- the CPU puts out 1400. The memory circuitry finds the
location. Activates the read signal, indicating the memory
location 1400. B0 is put on the bus and brought to the CPU

PC=1400
CPU
Inst Decoder
B0 decode

MEM
Read

B0

3- B0 is decoded internally it now knows it needs to fetch the


next byte!. It brings 21h from 1401. The program counter
automatically increments itself to the next location to fetch the
next data/instruction.

21

General Purpose Microprocessors


Microprocessors lead to versatile products
Data bus

CPU General
Purpose
Microprocessor

RAM

ROM

I/O

Timer

Serial
COM
Port

Address bus
These general microprocessors contain no RAM, ROM, or I/O
ports on the chip itself
Ex. Intels x86 family (8088, 8086, 80386, 80386, 80486,
Pentium)
Motorolas 680x0 family (68000, 68010, 68020, etc)

22

Microcontrollers
Microcontroller

CPU

RAM

ROM

I/O

TIMER

Serial Com
Port

A microcontroller has a CPU in addition to a fixed amount of


RAM, ROM, I/O ports on one single chip; this makes them ideal
for applications in which cost and space are critical
Example: a TV remote control does not need the computing
23
power of a 486

Computer Operating Systems

What happens when the computer is first turned on?


MS-DOS
A startup program in the BIOS is executed
This program in turn accesses the master boot record on the floppy or
hard disk drive
A loader then transfers the system files IO.SYS and MSDOS.SYS from
the disk drive to the main memory
Finally, the command interpreter COMMAND.COM is loaded into
memory which puts the DOS prompt on the screen that gives the user
access to DOSs built-in commands like DIR, COPY, VER.

The 640 K Barrier


DOS was designed to run on the original IBM PC
8088 microprocessor, 1Mbyte of main memory
IBM divided this 1Mb address space into specific blocks
640 K of RAM (user RAM)
384 K reserved for ROM functions (control programs for the video system,
hard drive controller, and the basic input/output system)

47

Memory Map

48

MS-DOS Functions and BIOS Services

Program Support
BIOS: usually stored in ROM these routines provide access to the
hardware of the PC
Access to the BIOS is done through the software interrupt instruction
Int n
For example, the BIOS keyboard services are accessed using the
instruction INT 16h
In addition to BIOS services DOS also provides higher level
functions
INT 21h
More details later

49

Microprocessors

An Intel Pentium II

Heart of a computer Central Processing Unit


Small integrated circuit with many transistors
Programmable
Be able to compute (arithmetic, logic, etc.)
Work with I/O peripherals & memory
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Early history
1969 - 70

Intel 4004, the first microprocessor, 4-bit


Intel 4040, faster then 4004

1971

Intel 8008, a 8-bit version of 4004

1973

Intel 8080, 10 times faster than 8008


(Similar products: Motorola MC6800, Zilog Z80)

1974

MITS Altair 8800, the first microcomputer


programmed with BASIC developed by Bill Gates and Paul Allen

1977

Apple II, the first popular home computer


Intel 8085, the last 8-bit microprocessor

1978

Intel 8086, 16-bit microprocessor, much faster

1979

Intel 8088

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

1980s
1980

Motorola 68000

1981

IBM PC with Intel 8088, running at 4.77 MHz with a 160K floppy
disk drive & MS-DOS 1.0/1.1

1982

Intel 80286

1984

Apple Macintosh, with Motorola 68000

1985

Intel 80386

1987

Macintosh II

1989

Intel 80486 at 25 MHz or higher speed

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

More recently
1990

Microsoft Windows 3.0 released


Motorola 68040 developed

1991

Apple and IBM formed a partnership to investigate RISC

1992

Microsoft Windows 3.1 became the standard for PCs.

1993

Intel Pentium (80586) released, MMX technology provided later

1995

Microsoft Windows 95

1995

Intel Pentium Pro (P6)

1997

Intel Pentium II

1998

Intel Pentium II Xeon

1999

Intel Pentium III

2001

Intel Pentium IV

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Growth of capability: the Intel family


Addressable
Memory
640 Bytes

Clock Speed
(MHz)
0.108

MIPs

4004

No. of
transistors
2,300

8008

3,500

16 KBytes

0.2

0.06

8080

6,000

64 KBytes

2 3.1

0.64 1

8086

29 K

1 MBytes

5 10

0.33 0.75

8088

29 K

1 MBytes

5 10

0.33 0.68

80186

29 K

1 MBytes

8 12

1.2 1.66

80286

134 K

16 MBytes

8 12

1.2 1.66

80386SX

275 K

16 MBytes

16 33

2.5 5

80386DX

275 K

4 GBytes

16 33

6 12

80486DX

3,200 K

4 GBytes

25 100

20 80

Pentium

3,200 K

4 GBytes

60 133

100 200

Pentium Pro

5,500 K

64 GBytes

150 200

~ 250

Pentium II (Klamatch)

7,500 K

64 GBytes

233 500

???

Pentium III (Katmai)

9,500 K

64 GBytes

up to 1,200

???

???

???

???

???

Pentium IV
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

0.06

Other processors
Intel-compatible:
AMD (e.g. K6, k7 series)
Cyrix
IDT

Other general-purpose CPUs:


Motorola 68K series (Apple Macintosh)
IBM PowerPC
DEC Alpha
SunMicros UltraSPARC, MAJC (for Java Computing)

Special-purpose processors
Microcontroller: e.g. Intel 8051,
Digital Signal Processors: e.g. TMS320C series
For handheld products: Intel StrongArm
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Microprocessor-based computer

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Bus, memory & I/O


Bus:

a set of connections
carry the same type of information
binary

Memory: ICs that store programs & data


I/O:

Input/output devices via which the


microprocessor communicates with outside world

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Bit & byte


Information is generated, transmitted and stored in binary format.
Bit is the basic unit of binary information. It takes the value 1 or 0.
In digital computers, a data bit is transmitted via a dedicated electrical
connection and stored in a memory cell.
Byte is a larger unit: 1 byte = 8 bits.
Binary

Decimal (unsigned integer)

1 bit

01

1 byte

0 255

2 bytes

0 65,535

4 bytes

0 4,294,967,295

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Memory & address


Computer memory is organized on per byte basis: data are stored in
groups of 8 bits.
The location of a data byte is represented by an address in the
memory system. Each address points to a 8-bit data.
The address is also a binary number.
Address

Revised on 2001/9/10 1:15 PM

111

10000100

110

01010010

101

10000000

100

00000000

011

11001011

010

11110001

001

01110100

000

11001111

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

Data in memory

10

Address bits & address bus


1-bit address can point to only two memory locations.
8-bit address can index 28 = 256 memory locations.
The number of address bits is referred to as the width of address bus.
Intel 8086/8088 uses 20-bit address bus. Thus the address range is
0000 0000 0000 0000 0000

1111 1111 1111 1111 1111

or in hexadecimal
00000H FFFFFH

The number of memory locations is 220 = 1,048,576


210 = 1,024 = 1 K
230 = 1 K 1 M = 1 G

220 = 1 K 1 K = 1 M

Question: How many address bits are required to fully access the RAM
in your home computer ?
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

11

I/O space
I/O space is organized and addressed in the same way as the memory
space. Each I/O address corresponds to an 8-bit I/O port.
For Intel 8088, 64K (65,536) I/O ports are addressed. This requires only
16 address lines.
For memory space addressing, all 20 address lines are used.
The I/O and memory share the same address bus. A separate control
signal is needed to indicate whether the bus is carrying I/O address or
memory address.

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

12

8088 based microcomputer

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

13

Microprocessor operation
There is little memory inside a microprocessor (
P). This internal
memory is referred as register.
The P has to load data and program from outside into its
internal registers
Both data and program are binary
Program is often stored in the memory
Program is divided into many tiny steps. Each step is performed
by an instruction
Typically an instruction is several bytes long
Data are either loaded from the memory or supplied by the I/O

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

14

Fetch-decode-execution cycle
Fetch

load an instruction from memory


into an internal register

Decode

interpret the fetched instruction

Execution

execute the instruction


e.g. read/write data, arithmetic
computation on loaded data

During the fetch-decode-execution cycle, the P may receive an


interrupt signal via the control bus
Upon the interrupt request, the P will finish the execution of current
instruction and then responds to the interrupt
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

15

Programming the microprocessor


An instruction is a simple command telling the P what to do
Each model of microprocessor has its own instruction set
Intel 8088 has 90 basic instructions.
The P understands binary numbers only. Any instruction is nothing
but a string of 0s and 1s, which is called machine language.
Each instruction may occupy multiple bytes:
Op code

indicating
what to do

Revised on 2001/9/10 1:15 PM

Operand

... ...

Operand

data (or the addresses


where data are stored)

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

16

Machine language
Binary code
1st instruction
2nd instruction

Action

B8 23 01

[Move the value 0123H to AX]

05 25 00

[Add the value 0025H to AX]

8B D8

[Move the content of AX to BX]

03 D8

[Add the content of AX to BX]

8B CB

[Move the content of BX to CX]

2B C8

[Subtract the content of AX from CX]

2B C0

[Subtract the content of AX from AX]

C3

[Return to system]
AX, BX, CX, etc. are the internal
registers in the P.
0123H means hexadecimal value 0123,
i.e. 0000 0001 0010 0011

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

17

Assembly language
Programming directly with machine codes is neither desirable nor
feasible. It is very difficult to debug.
Assembly language is represented by word-like terms that are
much more comprehensible than binary number.
B8 23 01

MOV AX,0123H

[Move the value 0123H to AX]

05 25 00

ADD AX,25H

[Add the value 0025H to AX]

8B D8

MOV BX,AX

[Move the content of AX to BX]

03 D8

ADD BX,AX

[Add the content of AX to BX]

8B CB

MOV CX,BX

[Move the content of BX to CX]

2B C8

SUB CX,AX

[Subtract the content of AX from CX]

2B C0

SUB AX,AX

[Subtract the content of AX from AX]

C3

RET

[Return to system]

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

18

8088/8086 internal architecture


Registers: small, fast
memory that store data or
addresses temporarily.

Execution unit (EU)


Arithmetic
& logic unit
EU register
set

16 bit
data
bus

In a 8086/8088, there are


ten 16-bit EU registers and
another four 16-bit segment
registers.

Bus interface unit (EU)


Segment
registers
Instruction
queue

Revised on 2001/9/10 1:15 PM

Data (16 bit in 8086,


bus 8 bit in 8088)

Bus
control
unit

Address (20 bit)


bus
Control
bus

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

19

Internal registers

8 bit

8 bit

8 bit

16 bit

Flag register

16 bit

Revised on 2001/9/10 1:15 PM

16 bit

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

20

Segment and offset


8086/8088 uses a 20-bit address bus
However, all of its internal registers are 16 bit. How are these registers
used to store the 20 bit address ?
16-bit segment
address

15

20-bit physical
address

15

11

15

11

+)

16-bit offset address

19

11

shift by 4 bit

The offset address can specify up to 216 = 64 KBytes of memory.


The segment address gives the beginning of such a 64 K block.
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

21

Segment and offset (continued)


CS is a segment register, holding the
value A000H.
IP holds the offset address 5F00H.
The physical address is A5F00H

Exercises:
CS = 2300H and IP = 1000H

23000H + 01000H = 24000H

CS = 1A00H and IP = B000H

1A000H + 0B000H = 25000H

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems


Lecture on 10 September 2001

22

Vous aimerez peut-être aussi