You are on page 1of 31

Lecture no.

18 Microprocessors & Microcontrollers

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

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 MEM
Read

PC=1400 CPU
Inst Decoder B0 decode

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 1

Early history
1969 - 70 1971 1973 1974 1977 1978 1979 Intel 4004, the first microprocessor, 4-bit Intel 4040, faster then 4004 Intel 8008, a 8-bit version of 4004 Intel 8080, 10 times faster than 8008 (Similar products: Motorola MC6800, Zilog Z80) MITS Altair 8800, the first microcomputer programmed with BASIC developed by Bill Gates and Paul Allen Apple II, the first popular home computer Intel 8085, the last 8-bit microprocessor Intel 8086, 16-bit microprocessor, much faster Intel 8088

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

1980s
1980 1981 1982 1984 1985 1987 1989 Motorola 68000 IBM PC with Intel 8088, running at 4.77 MHz with a 160K floppy disk drive & MS-DOS 1.0/1.1 Intel 80286 Apple Macintosh, with Motorola 68000 Intel 80386 Macintosh II 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 1991 1992 1993 1995 1995 1997 1998 1999 2001 Microsoft Windows 3.0 released Motorola 68040 developed Apple and IBM formed a partnership to investigate RISC Microsoft Windows 3.1 became the standard for PCs. Intel Pentium (80586) released, MMX technology provided later Microsoft Windows 95 Intel Pentium Pro (P6) Intel Pentium II Intel Pentium II Xeon Intel Pentium III Intel Pentium IV
ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001 4

Revised on 2001/9/10 1:15 PM

Growth of capability: the Intel family


No. of transistors 2,300 3,500 6,000 29 K 29 K 29 K 134 K 275 K 275 K 3,200 K 3,200 K 5,500 K 7,500 K 9,500 K ??? Addressable Memory 640 Bytes 16 KBytes 64 KBytes 1 MBytes 1 MBytes 1 MBytes 16 MBytes 16 MBytes 4 GBytes 4 GBytes 4 GBytes 64 GBytes 64 GBytes 64 GBytes ??? Clock Speed (MHz) 0.108 0.2 2 3.1 5 10 5 10 8 12 8 12 16 33 16 33 25 100 60 133 150 200 233 500 up to 1,200 ??? MIPs 0.06 0.06 0.64 1 0.33 0.75 0.33 0.68 1.2 1.66 1.2 1.66 2.5 5 6 12 20 80 100 200 ~ 250 ??? ??? ???
5

4004 8008 8080 8086 8088 80186 80286 80386SX 80386DX 80486DX Pentium Pentium Pro Pentium II (Klamatch) Pentium III (Katmai) Pentium IV
Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

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 6

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

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 111 110 101 100 011 010 001 000
Revised on 2001/9/10 1:15 PM

10000100 01010010 10000000 00000000 11001011 11110001 01110100 11001111


10

Data in memory

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

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 Operand ... ... Operand

indicating what to do

data (or the addresses where data are stored)

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

16

Machine language
Binary code 1st instruction 2nd instruction
B8 23 01 05 25 00 8B D8 03 D8 8B CB 2B C8 2B C0 C3

Action
[Move the value 0123H to AX] [Add the value 0025H to AX] [Move the content of AX to BX] [Add the content of AX to BX] [Move the content of BX to CX] [Subtract the content of AX from CX] [Subtract the content of AX from AX] [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 05 25 00 8B D8 03 D8 8B CB 2B C8 2B C0 C3
Revised on 2001/9/10 1:15 PM

MOV AX,0123H ADD AX,25H MOV BX,AX ADD BX,AX MOV CX,BX SUB CX,AX SUB AX,AX RET

[Move the value 0123H to AX] [Add the value 0025H to AX] [Move the content of AX to BX] [Add the content of AX to BX] [Move the content of BX to CX] [Subtract the content of AX from CX] [Subtract the content of AX from AX] [Return to system]

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

18

8088/8086 internal architecture


Execution unit (EU) Arithmetic & logic unit EU register set Bus interface unit (EU) Segment registers Instruction queue
Data (16 bit in 8086, bus 8 bit in 8088) 16 bit data bus

Registers: small, fast memory that store data or addresses temporarily. In a 8086/8088, there are ten 16-bit EU registers and another four 16-bit segment registers.

Bus control unit

Address (20 bit) bus Control bus

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

19

Internal registers

8 bit

8 bit

8 bit

Flag register

16 bit 16 bit

16 bit

Revised on 2001/9/10 1:15 PM

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 16-bit offset address
15 11 7 3 0 shift by 4 bit

15

+)
19 15

11

20-bit physical address

11

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 CS = 1A00H and IP = B000H 23000H + 01000H = 24000H 1A000H + 0B000H = 25000H

Revised on 2001/9/10 1:15 PM

ELE3230A Microprocessor & Computer Systems Lecture on 10 September 2001

22

You might also like