Microprosessors نظري 2022
Microprosessors نظري 2022
Microprosessors نظري 2022
املعاجلات املايكروية
Microprocessors
د .محيد عبد الكريم يونس م.م .عبد الكريم حسني عبد الكريم
كلية علوم احلاسوب وتكهولوجيا املعلومات/جامعة البصرة
قسم علوم احلاسوب
Syllabus:
1. History of Microprocessor.
2. Input/Output.
3. Central Processing Unit (CPU).
4. Buses
- Address Bus.
- Data Bus.
- Control Bus.
5. Hardware, Software and Firmware.
6. Intel 8086 (40 pins).
7. Architecture of the 8086 Processor Model.
8. Queue.
9. Read (Word, Byte, Address).
10. Register Organization of 8086.
11. The Fetch and Execute Cycle.
12. Memory Types.
- RAM (SRAM (Cache), DRAM).
- ROM.
- PROM.
- EPROM.
- EEPROM.
13. Generating a Memory Address.
14. The Stack (Push, Pop algorithm).
15. Addressing Modes of The 8088/8086.
- Register Addressing Mode.
- Immediate Addressing Mode.
- Direct Addressing Mode.
1
- Register Indirect Addressing Mode.
- Based Addressing Mode.
- Index Addressing Mode.
- Based Index Addressing Mode.
Reference:
1. Peter Abel, "IBM PC Assembly Language and Programming", 4th Edition,
Principle Hall, USA, 1998.
2. M. Rafiquzzaman & R. Chandra, "Modern Computer Architecture",
West Publishing Company, USA, 1988.
2
Microprocessors Introduction
Microprocessor
A microprocessor is an electronic device which computes on the given input
similar to CPU of a computer. It is made by fabricating millions (or billions)
of transistors on a single chip.
History of Microprocessor
Microprocessor journey started with a 4-bit processor called 4004; it was
made by Intel Corporation in 1971. It was 1st single chip processor. Then the
idea was extended to 8-bit processors like 8008, 8080 and then 8085 (all are
Intel products). 8085 was a very successful one among the 8-bit processors;
however its application is very limited because of its slower computing speed
and other quality factors. Some years later Intel came up with its 1st 16-bit
processors 8086. Using this the first portable calculator is designed. The
following Table 1 shows the list of Intel microprocessors.
Table 1
Year Name Bit Size (bit)
1971 4004 4
1972 8008 8
1974 8080 8
1977 8085 8
1978 8086 16
1979 8089 16
1982 80286 32
1985 80386 32
1989 80486 32
1993 80586(Pentium) 32
1995 Pentium Pro 32
3
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
1997 Pentium II 32
1999 Celeron and Pentium III 32
2000 Pentium IV 32
2001 Titanium 64
2003 Pentium M processor 64
2005 Pentium IV and Xeon 64
2006 Pentium D 900 64
Table 2
Company Name Processor Name
AMD Athlon
Cypress CY7C601
DEC ALPHA
Fujitsu MBL8086
Harris CS80C286
LSI Logic LR 30000
National Semiconductor NS321016N
SGS-Thomson ST6X86
SUN-Micro SRP1030
Texas Instruments TMS390
Toshiba TC85R4000
Zilog Z80
Motorola 68000
4
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
5
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
6
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
indicates the size of the data bus which carried data between the CPU and
memory and between the CPU and I/O device.
Word 0
Word 1
Word I
Word m-1
N bits
* Important Note
- Each digit in a binary number is called a BIT, 4 bits form a NIBBLE, 8
bits form a BYTE, two bytes form a WORD, two words form a DOUBLE
WORD (rarely used):
7
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
- Byte = 8 bits.
- Nibble= 4 bits.
10 10 20
- Mega Byte (MB) = 1024 KB = 2 ^ .2 ^ Bytes = 2 ^ bytes
=1,048,576 bytes.
10 20 30
- Gega Byte (GB) = 1024 MB = 2 ^ .2 ^ bytes = 2 ^ byte
=1,073,741,824 bytes.
- Tera Byte (TB) = 1024 GB = 2040 bytes.
- Memory Word Length or (memory location length) : it term use to refer to
the number of bits in one memory location .
Table 3
Max
Address
Processor Addressable In English!
Bus Size
Memory
8088 20 1,048,576 One Megabyte
8086 20 1,048,576 One Megabyte
80188 20 1,048,576 One Megabyte
80186 20 1,048,576 One Megabyte
8
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
Sixteen
80286 24 16,777,216
Megabytes
Sixteen
80386sx 24 16,777,216
Megabytes
80386dx 32 4,294,976,296 Four Gigabytes
80486 32 4,294,976,296 Four Gigabytes
80586 /
Pentium 32 4,294,976,296 Four Gigabytes
(Pro)
9
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
general purpose register, which are used for temporary storage or binary data
and circuitry, which generates the control bus signals.
Address bus: The address bus consists of 16, 20, 24 or 32 parallel lines. On
these lines the CPU sends out the address of the memory locations that are to
be written to or read from.
Data bus: It consists of 8, 16, 32 parallel signal lines. The data bus lines are
bidirectional. This means that the CPU can read, data from memory or from a
port on these lines, or it can send data out to memory or to port on these lines.
Control bus: The control bus consists of 4 to 10 parallel signals lines. The
CPU sends out signals on the control bus enable the outputs of addressed
memory devices or port devices. Typical control bus signal are memory read,
memory write, I/O read and I/O write.
Intel 8086
The 8086 is a 16-bit microprocessor chip designed by Intel corporation in
between early 1976 and mid-1978. The release of Intel's 8086 microprocessor
in 1978 was a watershed moment for personal computing.
10
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
11
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
Architecture
The internal architecture 8086 microprocessor is as shown in the Figure 2.
The 8086CPU is divided into two independent functional parts, the Bus
Interface Unit (BIU) and Execution Unit (EU).The Bus Interface Unit
contains Bus Interface Logic, Segment registers, Memory addressing logic
and a Six byte instruction object code queue. The execution unit contains the
Data and Address registers, the Arithmetic and Logic Unit, the Control Unit
and flags.
12
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
13
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
The BIU sends out address, fetches the instructions from memory, read data
from ports and memory, and writes the data to ports and memory. In other
words the BIU handles all transfers of data and addresses on the buses for the
execution unit.
The execution unit (EU) of the 8086 tells the BIU where to fetch
instructions or data from, decodes instructions and executes instruction. The
EU contains control circuitry which directs internal operations. A decoder in
the EU translates instructions fetched from memory into a series of actions
which the EU carries out. The EU is has a 16-bit ALU which can add,
subtract, AND, OR, XOR, increment, decrement, complement or shift binary
numbers. The EU is decoding an instruction or executing an instruction which
does not require use of the buses.
The Queue: The BIU fetches up to 6 instruction bytes for the following
instructions. The BIU stores these pre-fetched bytes in first-in-first-out
register set called a queue. When the EU is ready for its next instruction it
simply reads the instruction byte(s) for the instruction from the queue in the
BIU. This is much faster than sending out an address to the system memory
and waiting for memory to send back the next instruction byte or bytes.
Except in the case of JMP and CALL instructions, where the queue must be
dumped and then reloaded starting from a new address, this prefetch-and-
queue scheme greatly speeds up processing. Fetching the next instruction
while the current instruction executes is called pipelining.
Word Read
Each of 1 MB memory address of 8086 represents a byte wide location.16-
bit words will be stored in two consecutive memory locations.
14
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
*DX
15
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
Each of these 16-bit registers are further subdivided into two 8-bit registers.
Segment Registers
To complete 1Mbyte memory is divided into 16 logical segments. The
complete 1Mbyte memory segmentation is as shown in fig 5. Each segment
contains 64Kbyte of memory. There are four segment registers.
17
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
in the data segment. DS register can be changed directly using POP and LDS
instructions. It points to the data segment memory where the data is resided.
18
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
Flags Register determines the current state of the processor. They are
modified automatically by CPU after mathematical operations, this allows to
determine the type of the result, and to determine conditions to transfer
control to other parts of the program.
The 8086 flag register as shown in the Figure 5. 8086 has 9 active flags and
they are
divided into two categories:
1. Conditional Flags
2. Control Flags
Conditional Flags
Conditional flags are as follows:
Carry Flag (CF): This flag indicates an overflow condition for unsigned
integer arithmetic. It is also used in multiple-precision arithmetic.
Auxiliary Flag (AF): If an operation performed in ALU generates a
carry/barrow from lower nibble (i.e., D0 – D3) to upper nibble (i.e., D4 – D7),
the AC flag is set i.e., carry given by D3 bit to D4 is AF flag. This is not a
general-purpose flag, it is used internally by the Processor to perform Binary
to BCD conversion.
Parity Flag (PF): This flag is used to indicate the parity of result. If lower
order 8-bits of the result contains even number of 1’s, the Parity Flag is set
and for odd number of 1’s, the Parity flag is reset.
Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero
else it is reset.
Sign Flag (SF): In sign magnitude format the sign of number is indicated by
MSB bit. If the result of operation is negative, sign flag is set.
20
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
Start
Halt
21
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
22
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Introduction
23
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
MEMORY TYPES
Random Access Memory (RAM)
The short-term memory. Data and programs are stored temporarily, while
the CPU processes the data according to program's instructions, once the
program has completes its task, the newly processed data can be stored in the
computer's long-term-memory such as a hard disk. The RAM can be used for
another processing task. RAM is what we have allows the computer to store
information quickly for latter reference, so that RAM holds
RAM is a volatile even a short interruption in the computers power supply
erase RAM. When a program instruction read the data its gets a copy of the
data? This is called a nondestructive read because the content of the memory
address are not changed. Sending data to a RAM memory address is called a
destructive write because the new data erases whatever was there before
RAM can be divided as:
• Static RAM (SRAM)
Semiconductor memory devices in which the stored data will remain
permanently stored as long as power is supplied, without the need for
periodically rewriting the data into memory. Example of SRAM cache
memory.
• Dynamic RAM (DRAM)
Semiconductor memory devices in which the stored data will NOT remain
permanently stored, even with power applied, unless the data are periodically
rewriting the data into memory. The later operation is called a refresh
operation. Example of DRAM.
Read-Only Memory (ROM)
As the name suggests can only be read, it cannot be written to under
normal circumstance. The contents of ROM remain intact even after the
24
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
Main
memory CPU
32k×8
Cache
memory
512×8
25
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
26
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
Logical Addresses: In the 8088 / 8086 CPU, the address of any memory
location can be written in the form (segment : offset), so
the address divided into two parts :
Segment address: which held in the segment registers and have 16- bit
length.
Offset: which represent the distance the location which we want to reach
from the beginning of the segment. The length of the offset 16 –
bit also. And the value of the offset store in one of the pointer
register, therefore, it will be clear that the length of one segment
not more than 64KB.
Segment ( CS , DS , SS , ES )
Offset ( IP , SI , DI , SP ,BP )
27
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
002B1H
002B3H
002B4H
Logical 13H= Offset
002B5H
Address
002B6H
002C3H
Physical address
Ex.1: find the physical address if you have offset = 50h and segment
address=3572h.
= 35720h + 50h
28
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
Another solution:
(3 5 7 7 0)h
Ex.2: Find P.A. if segment address = 123416 and offset address = 002216?
THE STACK
It is 64 KB of memory organized as word, used to store important
register's contents, that return address while call instruction address is
executed.
The principle of the Stack operation is Least-In-First-Out (LIFO)
29
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
i.e., the last stored value is the first one returned from the stack. The stack
operated by limited number of instruction such as: PUSH, POP, CALL, and
RET.
LOW HIGH
46KB . .
. .
. .
P.A. stack = SS + SP
PUSH Algorithm
1. Sp Sp - 2
2. [Sp] register (the content of source register is stored in the stack)
30
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
PUSH AX
CALL Algorithm
1. Sp Sp – 2
2. [Sp] IP
3. IP the address of subroutine.
1. register [Sp] (the content of stack [word] is returned from the stack
into the destination register)
2. Sp SP + 2
POP CX
RET Algorithm
1. IP [Sp]
2. Sp SP + 2
RET
31
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprocessors Memory
* Any number of stack may exist in an 8088 microcomputer. A new stack can
be brought changing the value in the SS register.
* Only one stack is active at a time.
* The 8088 pushes data and address to the stack one word at a time.
Ex:
PUSH AX ; where AX=1234 , SS= 0105 , SP= 0006
AX 12 34
Befor After
e after
1056 XX YY SP 1056 XX Y
1054 1054 34 12 SP
AX 12 34
Before After
after
1056 XX YY 1056 XX YY SP
1054 34 12 SP 1054
32
Abdulkareem Hussien Abdulkareem & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprosessors Addressing Modes
Addressing Modes
The manner in which a processor determines the addresses of the operands
involved in that instruction is called addressing mode.
There are many modes for addressing the operands, these modes will
discuss briefly:-
1. Implied Mode: In this mode, the operands are specified implicitly in the
definition of the instruction.
Zero-address instructions in a stack-organization are implied mode
instructions, since the operands are implied to be on top of the stack.
2. Immediate Mode: In this mode, an instruction contains the operand value.
This mode has an operand field rather than an address field .
3. Register Mode: In this mode, the operand values are held in the CPU
registers.
The selected register contains the address of the operand rather than the
operand itself.
The advantage of this mode is that the address field of the instruction uses
fewer bits to select a registers than would have been required to specify a
memory address directly.
The Effective Address (EA) or (FA): Is the memory address obtained
from the computation of the given addressing mode.
5. Direct Addressing Mode: In this mode, the effective address (PA) is equal to
the address part of the instruction. The operand resides in memory and its
address is given directly by the address field of the instruction.
Example: SUB R1, X
6. Indirect Addressing Mode: In this mode, the address field of the instruction
gives the address where the effective address (PA) is stored in memory.
Example: ADD R1, [X]
Figure (1) shows some of addressing modes.
ACC
7. Relative Addressing Mode: In this mode, the content of the program counter
(PC) is added to the address part of the instruction, in order to obtain the
effective address (PA). The position of the effective address in memory is
relative to the address of the next instruction.
Example: Let PC=825, and the address part of the instruction contains the
number 24. To calculate the effective address:
1- Increment the PC after reading the current instruction. PC =PC + 1 = 826
2- Effective address = PC + 24 = 826 + 24 = 850
D 100 X(0) 3 XR
101 X(1)
102 X(2)
103 X(3)
EA or PA=D+XR=103
9. Base Register Addressing Mode: In this mode, the content of a base register
(BR) is added to the address part of the instruction to obtain the effective address
(PA). A base register held the base address, and address field gives a
displacement relative to this base address.
The base register addressing mode is used in computers to facilitate the
relocation of programs in memory. When programs and data are moved
from one segment of memory to another, the address values of the
displacement (D) values of instructions do not have to change. Only the
values of the base register requires updating to reflect the new memory
segment.
Numerical Example
Memory
200 Load to Acc Mode
PC=200
201 Address field=500
R1=400 202 Next Instruction
XR or IR=100
399 450
ACC
400 700
500 800
600 900
702 325
Addresses
800 300
In this example, we show the effective of the addressing (PA) mode on the
above instruction, where the two-word instruction at address 200 and 201 is
"Load to Acc" with on address field=500.
For each possible mode, we calculate the effective address (PA) and the
operand that must be loaded in to Acc.
1. Immediate Mode:
.Effective address =201.
.Operand=500.
2. Direct Address Mode:
.Effective address =500.
.Operand=800.
3. Indirect Address Mode:
.Effective address is stored in memory at address 500, So
Abdulkareem Hussien Abdulkareem 36 & Dr. Hameed Abdulkareem Younis
Basrah Univ., Computer Science and Information Technology College, Computer Scie. Dept.
Microprosessors Addressing Modes