Lecture 1
Lecture 1
Microprocessor system
Elements of a Microprocessor system
CPU
• Central processing unit. This performs the
Registers RAM | ROM
arithmetic and logical operations, such as
program data
add/subtract, multiply/divide, binary storage storage
manipulation, and so on.
• Memory. This holds both the program Control, data, address bus
Control
unit input
output
unit unit
Microprocessor system
Elements of a Microprocessor system
CPU
• Input device. This is used to read data into
Registers RAM | ROM
the memory. Example input devices are
program data
keyboards, disk storage, etc). The input storage storage
device loads both program instructions and
data into memory.
Control, data, address bus
program data
storage storage
Control
unit
output input
unit unit
System buses : ( Transfers data between components inside the computer or between computers )
Address bus (carry address)
Data bus (carry data)
Control bus (control & coordination)
Microprocessor system
Elements of a Microprocessor system
CPU
Registers
Address Bus
RAM | ROM
program data
storage storage
Data Bus
CPU
program data
The Data Bus carries the data which is storage storage
Control Bus
CPU
program data
Control
Example unit
output input
RD: (read signal) read data into MPU unit unit
WR: (write signal) write data from MPU
Classification of Microprocessor Systems
• Small embedded systems
– small processing elements, which have minimal input and output,
and have a simple program which runs on the processor.
– have their own local permanent memory
– do not require an operating system, and the code runs directly
on the processing element.
• Desktop systems
– general-purpose computers, which can be installed with any type
of operating system, and any user program which can be supported
on the installed operating system
– can have a large range of hardware and software installed on them
Classification of Microprocessor Systems (cont.)
• Server systems
– have a definite purpose of running server programs for client computers.
– robust, and have large amounts of memory to run many consecutive
connections
– may also have several different storage sources, which allow for one or more
to fail, without a loss of data
– not as reliable as embedded systems, as they support a wide range of
hardware and software, but these tend to be more robust than the types used
in a desktop system
• Supercomputers
– extremely fast computers, with an optimized architecture.
– have multiple processors, with a fast communications channel between them
– have a base performance speed which is at least 10 times as great as a top-of-
the-range desktop computer
Classification of Microprocessor Systems (cont.)
• Control systems
– support the interfacing of many devices, with some form of
control program
– as this control must be achieved within given time limits, there
must be a robust and powerful operating system to support fast
response speeds
– must be able to prioritize signals, as the safety critical control
should have a higher priority over optimization controls
Internal Architecture of a Generic Microprocessor
Internal Architecture of a Generic Microprocessor
• Accumulator General
Registers
• Clock signals
Program Counter
registers N
ALU
• Memory address register (MAR) RESET
Control Unit
Clock
• Status registers (SR)
General
Arithmetic logic unit (ALU): Registers
accumulator Instruction
General
computer Registers
of the program
Internal Data Bus
Keeps track of the memory
location
Instruction
Control Unit
serious error can result Clock
Stack Pointer
program
Memory address register (MAR): Internal Data Bus
Holds the address of the next
instruction Instruction
program Status
C
Z
SR must be either 0 or 1
IOR# IOW# MEMR# MEMW# INTR INTA# MPU
How the CPU Executes Program Instructions
Before execute an instruction, program instructions and data must be
placed into memory from input device or secondary memory
The first two steps make up what is called the instruction time, or fetch cycle
The last two steps make up what is called the execution time, or execution cycle.
The combination of the fetch cycle and execution cycle is called a machine cycle
Each type of central processing unit is designed to understand a specific group of
instructions called the instruction set
Instruction Fetch
Addr generation
Bus Controller
BIU
AH AL
BH BL ADD
CH CL 1
DH DL
EU BP
2
Instruction
3
CS Queue
DI 4
ES
SI 5
SS
SP 6
DS
IP
ALU
FLAGS
Registers
memory hierarchy A
H
A
L
ADD
B B
your system B
P
D
I
C
S
E
3
4
Instruction
Queue
S S 5
• Purposes
I S
S S
6
P D
S
I
operations
Internal Data Bus
Special Registers
Instr Pointer IP
EIP
Flags FLAG
EFLAG
General Purpose Registers
General Purpose
• Accumulator (AH,AL,AX,EAX)
– Accumulates results from mathematical calculations AH AL
Accumulator
• Base (BH,BL,BX,EBX) AX
EAX
– Points to memory locations
BH BL
• Count (CL,CH,CX,ECX) Base
BX
– Counter used typically for loops EBX
• SP, ESP
– Stack pointer Index Registers
• BP, EBP
– Address stack memory, used to access Stack Pointer SP
subroutine arguments ESP
• Base Pointer BP
SI, ESI, DI, EDI
EBP
– Source/Destination registers
Dest Index DI
– Point to the starting address of a
EDI
string/array
Source Index SI
– Used to manipulate strings and similar
ESI
data types
Segment Registers
• CS
– Points to the memory area where your
program’s instructions are stored
Segment Registers
• DS
– Points to the memory area where your CS Code Segment
program’s data is stored
DS Data Segment
• SS ES Extra Segment
– Points to the memory area where your
SS Stack Segment
stack is stored
FS
• ES,FS,GS
GS
– They can be used to point to
additional data segments, if
necessary
Special Registers
• IP, EIP
– Instruction pointer, points
Special Registers
always to the next instruction
that the processor is going to Instr Pointer IP
execute EIP
• FLAG, EFLAG Flags FLAG
– Flags register, contains
EFLAG
individual bits set by different
operations (e.g. carry, overflow,
zero)
– Used massively with branch
instructions
The Flags
• RFLAGS indicate the condition of the microprocessor and control its operation.
• The Figure shows the flag registers of all versions of the microprocessor.
• Flags are upward-compatible from the 8086/8088 through Core2 .
• The rightmost five and the overflow flag are changed by most arithmetic and logic
operations.
– although data transfers do not affect them
• Flags never change for any data transfer or program control operation.
• Some of the flags are also used to control features found in the microprocessor.
The Flags
0x12340
+ 0x06789 x 16 +
----------------
0x18AC9
20-bit bus-address
Physical address: 0x18AC9
(11MB)
MB
20-bit (5-byte) 64 KB +
Physical Segment 16-bit each
Memory address
BX, DI, SI, 8-bit or 16-bit # EBX, EDI, ESI, EAX ECX, Data
DS EDX, 8-bit or 32-bit #
DI, with string instructions EDI, with string instructions String
ES destination
Stack
Disadvantages:
• Complex hardware and for address generation
• Address computation delay for every memory access
• Software limitation: Program size limited by segment size
(64KB with the 8086)
Limitations of the above real mode segmentation scheme
80286 and above use 24, 32 bit addresses but still 16-bit segment registers
• No protection mechanisms: Programs can overwrite operating system code
segments and corrupt them!