The x86
Microprocessors
Introduction
The 80x86 Microprocessors
1.1
Assembly Language
Numbering and Coding Systems
Human beings use the
decimal system (base 10)
Decimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Computer systems use the
binary system (base 2)
Binary digits: 0, 1
Bit (Binary Digit): 0 or 1
The
The
Octal system (base 8) has 8 digits
0, 1, 2, 3, 4, 5, 6, 7
hexadecimal system (base 16) has 16 digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The 80x86 Microprocessors
1.2
Assembly Language
Decimal, Binary, and Hex
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
The 80x86 Microprocessors
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
1.3
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Assembly Language
Example: Convert (35)10 to binary
Dividing the decimal number by 2 repeatedly
Keeping track of the remainders
This process continues until the quotient becomes zero.
The remainders are then written in reverse order to obtain the binary.
Quotient
Remainder
35/2
17
1 (LSB) Beside the binary point
17/2
8/2
4/2
2/2
1/2
1 (MSB)
(100011.0)2
(35)10 = (100011)2
The 80x86 Microprocessors
1.4
Assembly Language
Example: Convert (0.35)10 to binary
0.35*2 =
0.7
0 (MSB)
0.7*2
0.4
0.4*2
0.8
0.8*2
0.6
0.6*2
0.2
0.2*2
0.4
0 (LSB)
Beside the binary point
(0.01011)2
(0.35)10 = (0.010110)2
The 80x86 Microprocessors
1.5
Assembly Language
Converting from Binary to Decimal
There is a weight associated with each digit position
Multiply the weigh of each digit position by the content of position
Sum the weight of all digits
Example: Convert (315)10 from decimal to decimal !!!
3102
1101
5100
3100
110
51
3100 + 110 + 51 = 315
The 80x86 Microprocessors
1.6
Assembly Language
Example: Convert (110101)2 to Decimal
1
125
124
023
122
021
120
132 + 116 + 08 + 14 + 02 + 11
(110101)2 = (53)10
The 80x86 Microprocessors
1.7
Assembly Language
Example: Convert (0.110101)2 to Decimal
1
12-1
12-2
02-3
12-4
02-5
12-6
1/2 + 1/4 + 0/8 + 1/16 + 0/32 + 1/64
(0.110101)2 = (0.828125)10
The 80x86 Microprocessors
1.8
Assembly Language
Converting between Binary and Hex
Converting from binary to hex
Start from the right and group 4 bits at a time
Replace each 4-bit binary number with its hex equivalent
Example: Represent binary 100111110101 in hex
1001
9
1111
F
0101
5
Therefore, (100111110101)2 = (9F5)16 hexadecimal.
Converting from hex to binary
Replace each hex digit with its 4-bit binary equivalent
Example: Convert hex 29B to binary
The 80x86 Microprocessors
2
0010
9
1001
B
1011
After dropping the leading zeros, (29B)16 = (1010011011)10
1.9
Assembly Language
Converting from Decimal to Hex
Converting from decimal to hex could be approached in two ways:
1. Convert to binary first and then convert to hex.
Example: Convert (45)10 to hex
(45)10 = (101101)2 = (0010 1101)2 = (2D)16
2. Convert directly from decimal to hex by the method of repeated division,
keeping track of the remainders.
Example: Convert (45)10 to hex
Quotient
45/16
2/16
Remainder
13 (hex D)
2
(L.S.D)
(M.S.Digit)
(45)10 = (101101)2 = (0010 1101)2 = (2D)16
Example: Convert decimal (629)10 to hexadecimal.
The 80x86 Microprocessors
(629)10 = (0010 0111 0101)2 = (275)16
1.10
Assembly Language
Converting from Hex to Decimal
Conversion from hex to decimal can also be approached in two ways:
1. Convert from hex to binary and then to decimal.
Example: Convert hexadecimal (6B2)16 to decimal.
(6B2)16 = (0110 1011 0010)2 =
(129+128+027+126+025+124+123+022+022+121+020)10 =
(1714)10
2. Convert directly from hex to decimal by summing the weight of all
digits.
Example: Convert hexadecimal (6B2)16 to decimal.
(6B2)16 = (6162+B161+2160)10 = (1714)10
The 80x86 Microprocessors
1.11
Assembly Language
Addition of Binary and Hex numbers
Add the following unsigned binary
numbers
Ci
Carry
Sum
(1010100)2 + (1100100)2 = ?
1010100
1100100
__________
10111000
000100
(84)10 + (100)10 = (184)10
The 80x86 Microprocessors
1.12
Assembly Language
Signed Addition
Add the following signed binary numbers
(01010100)2 + (01100100)2 = ?
01000100
ERROR
01010100
+84
01100100
+100
__________
10111000
-72
2s complement 10111000 of is 01001000 (-72)
The 80x86 Microprocessors
1.13
Assembly Language
Unsigned Subtraction
There is no separate circuitry for subtractors.
Instead, adders are used in conjunction with 2's complement circuitry to
perform subtraction.
To implement "x - y", the computer takes the 2's complement of y and
adds it to x.
Example: Subtract the following unsigned numbers (100 80 = 20)
1100100 1010000 (note that each number has the same number of
digits)
1100100 + 0110000 = 10010100
The result is +ve
+(0010100) 2= +(20)
Example: Subtract the following unsigned numbers (80 - 100 = -20)
1010000 - 1100100
1010000 + 0011100 = 1101100 (Note: no extra digit)
The result is -ve
-(0010100) 2= -(20)
The 80x86 Microprocessors
1.14
Assembly Language
Signed Subtraction
Example: Subtract the following signed numbers (100 80 = 20)
(+100) (+80)
01100100 01010000
01100100 + 10110000 = 100010100 00010100 +20
Any carry out of the sign-bit position is discarded
The negative result is automatically in the 2s complement form
Example: Subtract the following unsigned numbers (80 - 100 = -20)
(+80) (+100)
01010000 - 01100100
01010000 + 10011100 = 11101100 - 00010100 -20
The 80x86 Microprocessors
1.15
Assembly Language
ASCII Code
ASCII: American Standard Code for Information Interchange
The great advantage of this system is that it is used by most computers,
so that information can be shared among computers.
The ASCII code assigns binary patterns for
numbers 0 to 9,
uppercase (capital) letters A to Z
lowercase letters a to z
Another characters { !@$
many control codes
The ASCII system uses a total of 7 bits to represent each code.
Example
100 0001 uppercase letter "A"
110 0001 lowercase letter "a".
Often, a zero is placed in the most significant bit position to make it an 8bit code.
The 80x86 Microprocessors
1.16
Assembly Language
Note That
The pattern of ASCII codes was designed to allow for easy manipulation
of ASCII data.
Digits (0)10 through (9)10 are represented by ASCII codes
30H or (0011 0000)2 through 39H or (0011 1001)2.
This enables a program to easily convert ASCII to decimal by masking off
the "3" in the upper nibble.
There is a relationship between the uppercase and lowercase letters.
Uppercase letters are represented by ASCII codes 41H or (0100 0001)2
through 5AH or (0101 1010)2 while lowercase letters are represented by
ASCII codes 61H or (0110 0001)2 through 7AH or (0111 1010)2.
Looking at the binary code, the only bit that is different between
uppercase "A" and lowercase "a" is bit 5.
Therefore conversion between uppercase and lowercase is as simple as
changing bit 5 of the ASCII code.
The 80x86 Microprocessors
1.17
Assembly Language
Some Important Terminology
Bit: a binary digit that can have the value 0 or 1.
Byte: 8 bits.
Nibble: half a byte or 4 bits.
Word: two bytes, or 16 bits.
Kilobyte: 210 bytes, which is 1024 bytes.
The abbreviation K is often used (356K bytes of data).
Megabyte: 220 bytes, which is a little over 1 million bytes; it is exactly
1,048,576.
Gigabyte: 230 bytes (over 1 billion)
Terabyte: 240 bytes (over 1 trillion).
RAM: random access memory (sometimes called read/write memory)
The data in RAM is lost when the computer is turned off (volatile
memory).
ROM: read-only memory
The information in ROM is permanent, cannot be changed by the
user, and is not lost when the power is turned off (nonvolatile
memory).
The 80x86 Microprocessors
1.18
Assembly Language
Internal Organization of Computers
The internal working of every computer can be broken down into three
parts:
1.
CPU (central processing unit): to execute (process) information stored
in memory.
2.
Memory: to store programs and data
3.
I/O (input/output) devices: to provide a means of communicating with
the CPU.
The CPU is connected to memory and I/O through strips of wire called a
bus. The bus inside a computer carries information from place to place
The 80x86 Microprocessors
1.19
Assembly Language
Computer Buses
Address Bus, Data Bus, and Control Bus.
Address bus,
The number of address buses for a CPU determines the number of locations
with which CPU can communicate.
The number of locations is always equal to 2x, where x is the number of
address lines, regardless of the size of the data bus.
A CPU with 16 address lines can provide a total of 65,536 (2 16) or 64K, bytes
of addressable memory. Each location can have a maximum of 1 byte of data.
Data bus: used to carry information in and out of a CPU,
The more data buses available, the better the CPU.
More data buses mean a more expensive CPU and computer.
The average size of data buses in CPUs varies between 8 and 64.
Data buses are bidirectional, since the CPU must use them either to receive or
to send data.
The processing power of a computer is related to the size of its buses, since an
8-bit bus can send out one byte a time, but a 16-bit bus can send out 2 bytes at
a time, which is twice as fast.
Control bus: used to provide read or write signals to the device to indicate if the
CPU is asking for information or sending it information.
The 80x86 Microprocessors
1.20
Assembly Language
Internal Organization of Computers
For the CPU to process information, the data must be stored in RAM or ROM.
The CPU gets the information to be processed, first from RAM (or ROM).
Only if it is not there does the CPU seek it from a mass storage device such as a
disk, and then it transfers the information to RAM.
For this reason, RAM and ROM are sometimes referred to as primary memory and
disks are called secondary memory.
The 80x86 Microprocessors
1.21
Assembly Language
Internal Block Diagram of a CPU
PC (IP): point to the address of the
next instruction to be executed
CPU
Fetches instructions from memory
Executes fetched instructions
Decoder: interpret the instruction
fetched into the CPU
Arithmetic/logic unit: perform arithmetic
functions such as add, subtract, multiply,
and divide, and logic functions such as
AND, OR, and NOT
The 80x86 Microprocessors
Store information temporarily
1.22
Assembly Language
The x86
Microprocessors
The 80x86 Microprocessors
1.23
Assembly Language
Processor Architecture Impacting Factors
Markets
Processor
Architecture
Applications
Technology
The 80x86 Microprocessors
1.24
Assembly Language
Evolution of Intels Processors
Moores law: The number of transistors per integrated
circuit would double every 18 months
~ 30 years
Pentium 4, 2001
55 Million Transistors
1.5 GHz
4004, 1971
2300 Transistors
108 kHz
The 80x86 Microprocessors
1.25
Assembly Language
Evolution of Intels Processors
Product 4004 8008 8080 8085 8086
8088
80286
80386
80486
Year
1971 1972 1974 1976 1978 1979
1982
1985
1989
1992
1995
MHz
.108 .5-.8
Pentium P. Pro
2-3
3-8 5-10
5-8
6-16
16-33
25-50
60, 66
150
273
387
18
18
40
40
40
40
68
132
168
# Tran K
2.9
4.5
6.5
29
29
130
275
1,200
Memory
4K
16K
64K 64K
1M
1M
16M
4G
4G
4G
64G
Int.
16
16
16
32
32
32
32
Ext.
16
16
32
32
64
64
Add bus
16
16
20
20
24
32
32
32
36
Data type
Data bus
# Pins
The 80x86 Microprocessors
8, 16 8, 16
1.26
8, 16
3,100 5,500
8, 16, 32 8, 16, 32 8, 16, 32
8, 16,
32
Assembly Language
Evolution from 8080/8085 to 8086
In 1978, Intel Corp. introduced a
16-bit microprocessor called the 8086.
8086 was a major improvement over 8080/8085 in several ways:
1.
The 8086's capacity of 1 megabyte of memory exceeded the
8080/8085's capability of handling a maximum of 64K bytes.
2.
The 8080/8085 was an 8-bit system (work on only 8 bits of data at a
time). Data larger than 8 bits had to be broken into 8-bit pieces to be
processed by the CPU.
3.
The 8086 was a pipelined processor, as opposed to the non
pipelined 8080/8085.
The 80x86 Microprocessors
In a system with pipelining, the data and address buses are busy
transferring data while the CPU is processing information, thereby
increasing the effective processing power of the microprocessor.
1.27
Assembly Language
Evolution from 8086 to 8088
The 8086 is a microprocessor with a 16-bit data bus internally and
externally
All registers are 16 bits wide and there is a 16-bit data bus to transfer
data in and out of the CPU.
At that time all peripherals were designed around an 8-bit microprocessor
instead of 16-bit external data bus .
A printed circuit board with a 16-bit data bus was much more expensive.
Therefore, Intel came out with the 8088 version.
8088 is identical to the 8086 as far as programming is concerned, but
externally it has an 8-bit data bus instead of a 16-bit bus.
8088 has the same memory capacity, 1 megabyte.
The 80x86 Microprocessors
1.28
Assembly Language
Other Microprocessors: 80286, 80386, 80486
Intel introduced the 80286 in 1982.
Its features included
16-bit internal and external data buses
24 address lines, which give 16 megabytes of memory (224 = 16
Virtual memory
megabytes); and most significantly,
The 80286 can operate in one of two modes: real mode or
protected mode.
Virtual memory is a way of fooling the microprocessor into thinking
that it has access to an almost unlimited amount of memory by
swapping data between disk storage and RAM.
Real
mode is simply a faster 8088/8086 with the same maximum
of 1 megabyte of memory.
Protected
mode allows for 16M of memory but is also capable
of protecting the operating system and programs from accidental
or deliberate destruction by a user
The 80x86 Microprocessors
1.29
Assembly Language
32-bit Microprocessor
In 1985 Intel introduced the 80386 (sometimes called 80386DX), internally
and externally a 32-bit microprocessor with a 32-bit address bus.
It is capable of handling physical memory of up to
4 gigabytes (232).
Virtual memory was increased to 64 terabytes (246).
Intel introduced numeric data processing chips, called math coprocessors,
such as the 8087, 80287, and 80387.
Later Intel introduced the 386SX, which is internally identical to the 80386
but has a 16-bit external data bus and a 24-bit address bus which gives a
capacity of 16 megabytes (224) of memory.
This makes the 386SX system much
cheaper.
With the introduction of the 486 in 1989, Intel put a greatly enhanced
version of the 386 and the math coprocessor on a single chip plus
additional features such as cache memory.
Cache memory is static RAM with a very fast access time.
The 80x86 Microprocessors
1.30
Assembly Language
Pentium
In 1992 Intel introduced the Pentium.
The Pentium had speeds of 60 and 66 MHz, but new design features
made its processing speed twice that of the 66-MHz 80486.
64-bit data bus, its registers are 32-bit and
it has a 32-bit address bus capable of addressing 4 gigabyes of
Although the Pentium has a
memory.
In 1995 Intel introduced the Pentium Pro, the sixth generation of the x86
family.
Pentium Pro is an enhanced version of the Pentium.
The 80x86 Microprocessors
1.31
Assembly Language
Pipelining
There are two ways to make the CPU process information faster:
1.
Increase the working frequency or
2.
Change the internal architecture of the CPU
The first option is technology dependent, meaning that the designer must
use whatever technology is available at the time, with consideration for
cost.
The technology determines the working frequency, power consumption,
and the number of transistors packed into a single-chip microprocessor.
The second option for improving the processing power of the CPU has to
do with the internal working of the CPU.
In the 8085 microprocessor, the CPU could either fetch or execute at a
given time.
Fetch
The 80x86 Microprocessors
Execute
1.32
Fetch
Execute
Assembly Language
Pipelining (Cont.)
The idea of pipelining in its simplest form is to allow the CPU to fetch and
execute at the same time.
Fetch
Execute
Fetch
Execute
Fetch
Fetch
The 80x86 Microprocessors
2-stage pipeline
Execute
Fetch
Fetch
Non pipelined
Execute
Execute
Decode
Execute
Fetch
Decode
Execute
Fetch
Decode
1.33
3-stage pipeline
Execute
Assembly Language
Pipelining in the 8088/86
Intel implemented the concept of pipelining in the 8088/86 by splitting the
internal structure of the microprocessor into two sections:
the execution unit (EU) and
the bus interface unit (BIU).
These two sections work simultaneously. The BIU accesses memory and
peripherals while the EU executes instructions previously fetched.
This works only if the BIU keeps ahead of the EU; thus the BIU of the
8088/86 has a buffer, or queue.
The buffer is 4 bytes long in the 8088 and 6 bytes in the 8086.
If any instruction takes too long to execute, the queue is filled to its
maximum capacity and the buses will sit idle.
The BIU fetches a new instruction whenever the queue has room for 2
bytes in the 6-byte 8086 queue, and for 1 byte in the 4-byte 8088 queue.
In some circumstances, the microprocessor must flush out the queue.
The 80x86 Microprocessors
1.34
Assembly Language
Internal Block Diagram of the 8088/86 CPU
BUS INTERFACE UNIT (BIU)
EXECUTION UNIT (EU)
address
generation and
bus control
The 80x86 Microprocessors
1.35
Assembly Language
8088/86 Registers
Registers: used to store information temporarily.
Information: data (8/16-bit) to be processed or the address of data.
registers, 16-bit each
14
Six
categories
Category
Bits
Register Names
16
AX (accumulator), BX (base addressing),
CX (counter), DX (point to data in I/O operations)
AH, AL, BH, BL, CH, CL, DH, DL
Pointer
16
SP (stack pointer), BP (base pointer)
Index
16
SI (source index), DI (destination index)
Segment
16
CS (code segment), DS (data segment),
SS (stack segment), ES (extra segment)
Instruction
16
IP (instruction pointer)
Flag
16
FR (flag register)
General
The 80x86 Microprocessors
1.36
Assembly Language
8-bit/16-bit Registers
8-bit registers
16-bit registers
The 80x86 Microprocessors
1.37
Assembly Language