PowerPoint Presentation
SSK3207 – Chapter 9
*
CHAPTER 9
ORGANIZATION OF INTEL PC AND THE INSTRUCTION FORMAT
SSK3207 – Chapter 9
*
Topics
9.1 Introduction
9.2 Organization of Intel Microprocessor
9.3 Instruction Format
9.4 Addressing Mode
SSK3207 – Chapter 9
*
9.1) Introduction
Intel 4004 was the first chip to contain all of the components of a CPU on a single chip (1971 : the first microprocessor )
In 1972, Intel 8008 was introduced and it was the first 8-bit microprocessor.
Both 4004 and 8008 had been designed for specific applications.
In 1974, Intel 8080 was designed to be the CPU of a general-purpose microcomputer.
SSK3207 – Chapter 9
*
Table 9.1, Table 9.2, Table 9.3 and Table 9.4 are the evolution of Intel Microprocessors:
Table 9.1 : 1970s Processors
4004 8008 8080 8086 8088
Introduced 1971 1972 1974 1978 1979
Clock speeds 108 kHz 108 kHz
2 MHz
5 MHz
8 MHz
10 MHz 5 MHz
8 MHz
Bus width 4 bits 8 bits 8 bits 16 bits 8 bits
Num. of transistors 2300 3500 6000 29000 29000
Feature size (m) 10 6 3 6
Addressable memory 640 Bytes 16 KB 64 KB 1 MB 1 MB
SSK3207 – Chapter 9
*
Table 9.2 : 1980s Processors
80286 386TM DX 386TM SX 486TM DX CPU
Introduced 1982 1985 1988 1989
Clock speeds 6 – 12.5 MHz 16 – 33 MHz 16 – 33 MHz 25 – 50 MHz
Bus width 16 bits 32 bits 16 bits 32 bits
Num. of transistors 134000 275000 275000 1.2 million
Feature size (m) 1.5 1 1 0.8 – 1
Addressable memory 16 MB 4 GB 16 MB 4 GB
Virtual memory 1 GB 64 TB 64 TB 64 TB
Cache – – – 8 kB
SSK3207 – Chapter 9
*
Table 8.3 : 1990s Processors
486TM SX Pentium Pentium Pro Pentium II
Introduced 1991 1993 1995 1997
Clock speeds 16 – 33 MHz 60 – 166 MHz 150 – 200 MHz 200 – 300 MHz
Bus width 32 bits 32 bits 64 bits 64 bits
Num. of transistors 1.185 million 3.1 million 5.5 million 7.5 million
Feature size (m) 1 0.8 0.6 0.35
Addressable memory 4 GB 4 GB 64 GB 64 GB
Virtual memory 64 TB 64 TB 64 TB 64 TB
Cache 8 kB 8 kB 512 kB L1 and 1 MB L2 512 kB L2
SSK3207 – Chapter 9
*
Table 8.4 : Recent Processors
Pentium III Pentium 4 Core 2 Duo Core 2 Quad
Introduced 1999 2000 2006 2008
Clock speeds 450 – 660 MHz 1.3 – 1.8 GHz 1.06 – 1.2 GHz 3 GHz
Bus width 64 bits 64 bits 64 bits 64 bits
Num. of transistors 9.5 million 42 million 167 million 820 million
Feature size (nm) 250 180 65 45
Addressable memory 64 GB 64 GB 64 GB 64 GB
Virtual memory 64 TB 64 TB 64 TB 64 TB
Cache 512 kB L2 256 kB L2 2 MB L2 6 MB L2
SSK3207 – Chapter 9
*
9.2) The Organization of Intel Microprocessors
Figure 9.1 below is a block diagram of Intel 8086. The registers are divided into three categories:
General Purpose Registers
Address Registers
Segment register
Pointer Register
Index Register
Status or Flag register
SSK3207 – Chapter 9
*
Figure 9.1: Block Diagram of Intel 8086
AH AL
BH BL
CH CL
DH DL
SP
BP
SI
DI
AX
CX
DX
BX
EU : Execution Unit
BIU : Bus Interface Unit
CS
Program Control
DS
SS
ES
ALU
CU
Flag register
1
2
3
Bus Control Unit
4
n
Bus
Instruction Pointer
Instruction Queue
(Program Counter)
SSK3207 – Chapter 9
*
Segment And Addressing
Segment is a special area in a memory that is defined in a program
The segment position in a memory is not fixed and can be determined by the programmer
3 main segments for the programming process are:
Code Segment
Data Segment
Stack Segment
SSK3207 – Chapter 9
*
Address
Address
Address
Stack segment
Data segment
Code segment
Contains the starting address of each segment
Segment registers
(in the CPU)
memory
(MM)
SS Register
DS Register
CS Register
SSK3207 – Chapter 9
*
Code Segment (CS)
Contains the machine instructions/codes that are going to be executed in a CPU.
Typically, the first executable instruction is at the beginning of this segment, and the operating system links to that location to begin program execution.
CS register (in a CPU) will hold the starting address of the Code Segment.
Data Segment (DS)
Contains a program’s defined data, constants and works areas.
SSK3207 – Chapter 9
*
DS register will hold the starting address of the Data Segment.
Stack Segmen (SS)
Contains any data or address that the program needs to save temporarily.
SS register will hold the starting address of the Stack Segment.
SSK3207 – Chapter 9
*
Segment Offsets
All memory locations within a segment are relative to the segment’s starting address.
The distance in bytes from the first location of the segment to another location within the segment is expressed as an offset.
Thus the first location of the code segment is at offset 00, the second location is at offset 01 and so forth.
In Intel series, the location is in term of byte.
SSK3207 – Chapter 9
*
To refer any memory location in a segment, the processor combines the value in a segment register with the offset value of that location.
Eg:
A starting address of data segment is 038E0H, so the value in DS register is 038E0H.
An instruction refers a location with an offset of 0032H bytes from the start of the data segment.
the actual address is:
= [DS register] + offset
= 38E0H + 0032H = 3912H
SSK3207 – Chapter 9
*
Intel CPU Registers
General Purpose Registers
There are four 16-bit general purpose registers that can be accessed separately the high and low bytes of the registers.
AX register (Accumulator register)
is the preferred register to use in arithmetic, logic, and data transfer instruction because its generates the shortest machine code.
in multiplication and division operations, one of the numbers involved must be in AX or AL.
SSK3207 – Chapter 9
*
I/O operations also require the use of AX and AL.
BX register (Base register)
beside used for computation, it also serves as an address register. An example is a table look-up instruction .
AX
EAX
AX
EAX
AH AL
BH BL
SSK3207 – Chapter 9
*
CX register (Count register)
serves as a loop counter (CX) and also as a count in instructions that shift and rotate bits.
Also as a data register in arithmetic operations.
DX register (Data register)
uses in multiplication and division and also I/O operations.
also as a data register in an arithmetic operations
CX
ECX
DX
EDX
CH CL
DH DL
*
SSK3207 – Chapter 9
*
Address Registers
Segment Registers
There are 6 segment registers:
i) Code Segment (CS) register
Contains the starting address of a code segment.
The content of CS register will be added to the content in Instruction Pointer (IP) register to obtain the address of an instruction (in the MM) that are going to be fetched by the CPU.
SSK3207 – Chapter 9
*
ii) Data Segment (DS) register
Contains the starting address of a data segment.
The content of DS register will be added to the value in the address field of an instruction format to obtain the real address of the data in a data segment.
Stack Segment (SS) register
Contains the starting address of a stack segment.
SSK3207 – Chapter 9
*
The content of SS register will be added to the content in the Stack Pointer (SP) register to obtain the required word.
iv) Extra Segment (ES) register
Used by some string (character data) operations to handle memory addressing
ES register is associated Data Index (DI) register.
v) FS and GS Registers
Additional extra segment registers introduced in 80386 to handling storage requirement.
SSK3207 – Chapter 9
*
Pointer Registers
i) Instruction Pointer (IP) register
contains the offset address of the next instruction that will be fetched and executed by the CPU
The content of the IP register will be added to the content of the CS register to obtain the real address of an instruction.
ii) Stack Pointer (SP) register
is used in conjunction with SS register for accessing the stack segment.
SSK3207 – Chapter 9
*
iii) Base Pointer (BP) register
is used primarily to access data on the stack.
unlike SP, BP can also be used to access data in the other segments.
Index Register
i) Source Index (SI) register
is used to point the memory locations in the data segment addressed by DS.
by incrementing the content of SI, consecutive memory location can easily be accessed
SSK3207 – Chapter 9
*
ii) Destination Index (DI) register
perform the same function as SI register.
used in string operations to access memory locations addressed by ES.
Status of Flags register
the purpose is to indicate the status of the microprocessor by setting the individual bits of the register.
two kinds of flags: status flags and control flags
SSK3207 – Chapter 9
*
i) The Status Flags
reflect the result of an instruction executed by the processor.
example when a subtraction operation result is a 0, the ZF (zero flag) is set to 1 (true).
ii) The Control Flags
enable or disable certain operations of the processor.
example if the IF (interrupt flag) is cleared (set to 0), inputs from the keyboard are ignored by the processor.
SSK3207 – Chapter 9
*
9.3) Instruction Format
The operation of the CPU is determined by the instructions it executes (machine or computer instructions).
CPU’s instruction set – the collection of different instructions that CPU can execute.
SSK3207 – Chapter 9
*
Each instruction must contain the information required by the CPU for the execution as listed below:
Operation code – opcode
Source operand reference
Result operand reference
Next instruction reference
Instruction Format
SSK3207 – Chapter 9
*
Operands (source & result) can be in one of the 3 areas:-
Main or Virtual Memory
CPU register
I/O device
It is not efficient to put all the information required by CPU in a machine instruction
Each instruction is represented by sequence of bits and is divided into 2 fields; opcode & address
opcode address
SSK3207 – Chapter 9
*
Processing become faster if all information required by the CPU are within one instruction or one instruction format
Problems instruction become long (takes a few words in a main memory to store one single instruction)
Solution provide a few instruction formats;
1-address instruction
2-address instruction
3-address instruction
SSK3207 – Chapter 9
*
Opcodes or operation codes are represented by abbreviations, called mnemonics, that indicate the operation. Common examples:
ADD Add
SUB Subtract
DIV Divide
MUL Multiply
LOAD Load data from memory
STOR Store data to memory
SSK3207 – Chapter 9
*
3-address Instruction
Example :
SUB Y A B Y = A – B
Opcode: SUB
Result: Y
Operand 1: A
Operand 2: B
Address for Next instruction: in a special register that called program counter (PC)
Opcode address for Result address for Operand 1 address for Operand 2
SSK3207 – Chapter 9
*
2-address Instruction
Example :
SUB Y B Y = Y – B
Opcode: SUB
Operand 1: Y
Operand 2: B
Result: replace operand 1, Y
Next instruction: in a special register that called program counter (PC)
opcode address for Operand 1 & Result address for Operand 2
SSK3207 – Chapter 9
*
1-address Instruction
Example :
LOAD A
SUB B AC = AC – B
Opcode: SUB
Operand 1: in a special register called accumulator (AC)
Operand 2: B
Result: replace operand 1, AC
Next instruction: in a special register called program counter (PC)
opcode address for Operand 2
SSK3207 – Chapter 9
*
What is the maximum number of addresses one might need in an instruction?
Example: Write a program using 1, 2 and 3-address instruction to compute:
Note: Do not alter the value of any of the operand locations.
Y = (A-B) / (C+D x E)
SSK3207 – Chapter 9
*
Y = (A-B) / (C+D x E)
Instruction
SUB Y, A, B
MPY T, D, E
ADD T, T, C
DIV Y, Y, T
Comment
Y A – B
T D x E
T T + C
Y Y / T
3-address Instruction
SSK3207 – Chapter 9
*
Y = (A-B) / (C+D x E)
MOVE Y, A
SUB Y, B
MOVE T, D
MPY T, E
ADD T, C
DIV Y, T
Instructions
Comment:
Y A
Y Y – B
T D
T T * E
T T + C
Y Y / T
2-address Instruction
SSK3207 – Chapter 9
*
Y = (A-B) / (C+D x E)
Instructions
LOAD D
MPY E
ADD C
STOR Y
LOAD A
SUB B
DIV Y
STOR Y
Comment
AC D
AC AC x E
AC AC + C
Y AC
AC A
AC AC – B
AC AC / Y
Y AC
1-address Instruction
SSK3207 – Chapter 9
*
Utilization of Instruction Addresses (Nonbranching Instructions)
** Zero-address instructions are applicable to a special memory organisation,
called a stack.
SSK3207 – Chapter 9
*
The number of addresses per instruction is a basic design decisions
Fewer addresses per instruction result in more primitive instructions, require less complex CPU, also shorter length of instructions.
On the other hand, programs contain more total instructions, which in general results in longer execution times and longer, more complex programs.
SSK3207 – Chapter 9
*
An important threshold between one address and multiple address instructions is for one address instructions: the programmer generally has available only one general purpose register, the accumulator but for multiple address instructions, it is common to have multiple general purpose registers
SSK3207 – Chapter 9
*
Design trade offs involved in choosing the number of addresses per instruction are complicated by other factors
Issue of whether an address references a memory location or a register
A machine may offer a variety of addressing modes and the specification of mode takes one or more bits
The result is that most CPU designs involve a variety of instruction formats
SSK3207 – Chapter 9
*
9.4) Addressing Mode
Address field address for operand & result
number of bit required to store data (operand & result)
Eg: Field size = 4 bit
operand value = 4 bit value
(00002 11112)
operand address = 24 =16 address space.
How is the address of an operand specified?
SSK3207 – Chapter 9
*
Addressing Mode (Cont.)
Addressing mode – refer to the mode of address field in an instruction format
The most common addressing modes are:
Immediate
Direct
Indirect
Register
Register Indirect
Displacement
Stack
SSK3207 – Chapter 9
*
Immediate Addressing Mode
Address field the data or operand value
Eg: ADD 20
Operand value = 20
add 20 to contents of accumulator (AC)
AC AC + 20
Assume that the initial value in AC = 10.
AC AC + 20
AC 10 + 20 = 30
Instruction
Address field contain the real data or operand value
opcode address
SSK3207 – Chapter 9
*
Advantages:
No memory reference to fetch data
Fast
Disadvantage:
Limited operand magnitude because the size of the number is restricted to the size of the address field (small compared with the word length.)
SSK3207 – Chapter 9
*
Address field address of operand in memory
Eg. ADD A
Look in memory at location with an address A for operand value
Add contents of word A to AC and store the result back to AC
AC = AC + M(A)
Direct Addressing Mode
SSK3207 – Chapter 9
*
Disadvantage:
Limited address space (the length of address field is less than the word length)
A
Advantages:
One memory reference to access data
No additional calculations to work out to get an effective address
A
Opcode
Instruction
Memory
Operand value
SSK3207 – Chapter 9
*
Address field address of a memory word that contain the actual address of an operand.
Eg. ADD A
Look in memory at location or word with address A. The actual address of an operand is in this word. (assume that the value in word A = B)
Add contents of word B to AC and store the result back to AC
AC = AC + M(M(A))
= AC + M(B)
Indirect Addressing Mode
SSK3207 – Chapter 9
*
Advantage:
Bigger address space (compare with direct addressing mode)
Disadvantage:
Multiple memory accesses to find operand
(hence slower access time)
A
B
A
Opcode
Instruction
Memory
Operand
Point to operand (B)
SSK3207 – Chapter 9
*
Register Direct Addressing Mode
the operand is held in a register named in address field
Advantages:
Small address field is needed
No memory references are required
Fast execution
Disadvantage:
Very limited address space
opcode Register address
SSK3207 – Chapter 9
*
R
Eg.: ADD R
The operand value is in a register
Add contents of register R to AC and store the result back to AC
AC = AC + (R)
Register Address R
Opcode
Instruction
Registers
Operand value
SSK3207 – Chapter 9
*
Register Indirect Addressing Mode
R
B
Register Address R
Opcode
Instruction
Memory
Operand value
Pointer to Operand (B)
Registers
SSK3207 – Chapter 9
*
Is analogous to indirect addressing
Address field refers to a register
Operand value is in a memory word or location pointed by a content of a register
Advantage:
Bigger address space (same as indirect addressing)
Disadvantages:
Multiple memory accesses to find operand, hence slower access time (but faster than indirect addressing)
SSK3207 – Chapter 9
*
Displacement Addressing Mode____
Combines the capabilities of direct addressing & register indirect addressing
Known by a variety of names depending on the context of its use
Requires that the instruction has two address fields
Address field hold two values
A = base value
R = register that holds displacement
or vice versa
Effective address = A + (R)
*
15
SSK3207 – Chapter 9
*
Register R
Opcode
Instruction
Memory
Operand
Pointer to Operand
Registers
Address A
+
SSK3207 – Chapter 9
*
Displacement Addressing ( Continue)
Common uses of displacement addressing:
Relative Addressing
R = Program counter, PC
EA = A + (PC)
i.e. get operand from A cells from current location pointed to by PC
Base-Register Addressing
A holds displacement
R holds pointer to base address
R may be explicit or implicit
e.g. segment registers in 80×86
Indexed Addressing
A = base
R = displacement
EA = A + R
Good for accessing arrays
EA = A + R
R++
*
17
SSK3207 – Chapter 9
*
Displacement Addressing
Relative Addressing
Base-Register Addressing
Indexed Addressing
Address A
Opcode
Instruction
Memory
Operand
PC
Program Counter
+
Address A
Opcode
Instruction
Memory
Operand
Base Register
Registers
+
Address A
Opcode
Instruction
Memory
Operand
Index Register
+
SSK3207 – Chapter 9
*
Stack Addressing Mode
Operand is (implicitly) on top of stack
e.g.
ADD Pop top two items from stack and add
Operand
Opcode
Instruction
Top of stack
Top of stack register
implicit
*
21
*
SSK3207 – Chapter 9