Microprocessors
Microprocessors
Introduction
A Microprocessor incorporates most or all of the functions of a computer's
central processing unit (CPU) on a single integrated circuit. It is the part of
the microcomputer that executes instructions of the program and processes
data. It is responsible for performing all arithmetic operations and making the
logical decisions initiated by the computer’s program. In addition to
arithmetic and logic functions, the MPU controls overall system operation.
Memory Unit
Primary Storage Unit
Program Data Secondary
Storage Storage Storage Unit
Memory Memory
Input Output
Unit MPU Unit
1
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Basic Definitions
o A bit or binary digit is the basic unit of information in computing and
telecommunications; it is the amount of information that can be stored
by a digital device.
o The byte is an ordered collection of bits, in which each bit denotes the
binary value of 1 or 0. The size of a byte is typically hardware
dependent, but the modern de facto standard is 8 bits, as this is a
convenient power of 2. Most of the numeric values used by many
applications are representable in 8 bits and processor designers
optimize for this common usage.
History of Microprocessors
Microprocessors generally are categorized in terms of the maximum number
of binary bits in the data they process – that is, their word length. Over time,
five standard data widths have evolved for microprocessors: 4-bit, 8-bit, 16-
bit, 32-bit, 64-bit.
There are so many manufacturers of Microprocessors, but only two
companies have been producing popular microprocessors: Intel and Motorola.
Table 1 lists some of types that belong to these companies (families) of
microprocessors.
The 8086 has data bus width of 16-bit, and is able to address 1Megabyte of
memory.
It is important to note that 80286, 80386, 80486, and Pentium-Pentium4
microprocessors are upward compatible with the 8086 Architecture. This
means that 8086 code will run on the 80286, 80386, 80486, and Pentium
Processors, but the reverse is not true if any of the new instructions are in use.
Beside to the general-purpose microprocessors, these families involve
another type called special-purpose microprocessors that used in embedded
control applications. This type of embedded microprocessors is called
microcontroller. The 8080, 8051, 8048, 80186, 80C186XL are some
examples of microcontroller.
2
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Numbers System
For microprocessors and microcomputers, information such as instructions,
data, and addresses are described with numbers. The types of numbers used
are not normally the decimal numbers we are familiar with; instead, binary
and hexadecimal numbers are used.
MSD LSD
10+3 10+2 10+1 100 . 10-1 10-2 10-3
weights 1000 100 10 1 . 1/10 1/100 1/1000
3
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
MSD LSD
2+3 2+2 2+1 20 . 2-1 2-2 2-3
weights 8 4 2 1 . 1/2 1/4 1/8
MSD LSD
Software Architecture
The 8086 microprocessor employs parallel processing – that is, it is
implemented with several simultaneously operating processing units. It
contains two processing units: the Bus Interface Unit (BIU) and the
Execution Unit (EU). Each unit has dedicated functions and both operate at
the same time. This parallel processing makes the fetch and execution of
4
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The BIU is responsible for performing all external bus operations, such as
instruction fetching, reading and writing of data operands for memory,
address generating, and inputting or outputting data for input/output
peripherals. These operations take place over the system bus. This bus
includes 16-bit bidirectional data bus, a 20-bit address bus, and the signals
needed to control transfer over the bus. It is also responsible for instruction
queuing.
Software Model
Software architecture of 8086 includes 13 16-bit internal registers: the
instruction pointer, four data registers, two pointer registers, two index
registers, and four segment registers. In addition, there is status register with
nine of its bits implemented as status & control flags.
5
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
6
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
0072416 0216
0072516 5516
The storage location at the lower address 0072416 contains the value 0216. The
content of the next higher address storage location 0072516 is 5516. These two
bytes represent the word 550216. This word has its least significant byte
stored at even address 0072416 so it is called aligned word, otherwise if the
least significant byte is stored at odd address, it is called misaligned word.
Figure 4 shows some aligned and misaligned words of data, words 0, 2, 4, and
6 are aligned words, while words 1 and 5 are misaligned words. A double
word corresponds to four consecutive bytes of data stored in memory.
7
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Memory Segmentation
Even though the 8086 has a 1Mbyte address space, not all this memory is
active at one time. Actually, the 1Mbytes of memory are partitioned into
64Kbyte (65,536) segments. A segment represents an independently
addressable unit of memory consisting of 64 K consecutive byte-wide storage
locations. Each segment is assigned a base address that identifies its starting
point (its lowest address byte-storage location). Only four of these 64 Kbytes
segments are active at a time: the code segment, stack segment, data segment,
and extra segment.
Internal Registers
o Segment Registers The segments of memory that are active are
identified by the values of addresses held in 8086’s four internal
segment registers: CS (code segment), SS (stack segment), DS (data
segment), and ES (extra segment). Each of these registers contains a
16-bit base address that points to the lowest addressed byte of the
segment in memory.
o Instruction Pointer Register It is also 16-bit in length and identifies the
location of the next word of instruction code to be fetched from the
current code segment of memory. It contains the offset of the next word
of instruction code instead of its actual address. Every time a word of
8
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
code is fetched from memory, the 8086 updates the value in IP such
that it points to the first byte of the next sequential word of code (IP
incremented by 2).
o Data Registers The 8086 has four general purpose data registers: the
accumulator register (A), the base register (B), the count register (C),
and the data register (D). These names imply special functions they are
meant to perform.
9
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
10
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
2. The parity flag: PF is set if the result produced by the instruction has
even parity (if it contains an even number of bits at the 1 logic level). If
parity is odd, PF is reset.
3. The auxiliary flag: AF is set if there is a carry-out from the low nibble
into the high nibble or a borrow-in from the high nibble into the low
nibble of the lower byte in a 16-bit word. Otherwise, AF is reset.
4. The zero flag: ZF is set if the result produced by an instruction is zero.
Otherwise, ZF is reset.
5. The sign flag: The MSB of the result is copied into SF. Thus, SF is set
if the result is a negative number or reset if it is positive.
6. The overflow flag: When OF is set, it indicates that the signed result is
out of range. If the result is not out of range, OF remains reset.
11
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
segment has an offset of 000016, and the highest address byte has an offset of
FFFF16.
To obtain the physical address, the value in the segment register is shifted left
by four bits (with its LSBs filled with zeros). The offset value is then added.
The result of this addition is 20-bit physical address.
Many different logical addresses map to the same physical address location in
memory. If a segment register contains 002B16 with offset 001316, it will map
to the same physical address in the above example. Try base segment 002C 16
with a new offset of 000316.
12
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The Stack
The address obtained from the contents of SS and SP (SS:SP) is the address
of the last storage location in the stack to which data were pushed, it is called
top of the stack. The highest-addressed word location in the stack
(SS:FFFE16) is called bottom of the stack. The lowest-addressed word
location in the stack (SS:000016) is called end of the stack.
When a call instruction is executed, the 8086 automatically pushes the current
values in CS and IP onto the stack. As part of the subroutine, the contents of
other registers may also be saved on the stack by executing push instructions.
Near the end of the subroutine, pop instructions are included to pop values
from the stack back into their corresponding internal registers. At the end of
the subroutine, a return instruction causes the values of CS and IP to be
popped off the stack and put back into the internal register where they
originally resided.
Data transferred to and from the stack are word wide (not byte-wide). Each
time a word is to be pushed onto the top of stack, the value in SP is first
automatically decremented by two, and then the content of the register is
written into the stack.
13
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
When a value is popped from the top of stack, the reverse occurs. Its content
is first popped off the stack and put into the specific register, and then SP is
automatically incremented by two.
Software
A microcomputer does not know how to process data, it must be told where to
get data, what to do with the data, and where to put the results when it is done.
These are the jobs of the software. The sequence of commands to tell a
microcomputer what to do is called a program. Each command in a program
is an instruction.
Programs must always be coded in machine language before they can be
executed by the microprocessor. A program written in machine language is
often referred to as machine code (instruction is encoded using 0s and 1s). It
is almost impossible to write programs directly in machine language. For this
reason, programs are normally written in 8086 assembly language or a high-
level language such as C. In assembly language, each of the operations is
described with alphanumeric symbols instead of 0s and 1s.
An instruction can be divided into two parts: operation code (opcode) and
operands. The opcode is the part of instruction that identifies the operation
that is to be performed (add, subtract, move, …). Each opcode is assigned a
unique letter combination called a mnemonic (ADD, SUB, MOV, …).
Operands describe the data are to be processed as the microprocessor carries
out the operation specified by the opcode. They identify whether the source
and destination of the data are registers within the MPU or storage locations
in data memory.
The assembler is the program that translates the assembly language programs
to an equivalent machine language program for execution by microprocessor.
The compiler is the program that converts high-level language statements to
machine code instructions.
Addressing modes
An addressing mode is a method of specifying an operand. The 8086 is
provided with various addressing modes to access operands. The data may be
part of the instruction, may reside in one of the internal registers, may be
stored in memory, or may be held at an I/O port. The addressing modes are
categorized as following:
1- Register operand addressing mode.
14
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
15
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
This stands for “move the content of memory location with offset 1234H in
the current data segment to CX”.
d- Indexed addressing mode the physical address is obtained from the value
in a segment register, an index register (SI or DI), and a displacement. For
example:
MOV AL, [SI] + 1234H
16
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
6- String-handling instructions
Integer Instructions
The 8086 has group of data-transfer instructions provided to move data either
between its internal registers or between an internal register and a storage
location in memory. This group includes:
17
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
18
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Flags
Mnemonic Meaning Format Operation
affected
Load effective
LEA address
LEA reg16, EA EA (Reg16) None
EA (Reg16)
LDS Load register & DS LDS reg16, EA
EA + 2 (DS)
None
EA (Reg16)
LES Load register & ES LES reg16, EA
EA + 2 (ES)
None
LDS and LES are able to load a complete address pointer that is stored in
memory (executing them can activate a new data segment and extra segment).
19
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
2- Arithmetic Instructions
Addition Instructions
INC AH
ADD AL, BL
DAA
The contents of AL and BL must be packed BCD numbers (two BCD digits
packed into a byte). The adjusted result in AL is again a packed BCD byte.
Subtraction Instructions
21
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
22
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
23
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
24
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The last two instructions are used to allow division of 8-bit dividend in AL by
8-bit divisor and 16-bit dividend in AX by 16-bit divisor
3- Logic Instructions
The 8086 has instructions for performing the logic operations AND, OR,
exclusive-OR, and NOT bit-wise on byte-wide and word-wide data.
25
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
4- Shift Instructions
The four shift instructions of 8086 can perform two basic types of shift
operations; the logical and arithmetic shifts. Each of these operations can be
performed to the right or to the left. These instructions are used to align data,
isolate bits of a byte or word so that it can be tested, and to perform simple
multiply and divide computations.
26
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
27
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
5- Rotate Instructions
The rotate instructions are similar to the shift instructions; they perform many
of the same programming functions such as alignment of data and isolation of
a bit of data.
28
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The control flow instructions give the ability to alter the sequence in which
instructions of a program execute.
29
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
1- Flag-Control Instructions
o LAHF Instruction loads the flags into AH to read them. The format of
the flags information in AH is as shown below (bits 1, 3, and 5) are not
used.
AH
SF ZF x AF x PF x CF
b7 b0
o CLC, STC, CMC Instructions used to manipulate the carry flag, they
permit CF to be cleared, set, or complemented, respectively.
30
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
2- Compare Instruction
3- Jump Instructions
In the 8086, the code segment register and instruction pointer keep track of
the next instruction to be fetched for execution. Thus to initiate a change in
control flow, a jump instruction must change the content of these registers. In
this way, execution continues at an address other than that of the next
sequential instruction. There are two types of jump operations; conditional
and unconditional jump.
a- Unconditional Jump
31
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
32
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
b- Conditional Jump
For a conditional jump, status conditions that exist at the time the jump
instruction is executed decide whether or not the jump will occur. If the
conditions are met, the jump takes place; otherwise, execution continues with
the next sequential instruction. The conditions that can be referenced by a
conditional jump instruction are status flags.
Table 1 shows the conditional jump instruction set. Each of these instructions
tests for the presence or absence of certain status conditions. For some of the
instructions, two different mnemonics can be used (this improves the program
readability).
33
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Above and below are used to describe the comparison of unsigned numbers;
while less and greater to describe comparison of signed numbers. For
example, the number ABCDH is above the number 1234H if they are
considered to be unsigned numbers. On the other hand, ABCDH is less than
1234H if they are treated as signed numbers.
When signed numbers are compared, use the JG, JL, JGE, JLE, JE, and JNE
instructions. When unsigned numbers are compared, use the JA, JB, JAE,
JBE, JE, and JNE instructions.
34
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
. First instruction
. .
. .
Call subroutine A .
Next instruction
. Return
.
.
Call subroutine A
Next instruction
.
.
.
35
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
There are instructions provided to transfer control from the main program to a
subroutine and return control back to the main program.
36
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
CALL 1234:5678H
37
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
o POPF Instruction returns the flags from the top of stack to the flag
register.
5- Loops Instructions
6- Strings Instructions
A string is a series of data words (or bytes) that reside in consecutive memory
locations. The string instructions of 8086 permit programmer to implement
operations such as to move data from one block of memory to a block
elsewhere in memory, scanning a string of data elements stored in memory to
look for a specific value, comparing the elements of two strings in order to
determine whether they are the same or different, and initializing a group of
consecutive memory locations. These operations must be repeated to handle a
string of more than one element.
39
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
40
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
String Prefixes
REP Prefix causes the basic string operation to be repeated until the
contents of CX become = 0. Each time the instruction is executed, it
causes CX to be tested for 0. If CX is found ≠ 0, it is decremented by 1
and the basic string operation is repeated. On the other hand, if it is 0,
41
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
the repeat string operation is done and the next instruction in the
program is executed. The repeat count must be loaded into CX prior to
executing the repeat string instruction. The REP prefix is used with the
MOVS and STOS instructions.
The 8085 has simple architecture and it is easy to use. It operates with a
power supply of +5 volts and GND. It uses approximately 6500 transistors. It
has 8-bit data and uses 16-bit address to access the memory. With the help of
16-bit address, 8085 can access 216 = 65536 = 64K memory locations. The 8-
bit data bus is multiplexed with the lower part of the 16-bit address bus to
limit the number of pins to 40.
42
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
1- Address Bus (16 pins) The 8085 has 16 signal lines that are used as the
address bus, so address ranges from 0000H to FFFFH. These lines are split
into 2 groups, AD0 – AD7 and A8 – A15. The 8 signal lines, A8 – A15, are
unidirectional and used for the most significant address bits. The signal lines
AD0 – AD7 are used for a dual purpose; as a lower-order address lines and
also as a data bus. The demultiplexing of AD0 – AD7 is determined by ALE
(Address Latch Enable) signal. When this control signal goes high, the
content of the address bus is address bits. When ALE is low, data is placed on
the bus.
Question Calculate the address lines required for an 8 Kbytes memory chip.
2- Data Bus (8 pins) The signal lines AD0 – AD7 are bidirectional. They are
used as the low-order address bus as well as the data bus. The data flows both
ways between the microprocessor and memory or I/O. The 8 data lines enable
the 8085 to manipulate 8 bits data only at a time, ranging from 00H to FFH.
43
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
3- Control & Status Bus (6 pins) This group of signals is used to identify the
nature of operation. It is responsible for overall control and synchronization of
the system. This group of signals includes: two control signals (RD and WR),
three status signals (IO/M, S0 and S1) and one special signal (ALE).
4- Power Supply & Frequency (5 pins) These signals are: Vcc (+5 V power
supply), Vss (Ground Reference), X1, X2 (A crystal or RC, LC network) is
connected at these pins, and CLK OUT (Clock Output). This signal can be
used as the system clock for other devices.
5- Externally Initiated & Acknowledgement Signals (11 pins) The 8085 has
5 interrupt signal that can be used to interrupt a program execution. (INTR,
RST7.5, RST 6.5, RST 5.5, TRAP). Restart interrupts (RST5.5, RST 6.5,
RST 7.5) are vectored interrupts that transfer the program control to specific
memory locations. They have higher priorities than the INTR interrupt.
Among these three, the priority order is 7.5, 6.5, 5.5. TRAP is a nonmaskable
interrupt and has the highest priority. INTA is used to acknowledge an
interrupt. HOLD indicates that a peripheral is requesting the use of the
address and data buses. HLDA acknowledges the HOLD request. READY is
used to delay the 8085 Read or Write cycles until a slow responding
peripheral is ready to send or accept data. RESET IN when the signal on this
pin goes low, the 8085 is reset. RESET OUT signal indicates that the 8085 is
being reset. it can be used to reset other devices.
6- Serial I/O ports (2 pins) The 8085 has two signals to implement the serial
transmission: SID (Serial Input Data) and SOD (Serial Output Data). In serial
transmission, data bits are sent over a single line, one bit at a time.
44
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Arithmetic and Logic Unit ALU performs many of the functions that
involve arithmetic and logic operations. It also handles all data
manipulation, such as shift, rotate, and the 2’s complement operations.
45
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Serial I/O Control is used to convert serial data into parallel and
parallel data into serial. Microprocessor works with 8-bit parallel data
and serial I/O devices works with serial transfer of data; therefore, this
unit is the interface between microprocessor and serial I/O devices.
Programming Model
The 8085 programming model includes six registers, one accumulator, one
flag register, and two 16-bit registers (stack pointer and program counter).
The 8085 uses six General-Purpose Registers to store 8-bit data; these are
identified as B, C, D, E, H, and L. They can be combined as register pairs
(BC, DE, and HL) to perform some 16-bit operations. The programmer can
use these registers to store or copy data into the registers by using data copy
instructions.
46
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The ALU includes five Flags, which are set or reset after an operation
according to data conditions of the result in the accumulator and other
registers. These are Zero flag (Z), Carry (CY), Sign (S), Parity (P), and
Auxiliary Carry (AC) flags. The microprocessor uses these flags to test data
conditions so they have critical importance in the decision-making process of
the microprocessor. Five bit positions out of eight are used to store the five
flags.
S Z X AC X P X CY
B7 B6 B5 B4 B3 B2 B1 B0
The Program Counter (PC) is a 16-bit register deals with sequencing the
execution of instructions. This register is a memory pointer. Memory
locations have 16-bit addresses, and that is why this is a 16-bit register. To
execute a program, the starting address of the program is loaded in program
counter. The PC sends out an address to fetch a byte of instruction from
memory and increment its content automatically. Hence, when a byte of
instruction is fetched, the PC holds the address of the next byte of the
instruction or next instruction.
The Stack Pointer (SP) is also a 16-bit register used as a memory pointer. It
points to a memory location in the stack. The beginning of the stack is defined
by loading 16-bit address in the stack pointer.
Instruction Format
Each instruction has two parts; the operation code (op-code) and the operand.
The operand (or data) can be specified in various ways. It may include 8-bit
47
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
(or 16-bit) data, an internal register, a memory location, or 8-bit (or 16-bit)
address. In some instructions, the operand is implicit.
Addressing Modes
Instruction Set
The 8085 instruction set can be classified into the following five functional
headings:
48
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Interrupts
The 8086, announced in 1978, was the first 16-bit microprocessor introduced
by Intel Corporation. The 8086 is manufactured using high-performance
metal-oxide semiconductor (HMOS) technology, and the circuitry on its chips
is equivalent to approximately 29000 transistors. It is housed in a 40-pin dual
in-line package.
49
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
As seen above, many of 8086’s pins have multiple functions. For example, we
see that address bus lines A0 through A15 and data bus lines D0 through D15
are multiplexed. For this reason, these leads are labeled AD0 through AD15.
By multiplexed we mean that the same physical pin carries an address bit at
one time and the data bit at another time.
50
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The minimum-mode signals can be divided into the following basic groups:
51
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
HLDA
Write control Output
WR
IO/memory control Output
M/IO
Data transmit /receive Output
DT/R
Data enable Output
DEN
Bank high enable/Status line 7 Output
BHE /S7
Address latch enable Output
ALE
Interrupt acknowledgment Output
INTA
1- Address/Data Bus the address bus is 20 bits long and consists of signal
lines A0 (the LSb) to A19 (the MSb).
The data bus is 16 bits long and consists of signals lines D 0 (the LSb) to D15
(the MSb). When acting as a data bus, they carry read/write data for memory,
input/output data for I/O devices, and interrupt-type codes from an interrupt
controller.
2- Status Signals the four most significant address lines, A16 through A19 are
also multiplexed, but with status signals S3 through S6. These status bits are
output on the bus at the same time that data are transferred over the other bus
lines. Bits S3 and S4 together form a 2-bit binary code that identifies which of
the internal segment registers was used to generate the physical address that
was output on the address bus during the current bus cycle. Status line S5
reflects the status of logic level of the internal interrupt enable flag.
52
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
3- Control Signals these are provided to support the memory and I/O
interfaces of the 8086:
53
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
54
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
55
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
o 𝑺𝟎, 𝑺𝟏, 𝑺𝟐 these three bits are input to the external bus controller
device, the 8288, which decodes them to identify the type of next bus
cycle. In addition to the signal produced the 8288 bus controller
produces DEN, DT/R, and ALE.
o 𝑳𝑶𝑪𝑲 Signal this signal is meant to be output (logic 0) whenever the
processor wants to lock out the other processors from using the bus.
o Queue Status Signals (QS0, QS1) these two bits tell the external
circuitry what type of information was removed from the queue.
o 𝑹𝑸/𝑮𝑻𝟎, 𝑹𝑸/𝑮𝑻𝟏 these two signals provide a prioritized bus access
mechanism for accessing the local bus.
Status Inputs
CPU Cycle 8288 Command Meaning
𝑺𝟐 𝑺𝟏 𝑺𝟎
Interrupt
0 0 0 Acknowledge INTA Interrupt acknowledge
System Clock
The time base for synchronization of the internal and external operations of
the microprocessor in a microcomputer system is provided by the clock
(CLK) input signal. The 8086 microprocessor is manufactured in three
speeds: the 5-MHz 8086, the 8-MHz 8086-2 and the 10-MHz 8086-1.
56
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The bus cycle of 8086 microprocessors consists of at least four clock periods
(T1, T2, T3, and T4):
These four clock states give a bus cycle duration of 125 ns × 4= 500 ns in an
8-MHz system.
Idle States
Wait States
Wait states can be inserted into a bus cycle. This is done in response to
request by an event in external hardware instead of an internal event such as a
full queue. The READY input of the 8086is provided specifically for this
purpose. As long as READY is held at the 0 level, wait states are inserted
between states T3and T4 of the current bus cycle, and the data that were on the
bus during T3 are maintained. The bus cycle is not completed until the
external hardware returns READY back to the 1 logic level.
57
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Read Cycle
The read bus cycle begins with state T1. During this period, the 8086 output
the 20-bit address of the memory location to be accessed on its multiplexed
address/data bus AD0 through AD15 and multiplexed lines A16/S3 through
A19/S6.note that at the same time a pulse is also produced at ALE. The signal
BHE is also supplied with the address lines.
58
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The status signals𝑆0 , 𝑆1 , and 𝑆2 are outputs of the 8086 and inputs to the 8288
bus controller which decodes them to produce command and control signals
needed to coordinate data transfer over the bus.
The address bus is latched, buffered, and decoded. The address lines A 0
through A19 are latched along with control signal 𝐵𝐻𝐸 in the address bus
latch. The latched address lines A17L through A19L are decoded to produce
chip enable output 𝐶𝐸 0 through𝐶𝐸 7.
59
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The 8288 bus controller produces the address latch enable ALE control signal
from 𝑆2𝑆1𝑆0. It is applied to the CLK input of latches.
During read operations, the bank read control logic determines whether the
data are read from one of the two memory banks or from both (depending on
whether a byte or word data transfer). Similarly, the bank write control logic
determines to which memory bank the data are written.
The bus transceivers control the direction of data transfer between the
microprocessor and memory subsystem. DEN is applied to the EN input of the
transceivers to enable them for operation. DT/𝑅 is applied to the DIR input of
the bus transceivers to select the direction of data transfer (logic 0 makes data
pass from memory to microprocessor, logic 1 makes data be carried from the
microprocessor to the memory).
For the minimum mode, the memory interface is similar to above except that
the signals ALE,𝐷𝐸𝑁, and DT/𝑅 are delivered by 8086 directly. 𝑀𝑊𝑇𝐶 and
𝑀𝑅𝐷𝐶 are produced using 𝑅𝐷, 𝑊𝑅, and M/𝐼𝑂 signals as shown below.
60
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Memory Types
Every microprocessor-based system has a memory system. Memory provides
the ability to store and retrieve digital information. The memory unit of the
microcomputer is partitioned into a primary storage section and secondary
storage section.
Almost all systems contain two main types of memory: Read-Only Memory
ROM and Random Access Memory RAM. ROM contains system software
and permanent system data, while RAM contains temporary data and
application software.
61
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Static RAM (SRAM) data remain valid as long as the power supply is
not turned off.
Dynamic RAM (DRAM) to retain data in a DRAM, it is not sufficient
just to maintain the power supply; we must periodically restore the data
in each storage location (Refreshing the DRAM).
Memory Expansion
62
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Sol.
The 8086 has 20 address bits (A0-A19) and 16 data bits (D0-D15)
1𝑀𝐵 210 𝐾𝐵
= 6 = 16
64𝐾𝐵 2 𝐾𝐵
16 units are needed (8 for low bank and same for high bank)
The three MSbits (A17, A18, and A19) are input to decoders
63
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Input/Output Types
The input/output (I/O) system of the microprocessor allows peripherals to
provide data or receive results of processing the data; this is done using I/O
ports. Through the I/O interface, the MPU can input or output data in bit, byte,
or word.
The 8086 microcomputers can employ two different types of (I/O); Isolated
I/O and Memory-mapped I/O. These I/O methods differ in how I/O ports are
mapped into the 8086’s address spaces.
64
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
65
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The memory address space is not Part of the memory address space is
affected lost
All data transfers must take place Data transfers can take place
between AL or AX register and the between an I/O port and an internal
I/O port register other than just AL or AX
66
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The minimum mode isolated I/O interface is shown in Figure 3. Unlike the
memory interface, just the 16 least significant lines of the address bus (A 0
through A15) are used. This interface uses the signals ALE, BHE, M/IO, RD,
WR, DT/R, and DEN.
Figure 4 shows the maximum mode isolated I/O interface. This interface uses
the 8288 bus controller. Here the bus controller decodes the status bits S0, S1,
S2 to produce bus cycle commands (IORC, IOWC, and AIOWC) and the
signals ALE, DT/R, and DEN. The command signals are used to enable I/O
ports to deliver/receive data to/from the system bus during write and read
operations.
67
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Input/Output Instructions
Isolated Input/output operations are performed using special input and output
instructions (IN and OUT). All data transfers take place between an I/O
device and the accumulator (byte transfers involve AL, and word transfers
involve AX).
There are two different forms of IN and OUT instructions; the Direct I/O
instructions and Variable I/O instructions.
Direct I/O instructions The address of the I/O port is specified as part
of the instruction. Eight bits are provided for this direct address. For
this reason, its value is limited to the address range from 00H to FFH
(Page 0).
68
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The input/output bus cycles are essentially the same as those involved in the
memory interface. Figure 5 shows the output bus cycle of the 8086. It’s
similar to the write cycle except for the signal M/IO.
69
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Here we explain the circuits that can be used to implement parallel output
ports (8 bit) in microcomputer system employing isolated I/O.
Figure 6 shows how to attach an LED to output port O7 of parallel port 0. The
port address is 8000H, and the LED corresponds to bit7 of the byte of data
that is written to port 0. The circuit uses 74LS374 edge clocked octal latch to
provide the output ports.
For the LED to turn on, O7 must be switched to logic 0, and it will remain on
until this output is switched back to 1. To make O7 logic 0, simply write 0 to
that bit of the octal latch.
70
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
71
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Sol.
The program must first makes O7 logic 0 to turn on the LED, delays for a
short period of time, and then switches O7 back to 1 to turn off the LED. This
piece of program can run as a loop to make the LED continuously blink.
Ex. What is the I/O address of port 7 on the circuit in Figure 6? Assume all
unused address bits are at logic 0.
Sol.
Here we explain the circuits that can be used to implement parallel input ports
(8 bit) in microcomputer system employing isolated I/O.
72
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Figure 7 shows how to attach a switch to input line I2 of parallel port 0. The
port address is 8000H, and the switch corresponds to bit2 of the byte of data
that is read from port 0. The circuit uses 74LS244 unidirectional octal buffer
to implement the input ports.
Sol.
Sol.
73
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
74
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The standard configuration of the 82C55A makes it compatible with the 8086,
8088 and other microprocessors.
75
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
82C55A consists of 3 8-bit I/O ports (A, B, and C).They are grouped as group
A (Port A with the 4 upper bits of port C) and group B (Port B with the 4
lower bits of port C).
8-bit 8-bit
D7-D0 82C55 Port A
RD
8-bit
WR Port B
RESET 8-bit
Port C
A1
Control Reg.
A0
CS
D0-D7 are bidirectional three-state data bus lines. RD is an active low control
signal used by the CPU to read status information or data via the data bus.
WR is an active low control signal used by the CPU to load control words and
data into the 82C55A.
The RESET signal (active high) clears the control register and all ports (A, B,
and C) are set to the input mode. Chip select (CS) is an active low input used
to enable the 82C55A for communications.
A0 and A1 signals control the selection of one of the three ports or the control
word register.
76
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The bits of control register and their control functions are shown below.
Ex. Write down 82C55A control word that sets port A, port B and port C
lower as input, port C upper as output; all in mode 0.
Sol.
77
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Ex. 2 In 8086's 8-bit isolated I/O system, an 82C55A PPI is connected so that
the address of A, B, C ports, and Control register are 4D08H, 4D09H,4D0AH
and 4D0BH respectively.
Sol.
a)
78
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
b)
D7 D6 D5 D4 D3 D2 D1 D0
Control word = 92H
1 0 0 1 0 0 1 0
79
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
There are two types of LED seven-segment displays: common cathode (CC)
and common anode (CA). The difference between the two displays is that
common cathode has all the cathodes of the seven-segments connected
directly together and that the common anode has all the anodes of the seven-
segments connected together.
a b c d e f g
1 1 1 1 0 1 1 x
If the byte F6H (or F7H because bit D0 is neglected) is written to address of
the seven-segment display then it will display number nine.
80
3’rd year
Microprocessors
81
Lec. No. Microprocessors
Figure 5 Four –Digit Seven-Segment Display Interface to 8086 Microprocessor using 82C55 PPI
Yamama A. Shafeek
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Increasing
priority
Reset
Internal interrupts and exceptions
Software interrupts
Nonmaskable interrupt
External hardware interrupts
The user defines the function of the external hardware, software, and
nonmaskable interrupt. For instance, hardware interrupts are often assigned to
devices such as the keyboard, printer, and timers. On the other hand, the
functions of the internal interrupts and reset are not user defined. They
perform dedicated system functions.
The interrupt vector table contains 256 address pointers (vectors). Which are
identified as vector 0 through vector 255. That is, one pointer corresponds to
each of the interrupt types 0 through 255. These address pointers identify the
starting location of their service routines in program memory.
83
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The pointer table is located at the low-address end of the memory address
space. It starts at address 00000H and ends at 003FEH. This represents the
first 1Kbytes of the memory.
Each of the 256 pointers requires two words (4 bytes) of memory and is
always stored at an even-address boundary. For example, the offset and base
address for type number 255, IP255 and CS255, are stored at word addresses
003FCH and 003FEH, respectively. When loaded into the MPU, it points to
the instruction at CS255:IP255.
The first 31 pointers either have dedicated functions or are reserved. The 27
reserved pointers, 5 through 31, represent a reserved portion of the pointer
table and should not be used. The remainder of the table, the 224 pointers in
the address range 00080H through 003FFH, is available to the user for storage
of software or hardware interrupt vectors.
Software Interrupts
Interrupt Instructions
84
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
(IP) ((SP)-6)
(4*n) (IP)
((SP)) (IP)
((SP)+2) (CS)
IRET Interrupt return IRET All
((SP)+4) (Flags)
(SP)+ 6 (SP)
Interrupt on
INTO INTO INT 4 steps TF , IF
overflow
Wait for an
HLT Halt HLT external interrupt None
or reset to occur
Wait for TEST
WAIT Wait Wait None
input to go active
o HALT Instruction makes the MPU suspends operation and enters the
idle state.
o WAIT Instruction makes the MPU checks the logic level of the TEST
input prior to going into the idle state. Only if it is logic 1 then the
MPU will go into the idle state.
If the INTR pin is logic 1, a request for service is recognized. The 8086
checks the IF if it = 0 then the interrupt request is ignored and the next
sequential instruction is executed. If IF = 1 then the service routine is initiated
and the 8086:
86
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
During T1 of the first bus cycle, a pulse is output on ALE along with putting
the address/data bus on high impedance state and for the rest of the bus cycle.
During T2 and T3, INTA is switched to logic 0. This signals external circuitry
that the request is granted and the logic 1 at INTR can be removed.
The LOCK signal is produced only in the maximum mode. It is used to lock
other devices off the system bus, ensuring that the interrupt acknowledge
sequence continues to completion without interruption.
During the second bus cycle, a similar sequence occurs. External circuitry
puts the type number of the active interrupt on the data bus AD 0-AD7. This
code must be valid during periods T3 and T4 of the second bus cycle.
The RESET (active high) input of the 8086 MPU provides a hardware means
for initializing the microcomputer. when RESET goes back to logic 0 the
MPU clears all flags, sets IP to 0000H, CS to FFFFH, DS, SS, and ES all are
set to 0000H, and the instruction queue is emptied.
87
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Ex. Draw a circuit that places interrupt type number 60H on the data bus in
response to the INTR then:
(a) Write service routine at address 2000:1000H that increments the content
of memory location 0100H by 1 and outputs the new content at output port
5000H.
(b) Make this program an ISR for the type 60H interrupt.
Sol.
(a)
2000:1000H PUSH AX
PUSH DX
MOV DX, 5000H
MOV AX, [0100H]
INC AX
MOV [0100H], AX
OUT DX, AX
POP DX
POP AX
IRET
88
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
(b)
Then IP60 (1000H) is stored at addresses 00180H and 00181H and CS60
(2000H) is stored at addresses 00182H and 00183H.
o Single Step relates to an operation option of the 8086. If the trap flag
(TF) is set, the single-step mode of operation is enabled and the MPU
initiates type 1 interrupt service routine at the completion of execution
of every instruction of the user program.
89
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The 80286 microprocessor has 16-bit data bus and 24-bit address bus so it can
address memory up to 16 MB. None of its signal lines are multiplexed with
another signal. The instruction set of the 80286 is almost identical to the
8086, except for a few additional instructions that managed the extra 15M
bytes of memory. The clock speed of the 80286 was increased, so it executed
some instructions in as little as 250 ns with the original release 8.0 MHz. The
80286 was designed to run multitasking applications, including
communications, real-time process control, and multi-user systems.
The 80386 was Intel’s first practical 32-bit microprocessor that contained a
32-bit data bus and a 32-bit memory address that allowed it to address up to
4GB of memory. The instruction set of the 80386 was upward-compatible
with the earlier 8086, 80286 microprocessors.
80386SX is a low cost version of the 80386 with a 16-bit data bus to
simplify circuit board layout and reduce total cost. This simplified
designs but hampered performance. Only 24 pins were connected to the
address bus, therefore limiting addressing to 16 MB.
80386SL was introduced as a power efficient version for laptop
computers. The processor offered several power management options,
as well as different "sleep" modes to conserve battery power. It also
contained support for an external cache of 16 to 64 KB.
90
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
The internal architecture of the 80486 was modified so that about half of its
instructions executed in one clock instead of two clocks. Also the 80486 was
available in different versions.
Real Mode
The 80286 and above operate in either the real or protected mode. Only the
8086 operate exclusively in the real mode. Real mode operation allows the
microprocessor to address only the first 1M byte of the memory space. The
DOS operating system requires the microprocessor to operate in the real
mode. Real mode operation allows application software written for the 8086,
which contain only 1M byte of memory, to function in the 80286 and above
without changing the software. In all cases, each of these microprocessors
begins operation in the real mode by default whenever power is applied or
microprocessor is reset.
91
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Protected Mode
92
Microprocessors Microprocessors Lec. No.
3’rd year Yamama A. Shafeek
Applications: Applications:
93