Microprocessors and Microcontrollers Syllabus
Microprocessors and Microcontrollers Syllabus
Microprocessors and Microcontrollers Syllabus
Lecture Plan:
Next Page
• It requires single phase clock with 33% duty cycle to
provide internal timing.
• 8086 is designed to operate in two modes, Minimum and
Maximum.
• It can prefetches upto 6 instruction bytes from memory and
queues them in order to speed up instruction execution.
• It requires +5V power supply.
• A 40 pin dual in line package.
Next Page
Minimum and Maximum Modes:
• The minimum mode is selected by applying logic 1 to the
MN / MX# input pin. This is a single microprocessor
configuration.
• The maximum mode is selected by applying logic 0 to the
MN / MX# input pin. This is a multi micro processors
configuration.
Intel C8086
Intel C8086
5 MHz
40-pin ceramic DIP
Rare Intel C8086 processor in purple ceramic DIP package
with side-brazed pins.
Internal Architecture of 8086
Next Page
• Both units operate asynchronously to give the 8086 an
overlapping instruction fetch and execution mechanism
which is called as Pipelining. This results in efficient use
of the system bus and system performance.
• BIU contains Instruction queue, Segment registers,
Instruction pointer, Address adder.
• EU contains Control circuitry, Instruction decoder, ALU,
Pointer and Index register, Flag register.
Next Page
• BUS INTERFACR UNIT:
• It provides a full 16 bit bidirectional data bus and 20 bit
address bus.
• The bus interface unit is responsible for performing all
external bus operations.
Specifically it has the following functions:
• Instruction fetch, Instruction queuing, Operand fetch and
storage, Address relocation and Bus control.
• The BIU uses a mechanism known as an instruction stream
queue to implement a pipeline architecture.
Next Page
• This queue permits prefetch of up to six bytes of
instruction code. When ever the queue of the BIU is not
full, it has room for at least two more bytes and at the same
time the EU is not requesting it to read or write operands
from memory, the BIU is free to look ahead in the program
by prefetching the next sequential instruction.
• These prefetching instructions are held in its FIFO queue.
With its 16 bit data bus, the BIU fetches two instruction
bytes in a single memory cycle.
• After a byte is loaded at the input end of the queue, it
automatically shifts up through the FIFO to the empty
location nearest the output.
Next Page
• The EU accesses the queue from the output end. It reads
one instruction byte after the other from the output of the
queue. If the queue is full and the EU is not requesting
access to operand in memory.
• These intervals of no bus activity, which may occur
between bus cycles are known as Idle state.
• If the BIU is already in the process of fetching an
instruction when the EU request it to read or write
operands from memory or I/O, the BIU first completes the
instruction fetch bus cycle before initiating the operand
read / write cycle.
Next Page
• The BIU also contains a dedicated adder which is used to
generate the 20bit physical address that is output on the
address bus. This address is formed by adding an appended
16 bit segment address and a 16 bit offset address.
• For example: The physical address of the next instruction
to be fetched is formed by combining the current contents
of the code segment CS register and the current contents of
the instruction pointer IP register.
• The BIU is also responsible for generating bus control
signals such as those for memory read or write and I/O
read or write.
Next Page
• EXECUTION UNIT : The Execution unit is responsible
for decoding and executing all instructions.
• The EU extracts instructions from the top of the queue in
the BIU, decodes them, generates operands if necessary,
passes them to the BIU and requests it to perform the read
or write bys cycles to memory or I/O and perform the
operation specified by the instruction on the operands.
• During the execution of the instruction, the EU tests the
status and control flags and updates them based on the
results of executing the instruction.
Next Page
• If the queue is empty, the EU waits for the next instruction
byte to be fetched and shifted to top of the queue.
• When the EU executes a branch or jump instruction, it
transfers control to a location corresponding to another set
of sequential instructions.
• Whenever this happens, the BIU automatically resets the
queue and then begins to fetch instructions from this new
location to refill the queue.
COMMON SIGNALS
Name Function Type
AD 15 – AD 0 Address/ Data Bus Bidirectional
3 - state
A19 / S 6 – A 16 / S 3 Address / Status Output 3 - State
Output,
S2 – S0 Bus Cycle Status 3- State
QS1, QS0 Instruction Queue Status Output
Minimum Mode Interface
Next Page
Vcc GND
INTR
A0-A15,A16/S3 – A19/S6
INTA
Interrupt Address / data bus
interface
TEST
D0 – D15
NMI
8086
ALE
RESET MPU
BHE / S7
M / IO Memory
HOLD I/O controls
DMA DT / R
interface
HLDA RD
WR
Vcc
DEN
Mode select
READY
MN / MX
Next Page
CLK clock
Next Page
S4 S3 Segment Register
0 0 Extra
0 1 Stack
1 0 Code / none
1 1 Data
Next Page
• Status line S5 reflects the status of another internal
characteristic of the 8086. It is the logic level of the
internal enable flag. The last status bit S6 is always at the
logic 0 level.
• Control Signals : The control signals are provided to
support the 8086 memory I/O interfaces. They control
functions such as when the bus is to carry a valid address
in which direction data are to be transferred over the bus,
when valid write data are on the bus and when to put read
data on the system bus.
Next Page
• ALE is a pulse to logic 1 that signals external circuitry
when a valid address word is on the bus. This address must
be latched in external circuitry on the 1-to-0 edge of the
pulse at ALE.
• Another control signal that is produced during the bus
cycle is BHE bank high enable. Logic 0 on this used as a
memory enable signal for the most significant byte half of
the data bus D8 through D1. These lines also serves a
second function, which is as the S7 status line.
• Using the M/IO and DT/R lines, the 8086 signals which
type of bus cycle is in progress and in which direction data
are to be transferred over the bus.
Next Page
• The logic level of M/IO tells external circuitry whether a
memory or I/O transfer is taking place over the bus. Logic
1 at this output signals a memory operation and logic 0 an
I/O operation.
• The direction of data transfer over the bus is signaled by
the logic level output at DT/R. When this line is logic 1
during the data transfer part of a bus cycle, the bus is in the
transmit mode. Therefore, data are either written into
memory or output to an I/O device.
• On the other hand, logic 0 at DT/R signals that the bus is in
the receive mode. This corresponds to reading data from
memory or input of data from an input port.
Next Page
• The signal read RD and write WR indicates that a read bus
cycle or a write bus cycle is in progress. The 8086 switches
WR to logic 0 to signal external device that valid write or
output data are on the bus.
• On the other hand, RD indicates that the 8086 is
performing a read of data of the bus. During read
operations, one other control signal is also supplied. This is
DEN ( data enable) and it signals external devices when
they should put data on the bus.
• There is one other control signal that is involved with the
memory and I/O interface. This is the READY signal.
Next Page
• READY signal is used to insert wait states into the bus
cycle such that it is extended by a number of clock periods.
This signal is provided by an external clock generator
device and can be supplied by the memory or I/O sub-
system to signal the 8086 when they are ready to permit
the data transfer to be completed.
• Interrupt signals : The key interrupt interface signals are
interrupt request (INTR) and interrupt acknowledge
( INTA).
• INTR is an input to the 8086 that can be used by an
external device to signal that it need to be serviced.
Next Page
• Logic 1 at INTR represents an active interrupt request.
When an interrupt request has been recognized by the
8086, it indicates this fact to external circuit with pulse to
logic 0 at the INTA output.
• The TEST input is also related to the external interrupt
interface. Execution of a WAIT instruction causes the 8086
to check the logic level at the TEST input.
• If the logic 1 is found, the MPU suspend operation and
goes into the idle state. The 8086 no longer executes
instructions, instead it repeatedly checks the logic level of
the TEST input waiting for its transition back to logic 0.
Next Page
• As TEST switches to 0, execution resume with the next
instruction in the program. This feature can be used to
synchronize the operation of the 8086 to an event in
external hardware.
• There are two more inputs in the interrupt interface: the
nonmaskable interrupt NMI and the reset interrupt RESET.
• On the 0-to-1 transition of NMI control is passed to a
nonmaskable interrupt service routine. The RESET input is
used to provide a hardware reset for the 8086. Switching
RESET to logic 0 initializes the internal register of the
8086 and initiates a reset service routine.
Next Page
• DMA Interface signals :The direct memory access DMA
interface of the 8086 minimum mode consist of the HOLD
and HLDA signals.
• When an external device wants to take control of the
system bus, it signals to the 8086 by switching HOLD to
the logic 1 level. At the completion of the current bus
cycle, the 8086 enters the hold state. In the hold state,
signal lines AD0 through AD15, A16/S3 through A19/S6,
BHE, M/IO, DT/R, RD, WR, DEN and INTR are all in the
high Z state. The 8086 signals external device that it is in
this state by switching its HLDA output to logic 1 level.
Next Page
Maximum Mode Interface
Next Page
INIT
Multi Bus
S0 BUSY
S1 CBRQ
S2 8289 Bus BPRO
LOCK arbiter BPRN
CRQLCK
CLK RESB BREQ
Vcc GND SYSB/RESB
ANYREQ CLK AEN IOB BCLK
Next Page
• The 8288 produces one or two of these eight command
signals for each bus cycles. For instance, when the 8086
outputs the code S2S1S0 equals 001, it indicates that an I/O
read cycle is to be performed.
• In the code 111 is output by the 8086, it is signaling that no
bus activity is to take place.
• The control outputs produced by the 8288 are DEN, DT/R
and ALE. These 3 signals provide the same functions as
those described for the minimum system mode. This set of
bus commands and control signals is compatible with the
Multibus and industry standard for interfacing
microprocessor systems.
Next Page
• 8289 Bus Arbiter – Bus Arbitration and Lock Signals :
This device permits processors to reside on the system bus.
It does this by implementing the Multibus arbitration
protocol in an 8086-based system.
• Addition of the 8288 bus controller and 8289 bus arbiter
frees a number of the 8086 pins for use to produce control
signals that are needed to support multiple processors.
• Bus priority lock ( LOCK) is one of these signals. It is
input to the bus arbiter together with status signals S0
through S2.
Next Page
• The output of 8289 are bus arbitration signals: bus busy
(BUSY), common bus request (CBRQ), bus priority out
(BPRO), bus priority in (BPRN), bus request (BREQ) and
bus clock (BCLK).
• They correspond to the bus exchange signals of the
Multibus and are used to lock other processor off the
system bus during the execution of an instruction by the
8086.
• In this way the processor can be assured of uninterrupted
access to common system resources such as global
memory.
Next Page
• Queue Status Signals : Two new signals that are produced
by the 8086 in the maximum-mode system are queue status
outputs QS0 and QS1. Together they form a 2-bit queue
status code, QS1QS0.
• Following table shows the four different queue status.
Next Page
QS1 QS0 Queue Status
Next Page
• Local Bus Control Signal – Request / Grant Signals: In
a maximum mode configuration, the minimum mode
HOLD, HLDA interface is also changed. These two are
replaced by request/grant lines RQ/ GT0 and RQ/ GT1,
respectively. They provide a prioritized bus access
mechanism for accessing the local bus.
Internal Registers of 8086
Next Page
• Most of the registers contain data/instruction offsets within
64 KB memory segment. There are four different 64 KB
segments for instructions, stack, data and extra data. To
specify where in 1 MB of processor memory these 4
segments are located the processor uses four segment
registers:
• Code segment (CS) is a 16-bit register containing address
of 64 KB segment with processor instructions. The
processor uses CS segment for all accesses to instructions
referenced by instruction pointer (IP) register. CS register
cannot be changed directly. The CS register is
automatically updated during far jump, far call and far
return instructions.
Next Page
• Stack segment (SS) is a 16-bit register containing address
of 64KB segment with program stack. By default, the
processor assumes that all data referenced by the stack
pointer (SP) and base pointer (BP) registers is located in
the stack segment. SS register can be changed directly
using POP instruction.
• Data segment (DS) is a 16-bit register containing address
of 64KB segment with program data. By default, the
processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is
located in the data segment. DS register can be changed
directly using POP and LDS instructions.
Next Page
• Extra segment (ES) is a 16-bit register containing address
of 64KB segment, usually with program data. By default,
the processor assumes that the DI register references the
ES segment in string manipulation instructions. ES register
can be changed directly using POP and LES instructions.
• It is possible to change default segments used by general
and index registers by prefixing instructions with a CS, SS,
DS or ES prefix.
• All general registers of the 8086 microprocessor can be
used for arithmetic and logic operations. The general
registers are:
Next Page
• Accumulator register consists of two 8-bit registers AL
and AH, which can be combined together and used as a 16-
bit register AX. AL in this case contains the low-order byte
of the word, and AH contains the high-order byte.
Accumulator can be used for I/O operations and string
manipulation.
• Base register consists of two 8-bit registers BL and BH,
which can be combined together and used as a 16-bit
register BX. BL in this case contains the low-order byte of
the word, and BH contains the high-order byte. BX register
usually contains a data pointer used for based, based
indexed or register indirect addressing.
Next Page
• Count register consists of two 8-bit registers CL and CH,
which can be combined together and used as a 16-bit
register CX. When combined, CL register contains the
low-order byte of the word, and CH contains the high-
order byte. Count register can be used in Loop, shift/rotate
instructions and as a counter in string manipulation,.
• Data register consists of two 8-bit registers DL and DH,
which can be combined together and used as a 16-bit
register DX. When combined, DL register contains the
low-order byte of the word, and DH contains the high-
order byte. Data register can be used as a port number in
I/O operations. In integer 32-bit multiply and divide
instruction the DX register contains high-order word of the
initial or resulting number.
Next Page
• The following registers are both general and index
registers:
• Stack Pointer (SP) is a 16-bit register pointing to program
stack.
• Base Pointer (BP) is a 16-bit register pointing to data in
stack segment. BP register is usually used for based, based
indexed or register indirect addressing.
• Source Index (SI) is a 16-bit register. SI is used for
indexed, based indexed and register indirect addressing, as
well as a source data address in string manipulation
instructions.
Next Page
• Destination Index (DI) is a 16-bit register. DI is used for
indexed, based indexed and register indirect addressing, as
well as a destination data address in string manipulation
instructions.
Other registers:
• Instruction Pointer (IP) is a 16-bit register.
• Flags is a 16-bit register containing 9 one bit flags.
• Overflow Flag (OF) - set if the result is too large positive
number, or is too small negative number to fit into
destination operand.
Next Page
• Direction Flag (DF) - if set then string manipulation
instructions will auto-decrement index registers. If cleared
then the index registers will be auto-incremented.
• Interrupt-enable Flag (IF) - setting this bit enables
maskable interrupts.
• Single-step Flag (TF) - if set then single-step interrupt will
occur after the next instruction.
• Sign Flag (SF) - set if the most significant bit of the result
is set.
• Zero Flag (ZF) - set if the result is zero.
Next Page
• Auxiliary carry Flag (AF) - set if there was a carry from
or borrow to bits 0-3 in the AL register.
• Parity Flag (PF) - set if parity (the number of "1" bits) in
the low-order byte of the result is even.
• Carry Flag (CF) - set if there was a carry from or borrow
to the most significant bit during last result calculation.
Addressing Modes
• Implied - the data value/data address is implicitly
associated with the instruction.
• Register - references the data in a register or in a register
pair.
• Immediate - the data is provided in the instruction.
• Direct - the instruction operand specifies the memory
address where data is located.
• Register indirect - instruction specifies a register
containing an address, where data is located. This
addressing mode works with SI, DI, BX and BP registers.
• Based :- 8-bit or 16-bit instruction operand is added to the
contents of a base register (BX or BP), the resulting value
is a pointer to location where data resides.
Next Page
• Indexed :- 8-bit or 16-bit instruction operand is added to
the contents of an index register (SI or DI), the resulting
value is a pointer to location where data resides.
• Based Indexed :- the contents of a base register (BX or
BP) is added to the contents of an index register (SI or DI),
the resulting value is a pointer to location where data
resides.
• Based Indexed with displacement :- 8-bit or 16-bit
instruction operand is added to the contents of a base
register (BX or BP) and index register (SI or DI), the
resulting value is a pointer to location where data resides.
Memory
Next Page
• Program memory - program can be located anywhere in
memory. Jump and call instructions can be used for short
jumps within currently selected 64 KB code segment, as
well as for far jumps anywhere within 1 MB of memory.
• All conditional jump instructions can be used to jump
within approximately +127 to -127 bytes from current
instruction.
• Data memory - the processor can access data in any one
out of 4 available segments, which limits the size of
accessible memory to 256 KB (if all four segments point to
different 64 KB blocks).
Next Page
• Accessing data from the Data, Code, Stack or Extra
segments can be usually done by prefixing instructions
with the DS:, CS:, SS: or ES: (some registers and
instructions by default may use the ES or SS segments
instead of DS segment).
• Word data can be located at odd or even byte boundaries.
The processor uses two memory accesses to read 16-bit
word located at odd byte boundaries. Reading word data
from even byte boundaries requires only one memory
access.
Next Page
• Stack memory can be placed anywhere in memory. The
stack can be located at odd memory addresses, but it is not
recommended for performance reasons (see "Data
Memory" above).
Reserved locations:
• 0000h - 03FFh are reserved for interrupt vectors. Each
interrupt vector is a 32-bit pointer in format segment:
offset.
• FFFF0h - FFFFFh - after RESET the processor always
starts program execution at the FFFF0h address.
Interrupts
0 0 1 I / O read
1 0 I/O write
0
1 0 1 Memory read
1 1 0 Memory write
ALE
RD
DEN
DT / R
Clk
ALE
BHE S7 – S3
ADD / STATUS A19 – A16
WR
DEN
DT / R
HOLD
HLDA
8086
CLK
AD6-AD15 A/D Address bus
A16-A19 Latches
Add bus
DT/R
BHE A0
DIR
Data CS0H CS0L RD CS WR RD
buffer WR
DEN G Memory Peripherals
Data bus
Clk
ALE
MRDC
DT / R
DEN
Clk
ALE
ADD/STATUS BHE S7 – S3
MWTC or IOWC
DT / R high
DEN
RQ / GT
General definitions
¾ 8085 Architecture
• Pin Diagram
RST 7.5 7 34 IO / M
RST 6.5 8 33 S
RST 5.5 9
8085 A 32
___ 1
RD
___
INTR
_____ 10 31 WR
INTA 11
30 ALE
AD0 12
29 S0
AD1 13
28 A15
AD2 A14
14 27
AD3 15 26 A13
AD4 25 A12
16
AD5 24 A11
17
AD6 18 23 A10
AD7 19 22 A9
VSS 20 21 A8
INTA WR
INTR
8 BIT INTERNAL
DATA BUS
INSTRUCTION
ACCUMULATOR TEMP REG (8) MULTIPLXER
REGISTER
(8)
(8) W ( 8 )
R
E TEMP . REG.
B REG (8) C REG ( 8 )
G
FLAG
. D REG ( 8 )
( 5) E REG ( 8 )
S
FLIP FLOPS INSTRUCTION H REG (
L REG ( 8 )
ARITHEMETIC DECODER E 8 )
LOGIC UNIT ( ALU) AND MACHINE STACK POINTER ( 16 )
L
ENCODING PROGRAM COUNTER ( 16 )
(8) E
+5V INCREAMENT / DECREAMENT ADDRESS
C
LATCH ( 16 )
GND T
CLK
RESET IN A 15 – A8
OUT
READY RD WR ALE S0 S1 IO / M HOLD HLDA RESET OUT ADDRESS BUS AD7 – AD0 ADDRESS / BUFFER
BUS
Flag Registers
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
COMBININATON
B & C, D & E, H & L
¾ 8086 Architecture
• Pin Diagram
EU
ALU CONTROL INSTRUCTION QUEUE
SYSTEM Q BUS
1 2 3 4 5 6
8 BIT
FLAGS
BUS INTERFACE UNIT ( BIU)
EXECUTION UNIT ( EU )
Pin Diagram of 8086
GND 1 40 VCC
AD14 39 AD15
2
AD13 3 38 A16 / S3
AD12 4 37 A17 / S4
AD11 5 36 A18 / S5
AD10 6 35 A19/S6 _____
AD4 30 RQ / GT
___1
( HLDA)
12 _______
29 ____
AD3 LOCK (WR) ____
13
28 ___
___ S2 (M / IO )
AD2 14 27 S 1
___
(DT
_____
/ R)
AD1 15 26 S0 (DEN)
AD0 25 ________ QS0 (ALE)
16
NMI 24 QS1 (INTA)
17
______
INTR 18 23
TEST
CLK 19 22
READY
GND 20 21 RESET
INTR
_____
TEST INTERFACE
D0 - D15
MEMORY M / IO __
I/O DT / R
HOLD DMA ____
CONTROLS RD
HLDA INTERFACE _____
WR
VCC _____
DEN
MODE
____
SELECT READY
MN / MX
CLK 11
Signal Description of 8086
S4 S3 Indication
0 0 Alternate Data
0 1 Stack
1 0 Code or none
1 1 Data
ALE
S2 – S0
A19-A16 S3-S7 A19-A16 S3-S7
Add/stat
BHE Bus reserve BHE
Add/data for Data In Data Out D15 – D0
A0-A15 D15-D0 A0-A15 D15-D0
RD/INTA
Ready
READY Ready
DT/R Wait Wait
DEN
Contents
General definitions
¾ 8085 Architecture
• Pin Diagram
RST 7.5 7 34 IO / M
RST 6.5 8 33 S1
RST 5.5
9
8085 A 32
___
RD
___
INTR 10
_____ 31 WR
INTA 11
30 ALE
AD0 12
29 S0
AD1 13
28 A15
AD2 A14
14 27
AD3 15 26 A13
AD4 25 A12
16
AD5 24 A11
17
AD6 18 23 A10
AD7 19 22 A9
VSS 20 21 A8
+5V GND
XTAL
X1 X2 Vcc Vss
A15
SID 5 High order Address bus
A8
SOD 4
TRAP AD7
RESET 7.5
RESET 6.5 AD0
RESET 5.5 ALE
INTR S1
READY S0 ___
HOLD ______________ IO / M
RESET IN ____
HLDA RD
____
______
INTA WR
INT
8 BIT INTERNAL
DATA BUS
INSTRUCTIO
ACCUMULATO TEMP (8) MULTIPLXER
N REGISTER
(8)
(8) R W ( 8 )
E TEMP .
G BREG
REG ( 8 ) C REG (
FLAG .
S D REG ( 8
( 5) E REG (8
FLIP E
INSTRUCTIO H REG
L L REG (8
ARITHEMETIC N DECODER (8 )
LOGIC UNIT ( E STACK POINTER ( 16 )
AND C
MACHINE T PROGRAM COUNTER (
(8)
+5V INCREAMENT / DECREAMENT
ADDRESS LATCH ( 16 )
GND
CLK A 15 – A8
RESET
OUT READY R WR AL S0 S1 IO / M HOLD HLDA RESET AD7 – AD0 ADDRESS /
ADDRESS
BUFFER BUS
Block Diagram
Flag Registers
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
COMBININATON
B & C, D & E, H & L
Memory
• Program, data and stack memories occupy the same memory space. The total
addressable memory size is 64 KB.
• Program memory - program can be located anywhere in memory. Jump, branch
and call instructions use 16-bit addresses, i.e. they can be used to jump/branch
anywhere within 64 KB. All jump/branch instructions use absolute addressing.
• Data memory - the processor always uses 16-bit addresses so that data can be
placed anywhere.
• Stack memory is limited only by the size of memory. Stack grows downward.
• First 64 bytes in a zero memory page should be reserved for vectors used by RST
instructions.
Interrupts
• The processor has 5 interrupts. They are presented below in the order of their
priority (from lowest to highest):
• INTR is maskable 8080A compatible interrupt. When the interrupt occurs the
processor fetches from the bus one instruction, usually one of these instructions:
• One of the 8 RST instructions (RST0 - RST7). The processor saves current
program counter into stack and branches to memory location N * 8 (where N
is a 3-bit number from 0 to 7 supplied with the RST instruction).
• CALL instruction (3 byte instruction). The processor calls the subroutine, address
of which is specified in the second and third bytes of the instruction.
• RST5.5 is a maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 2CH
(hexadecimal) address.
• RST6.5 is a maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 34H
(hexadecimal) address.
• RST7.5 is a maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 3CH
(hexadecimal) address.
• TRAP is a non-maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 24H
(hexadecimal) address.
• All maskable interrupts can be enabled or disabled using EI and DI instructions.
RST 5.5, RST6.5 and RST7.5 interrupts can be enabled or disabled individually
using SIM instruction.
Reset Signals
• RESET IN: When this signal goes low, the program counter (PC) is set to Zero,
µp is reset and resets the interrupt enable and HLDA flip-flops.
• The data and address buses and the control lines are 3-stated during RESET and
because of asynchronous nature of RESET, the processor internal registers and
flags may be altered by RESET with unpredictable results.
• RESET IN is a Schmitt-triggered input, allowing connection to an R-C network
for power-on RESET delay.
• Upon power-up, RESET IN must remain low for at least 10 ms after minimum
Vcc has been reached.
• For proper reset operation after the power – up duration, RESET IN should be
kept low a minimum of three clock periods.
• The CPU is held in the reset condition as long as RESET IN is applied. Typical
Power-on RESET RC values R1 = 75KΩ, C1 = 1µF.
• RESET OUT: This signal indicates that µp is being reset. This signal can be used
to reset other devices. The signal is synchronized to the processor clock and lasts
an integral number of clock periods.
• SID - Serial Input Data Line: The data on this line is loaded into accumulator bit
7 whenever a RIM instruction is executed.
• SOD – Serial Output Data Line: The SIM instruction loads the value of bit 7 of
the accumulator into SOD latch if bit 6 (SOE) of the accumulator is 1.
DMA Signals
• HOLD: Indicates that another master is requesting the use of the address and data
buses. The CPU, upon receiving the hold request, will relinquish the use of the
bus as soon as the completion of the current bus transfer.
• Internal processing can continue. The processor can regain the bus only after the
HOLD is removed.
• When the HOLD is acknowledged, the Address, Data RD, WR and IO/M lines are
3-stated.
• HLDA: Hold Acknowledge: Indicates that the CPU has received the HOLD
request and that it will relinquish the bus in the next clock cycle.
• HLDA goes low after the Hold request is removed. The CPU takes the bus one
half-clock cycle after HLDA goes low.
• READY: This signal Synchronizes the fast CPU and the slow memory,
peripherals.
• If READY is high during a read or write cycle, it indicates that the memory or
peripheral is ready to send or receive data.
• If READY is low, the CPU will wait an integral number of clock cycle for
READY to go high before completing the read or write cycle.
• READY must conform to specified setup and hold times.
Registers
• Accumulator or A register is an 8-bit register used for arithmetic, logic, I/O and
load/store operations.
• Flag Register has five 1-bit flags.
• Sign - set if the most significant bit of the result is set.
• Zero - set if the result is zero.
• Auxiliary carry - set if there was a carry out from bit 3 to bit 4 of the result.
• Parity - set if the parity (the number of set bits in the result) is even.
• Carry - set if there was a carry during addition, or borrow during
subtraction/comparison/rotation.
General Registers
• 8-bit B and 8-bit C registers can be used as one 16-bit BC register pair. When
used as a pair the C register contains low-order byte. Some instructions may use
BC register as a data pointer.
• 8-bit D and 8-bit E registers can be used as one 16-bit DE register pair. When
used as a pair the E register contains low-order byte. Some instructions may use
DE register as a data pointer.
• 8-bit H and 8-bit L registers can be used as one 16-bit HL register pair. When
used as a pair the L register contains low-order byte. HL register usually contains
a data pointer used to reference memory addresses.
• Stack pointer is a 16 bit register. This register is always
decremented/incremented by 2 during push and pop.
• Program counter is a 16-bit register.
Instruction Set
• 8085 instruction set consists of the following instructions:
• Data moving instructions.
• Arithmetic - add, subtract, increment and decrement.
• Logic - AND, OR, XOR and rotate.
• Control transfer - conditional, unconditional, call subroutine, return from
subroutine and restarts.
• Input/Output instructions.
• Other - setting/clearing flag bits, enabling/disabling interrupts, stack operations,
etc.
Addressing mode
• Register - references the data in a register or in a register pair.
Register indirect - instruction specifies register pair containing address, where
the data is located.
Direct, Immediate - 8 or 16-bit data.
8086 Microprocessor
•It is a 16-bit µp.
•8086 has a 20 bit address bus can access up to 220 memory locations (1 MB) .
•It can support up to 64K I/O ports.
•It provides 14, 16 -bit registers.
•It has multiplexed address and data bus AD0- AD15 and A16 – A19.
•It requires single phase clock with 33% duty cycle to provide internal timing.
•8086 is designed to operate in two modes, Minimum and Maximum.
•It can prefetches upto 6 instruction bytes from memory and queues them in order to
speed up instruction execution.
•It requires +5V power supply.
•A 40 pin dual in line package
Minimum and Maximum Modes:
•The minimum mode is selected by applying logic 1 to the MN / MX# input pin. This is a
single microprocessor configuration.
• The maximum mode is selected by applying logic 0 to the MN / MX# input pin. This is
a multi micro processors configuration.
AD6
9
CPU 32
RD _____ _____
28 ___ S2 (M / IO )
___
AD2 S1 (DT / R)
14 27
___ _____
AD1 15 26 S0 (DEN)
AD0 25 QS0 (ALE)
16 ________
NMI
17 24 QS1 (INTA)
______
INTR 18 23 TEST
CLK 19 22
READY
GND 20 21
RESET
VCC GND
INTR
_____
INTA
ADDRESS / DATA BUS
INTERRUPT
______ INTERFACE
TEST
D0 - D15
CLK
EU
ALU CONTRO INSTRUCTION
Q
L 1 2 3 4 5 6
8 BIT
• It provides a full 16 bit bidirectional data bus and 20 bit address bus.
•The bus interface unit is responsible for performing all external bus operations.
Specifically it has the following functions:
•Instruction fetch, Instruction queuing, Operand fetch and storage, Address relocation and
Bus control.
•The BIU uses a mechanism known as an instruction stream queue to implement a
pipeline architecture.
•This queue permits prefetch of up to six bytes of instruction code. When ever the queue
of the BIU is not full, it has room for at least two more bytes and at the same time the EU
is not requesting it to read or write operands from memory, the BIU is free to look ahead
in the program by prefetching the next sequential instruction.
•These prefetching instructions are held in its FIFO queue. With its 16 bit data bus, the
BIU fetches two instruction bytes in a single memory cycle.
•After a byte is loaded at the input end of the queue, it automatically shifts up through the
FIFO to the empty location nearest the output.
•The EU accesses the queue from the output end. It reads one instruction byte after the
other from the output of the queue. If the queue is full and the EU is not requesting
access to operand in memory.
•These intervals of no bus activity, which may occur between bus cycles are known as
Idle state.
•If the BIU is already in the process of fetching an instruction when the EU request it to
read or write operands from memory or I/O, the BIU first completes the instruction fetch
bus cycle before initiating the operand read / write cycle.
•The BIU also contains a dedicated adder which is used to generate the 20bit physical
address that is output on the address bus. This address is formed by adding an appended
16 bit segment address and a 16 bit offset address.
•For example: The physical address of the next instruction to be fetched is formed by
combining the current contents of the code segment CS register and the current contents
of the instruction pointer IP register.
•The BIU is also responsible for generating bus control signals such as those for memory
read or write and I/O read or write.
•EXECUTION UNIT
The Execution unit is responsible for decoding and executing all instructions.
•The EU extracts instructions from the top of the queue in the BIU, decodes them,
generates operands if necessary, passes them to the BIU and requests it to perform the
read or write bys cycles to memory or I/O and perform the operation specified by the
instruction on the operands.
•During the execution of the instruction, the EU tests the status and control flags and
updates them based on the results of executing the instruction.
•If the queue is empty, the EU waits for the next instruction byte to be fetched and shifted
to top of the queue.
•When the EU executes a branch or jump instruction, it transfers control to a location
corresponding to another set of sequential instructions.
•Whenever this happens, the BIU automatically resets the queue and then begins to fetch
instructions from this new location to refill the queue.
Signal Description of 8086
•The Microprocessor 8086 is a 16-bit CPU available in different clock rates and packaged
in a 40 pin CERDIP or plastic package.
•The 8086 operates in single processor or multiprocessor configuration to achieve high
performance. The pins serve a particular function in minimum mode (single processor
mode ) and other function in maximum mode configuration (multiprocessor mode ).
•The 8086 signals can be categorised in three groups. The first are the signal having
common functions in minimum as well as maximum mode.
•The second are the signals which have special functions for minimum mode and third
are the signals having special functions for maximum mode.
•The following signal descriptions are common for both modes.
•AD15-AD0 : These are the time multiplexed memory I/O address and data lines.
• Address remains on the lines during T1 state, while the data is available on the data bus
during T2, T3, Tw and T4.
• These lines are active high and float to a tristate during interrupt acknowledge and local
bus hold acknowledge cycles.
•A19/S6,A18/S5,A17/S4,A16/S3 : These are the time multiplexed address and status lines.
• During T1 these are the most significant address lines for memory operations.
•During I/O operations, these lines are low. During memory or I/O operations, status
information is available on those lines for T2,T3,Tw and T4.
• The status of the interrupt enable flag bit is updated at the beginning of each clock
cycle.
•The S4 and S3 combinedly indicate which segment register is presently being used for
memory accesses as in below fig.
•These lines float to tri-state off during the local bus hold acknowledge. The status line S6
is always low .
•The address bit are separated from the status bit using latches controlled by the ALE
signal.
S4 S3 Indication
0 0 Alternate Data
0 1 Stack
1 0 Code or none
1 1 Data
•BHE/S7 : The bus high enable is used to indicate the transfer of data over the higher
order ( D15-D8 ) data bus as shown in table. It goes low for the data transfer over D15-D8
and is used to derive chip selects of odd address memory bank or peripherals. BHE is low
during T1 for read, write and interrupt acknowledge cycles, whenever a byte is to be
transferred on higher byte of data bus. The status information is available during T2, T3
and T4. The signal is active low and tristated during hold. It is low during T1 for the first
pulse of the interrupt acknowledge cycle.
0 0 Whole word
0 1 odd address
Upper byte from or to even address
1 0 Lower byte from or to even address
•RD – Read : This signal on low indicates the peripheral that the processor is performing
s memory or I/O read operation. RD is active low and shows the state for T2, T3, Tw of
any read cycle. The signal remains tristated during the hold acknowledge.
•READY : This is the acknowledgement from the slow device or memory that they have
completed the data transfer. The signal made available by the devices is synchronized by
the 8284A clock generator to provide ready input to the 8086. the signal is active high.
•INTR-Interrupt Request : This is a triggered input. This is sampled during the last
clock cycles of each instruction to determine the availability of the request. If any
interrupt request is pending, the processor enters the interrupt acknowledge cycle.
•This can be internally masked by resulting the interrupt enable flag. This signal is active
high and internally synchronized.
•TEST : This input is examined by a ‘WAIT’ instruction. If the TEST pin goes low,
execution will continue, else the processor remains in an idle state. The input is
synchronized internally during each clock cycle on leading edge of clock.
•CLK- Clock Input : The clock input provides the basic timing for processor operation
and bus control activity. Its an asymmetric square wave with 33% duty cycle.
•MN/MX : The logic level at this pin decides whether the processor is to operate in either
minimum or maximum mode.
•The following pin functions are for the minimum mode operation of 8086.
•INTA – Interrupt Acknowledge : This signal is used as a read strobe for interrupt
acknowledge cycles. i.e. when it goes low, the processor has accepted the interrupt.
•ALE – Address Latch Enable : This output signal indicates the availability of the valid
address on the address/data lines, and is connected to latch enable input of latches. This
signal is active high and is never tristated.
•DT/R – Data Transmit/Receive: This output is used to decide the direction of data flow
through the transreceivers (bidirectional buffers). When the processor sends out data, this
signal is high and when the processor is receiving data, this signal is low.
•DEN – Data Enable : This signal indicates the availability of valid data over the
address/data lines. It is used to enable the transreceivers ( bidirectional buffers ) to
separate the data from the multiplexed address/data signal. It is active from the middle of
T2 until the middle of T4. This is tristated during ‘ hold acknowledge’ cycle.
•HOLD, HLDA- Acknowledge : When the HOLD line goes high, it indicates to the
processor that another master is requesting the bus access.
•The processor, after receiving the HOLD request, issues the hold acknowledge signal on
HLDA pin, in the middle of the next clock cycle after completing the current bus cycle.
•At the same time, the processor floats the local bus and control lines. When the
processor detects the HOLD line low, it lowers the HLDA signal. HOLD is an
asynchronous input, and is should be externally synchronized.
•If the DMA request is made while the CPU is performing a memory or I/O cycle, it will
release the local bus during T4 provided :
1.The request occurs on or before T2 state of the current cycle.
2.The current cycle is not operating over the lower byte of a word.
3.The current cycle is not the first acknowledge of an interrupt acknowledge sequence.
•The following pin function are applicable for maximum mode operation of 8086.
•S2, S1, S0 – Status Lines : These are the status lines which reflect the type of operation,
being carried out by the processor. These become activity during T4 of the previous cycle
and active during T1 and T2 of the current bus cycles.
S2 S1 S0 Indication
0 0 0 Interrupt Acknowledge
0 0 1 Read I/O port
0 1 0 Write I/O port
0 1 1 Halt
1 0 0 Code Access
1 0 1 Read memory
1 1 0 Write memory
1 1 1 Passive
•LOCK : This output pin indicates that other system bus master will be prevented from
gaining the system bus, while the LOCK signal is low.
•The LOCK signal is activated by the ‘LOCK’ prefix instruction and remains active until
the completion of the next instruction. When the CPU is executing a critical instruction
which requires the system bus, the LOCK prefix instruction ensures that other processors
connected in the system will not gain the control of the bus.
• The 8086, while executing the prefixed instruction, asserts the bus lock signal output,
which may be connected to an external bus controller.
•RQ/GT0, RQ/GT1 – Request/Grant : These pins are used by the other local bus master
in maximum mode, to force the processor to release the local bus at the end of the
processor current bus cycle.
•Each of the pin is bidirectional with RQ/GT0 having higher priority than RQ/GT1.
•RQ/GT pins have internal pull-up resistors and may be left unconnected.
•Request/Grant sequence is as follows:
1.A pulse of one clock wide from another bus master requests the bus access to 8086.
2.During T4(current) or T1(next) clock cycle, a pulse one clock wide from 8086 to the
requesting master, indicates that the 8086 has allowed the local bus to float and that it
will enter the ‘hold acknowledge’ state at next cycle. The CPU bus interface unit is likely
to be disconnected from the local bus of the system.
3.A one clock wide pulse from the another master indicates to the 8086 that the hold
request is about to end and the 8086 may regain control of the local bus at the next clock
cycle. Thus each master to master exchange of the local bus is a sequence of 3 pulses.
There must be at least one dead clock cycle after each bus exchange.
•The request and grant pulses are active low.
•For the bus request those are received while 8086 is performing memory or I/O cycle,
the granting of the bus is governed by the rules as in case of HOLD and HLDA in
minimum mode.
•The 8086 has a combined address and data bus commonly referred as a time multiplexed
address and data bus.
• The main reason behind multiplexing address and data over the same pins is the
maximum utilisation of processor pins and it facilitates the use of 40 pin standard DIP
package.
•The bus can be demultiplexed using a few latches and transreceivers, when ever
required.
•Basically, all the processor bus cycles consist of at least four clock cycles. These are
referred to as T1, T2, T3, T4. The address is transmitted by the processor during T1. It is
present on the bus only for one cycle.
•The negative edge of this ALE pulse is used to separate the address and the data or status
information. In maximum mode, the status lines S0, S1 and S2 are used to indicate the
type of operation.
•Status bits S3 to S7 are multiplexed with higher order address bits and the BHE signal.
Address is valid during T1 while status bits S3 to S7 are valid during T2 through T4.
ALE
S2 – S 0
A19-A16 S3-S7 A19-A16 S3-S7
Add/stat
BHE Bus reserve BHE
Add/data for Data In Data Out D15 – D0
A0-A15 D15-D0 A0-A15 D15-D0
RD/INTA
Ready
READY Ready
DT/R Wait Wait
DEN
•In a minimum mode 8086 system, the microprocessor 8086 is operated in minimum
mode by strapping its MN/MX pin to logic 1.
•In this mode, all the control signals are given out by the microprocessor chip itself.
There is a single microprocessor in the minimum mode system.
•The remaining components in the system are latches, transreceivers, clock generator,
memory and I/O devices. Some type of chip selection logic may be required for selecting
memory or I/O devices, depending upon the address map of the system.
•Latches are generally buffered output D-type flip-flops like 74LS373 or 8282. They are
used for separating the valid address from the multiplexed address/data signals and are
controlled by the ALE signal generated by 8086.
•Transreceivers are the bidirectional buffers and some times they are called as data
amplifiers. They are required to separate the valid data from the time multiplexed
address/data signals.
•They are controlled by two signals namely, DEN and DT/R.
•The DEN signal indicates the direction of data, i.e. from or to the processor. The system
contains memory for the monitor and users program storage.
•Usually, EPROM are used for monitor storage, while RAM for users program storage. A
system may contain I/O devices.
•
•The working of the minimum mode configuration system can be better described in
terms of the timing diagrams rather than qualitatively describing the operations.
•The opcode fetch and read cycles are similar. Hence the timing diagram can be
categorized in two parts, the first is the timing diagram for read cycle and the second is
the timing diagram for write cycle.
•The read cycle begins in T1 with the assertion of address latch enable (ALE) signal and
also M / IO signal. During the negative going edge of this signal, the valid address is
latched on the local bus.
•The BHE and A0 signals address low, high or both bytes. From T1 to T4 , the M/IO
signal indicates a memory or I/O operation.
•At T2, the address is removed from the local bus and is sent to the output. The bus is
then tristated. The read (RD) control signal is also activated in T2.
•The read (RD) signal causes the address device to enable its data bus drivers. After RD
goes low, the valid data is available on the data bus.
•The addressed device will drive the READY line high. When the processor returns the
read signal to high level, the addressed device will again tristate its bus drivers.
•A write cycle also begins with the assertion of ALE and the emission of the address. The
M/IO signal is again asserted to indicate a memory or I/O operation. In T2, after sending
the address in T1, the processor sends the data to be written to the addressed location.
•The data remains on the bus until middle of T4 state. The WR becomes active at the
beginning of T2 (unlike RD is somewhat delayed in T2 to provide time for floating).
•The BHE and A0 signals are used to select the proper byte or bytes of memory or I/O
word to be read or write.
•The M/IO, RD and WR signals indicate the type of data transfer as specified in table
below.
T1 T2 T3 TW T4 T1
Clk
ALE
BHE S7 – S3
ADD / STATUS A19 – A16
WR
DEN
DT / R
•Hold Response sequence: The HOLD pin is checked at leading edge of each clock
pulse. If it is received active by the processor before T4 of the previous cycle or during T1
state of the current cycle, the CPU activates HLDA in the next clock cycle and for
succeeding bus cycles, the bus will be given to another requesting master.
•The control of the bus is not regained by the processor until the requesting master does
not drop the HOLD pin low. When the request is dropped by the requesting master, the
HLDA is dropped by the processor at the trailing edge of the next clock.
Clk
HOLD
HLDA
•In the maximum mode, the 8086 is operated by strapping the MN/MX pin to ground.
•In this mode, the processor derives the status signal S2, S1, S0. Another chip called bus
controller derives the control signal using this status information .
•In the maximum mode, there may be more than one microprocessor in the system
configuration.
•The components in the system are same as in the minimum mode system.
•The basic function of the bus controller chip IC8288, is to derive control signals like RD
and WR ( for memory and I/O devices), DEN, DT/R, ALE etc. using the information by
the processor on the status lines.
•The bus controller chip has input lines S2, S1, S0 and CLK. These inputs to 8288 are
driven by CPU.
•It derives the outputs ALE, DEN, DT/R, MRDC, MWTC, AMWC, IORC, IOWC and
AIOWC. The AEN, IOB and CEN pins are specially useful for multiprocessor systems.
•
•AEN and IOB are generally grounded. CEN pin is usually tied to +5V. The significance
of the MCE/PDEN output depends upon the status of the IOB pin.
•If IOB is grounded, it acts as master cascade enable to control cascade 8259A, else it
acts as peripheral data enable used in the multiple bus configurations.
•INTA pin used to issue two interrupt acknowledge pulses to the interrupt controller or to
an interrupting device.
•IORC, IOWC are I/O read command and I/O write command signals respectively .
These signals enable an IO interface to read or write the data from or to the address port.
•The MRDC, MWTC are memory read command and memory write command signals
respectively and may be used as memory read or write signals.
•All these command signals instructs the memory to accept or send data from or to the
bus.
•For both of these write command signals, the advanced signals namely AIOWC and
AMWTC are available.
•Here the only difference between in timing diagram between minimum mode and
maximum mode is the status signals used and the available control and advanced
command signals.
Clk DEN
S0 DT/ R Control bus
S1 8288 IORC
S2 IOWT
AEN MWTC
Reset Reset S0
Clk IOB
S1 CEN AL MRDC
Generator Clk
S2
RDY 8284 Ready + 5V
8086
CLK
AD6-AD15 A/D Address bus
A16-A19 Latches
A
dd
DT/R bu
BHE A0
DIR
Data CS0H CS0L RD CS WR RD
buffer WR
DEN G Memory Peripheral
Data bus
•R0, S1, S2 are set at the beginning of bus cycle.8288 bus controller will output a pulse as
on the ALE and apply a required signal to its DT / R pin during T1.
•In T2, 8288 will set DEN=1 thus enabling transceivers, and for an input it will activate
MRDC or IORC. These signals are activated until T4. For an output, the AMWC or
AIOWC is activated from T2 to T4 and MWTC or IOWC is activated from T3 to T4.
•The status bit S0 to S2 remains active until T3 and become passive during T3 and T4.
•If reader input is not activated before T3, wait state will be inserted between T3 and T4.
•Timings for RQ/ GT Signals :
The request/grant response sequence contains a series of three pulses. The request/grant
pins are checked at each rising pulse of clock input.
•When a request is detected and if the condition for HOLD request are satisfied, the
processor issues a grant pulse over the RQ/GT pin immediately during T4 (current) or T1
(next) state.
•When the requesting master receives this pulse, it accepts the control of the bus, it sends
a release pulse to the processor using RQ/GT pin.
Clk
ALE
MRDC
DT / R
DEN
Clk
ALE
ADD/STATUS BHE S7 – S3
MWTC or IOWC
DT / R high
DEN
RQ / GT
INTR
A0-A15,A16/S3 – A19/S6
INTA
Interrupt
Address / data bus
interface
TEST
D0 – D15
NMI
8086
MPU ALE
RESET
BHE / S7
M / IO Memory I/O
DMA HOLD controls
DT / R
interface
HLDA RD
WR
Vcc
DEN
Mode select
READY
MN / MX
CLK clock
•Status signal:
The four most significant address lines A19 through A16 are also multiplexed but in this
case with status signals S6 through S3. These status bits are output on the bus at the same
time that data are transferred over the other bus lines.
•Bit S4 and S3 together from a 2 bit binary code that identifies which of the 8086 internal
segment registers are used to generate the physical address that was output on the address
bus during the current bus cycle.
•Code S4S3 = 00 identifies a register known as extra segment register as the source of the
segment address.
•Status line S5 reflects the status of another internal characteristic of the 8086. It is the
logic level of the internal enable flag. The last status bit S6 is always at the logic 0 level.
S4 S3 Segment Register
0 0 Extra
0 1 Stack
1 0 Code / none
1 1 Data
•Control Signals :
The control signals are provided to support the 8086 memory I/O interfaces. They
control functions such as when the bus is to carry a valid address in which direction data
are to be transferred over the bus, when valid write data are on the bus and when to put
read data on the system bus.
•ALE is a pulse to logic 1 that signals external circuitry when a valid address word is on
the bus. This address must be latched in external circuitry on the 1-to-0 edge of the pulse
at ALE.
•Another control signal that is produced during the bus cycle is BHE bank high enable.
Logic 0 on this used as a memory enable signal for the most significant byte half of the
data bus D8 through D1. These lines also serves a second function, which is as the S7
status line.
•Using the M/IO and DT/R lines, the 8086 signals which type of bus cycle is in progress
and in which direction data are to be transferred over the bus.
•The logic level of M/IO tells external circuitry whether a memory or I/O transfer is
taking place over the bus. Logic 1 at this output signals a memory operation and logic 0
an I/O operation.
•The direction of data transfer over the bus is signaled by the logic level output at DT/R.
When this line is logic 1 during the data transfer part of a bus cycle, the bus is in the
transmit mode. Therefore, data are either written into memory or output to an I/O device.
•On the other hand, logic 0 at DT/R signals that the bus is in the receive mode. This
corresponds to reading data from memory or input of data from an input port.
•The signal read RD and write WR indicates that a read bus cycle or a write bus cycle is
in progress. The 8086 switches WR to logic 0 to signal external device that valid write or
output data are on the bus.
• On the other hand, RD indicates that the 8086 is performing a read of data of the bus.
During read operations, one other control signal is also supplied. This is DEN ( data
enable) and it signals external devices when they should put data on the bus.
•There is one other control signal that is involved with the memory and I/O interface.
This is the READY signal.
•READY signal is used to insert wait states into the bus cycle such that it is extended by
a number of clock periods. This signal is provided by an external clock generator device
and can be supplied by the memory or I/O sub-system to signal the 8086 when they are
ready to permit the data transfer to be completed.
•Interrupt signals : The key interrupt interface signals are interrupt request (INTR) and
interrupt acknowledge ( INTA).
•INTR is an input to the 8086 that can be used by an external device to signal that it need
to be serviced.
•Logic 1 at INTR represents an active interrupt request. When an interrupt request has
been recognized by the 8086, it indicates this fact to external circuit with pulse to logic 0
at the INTA output.
•The TEST input is also related to the external interrupt interface. Execution of a WAIT
instruction causes the 8086 to check the logic level at the TEST input.
•If the logic 1 is found, the MPU suspend operation and goes into the idle state. The 8086
no longer executes instructions, instead it repeatedly checks the logic level of the TEST
input waiting for its transition back to logic 0.
•As TEST switches to 0, execution resume with the next instruction in the program. This
feature can be used to synchronize the operation of the 8086 to an event in external
hardware.
•There are two more inputs in the interrupt interface: the nonmaskable interrupt NMI and
the reset interrupt RESET.
•On the 0-to-1 transition of NMI control is passed to a nonmaskable interrupt service
routine. The RESET input is used to provide a hardware reset for the 8086. Switching
RESET to logic 0 initializes the internal register of the 8086 and initiates a reset service
routine.
•DMA Interface signals :The direct memory access DMA interface of the 8086
minimum mode consist of the HOLD and HLDA signals.
•When an external device wants to take control of the system bus, it signals to the 8086
by switching HOLD to the logic 1 level. At the completion of the current bus cycle, the
8086 enters the hold state. In the hold state, signal lines AD0 through AD15, A16/S3
through A19/S6, BHE, M/IO, DT/R, RD, WR, DEN and INTR are all in the high Z state.
The 8086 signals external device that it is in this state by switching its HLDA output to
logic 1 level.
•When the 8086 is set for the maximum-mode configuration, it provides signals for
implementing a multiprocessor / coprocessor system environment.
•By multiprocessor environment we mean that one microprocessor exists in the system
and that each processor is executing its own program.
• Usually in this type of system environment, there are some system resources that are
common to all processors.
•They are called as global resources. There are also other resources that are assigned to
specific processors. These are known as local or private resources.
•Coprocessor also means that there is a second processor in the system. In this two
processor does not access the bus at the same time.
•One passes the control of the system bus to the other and then may suspend its operation.
•In the maximum-mode 8086 system, facilities are provided for implementing allocation
of global resources and passing bus control to other microprocessor or coprocessor.
INIT
Multi Bus
S0 BUSY
S1 CBRQ
S2 8289 BPRO
LOCK Bus BPRN
CRQLCK
CLK RESB BREQ
Vcc GND SYSB/RESB
ANYREQ CLK AEN IOB BCLK
8086 does not directly provide all the signals that are required to control the memory,
I/O and interrupt interfaces.
•Specially the WR, M/IO, DT/R, DEN, ALE and INTA, signals are no longer produced
by the 8086. Instead it outputs three status signals S0, S1, S2 prior to the initiation of each
bus cycle. This 3- bit bus status code identifies which type of bus cycle is to follow.
•S2S1S0 are input to the external bus controller device, the bus controller generates the
appropriately timed command and control signals.
Status Inputs
CPU Cycles 8288
S2 S1 S0 Command
0 0 0 Interrupt Acknowledge INTA
0 0 1 Read I/O Port IORC
0 1 0 Write I/O Port IOWC, AIOWC
0 1 1 Halt None
1 0 0 Instruction Fetch MRDC
•The 8288 produces one or two of these eight command signals for each bus cycles. For
instance, when the 8086 outputs the code S2S1S0 equals 001, it indicates that an I/O read
cycle is to be performed.
•In the code 111 is output by the 8086, it is signaling that no bus activity is to take place.
•The control outputs produced by the 8288 are DEN, DT/R and ALE. These 3 signals
provide the same functions as those described for the minimum system mode. This set of
bus commands and control signals is compatible with the Multibus and industry standard
for interfacing microprocessor systems.
•The output of 8289 are bus arbitration signals:
Bus busy (BUSY), common bus request (CBRQ), bus priority out (BPRO), bus priority
in (BPRN), bus request (BREQ) and bus clock (BCLK).
•They correspond to the bus exchange signals of the Multibus and are used to lock other
processor off the system bus during the execution of an instruction by the 8086.
•In this way the processor can be assured of uninterrupted access to common system
resources such as global memory.
•Queue Status Signals : Two new signals that are produced by the 8086 in the
maximum-mode system are queue status outputs QS0 and QS1. Together they form a 2-bit
queue status code, QS1QS0.
•Following table shows the four different queue status.
•The 8086 has four groups of the user accessible internal registers. They are the
instruction pointer, four data registers, four pointer and index register, four segment
registers.
•The 8086 has a total of fourteen 16-bit registers including a 16 bit register called the
status register, with 9 of bits implemented for status and control flags.
•Most of the registers contain data/instruction offsets within 64 KB memory segment.
There are four different 64 KB segments for instructions, stack, data and extra data. To
specify where in 1 MB of processor memory these 4 segments are located the processor
uses four segment registers:
•Code segment (CS) is a 16-bit register containing address of 64 KB segment with
processor instructions. The processor uses CS segment for all accesses to instructions
referenced by instruction pointer (IP) register. CS register cannot be changed directly.
The CS register is automatically updated during far jump, far call and far return
instructions.
•Stack segment (SS) is a 16-bit register containing address of 64KB segment with
program stack. By default, the processor assumes that all data referenced by the stack
pointer (SP) and base pointer (BP) registers is located in the stack segment. SS register
can be changed directly using POP instruction.
•Data segment (DS) is a 16-bit register containing address of 64KB segment with
program data. By default, the processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment.
DS register can be changed directly using POP and LDS instructions.
•Accumulator register consists of two 8-bit registers AL and AH, which can be
combined together and used as a 16-bit register AX. AL in this case contains the low-
order byte of the word, and AH contains the high-order byte. Accumulator can be used
for I/O operations and string manipulation.
•Base register consists of two 8-bit registers BL and BH, which can be combined together
and used as a 16-bit register BX. BL in this case contains the low-order byte of the word,
and BH contains the high-order byte. BX register usually contains a data pointer used for
based, based indexed or register indirect addressing.
•Count register consists of two 8-bit registers CL and CH, which can be combined
together and used as a 16-bit register CX. When combined, CL register contains the low-
order byte of the word, and CH contains the high-order byte. Count register can be used
in Loop, shift/rotate instructions and as a counter in string manipulation,.
•Data register consists of two 8-bit registers DL and DH, which can be combined
together and used as a 16-bit register DX. When combined, DL register contains the low-
order byte of the word, and DH contains the high-order byte. Data register can be used as
a port number in I/O operations. In integer 32-bit multiply and divide instruction the DX
register contains high-order word of the initial or resulting number.
•The following registers are both general and index registers:
•Stack Pointer (SP) is a 16-bit register pointing to program stack.
•Base Pointer (BP) is a 16-bit register pointing to data in stack segment. BP register is
usually used for based, based indexed or register indirect addressing.
•Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and register
indirect addressing, as well as a source data address in string manipulation instructions.
•Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and
register indirect addressing, as well as a destination data address in string manipulation
instructions.
Other registers:
•Instruction Pointer (IP) is a 16-bit register.
•Flags is a 16-bit register containing 9 one bit flags.
•Overflow Flag (OF) - set if the result is too large positive number, or is too small
negative number to fit into destination operand.
•Direction Flag (DF) - if set then string manipulation instructions will auto-decrement
index registers. If cleared then the index registers will be auto-incremented.
•Interrupt-enable Flag (IF) - setting this bit enables maskable interrupts.
•Single-step Flag (TF) - if set then single-step interrupt will occur after the next
instruction.
•Sign Flag (SF) - set if the most significant bit of the result is set.
•Zero Flag (ZF) - set if the result is zero.
•Auxiliary carry Flag (AF) - set if there was a carry from or borrow to bits 0-3 in the AL
register.
•Parity Flag (PF) - set if parity (the number of "1" bits) in the low-order byte of the
result is even.
•Carry Flag (CF) - set if there was a carry from or borrow to the most significant bit
during last result calculation.
Addressing Modes
•Implied - the data value/data address is implicitly associated with the instruction.
•Register - references the data in a register or in a register pair.
•Immediate - the data is provided in the instruction.
•Direct - the instruction operand specifies the memory address where data is located.
•Register indirect - instruction specifies a register containing an address, where data is
located. This addressing mode works with SI, DI, BX and BP registers.
•Based :- 8-bit or 16-bit instruction operand is added to the contents of a base register
(BX or BP), the resulting value is a pointer to location where data resides.
•Indexed :- 8-bit or 16-bit instruction operand is added to the contents of an index
register (SI or DI), the resulting value is a pointer to location where data resides.
•Based Indexed :- the contents of a base register (BX or BP) is added to the contents of
an index register (SI or DI), the resulting value is a pointer to location where data resides.
•Based Indexed with displacement :- 8-bit or 16-bit instruction operand is added to the
contents of a base register (BX or BP) and index register (SI or DI), the resulting value is
a pointer to location where data resides.
Memory
•Program, data and stack memories occupy the same memory space. As the most of the
processor instructions use 16-bit pointers the processor can effectively address only 64
KB of memory.
• To access memory outside of 64 KB the CPU uses special segment registers to specify
where the code, stack and data 64 KB segments are positioned within 1 MB of memory
(see the "Registers" section below).
•16-bit pointers and data are stored as:
address: low-order byte
address+1: high-order byte
•Program memory - program can be located anywhere in memory. Jump and call
instructions can be used for short jumps within currently selected 64 KB code segment,
as well as for far jumps anywhere within 1 MB of memory.
•All conditional jump instructions can be used to jump within approximately +127 to -
127 bytes from current instruction.
•Data memory - the processor can access data in any one out of 4 available segments,
which limits the size of accessible memory to 256 KB (if all four segments point to
different 64 KB blocks).
•Accessing data from the Data, Code, Stack or Extra segments can be usually done by
prefixing instructions with the DS:, CS:, SS: or ES: (some registers and instructions by
default may use the ES or SS segments instead of DS segment).
•Word data can be located at odd or even byte boundaries. The processor uses two
memory accesses to read 16-bit word located at odd byte boundaries. Reading word data
from even byte boundaries requires only one memory access.
•Stack memory can be placed anywhere in memory. The stack can be located at odd
memory addresses, but it is not recommended for performance reasons (see "Data
Memory" above).
Reserved locations:
•0000h - 03FFh are reserved for interrupt vectors. Each interrupt vector is a 32-bit pointer
in format segment: offset.
•FFFF0h - FFFFFh - after RESET the processor always starts program execution at the
FFFF0h address.
Interrupts
The processor has the following interrupts:
•INTR is a maskable hardware interrupt. The interrupt can be enabled/disabled using
STI/CLI instructions or using more complicated method of updating the FLAGS register
with the help of the POPF instruction.
• When an interrupt occurs, the processor stores FLAGS register into stack, disables
further interrupts, fetches from the bus one byte representing interrupt type, and jumps to
interrupt processing routine address of which is stored in location 4 * <interrupt type>.
Interrupt processing routine should return with the IRET instruction.
•NMI is a non-maskable interrupt. Interrupt is processed in the same way as the INTR
interrupt. Interrupt type of the NMI is 2, i.e. the address of the NMI processing routine is
stored in location 0008h. This interrupt has higher priority then the maskable interrupt.
•Software interrupts can be caused by:
•INT instruction - breakpoint interrupt. This is a type 3 interrupt.
•INT <interrupt number> instruction - any one interrupt from available 256 interrupts.
•INTO instruction - interrupt on overflow
•Single-step interrupt - generated if the TF flag is set. This is a type 1 interrupt. When the
CPU processes this interrupt it clears TF flag before calling the interrupt processing
routine.
•Processor exceptions: Divide Error (Type 0), Unused Opcode (type 6) and Escape
opcode (type 7).
•Software interrupt processing is the same as for the hardware interrupts.
M. Krishna Kumar MAM/M7/MKK18/V1/2004 1
Contents
Description of Instructions
Assembly directives
¾ Example:
MOV AH,0 ;Clear AH for MSD
MOV AL,6 ;BCD 6 in AL
ADD AL,5 ;Add BCD 5 to digit in AL
AAA ;AH=1, AL=1 representing BCD 11.
MOV AL, 5
MOV BL, 7
MUL BL ;Multiply AL by BL , result in AX
AAM ;After AAM, AX =0305h (BCD 35)
¾ CMPS/CMPSB/
CMPSW Instruction - Compare string bytes or
string words
Example :
CLD ;Clear direction flag so that string pointers
;auto increment
¾ ESC Instruction
; - 28 * 59
; AL = 11100100 = - 28 decimal
;BL = 00001110 = 14 decimal
IMUL BL ;AX = F98Ch = - 1652 decimal
; MSB = 1 because negative result
¾ Example:
; AX = 7FFFh
INC AX ;After this instruction AX = 8000h
¾ JAE/JNB/
JNC Instructions - Jump if above or equal/
Jump if not below/
Jump if no carry.
¾ LODS/LODSB/
LODSW Instruction - Load string byte into AL or
Load string word into AX.
¾ LOOPE /
LOOPZ Instruction - loop while CX ≠ 0 and
ZF = 1
¾ MOVS/MOVSB/
MOVSW Instruction - Move string byte or string
word-MOVS destination,
source
¾ MUL Instruction - Multiply unsigned bytes or
words-MUL source
Example :
;DX =F038h
NOT DX ;after the instruction DX = 0FC7h
¾ Example:
PUSH BX ;Decrement SP by 2 and copy BX to stack
PUSH DS ;Decrement SP by 2 and copy DS to stack
PUSH TABLE[BX] ;Decrement SP by 2 and copy word
;from memory in DS at
;EA = TABLE + [BX] to stack .
( 2) ;CF = 1, BL = 00111000
RCR BL, 1 ;Result: BL = 10011100, CF =0
;OF = 1 because MSB is changed to 1.
¾ STOS/STOSB/
STOSW Instruction - Store byte or word in string.
¾ XLAT/
XLATB Instruction - Translate a byte in AL
¾ DB - Defined Byte.
¾ DW - Define Word
¾ EQU - Equate
¾ EXTRN
¾ LABLE
¾ NAME
¾ OFFSET
¾ ORG - Originate
¾ PTR - Pointer
¾ PUBLC
¾ SEGMENT
¾ SHORT
¾ TYPE
Description of Instructions
Assembly directives
MOV
PUSH
POP
XCHG
XLAT
IN
OUT
LEA
LDS
LES
LAHF
SAHF
PUSHF
POPF
ARITHMETIC INSTRUCTIONS
ADITION INSTRUCTIONS:
ADD
ADC
INC
AAA
DAA
SUBTRACTION INSTRUCTIONS:
SUB
SBB
DEC
NEG
CMP
AAS
DAS
MULTIPLICATION INSTRUCTIONS:
MUL
IMUL
AAM
DIVISION INSTRUCTIONS:
DIV
IDIV
AAD
CBW
CWD
NOT
AND
OR
XOR
TEST
SHIFT INSTRUCTIONS:
SHL / SAL
SHR
SAR
RPTATE INSTRUCTIONS:
ROL
ROR
RCL
RCR
STRING INSTRUCTIONS
REP
REPE / REPZ
REPNE / REPNZ
MOVS / MOVSB / MOVSW
COMPS / COMPSB / COMPSW
SCAS / SCASB / SCASW
LODS / LODSB / LODSW
STOS / STOSB / STOSW
CALL
RET
JMP
JA / JNBE
JAE / JNB
JB / JNAE
JBE / JNA
JC
JE / JZ
JG / JNLE
JGE / JNL
JL / JNGE
JLE / JNG
JNC
JNE / JNZ
JNO
JNP / JPO
JNS
JO
JP / JPE
JS
LOOP
LOOPE / LOOPZ
LOOPNE / LOOPNZ
JCXZ
INTERRUPT INSTRUCTIONS:
INT
INTO
IRET
STC
CLC
CMC
STD
CLD
STI
CLI
HLT
WAIT
ESC
LOCK
NOP
Instruction Description
AAA Instruction - ASCII Adjust after Addition
Example
AAA Instruction - AAA converts the result of the addition of two valid
unpacked BCD digits to a valid 2-digit BCD number and takes the AL register as its
implicit operand.
Two operands of the addition must have its lower 4 bits
contain a number in the range from 0-9.The AAA instruction then adjust AL so that it
contains a correct BCD digit. If the addition produce carry (AF=1), the AH register is
incremented and the carry CF and auxiliary carry AF flags are set to 1. If the addition did
not produce a decimal carry, CF and AF are cleared to 0 and AH is not altered. In both
cases the higher 4 bits of AL are cleared to 0.
AAA will adjust the result of the two ASCII characters that were in the
range from 30h (“0”) to 39h(“9”).This is because the lower 4 bits of those character fall
in the range of 0-9.The result of addition is not a ASCII character but it is a BCD digit.
•
Example:
MOV AH,0 ;Clear AH for MSD
MOV AL,6 ;BCD 6 in AL
ADD AL,5 ;Add BCD 5 to digit in AL
AAA ;AH=1, AL=1 representing BCD 11.
Example:
;AX=0607 unpacked BCD for 67 decimal
;CH=09H
AAD ;Adjust to binary before division
;AX=0043 = 43H =67 decimal
DIV CH ;Divide AX by unpacked BCD in CH
;AL = quotient = 07 unpacked BCD
;AH = remainder = 04 unpacked BCD
AAM Instruction - AAM converts the result of the multiplication of two valid
unpacked BCD digits into a valid 2-digit unpacked BCD number and takes AX as an
implicit operand.
To give a valid result the digits that have been multiplied must be
in the range of 0 – 9 and the result should have been placed in the AX register. Because
both operands of multiply are required to be 9 or less, the result must be less than 81 and
thus is completely contained in AL.
AAM unpacks the result by dividing AX by 10, placing the
quotient (MSD) in AH and the remainder (LSD) in AL.
Example:
MOV AL, 5
MOV BL, 7
MUL BL ;Multiply AL by BL , result in AX
AAM ;After AAM, AX =0305h (BCD 35)
AAS Instruction - AAS converts the result of the subtraction of two valid
unpacked BCD digits to a single valid BCD number and takes the AL register as an
implicit operand. The two operands of the subtraction must have its lower 4 bit contain
number in the range from 0 to 9 .The AAS instruction then adjust AL so that it contain a
correct BCD digit.
(a)
EXAMPLE:
AND Instruction - This Performs a bitwise Logical AND of two operands. The
result of the operation is stored in the op1 and used to set the flags.
AND op1, op2
To perform a bitwise AND of the two operands, each bit of the result is
set to 1 if and only if the corresponding bit in both of the operands is 1, otherwise the bit
in the result I cleared to 0 .
CALL Instruction
Example
CALL Instruction - This Instruction is used to transfer execution to a
subprogram or procedure. There are two basic types of CALL ’s : Near and Far.
A Near CALL is a call to a procedure which is in the same
code segment as the CALL instruction .
When 8086 executes the near CALL instruction it decrements the stack pointer by two
and copies the offset of the next instruction after the CALL on the stack. This offset
saved on the stack is referred as the return address, because this is the address that
execution will returns to after the procedure executes. A near CALL instruction will also
load the instruction pointer with the offset of the first instruction in the procedure.
A RET instruction at the end of the procedure will return execution to the
instruction after the CALL by coping the offset saved on the stack back to IP.
A Far CALL is a call to a procedure which is in a different
from that which contains the CALL instruction . When 8086 executes the Far CALL
instruction it decrements the stack pointer by two again and copies the content of CS
register to the stack. It then decrements the stack pointer by two again and copies the
offset contents offset of the instruction after the CALL to the stack. Finally it loads CS
with segment base of the segment which contains the procedure and IP with the offset of
the first instruction of the procedure in segment. A RET instruction at end of procedure
will return to the next instruction after the CALL by restoring the saved CS and IP from
the stack.
CBW Instruction - CBW converts the signed value in the AL register into an
equivalent 16 bit signed value in the AX register by duplicating the sign bit to the left.
This instruction copies the sign of a byte in AL to all the
bits in AH. AH is then said to be the sign extension of AL.
Example:
; AX = 00000000 10011011 = - 155 decimal
CBW ; Convert signed byte in AL to signed word in AX.
; Result in AX = 11111111 10011011
; = - 155 decimal
CLC Instruction - CLC clear the carry flag ( CF ) to 0 This instruction has no
affect on the processor, registers, or other flags. It is often used to clear the CF before
returning from a procedure to indicate a successful termination. It is also use to clear the
CF during rotate operation involving the CF such as ADC, RCL, RCR .
Example:
CLC ;Clear carry flag.
CLD Instruction - This instruction reset the designation flag to zero. This
instruction has no effect on the registers or other flags. When the direction flag is cleared
/ reset SI and DI will automatically be incremented when one of the string instruction
such as MOVS, CMPS, SCAS,MOVSB and STOSB executes.
Example :
CLI Instruction - This instruction resets the interrupt flag to zero. No other
flags are affected. If the interrupt flag is reset , the 8086 will not respond to an interrupt
signal on its INTR input. This CLI instruction has no effect on the nonmaskable interrupt
input, NMI
CMC Instruction - If the carry flag CF is a zero before this instruction, it will
be set to a one after the instruction. If the carry flag is one before this instruction, it will
be reset to a zero after the instruction executes. CMC has no effect on other flags.
Example:
CMC ;Invert the carry flag.
CWD Instruction - CWD converts the 16 bit signed value in the AX register
into an equivalent 32 bit signed value in DX: AX register pair by duplicating the sign bit
to the left.
The CWD instruction sets all the bits in the DX register to
the same sign bit of the AX register. The effect is to create a 32- bit signed result that has
same integer value as the original 16 bit operand.
Example:
Example:
ESC Instruction
Example:
DIV CX ; (Quotient) AX= (DX:AX)/CX
: (Reminder) DX=(DX:AX)%CX
For DIV the dividend must always be in AX or DX and AX, but
the source of the divisor can be a register or a memory location specified by one of the 24
addressing modes.
If you want to divide a byte by a byte, you must first put
the dividend byte in AL and fill AH with all 0’s . The SUB AH,AH instruction is a quick
way to do.
If you want to divide a word by a word, put the dividend
word in AX and fill DX with all 0’s. The SUB DX,DX instruction does this quickly.
HALT Instruction - The HLT instruction will cause the 8086 to stop fetching
and executing instructions. The 8086 will enter a halt state. The only way to get the
processor out of the halt state are with an interrupt signal on the INTR pin or an interrupt
signal on NMI pin or a reset signal on the RESET input .
IDIV Instruction - This instruction is used to divide a signed word by a signed
byte or to divide a signed double word by a signed word.
Example:
IMUL op1, op2 ;In this form op1 is always be a register operand and op2
may be a register or a memory operand.
Example:
Example:
; 69 * 14
; AL = 01000101 = 69 decimal
; BL = 00001110 = 14 decimal
IMUL BL ;AX = 03C6H = + 966 decimal
;MSB = 0 because positive result
; - 28 * 59
; AL = 11100100 = - 28 decimal
;BL = 00001110 = 14 decimal
IMUL BL ;AX = F98Ch = - 1652 decimal
; MSB = 1 because negative result
Example:
Example:
INC Instruction - INC instruction adds one to the operand and sets the flag
according to the result. INC instruction is treated as an unsigned binary number.
Example:
; AX = 7FFFh
INC AX ;After this instruction AX = 8000h
JAE/JNB/
JNC Instructions - Jump if above or equal/ Jump if not below/
Jump if no carry.
JA / JNBE - This instruction performs the Jump if above (or) Jump if not
below or equal operations according to the condition, if CF and ZF = 0 .
Example: ( 1 )
CMP AX, 4371H ;Compare by subtracting 4371H
;from AX
JA RUN_PRESS ;Jump to label RUN_PRESS if
;AX above 4371H
(2)
CMP AX, 4371H ;Compare ( AX – 4371H)
JNBE RUN_PRESS ;Jump to label RUN_PRESS if
;AX not below or equal to 4371H
JAE / JNB / JNC - This instructions performs the Jump if above or equal,
Jump if not below, Jump if no carry operations according to the condition, if CF = 0.
Examples:
Example:
Example:
Example:
Example:
Example:
CMP BL, 39H ;Compare by subtracting
;39H from BL
JG NEXT1 ;Jump to label if BL is
;more positive than 39H
Example:
Example:
Example:
Example:
Example:
ADD AL, BL ; Add signed bytes in AL and BL
JNO DONE ;Process done if no overflow -
MOV AL, 00H ;Else load error code in AL
DONE: OUT 24H, AL ; Send result to display
Example:
IN AL, 0F8H ;Read ASCII char from UART
OR AL, AL ;Set flags
JPO ERROR1 ;If even parity executed, if not
;send error message
Example:
Example:
Example:
LAHF Instruction - LAHF instruction copies the value of SF, ZF, AF,
PF, CF, into bits of 7, 6, 4, 2, 0 respectively of AH register. This LAHF instruction was
provided to make conversion of assembly language programs written for 8080 and 8085
to 8086 easier.
Example:
Example:
LODS/LODSB/
LODSW Instruction - Load string byte into AL or
Load string word into AX.
LOOPE /
LOOPZ Instruction - loop while CX ≠ 0 and
ZF = 1
Example:
Example:
MOV BX, OFFSET PRICE
;Point BX at first element in array
MOV CX, 40 ;Load CX with number of
;elements in array
NEXT: MOV AL, [BX] ; Get elements from array
ADD AL, 07H ;Ad correction factor
DAA ; decimal adjust result
MOV [BX], AL ; Put result back in array
LOOP NEXT ; Repeat until all elements
;adjusted.
Example:
MOV BX, OFFSET ARRAY
;point BX at start of the array
DEC BX
MOV CX, 100 ;put number of array elements in
;CX
NEXT:INC BX ;point to next element in array
CMP [BX], 0FFH ;Compare array elements FFH
LOOP NEXT
Example:
MOVS/MOVSB/
MOVSW Instruction - Move string byte or string
word-MOVS destination, source
MUL Instruction - Multiply unsigned bytes or
words-MUL source
Example:
NOP Instruction - This instruction simply uses up the three clock cycles and
increments the instruction pointer to point to the next instruction. NOP does not
change the status of any flag. The NOP instruction is used to increase the delay of a
delay loop.
NOT Instruction - NOT perform the bitwise complement of op and stores the
result back into op.
NOT op
Example :
;DX =F038h
NOT DX ;after the instruction DX = 0FC7h
Examples :
OUT Instruction - The OUT instruction copies a byte from AL or a word from
AX or a double from the accumulator to I/O port specified by op. Two forms of OUT
instruction are available : (1) Port number is specified by an immediate byte constant, ( 0
- 255 ).It is also called as fixed port form. (2) Port number is provided in the DX register
( 0 – 65535 )
Example: (1)
(2)
MOV DX, 0FFF8H;Load desired port address in DX
OUT DX, AL ; Copy the contents of AL to
;FFF8h
OUT DX, AX ;Copy content of AX to port
;FFF8H
POP Instruction - POP instruction copies the word at the current top of the
stack to the operand specified by op then increments the stack pointer to point to the next
stack.
Example:
POPF Instruction - This instruction copies a word from the two memory
location at the top of the stack to flag register and increments the stack pointer by 2.
PUSH Instruction - PUSH instruction decrements the stack pointer by 2 and
copies a word from a specified source to the location in the stack segment where the stack
pointer pointes.
Example:
PUSH BX ;Decrement SP by 2 and copy BX to stack
PUSH DS ;Decrement SP by 2 and copy DS to stack
PUSH TABLE[BX] ;Decrement SP by 2 and copy word
;from memory in DS at
;EA = TABLE + [BX] to stack .
Example:
CLC ;put 0 in CF
RCL AX, 1 ;save higher-order bit of AX in CF
RCL DX, 1 ;save higher-order bit of DX in CF
ADC AX, 0 ; set lower order bit if needed.
Example :
RCR Instruction - RCR instruction rotates the bits in the operand specified by
op1 towards right by the count specified in op2. RCR op1, op2
Example:( 1)
( 2)
;CF = 1, BL = 00111000
RCR BL, 1 ;Result: BL = 10011100, CF =0
;OF = 1 because MSB is changed to 1.
REP/REPE/REPZ/
REPNE/REPNZ - (Prefix) Repeat String instruction until specified
condition exist
ROL Instruction - ROL instruction rotates the bits in the operand specified by
op1 towards left by the count specified in op2. ROL moves each bit in the operand to
next higher bit position. The higher order bit is moved to lower order position. Last bit
rotated is copied into carry flag.
Example: ( 1 )
Example : ( 2 )
;BX = 01011100 11010011
;CL = 8 bits to rotate
ROL BH, CL ;Rotate BX 8 bits towards left
;CF =0, BX =11010011 01011100
ROR Instruction - Rotate all bits of operand right, LSB to MSB –
ROR destination, count
ROR Instruction - ROR instruction rotates the bits in the operand op1 to
wards right by count specified in op2. The last bit rotated is copied into CF.
(2)
Example (3)
;CF = 0, AL = 10110011,
MOVE CL, 04H ; Load CL
ROR AL, CL ;Rotate all bits of AL towards right
;by 4 bits, CF = 0 ,AL = 00111011
SAR Instruction - Shift operand bits right, new MAB = old MSB
SAR destination, count.
SAR Instruction - SAR instruction shifts the bits in the operand specified by
op1 towards right by count specified in op2.As bit is shifted out a copy of old MSB is
taken in MSB
MSB position and LSB is shifted to CF.
SAR op1, op2
Example: (1)
(2)
;BH = 11110011 = - 13 decimal, CF = 1
SAR BH, 1 ;Shifted signed byte in BH to right
;BH = 11111001 = - 7 decimal, CF = 1
SBB Instruction - SUBB instruction subtracts op2 from op1, then subtracts 1
from op1 is CF flag is set and result is stored in op1 and it is used to set the flag.
Example:
STOS/STOSB/
STOSW Instruction - Store byte or word in string.
Example:
(1)
(2)
(3)
;SI = 10010011 10101101 , CF = 0
SHR SI, 1 ; Result: SI = 01001001 11010110
; CF = 1, OF = 1, SF = 0, ZF = 0
XLAT/
XLATB Instruction - Translate a byte in AL
Examples:
Example :
;AL = 01010001
TEST Al, 80H ;AND immediate 80H with AL to
;test f MSB of AL is 1 or 0
;ZF = 1 if MSB of AL = 0
;AL = 01010001 (unchanged)
;PF = 0 , SF = 0
;ZF = 1 because ANDing produced is 00
In this code we are adding up of FWAIT instruction so that it will stop the execution of
the command until the above instruction is finishes it’s work .so that you are not loosing
data and after that you will allow to continue the execution of instructions.
The both operands must be the same size and one of the operand must always be a
register .
Example:
XOR Instruction - XOR performs a bit wise logical XOR of the operands
specified by op1 and op2. The result of the operand is stored in op1 and is used to set the
flag.
XOR op1, op2
Example : ( Numerical )
; BX = 00111101 01101001
;CX = 00000000 11111111
XOR BX, CX ;Exclusive OR CX with BX
;Result BX = 00111101 10010110
Assembler Directives
ASSUME
DB - Defined Byte.
Example:
ASUME CS:CODE ;This tells the assembler that the logical
segment named CODE contains the instruction statements for the program and should be
treated as a code segment.
ASUME DS:DATA ;This tells the assembler that for any
instruction which refers to a data in the data segment, data will found in the logical
segment DATA.
Example:
ENDP - ENDP directive is used along with the name of the procedure to
indicate the end of a procedure to the assembler
Example:
SQUARE_NUM PROCE ; It start the procedure
;Some steps to find the square root of a number
EQU - Equate
EXTRN
ENDS - This ENDS directive is used with name of the segment to indicate
the end of that logic segment.
Example:
CODE SEGMENT ;Hear it Start the logic
;segment containing code
; Some instructions statements to perform
;the logical operation
EQU - This EQU directive is used to give a name to some value or to a symbol.
Each time the assembler finds the name in the program, it will replace the name with the
value or symbol you given to that name.
Example:
FACTOR EQU 03H ; you has to write this statement at the starting of your
program and later in the program you can use this as follows
ADD AL, FACTOR ; When it codes this instruction the
assembler will code it as ADDAL, 03H
;The advantage of using EQU in this manner is, if FACTOR is used many no of
times in a program and you want to change the value, all you had to do is change the
EQU statement at beginning, it will changes the rest of all.
Example:
DATA1 SEGMENT
; Location counter will point to 0009 after assembler reads
;next statement
LABLE
NAME
OFFSET
ORG - Originate
PTR - Pointer
PUBLC
SEGMENT
SHORT
TYPE
PROC - The PROC directive is used to identify the start of a procedure.
The term near or far is used to specify the type of the procedure.
Example:
Example:
INC [BX] ; This instruction will not know whether to increment the
byte pointed to by BX or a word pointed to by BX.
INC BYTE PTR [BX] ;increment the byte
;pointed to by BX
This PTR operator can also be used to override the declared type of
variable . If we want to access the a byte in an array WORDS DW 437Ah,
0B97h,
MOV AL, BYTE PTR WORDS
Example:
PUBLIC DIVISOR, DIVIDEND ;these two variables are public so
these are available to all modules.
If an instruction in a module refers to a variable in another
assembly module, we can access that module by declaring as EXTRN directive.
Example:
Byte type variable – assembler will give a value 1
Word type variable – assembler will give a value 2
Double word type variable – assembler will give a value 4
Next Page
• Address connections: All memory devices have address
inputs that select a memory location within the memory
device. Address inputs are labeled from A0 to An.
• Data connections: All memory devices have a set of data
outputs or input/outputs. Today many of them have bi-
directional common I/O pins.
• Selection connections: Each memory device has an input,
that selects or enables the memory device. This kind of
input is most often called a chip select ( CS ), chip enable
( CE ) or simply select ( S ) input.
Next Page
A0 O0
A1 O1 OUTPUT OR
ADDRESS INPUT/OUTPUT
CONNECTION A2 O2 CONNECTION
AN ON
WE WRITE
CS OE
SELECT READ
MEMORY COMPONENT ILLUSTRATING THE ADDRESS, DATA AND
,
CONTROL CONNECTIONS Next Page
• RAM memory generally has at least one CS or S input and
ROM at least one CE.
• If the CE, CS, S input is active the memory device perform
the read or write.
• If it is inactive the memory device cannot perform read or
write operation.
• If more than one CS connection is present, all most be
active to perform read or write data.
• Control connections: A ROM usually has only one control
input, while a RAM often has one or two control inputs.
Next Page
• The control input most often found on the ROM is the
output enable ( OE ) or gate ( G ), this allows data to flow
out of the output data pins of the ROM.
• If OE and the selected input are both active, then the
output is enable, if OE is inactive, the output is disabled at
its high-impedance state.
• The OE connection enables and disables a set of three-state
buffer located within the memory device and must be
active to read data.
Next Page
• A RAM memory device has either one or two control
inputs. If there is one control input it is often called R/W.
• This pin selects a read operation or a write operation only
if the device is selected by the selection input ( CS ).
• If the RAM has two control inputs, they are usually labeled
WE or W and OE or G.
• ( WE ) write enable must be active to perform a memory
write operation and OE must be active to perform a
memory read operation.
• When these two controls WE and OE are present, they
must never be active at the same time.
• The ROM read only memory permanently stores programs
and data and data was always present, even when power is
disconnected.
• It is also called as nonvolatile memory.
• EPROM ( erasable programmable read only memory ) is
also erasable if exposed to high intensity ultraviolet light
for about 20 minutes or less, depending upon the type of
EPROM.
• We have PROM (programmable read only memory )
• RMM ( read mostly memory ) is also called the flash
memory.
Next Page
• The flash memory is also called as an EEPROM
(electrically erasable programmable ROM ), EAROM
( electrically alterable ROM ), or a NOVROM
( nonvolatile ROM ).
• These memory devices are electrically erasable in the
system, but require more time to erase than a normal
RAM.
• EPROM contains the series of 27XXX contains the
following part numbers : 2704( 512 * 8 ), 2708(1K * 8 ),
2716( 2K * 8 ), 2732( 4K * 8 ), 2764( 8K * 8 ),
27128( 16K * 8) etc..
Next Page
• Each of these parts contains address pins, eight data
connections, one or more chip selection inputs (CE) and an
output enable pin (OE ).
• This device contains 11 address inputs and 8 data outputs.
• If both the pin connection CE and OE are at logic 0, data
will appear on the output connection . If both the pins are
not at logic 0, the data output connections remains at their
high impedance or off state.
• To read data from the EPROM Vpp pin must be placed at a
logic 1.
Next Page
A7 24 Vcc
1
A6 23 A8
2
A5 3 22 A9
A4 4 21 Vpp
A3 5 20 CS
A2 6 19 A10
A1 7 18 PD/PGM
A0 17 O7
8
O0 16 O6
9
O1 15 O5
10
O2 14 O4
11
GND 13 O3
12
CS CHIP SELECT
PIN NAMES
Next Page
DATA OUTPUTS
Vcc O0 – O7
GND
Vpp
CHIP SELECT
CS POWER DOWN
AND PROGRAM OUTPUT
PD / PGM
LOGIC BUFFERS
Y Y-GATING
A0 - A10 DECODER
ADDRESS
INPUTS
16,386 BIT
X CELL
DECODER MATRIX
BLOCK DIAGRAM
• Static RAM memory device retain data for as long as DC
power is applied. Because no special action is required to
retain stored data, these devices are called as static
memory. They are also called volatile memory because
they will not retain data without power.
• The main difference between a ROM and RAM is that a
RAM is written under normal operation, while ROM is
programmed outside the computer and is only normally
read.
• The SRAM stores temporary data and is used when the
size of read/write memory is relatively small.
Next Page
A7 24 VCC
1
A6
2 23 A8
A5 3 22 A9
A4 4 21 W
A3 5 20 G
A2 6 19 A10
A1 7 18 S
A0
8 17 DQ8
DQ1 9 16 DQ7
DQ2 10 15 DQ6
DQ3 11 14 DQ5
Vss 12 13 DQ4
S CHIP SELECT
DATA IN /
DQ _ DQ
0 8 DATA OUT
OUT PUT
G ENABLE
Vss GROUND
Vcc + 5 V
SUPPLY
PIN NAMES
Next Page
• The control inputs of this RAM are slightly different from
those presented earlier. The OE pin is labeled G, the CS
pin S and the WE pin W.
• This 4016 SRAM device has 11 address inputs and 8 data
input/output connections.
Static RAM Interfacing
Next Page
• The basic dynamic RAM cell uses a capacitor to store the
charge as a representation of data. This capacitor is
manufactured as a diode that is reverse-biased so that the
storage capacitance comes into the picture. This storage
capacitance is utilized for storing the charge representation
of data but the reverse-biased diode has leakage current
that tends to discharge the capacitor giving rise to the
possibility of data loss. To avoid this possible data loss, the
data stored in a dynamic RAM cell must be refreshed after
a fixed time interval regularly. The process of refreshing
the data in RAM is called as Refresh cycle.
Next Page
• The refresh activity is similar to reading the data from each
and every cell of memory, independent of the requirement
of microprocessor. During this refresh period all other
operations related to the memory subsystem are suspended.
Hence the refresh activity causes loss of time, resulting in
reduce system performance.
• However keeping in view the advantages of dynamic
RAM, like low power consumption, high packaging
density and low cost, most of the advanced computing
system are designed using dynamic RAM, at the cost of
operating speed.
Next Page
• A dedicated hardware chip called as dynamic RAM
controller is the most important part of the interfacing
circuit.
• The Refresh cycle is different from the memory read
cycle in the following aspects.
1. The memory address is not provided by the CPU address
bus, rather it is generated by a refresh mechanism
counter called as refresh counter.
2. Unlike memory read cycle, more than one memory chip
may be enabled at a time so as to reduce the number of
total memory refresh cycles.
Next Page
3. The data enable control of the selected memory chip is
deactivated, and data is not allowed to appear on the
system data bus during refresh, as more than one
memory units are refreshed simultaneously. This is to
avoid the data from the different chips to appear on the
bus simultaneously.
4. Memory read is either a processor initiated or an external
bus master initiated and carried out by the refresh
mechanism.
Next Page
• Dynamic RAM is available in units of several kilobits to
megabits of memory. This memory is arranged internally
in a two dimensional matrix array so that it will have n
rows and m columns. The row address n and column
address m are important for the refreshing operation.
• For example, a typical 4K bit dynamic RAM chip has an
internally arranged bit array of dimension 64 * 64 , i.e. 64
rows and 64 columns. The row address and column
address will require 6 bits each. These 6 bits for each row
address and column address will be generated by the
refresh counter, during the refresh cycles.
• A complete row of 64 cells is refreshed at a time to
minimizes the refreshing time. Thus the refresh counter
needs to generate only row addresses. The row address are
multiplexed, over lower order address lines.
• The refresh signals act to control the multiplexer, i.e. when
refresh cycle is in process the refresh counter puts the row
address over the address bus for refreshing. Otherwise, the
address bus of the processor is connected to the address
bus of DRAM, during normal processor initiated activities.
• A timer, called refresh timer, derives a pulse for refreshing
action after each refresh interval.
• Refresh interval can be qualitatively defined as the time for
which a dynamic RAM cell can hold data charge level
practically constant, i.e. no data loss takes place.
• Suppose the typical dynamic RAM chip has 64 rows, then
each row should be refreshed after each refresh interval or
in other words, all the 64 rows are to refreshed in a single
refresh interval.
• This refresh interval depends upon the manufacturing
technology of the dynamic RAM cell. It may range
anywhere from 1ms to 3ms.
• Let us consider 2ms as a typical refresh time interval.
Hence, the frequency of the refresh pulses will be
calculated as follows:
• Refresh Time ( per row ) tr = (2 * 10 -3) / 64.
• Refresh Frequency fr = 64 / ( 2 * 10 -3) = 32 * 103 Hz.
• The following block diagram explains the refreshing logic
and 8086 interfacing with dynamic RAM.
• Each chip is of 16K * 1-bit dynamic RAM cell array. The
system contains two 16K byte dynamic RAM units. All the
address and data lines are assumed to be available from an
8086 microprocessor system.
• The OE pin controls output data buffer of the memory
chips. The CE pins are active high chip selects of memory
chips. The refresh cycle starts, if the refresh output of the
refresh timer goes high, OE and CE also tend to go high.
• The high CE enables the memory chip for refreshing,
while high OE prevents the data from appearing on the
data bus, as discussed in memory refresh cycle. The 16K *
1-bit dynamic RAM has an internal array of 128*128 cells,
requiring 7 bits for row address. The lower order seven
lines A0-A6 are multiplexed with the refresh counter output
A10-A16.
A7 – A13
16K*1 16K*1 16K*1 16K*1 16K* 16K*1 16K*1 16K*1
A6 – A0 1
OE CE OE CE OE CE OE CE OE CE OE CE OE CE OE CE
CE1
A7 – A13
A7 – A13
16K*1 16K*1 16K*1 16K*1 16K*1 16K*1 16K*1 16K*1
A6 – A0
OE CE OE CE OE CE OE CE OE CE OE CE OE CE OE CE
CE2
7 bit
A0-A6 bus
MUX
Ar0
–
Ar6 CE1 CE2
Address
Refresh Deciding logic
Ref. Add Refresh
timer
Counter A15 A14
To transreceivers
Dynamic RAM Refreshing Logic
+12 V CLK
X0/OP2 X1/CLK
Bank Select B0 Vcc
16K/64K
AH0 -AH7
OUT7 – OUT0
ADDRESS Address O/P
AL0 -AL7
CAS
Dout
WE
8267
XACK XCIEVER
XACK CS
WR
RD Read/
WR Write IR0
Interrupt
A0 Logic IN Service Priority Request IR1
Register Resolver Register
CS ISR IRR
CAS0 IR7
Cascade
CAS1 Buffer/
CAS2 Comparator
Interrupt Mask Register
SP / EN IMR
Internal Bus
Fig:1 8259A Block Diagram
• Priority Resolver : This unit determines the priorities of
the interrupt requests appearing simultaneously. The
highest priority is selected and stored into the
corresponding bit of ISR during INTA pulse. The IR0 has
the highest priority while the IR7 has the lowest one,
normally in fixed priority mode. The priorities however
may be altered by programming the 8259A in rotating
priority mode.
• Interrupt Mask Register (IMR) : This register stores the
bits required to mask the interrupt inputs. IMR operates on
IRR at the direction of the Priority Resolver.
• Interrupt Control Logic: This block manages the
interrupt and interrupt acknowledge signals to be sent to
the CPU for serving one of the eight interrupt requests.
This also accepts the interrupt acknowledge (INTA) signal
from CPU that causes the 8259A to release vector address
on to the data bus.
• Data Bus Buffer : This tristate bidirectional buffer
interfaces internal 8259A bus to the microprocessor system
data bus. Control words, status and vector information pass
through data buffer during read or write operations.
• Read/Write Control Logic: This circuit accepts and
decodes commands from the CPU. This block also allows
the status of the 8259A to be transferred on to the data bus.
• Cascade Buffer/Comparator: This block stores and
compares the ID’s all the 8259A used in system. The three
I/O pins CASO-2 are outputs when the 8259A is used as a
master. The same pins act as inputs when the 8259A is in
slave mode. The 8259A in master mode sends the ID of the
interrupting slave device on these lines. The slave thus
selected, will send its preprogrammed vector address on
the data bus during the next INTA pulse.
CS 1 28 Vcc
WR 2 27 A0
RD 3 26 INTA
D7 4 25 IR7
D6 5 24 IR6
D5 6 23 IR5
D4 7 22 IR4
D3 8 8259A 21 IR3
D2 9 20 IR2
D1 10 19 IR1
D0 11 18 IR0
CAS0 12 17 INT
CAS1 13 16 SP / EN
GND 14 15 CAS2
ICW2
NO (IC4 =0)
B B : IS ICW4 NEEDED ?
YES (IC4 = 1)
ICW4
Ready to Accept
Interrupt Request
Fig 3: Initialisation Sequence of 8259A
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 T7 T6 T5 T4 T3 A10 A9 A8
1 S7 S6 S5 S4 S3 S2 S1 S0
1 M7 M6 M5 M4 M3 M2 M1 M0
1 – Mask Set
0 – Mask Reset
Fig (a) : OCW1
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 – Poll 0 0 No Action
No Action
0 1 Command 0 1
Reset Special 1 0 Read IRR on
1 0 0 – No Poll
Mask next RD pulse
Set Special 1 1 Command 1 1
Read IRR on
Mask
next RD pulse
Fig : Operation Command Words
Fig (c) :OCW2
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 R SL EOI 0 0 L2 L1 L0
0 1 2 3 4 5 6 7
0 1 0 0 0 1 0 1
0 0 1 1 0 0 1 1
0 0 0 0 1 1 1 1
END OF
0 0 1 NON-SPECIFIC EOI COMMAND
INTERRUPT 1
0 1 SPECIFIC EOI COMMAND
1 0 1 ROTATE ON NON-SPECIFIC EOI MODE (SET)
AUTOMATIC 1 0
0 ROTATE IN AUTOMATIC EOI MODE (SET)
ROTATION 0 0 0 ROTATE IN AUTOMATIC EOI (CLEAR)
SPECIFIC 1 1 1 ROTATE ON SPECIFIC EOI COMMAND
ROTATION 1 1 0 SET PRIORITY COMMAND*
0 1 0 NO OPERATION
* - In this Mode L0 – L2 are used
1 x x x x w2 w1 w0
Binary code of
If = 1, there is an interrupt highest priority
level
Fig : Data Word of 8259
• Special Fully Nested Mode : This mode is used in more
complicated system, where cascading is used and the
priority has to be programmed in the master using ICW4.
this is somewhat similar to the normal nested mode.
• In this mode, when an interrupt request from a certain
slave is in service, this slave can further send request to the
master, if the requesting device connected to the slave has
higher priority than the one being currently served. In this
mode, the master interrupt the CPU only when the
interrupting device has a higher or the same priority than
the one current being served. In normal mode, other
requests than the one being served are masked out.
• When entering the interrupt service routine the software
has to check whether this is the only request from the
slave. This is done by sending a non-specific EOI can be
sent to the master, otherwise no EOI should be sent. This
mode is important, since in the absence of this mode, the
slave would interrupt the master only once and hence the
priorities of the slave inputs would have been disturbed.
• Buffered Mode: When the 83259A is used in the systems
where bus driving buffers are used on data buses. The
problem of enabling the buffers exists. The 8259A sends
buffer enable signal on SP/ EN pin, whenever data is
placed on the bus.
• Cascade Mode : The 8259A can be connected in a system
containing one master and eight slaves (maximum) to
handle upto 64 priority levels. The master controls the
slaves using CAS0-CAS2 which act as chip select inputs
(encoded) for slaves.
• In this mode, the slave INT outputs are connected with
master IR inputs. When a slave request line is activated
and acknowledged, the master will enable the slave to
release the vector address during second pulse of INTA
sequence.
• The cascade lines are normally low and contain slave
address codes from the trailing edge of the first INTA
pulse to the trailing edge of the second INTA pulse. Each
8259A in the system must be separately initialized and
programmed to work in different modes. The EOI
command must be issued twice, one for master and the
other for the slave.
• A separate address decoder is used to activate the chip
select line of each 8259A.
• Following Fig shows the details of the circuit connections
of 8259A in cascade scheme.
ADDRESS BUS
A1 A1
A1
CONTROL BUS
DATA BUS
INT
CAS0-CAS2
INTA
A0
RESET
CLK KEYBOARD
DISPLAY 16*8 CONTROL 8*8 FIFO/ DEBOUNCE
ADDRESS DISPLAY AND SENSOR AND
REGISTERS RAM TIMING RAM CONTROL
REGISTERS
TIMING
AND
DISPLAY CONTROL SCAN Return
REGISTERS UNIT COUNTER
SHIFT
OUT A0-A3 BD SL0 – SL3 RL0 – RL7 CNTL/
OUT B0-B3 STB
8279 Internal Architecture
RL2 1 40 Vcc
RL3 2 39 RL1
CLK 3 38 RL0
IRQ 4 37 CNTL/STB
RL4 5 36 SHIFT
RL5 6 35 SL3
RL6 7 34 SL2
RL7 8 33 SL1
RESET 9 32 SL0
8279
RD 10 31 OUT B0
WR 11 30 OUT B1
DB0 12 29 OUT B2
DB1 13 28 OUT B3
DB2 14 27 OUT A0
DB3 15 26 OUT A1
DB4 16 25 OUT A2
DB5 17 24 OUT A3
DB6 18 23 BD
DB7 19 22 CS
Vss 20 21 A0
IRQ RL0-7 8
CNTL/
STB
RD
CPU WR 8279 SL0-3 4
INTERFACE SCAN
CS
OUT A0-A3 4
A0
DISPLAY
RESET OUT B0 – B3 4 DATA
CLK BD
Vss
• The signal discription of each of the pins of 8279 as
follows :
• DB0-DB7 : These are bidirectional data bus lines. The data
and command words to and from the CPU are transferred
on these lines.
• CLK : This is a clock input used to generate internal
timing required by 8279.
• RESET : This pin is used to reset 8279. A high on this line
reset 8279. After resetting 8279, its in sixteen 8-bit display,
left entry encoded scan, 2-key lock out mode. The clock
prescaler is set to 31.
• CS : Chip Select – A low on this line enables 8279 for
normal read or write operations. Other wise, this pin
should remain high.
• A0 : A high on this line indicates the transfer of a
command or status information. A low on this line
indicates the transfer of data. This is used to select one of
the internal registers of 8279.
• RD, WR ( Input/Output ) READ/WRITE – These input
pins enable the data buffers to receive or send data over the
data bus.
• IRQ : This interrupt output lines goes high when there is a
data in the FIFO sensor RAM. The interrupt lines goes low
with each FIFO RAM read operation but if the FIFO RAM
further contains any key-code entry to be read by the CPU,
this pin again goes high to generate an interrupt to the
CPU.
• Vss, Vcc : These are the ground and power supply lines for
the circuit.
• SL0-SL3-Scan Lines : These lines are used to scan the key
board matrix and display digits. These lines can be
programmed as encoded or decoded, using the mode
control register.
• RL0 - RL7 - Return Lines : These are the input lines
which are connected to one terminal of keys, while the
other terminal of the keys are connected to the decoded
scan lines. These are normally high, but pulled low when a
key is pressed.
• SHIFT : The status of the shift input lines is stored along
with each key code in FIFO, in scanned keyboard mode. It
is pulled up internally to keep it high, till it is pulled low
with a key closure.
• BD – Blank Display : This output pin is used to blank the
display during digit switching or by a blanking closure.
• OUT A0 – OUT A3 and OUT B0 – OUT B3 – These are
the output ports for two 16*4 or 16*8 internal display
refresh registers. The data from these lines is synchronized
with the scan lines to scan the display and keyboard. The
two 4-bit ports may also as one 8-bit port.
• CNTL/STB- CONTROL/STROBED I/P Mode : In
keyboard mode, this lines is used as a control input and
stored in FIFO on a key closure. The line is a strobed lines
that enters the data into FIFO RAM, in strobed input mode.
It has an interrupt pull up. The lines is pulled down with a
key closer.
Modes of Operation of 8279
K K K Keyboard modes
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 0 1 P P P P P 1
c) Read FIFO / Sensor RAM : The format of this
command is given below.
• This word is written to set up 8279 for reading FIFO/
sensor RAM. In scanned keyboard mode, AI and AAA
bits are of no use. The 8279 will automatically drive data
bus for each subsequent read, in the same sequence, in
which the data was entered.
• In sensor matrix mode, the bits AAA select one of the 8
rows of RAM. If AI flag is set, each successive read will
be from the subsequent RAM location.
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 1 0 AI X A A A 1
X – don’t care
AI – Auto Increment Flag
AAA – Address pointer to 8 bit FIFO RAM
d) Read Display RAM : This command enables a
programmer to read the display RAM data. The CPU
writes this command word to 8279 to prepare it for
display RAM read operation. AI is auto increment flag
and AAAA, the 4-bit address points to the 16-byte
display RAM that is to be read. If AI=1, the address will
be automatically, incremented after each read or write to
the Display RAM. The same address counter is used for
reading and writing.
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 1 1 AI A A A A 1
e) Write Display RAM :
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 0 0 AI A A A A 1
f) Display Write Inhibit/Blanking : The IW ( inhibit
write flag ) bits are used to mask the individual nibble
as shown in the below command word. The output lines
are divided into two nibbles ( OUTA0 – OUTA3 ) and (
OUTB0 – OUTB3 ), those can be masked by setting the
corresponding IW bit to 1.
• Once a nibble is masked by setting the corresponding
IW bit to 1, the entry to display RAM does not affect the
nibble even though it may change the unmasked nibble.
The blank display bit flags (BL) are used for blanking A
and B nibbles.
• Here D0, D2 corresponds to OUTB0 – OUTB3 while D1
and D3 corresponds to OUTA0-OUTA3 for blanking and
masking.
• If the user wants to clear the display, blank (BL) bits are
available for each nibble as shown in format. Both BL bits
will have to be cleared for blanking both the nibbles.
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 0 1 X IW IW BL BL 1
g) Clear Display RAM : The CD2, CD1, CD0 is a
selectable blanking code to clear all the rows of the
display RAM as given below. The characters A and B
represents the output nibbles.
• CD2 must be 1 for enabling the clear display command.
If CD2 = 0, the clear display command is invoked by
setting CA=1 and maintaining CD1, CD0 bits exactly
same as above. If CF=1, FIFO status is cleared and IRQ
line is pulled down.
• Also the sensor RAM pointer is set to row 0. if CA=1,
this combines the effect of CD and CF bits. Here, CA
represents Clear All and CF as Clear FIFO RAM.
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 1 0 CD2 CD1 CD0 CF CA 1
150 Ω
Each
13 12 11 10 9 15 14 +5V
a b c d e f g
+5V Vcc
BI 5
7447
RBI 4
GND
A B C D LT 3
7 1 2 6
BCD INPUTS
Circuit for driving single 7-segment LED display with 7447
D0
D1
D2
D3
D4 + 5V
D5
D6
R5 R7
R1 R2 R3 R4 R6
OUTPUT
PORT Q1 Q2 Q3 Q4 Q5 Q6 Q7
+5V
Vcc
OUTPUT 7447
PORT GND D C B A
B D0
D1
D2
D3
Liquid Crystal Display
2to4
A1 DS1 2 bit Decoder
Latch
A2 DS2
Enable Enable
Back
Oscillator Plane
74LS138 CS1 / 128 Back Plane
One 16KHz Free Driver
Y2 Running Output
Shot Enable
CS2
+5 V OSC Enable
Enable Detector
Fig : Circuit for interfacing four LCD digits to an SDK-86 bus using ICM7211M
PIO 8255
RD WR CS A1 A0 Function
X X 1 X X Data bus tristated
1 1 0 X X Data bus tristated
Mode 0
• The salient features of this mode are as listed below:
1. Two 8-bit ports ( port A and port B )and two 4-bit ports
(port C upper and lower ) are available. The two 4-bit
ports can be combinedly used as a third 8-bit port.
2. Any port can be used as an input or output port.
3. Output ports are latched. Input ports are not latched.
4. A maximum of four ports are available so that overall 16
I/O configuration are possible.
• All these modes can be selected by programming a
register internal to 8255 known as CWR.
• The control word register has two formats. The first format
is valid for I/O modes of operation, i.e. modes 0, mode 1
and mode 2 while the second format is valid for bit
set/reset (BSR) mode of operation. These formats are
shown in following fig.
D7 D6 D5 D4 D3 D2 D1 D0
1 X X X
0- Reset
0-for BSR mode Bit select flags 1- Set
D3, D2, D1 are from 000 to 111 for bits PC0 TO PC7
CS PC4-PC7
RESET
8255A
PC0-PC3
A0
A1 PB0-PB7
RD
Vcc
WR
GND
Signals of 8255
3 4 PA0-PA7
Group A Group A
control Port A(8)
1
D0-D7 Data bus Group A PC7-PC4
Buffer Port C
8 bit int data bus upper(4)
Group B PC0-PC3
2 Port C
RD Lower(4)
WR READ/
WRITE PB7-PB0
A0 Group B
Control Group B
A1 Logic control Port B(8)
RESET
CS
Block Diagram of 8255
D7 D6 D5 D4 D3 D2 D1 D0
Mode for PA PC U Mode PB PC L
Port A for PB
Mode Set flag
1- active
0- BSR mode
Group - A Group - B
1 Input
PC u PCL 1 Input
0 Output
0 Output
1 Input
PA PB 1 Input
0 Output
00 – mode 0 0 Output
Mode
01 – mode 1 Mode 0 mode- 0
Select
10 – mode 2 Select
of PA 1 mode- 1
PC0 INTR
PC3 INTRA A
RD PC6 – PC7 I/O
RD
Mode 1 Control Word Group A Mode 1 Control Word Group B
I/P I/P
STB
IBF
INTR
RD
DATA from
Peripheral
OBF
INTR
ACK
Data OP to
Port
Mode 1 Strobed Data Output
Output control signal definitions Mode 1
1 0 1 0 1/0 X X X 1 X X X X 1 0 X
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
1 - Input
0 - Output
For PC4 – PC5
PC0 INTRB
PC3 INTRA
WR PC4 – PC5 I/O
OBF
INTR
ACK
STB
IBF
PA0-PA7
PC7 OBF
INTE 1 PC6
ACK
Mode 2 pins
Interfacing a Microprocessor To
Keyboard
• When you press a key on your computer, you are
activating a switch. There are many different ways of
making these switches. An overview of the construction
and operation of some of the most common types.
1. Mechanical key switches: In mechanical-switch keys,
two pieces of metal are pushed together when you press
the key. The actual switch elements are often made of a
phosphor-bronze alloy with gold platting on the contact
areas. The key switch usually contains a spring to return
the key to the nonpressed position and perhaps a small
piece of foam to help damp out bouncing.
Next Page
• Some mechanical key switches now consist of a molded
silicon dome with a small piece of conductive rubber foam
short two trace on the printed-circuit board to produce the
key pressed signal.
• Mechanical switches are relatively inexpensive but they
have several disadvantages. First, they suffer from contact
bounce. A pressed key may make and break contact
several times before it makes solid contact.
• Second, the contacts may become oxidized or dirty with
age so they no longer make a dependable connection.
Next Page
• Higher-quality mechanical switches typically have a
rated life time of about 1 million keystrokes. The
silicone dome type typically last 25 million keystrokes.
2. Membrane key switches: These switches are really a
special type of mechanical switches. They consist of a
three-layer plastic or rubber sandwich.
• The top layer has a conductive line of silver ink running
under each key position. The bottom layer has a
conductive line of silver ink running under each column
of keys.
Next Page
• When u press a key, you push the top ink line through
the hole to contact the bottom ink line.
• The advantages of membrane keyboards is that they can
be made as very thin, sealed units.
• They are often used on cash registers in fast food
restaurants. The lifetime of membrane keyboards varies
over a wide range.
3. Capacitive key switches: A capacitive keyswitch has two
small metal plates on the printed circuit board and
another metal plate on the bottom of a piece of foam.
Next Page
• When u press the key, the movable plate is pushed closer
to fixed plate. This changes the capacitance between the
fixed plates. Sense amplifier circuitry detects this change
in capacitance and produce a logic level signal that
indicates a key has been pressed.
• The big advantages of a capacitive switch is that it has no
mechanical contacts to become oxidized or dirty.
• A small disadvantage is the specified circuitry needed to
detect the change in capacitance.
• Capacitive keyswitches typically have a rated lifetime of
about 20 million keystrokes.
Next Page
4. Hall effect keyswitches: This is another type of switch
which has no mechanical contact. It takes advantage of
the deflection of a moving charge by a magnetic field.
• A reference current is passed through a semiconductor
crystal between two opposing faces. When a key is
pressed, the crystal is moved through a magnetic field
which has its flux lines perpendicular to the direction of
current flow in the crystal.
• Moving the crystal through the magnetic field causes a
small voltage to be developed between two of the other
opposing faces of the crystal.
Next Page
• This voltage is amplified and used to indicate that a key
has been pressed. Hall effect sensors are also used to detect
motion in many electrically controlled machines.
• Hall effect keyboards are more expensive because of the
more complex switch mechanism, but they are very
dependable and have typically rated lifetime of 100 million
or more keystrokes.
Key
Motion
HALL
VOLTAGE
Reference
Current
Magnetic Field
HALL EFFECT
Keyboard Circuit Connections and
Interfacing
• In most keyboards, the keyswitches are connecting in a
matrix of rows and columns, as shown in fig.
• We will use simple mechanical switches for our
examples, but the principle is same for other type of
switches.
• Getting meaningful data from a keyboard, it requires the
following three major tasks:
1. Detect a keypress.
2. Debounce the keypress.
3. Encode the keypress
Next Page
• Three tasks can be done with hardware, software, or a
combination of two, depending on the application.
1. Software Keyboard Interfacing:
• Circuit connection and algorithm : The following fig
(a) shows how a hexadecimal keypad can be connected
to a couple of microcomputer ports so the three
interfacing tasks can be done as part of a program.
• The rows of the matrix are connected to four output port
lines. The column lines of matrix are connected to four
input-port lines. To make the program simpler, the row
lines are also connected to four input lines.
Next Page
• When no keys are pressed, the column lines are held high
by the pull-up resistor connected to +5V. Pressing a key
connects a row to a column. If a low is output on a row and
a key in that row is pressed, then the low will appear on the
column which contains that key and can be detected on the
input port.
• If you know the row and column of the pressed key, you
then know which key was pressed, and you can convert
this information into any code you want to represent that
key.
Next Page
• The following flow chart for a procedure to detect,
debounce and produce the hex code for a pressed key.
• An easy way to detect if any key in the matrix is pressed is
to output 0’s to all rows and then check the column to see
if a pressed key has connected a low to a column.
• In the algorithm we first output lows to all the rows and
check the columns over and over until the column are all
high. This is done before the previous key has been
released before looking for the next one. In the standard
keyboard terminology, this is called two-key lockout.
Next Page
KEYBOARD
Next Page
• The final task is to determine the row and column of the
pressed key and convert this row and column information
to the hex code for the pressed key. To get the row and
column information, a low is output to one row and the
column are read. If none of the columns is low, the pressed
key is not in that row. So the low is rotated to the next row
and the column are checked again. The process is repeated
until a low on a row produces a low on one of the column.
• The pressed key then is in the row which is low at that
time.
Next Page
• The connection fig shows the byte read in from the input
port will contain a 4-bit code which represents the row of
the pressed key and a 4-bit code which represent the
column of the pressed key.
• Error trapping: The concept of detecting some error
condition such as “ no match found” is called error
trapping. Error trapping is a very important part of real
programs. Even in simple programs, think what might
happen with no error trap if two keys in the same row were
pressed at exactly at the same time and a column code with
two lows in it was produced.
Next Page
• This code would not match any of the row-column codes
in the table, so after all the values in the table were
checked, assigned register in program would be
decremented from 0000H to FFFFH. The compare
decrement cycle would continue through 65,536 memory
locations until, by change the value in a memory location
matched the row-column code. The contents of the lower
byte register at hat point would be passed back to the
calling routine. The changes are 1 in 256 that would be the
correct value for one of the pressed keys. You should keep
an error trap in a program whenever there is a chance for it.
Next Page
2. Keyboard Interfacing with Hardware: For the system
where the CPU is too busy to be bothered doing these
tasks in software, an external device is used to do them.
• One of a MOS device which can be do this is the
General Instruments AY5-2376 which can be connected
to the rows and columns of a keyboard switch matrix.
• The AY5-2376 independently detects a keypress by
cycling a low down through the rows and checking the
columns. When it finds a key pressed, it waits a
debounce time.
Next Page
• If the key is still pressed after the debounce time, the AY5-
2376 produces the 8-bit code for the pressed key and send
it out to microcomputer port on 8 parallel lines. The
microcomputer knows that a valid ASCII code is on the
data lines, the AY5-2376 outputs a strobe pulse.
• The microcomputer can detect this strobe pulse and read in
ASCII code on a polled basis or it can detect the strobe
pulse on an interrupt basis.
• With the interrupt method the microcomputer doesn’t have
to pay any attention to the keyboard until it receives an
interrupt signal.
Next Page
• So this method uses very little of the microcomputer time.
The AY5-2376 has a feature called two-key rollover. This
means that if two keys are pressed at nearly the same time,
each key will be detected, debounced and converted to
ASCII.
• The ASCII code for the first key and a strobe signal for it
will be sent out then the ASCII code for the second key
and a strobe signal for it will be sent out and compare this
with two-key lockout.
Next Page
+ 5V
Output port 01 C D E F
D0
8 9 A B
D1
4 5 6 7
D2
0 1 2 3
D3
10KΩ
Input port
02 D7
D
7 6
D
6 5
D
5 4
D
4 3
D
3 2
D
2 1
D0
Fig: (a) Port connections
Example
• Interface a 4 * 4 keyboard with 8086 using 8255 an write
an ALP for detecting a key closure and return the key code
in AL. The debounce period for a key is 10ms. Use
software debouncing technique. DEBOUNCE is an
available 10ms delay routine.
• Solution: Port A is used as output port for selecting a row
of keys while Port B is used as an input port for sensing a
closed key. Thus the keyboard lines are selected one by
one through port A and the port B lines are polled
continuously till a key closure is sensed. The routine
DEBOUNCE is called for key debouncing. The key code
is depending upon the selected row and a low sensed
column.
Next Page
+ 5V
10KΩ
10KΩ
10KΩ
10KΩ
RESET
LOWR
C D E F 10KΩ
IORD PA3
8 9 A B 10KΩ
D0-D7 PA2
8255 PA1 4 5 6 7 10KΩ
A2 A1 0 1 2 3 10KΩ
PA0
A1 A0
PB3
PB2
A15 PB1
A12 CS
A13
A14 PB0
A0
Interfacing 4 * 4 Keyboard
Next Page
• The higher order lines of port A and port B are left unused.
The address of port A and port B will respectively 8000H
and 8002H while address of CWR will be 8006H. The
flow chart of the complete program is as given. The control
word for this problem will be 82H. Code segment CS is
used for storing the program code.
• Key Debounce : Whenever a mechanical push-button is
pressed or released once, the mechanical components of
the key do not change the position smoothly, rather it
generates a transient response .
Next Page
START
Initialise 8255 row,
column counter and key
code reg.
No Key
Closed
Yes
Wait for Debounce
Set row counter
row
Ground one row Counter =0 ?
Next Page
+5V Logic 1
V0
Logic 0 Logic 0
Key released Key released
Key pressed
A O
A O OUTPUT OR
ADDRESS INPUT/OUTPUT
CONNECTION A O CONNECTION
A O
W WRIT
C O
SELEC REA
MEMORY COMPONENT ILLUSTRATING THE ADDRESS, DATA
,
CONTROL CONNECTIONS
• RAM memory generally has at least one CS or S input and ROM at least one CE.
• If the CE, CS, S input is active the memory device perform the read or write.
• If it is inactive the memory device cannot perform read or write operation.
• If more than one CS connection is present, all most be active to perform read or
write data.
• Control connections: A ROM usually has only one control input, while a RAM
often has one or two control inputs.
• The control input most often found on the ROM is the output enable ( OE ) or
gate ( G ), this allows data to flow out of the output data pins of the ROM.
• If OE and the selected input are both active, then the output is enable, if OE is
inactive, the output is disabled at its high-impedance state.
• The OE connection enables and disables a set of three-state buffer located within
the memory device and must be active to read data.
• A RAM memory device has either one or two control inputs. If there is one
control input it is often called R/W.
• This pin selects a read operation or a write operation only if the device is selected
by the selection input ( CS ).
• If the RAM has two control inputs, they are usually labeled WE or W and OE or
G.
• ( WE ) write enable must be active to perform a memory write operation and OE
must be active to perform a memory read operation.
• When these two controls WE and OE are present, they must never be active at the
same time.
• The ROM read only memory permanently stores programs and data and data was
always present, even when power is disconnected.
• It is also called as nonvolatile memory.
• EPROM ( erasable programmable read only memory ) is also erasable if exposed
to high intensity ultraviolet light for about 20 minutes or less, depending upon the
type of EPROM.
• We have PROM (programmable read only memory )
• RMM ( read mostly memory ) is also called the flash memory.
• The flash memory is also called as an EEPROM (electrically erasable
programmable ROM ), EAROM ( electrically alterable ROM ), or a NOVROM
( nonvolatile ROM ).
• These memory devices are electrically erasable in the system, but require more
time to erase than a normal RAM.
• EPROM contains the series of 27XXX contains the following part numbers :
2704( 512 * 8 ), 2708(1K * 8 ), 2716( 2K * 8 ), 2732( 4K * 8 ), 2764( 8K * 8 ),
27128( 16K * 8) etc..
• Each of these parts contains address pins, eight data connections, one or more
chip selection inputs (CE) and an output enable pin (OE ).
• This device contains 11 address inputs and 8 data outputs.
• If both the pin connection CE and OE are at logic 0, data will appear on the output
connection . If both the pins are not at logic 0, the data output connections
remains at their high impedance or off state.
• To read data from the EPROM Vpp pin must be placed at a logic 1.
A7 24 Vcc
1
A6 23 A8
2
A5 22 A9
3
A4 4 21 Vpp
A3 20 CS
5
A2 19 A10
6
A1 7 18 PD/PGM
A0 17 O7
8
O0 16 O6
9
O1 15 O5
10
O2 14 O4
11
GND 13 O3
12
C CHIP
O0-O7 OUT
PIN
DATA OUTPUTS
Vcc O0 – O7
GND
Vpp
CHIP SELECT
CS POWER DOWN
AND PROGRAM OUTPUT
PD / PGM LOGIC BUFFERS
Y Y-GATING
A0 - A10 DECODER
ADDRESS
INPUTS
16,386 BIT
X CELL
DECODER MATRIX
BLOCK DIAGRAM
• Static RAM memory device retain data for as long as DC power is applied.
Because no special action is required to retain stored data, these devices are called
as static memory. They are also called volatile memory because they will not
retain data without power.
• The main difference between a ROM and RAM is that a RAM is written under
normal operation, while ROM is programmed outside the computer and is only
normally read.
• The SRAM stores temporary data and is used when the size of read/write memory
is relatively small.
A7 24 V CC
1
A6
2 23 A8
A5 3 22 A9
A4 4 21 W
A3 5 20 G
A2 6 19 A10
A1 7 18 S
A0
8 17 DQ8
DQ1 9 16 DQ7
DQ2 10 15 DQ6
DQ3 11 14 DQ5
Vss 12 13 DQ4
S CHIP SELECT
DATA IN /
DQ _ DQ
0 8 DATA OUT
OUT PUT
G ENABLE
Vss GROUND
Vcc + 5 V
SUPPLY
PIN NAMES
• The control inputs of this RAM are slightly different from those presented earlier.
The OE pin is labeled G, the CS pin S and the WE pin W.
• This 4016 SRAM device has 11 address inputs and 8 data input/output
connections.
• As a good and efficient interfacing practice, the address map of the system should
be continuous as far as possible, i.e. there should not be no windows in the map
and no fold back space should be allowed.
• A memory location should have a single address corresponding to it, i.e. absolute
decoding should be preferred and minimum hardware should be used for
decoding.
Dynamic RAM
• Whenever a large capacity memory is required in a microcomputer system, the
memory subsystem is generally designed using dynamic RAM because there are
various advantages of dynamic RAM.
• E.g. higher packing density, lower cost and less power consumption. A typical
static RAM cell may require six transistors while the dynamic RAM cell requires
only a transistors along with a capacitor. Hence it is possible to obtain higher
packaging density and hence low cost units are available.
• The basic dynamic RAM cell uses a capacitor to store the charge as a
representation of data. This capacitor is manufactured as a diode that is reverse-
biased so that the storage capacitance comes into the picture. This storage
capacitance is utilized for storing the charge representation of data but the
reverse-biased diode has leakage current that tends to discharge the capacitor
giving rise to the possibility of data loss. To avoid this possible data loss, the data
stored in a dynamic RAM cell must be refreshed after a fixed time interval
regularly. The process of refreshing the data in RAM is called as Refresh cycle.
• The refresh activity is similar to reading the data from each and every cell of
memory, independent of the requirement of microprocessor. During this refresh
period all other operations related to the memory subsystem are suspended. Hence
the refresh activity causes loss of time, resulting in reduce system performance.
• However keeping in view the advantages of dynamic RAM, like low power
consumption, high packaging density and low cost, most of the advanced
computing system are designed using dynamic RAM, at the cost of operating
speed.
• A dedicated hardware chip called as dynamic RAM controller is the most
important part of the interfacing circuit.
• The Refresh cycle is different from the memory read cycle in the following
aspects.
1. The memory address is not provided by the CPU address bus, rather it is
generated by a refresh mechanism counter called as refresh counter.
2. Unlike memory read cycle, more than one memory chip may be enabled at a time
so as to reduce the number of total memory refresh cycles.
3. The data enable control of the selected memory chip is deactivated, and data is
not allowed to appear on the system data bus during refresh, as more than one
memory units are refreshed simultaneously. This is to avoid the data from the
different chips to appear on the bus simultaneously.
4. Memory read is either a processor initiated or an external bus master initiated and
carried out by the refresh mechanism.
A7 – A13
16K*1 16K*1 16K*1 16K*1 16K* 16K*1 16K*1 16K*1
A6 – A0 1
OE CE OE CE OE CE OE CE OE CE OE CE OE CE OE CE
CE1
A7 – A13
A7 – A13
16K* 16K*1 16K*1 16K*1 16K*1 16K*1 16K*1 16K*1
A6 – A0
OE CE OE CE OE CE OE CE OE CE OE CE OE CE OE CE
CE2
7 bit
A0-A6 bus
MUX
Ar0
–
Ar6 CE1 CE2
Address
Refresh Deciding logic
Ref. Add Refresh
timer
Counter A15 A14
To transreceivers
Dynamic RAM Refreshing Logic
+12 V CLK
X0/OP2 X1/CLK
Bank Select B0 Vcc
16K/64K
AH0 -AH7
OUT7 – OUT0
ADDRESS Address O/P
AL0 -AL7
Vcc +5V
A0 – A7
CAS
Dout
WE
8267
XACK XCIEVER
XACK CS
WR
• Most of the functions of 8208 and 8203 are similar but 8208 can be used to
refresh the dynamic RAM using DMA approach. The memory system is divided
into even and odd banks of 256K bytes each, as required for an 8086 system.
• The inverted AACK output of 8208 latches the A0 and BHE signals required for
selecting the banks. If the latched bank select signal and the WE/PCLK output of
8208 both become low. It indicates a write operation to the respective bank.
PIO 8255
• The parallel input-output port chip 8255 is also called as programmable
peripheral input-output port. The Intel’s 8255 is designed for use with Intel’s 8-
bit, 16-bit and higher capability microprocessors. It has 24 input/output lines
which may be individually programmed in two groups of twelve lines each, or
three groups of eight lines. The two groups of I/O pins are named as Group A and
Group B. Each of these two groups contains a subgroup of eight I/O lines called
as 8-bit port and another subgroup of four lines or a 4-bit port. Thus Group A
contains an 8-bit port A along with a 4-bit port. C upper.
• The port A lines are identified by symbols PA0-PA7 while the port C lines are
identified as PC4-PC7. Similarly, Group B contains an 8-bit port B, containing
lines PB0-PB7 and a 4-bit port C with lower bits PC0- PC3. The port C upper and
port C lower can be used in combination as an 8-bit port C.
• Both the port C are assigned the same address. Thus one may have either three 8-
bit I/O ports or two 8-bit and two 4-bit ports from 8255. All of these ports can
function independently either as input or as output ports. This can be achieved by
programming the bits of an internal register of 8255 called as control word
register ( CWR ).
• The internal block diagram and the pin configuration of 8255 are shown in fig.
• The 8-bit data bus buffer is controlled by the read/write control logic. The
read/write control logic manages all of the internal and external transfers of both
data and control words.
• RD, WR, A1, A0 and RESET are the inputs provided by the microprocessor to
the READ/ WRITE control logic of 8255. The 8-bit, 3-state bidirectional buffer is
used to interface the 8255 internal data bus with the external system data bus.
• This buffer receives or transmits data upon the execution of input or output
instructions by the microprocessor. The control words or status information is also
transferred through the buffer.
• The signal description of 8255 are briefly presented as follows :
• PA7-PA0: These are eight port A lines that acts as either latched output or
buffered input lines depending upon the control word loaded into the control word
register.
• PC7-PC4 : Upper nibble of port C lines. They may act as either output latches or
input buffers lines.
• This port also can be used for generation of handshake lines in mode 1 or mode
2.
• PC3-PC0 : These are the lower port C lines, other details are the same as PC7-
PC4 lines.
• PB0-PB7 : These are the eight port B lines which are used as latched output lines
or buffered input lines in the same way as port A.
• RD : This is the input line driven by the microprocessor and should be low to
indicate read operation to 8255.
• WR : This is an input line driven by the microprocessor. A low on this line
indicates write operation.
• CS : This is a chip select line. If this line goes low, it enables the 8255 to respond
to RD and WR signals, otherwise RD and WR signal are neglected.
• A1-A0 : These are the address input lines and are driven by the microprocessor.
These lines A1-A0 with RD, WR and CS from the following operations for 8255.
These address lines are used for addressing any one of the four registers, i.e. three
ports and a control word register as given in table below.
• In case of 8086 systems, if the 8255 is to be interfaced with lower order data bus,
the A0 and A1 pins of 8255 are connected with A1 and A2 respectively.
• D0-D7 : These are the data bus lines those carry data or control word to/from the
microprocessor.
• RESET : A logic high on this line clears the control word register of 8255. All
ports are set as input ports by default after reset.
RD WR CS A1 A0 Input (Read) cycle
0 1 0 0 0 Port A to Data bus
0 1 0 0 1 Port B to Data bus
0 1 0 1 0 Port C to Data bus
0 1 0 1 1 CWR to Data bus
RD WR CS A1 A0 Function
X X 1 X X Data bus tristated
1 1 0 X X Data bus tristated
PA PA6 – PA7 PA PA
8 PCU PC4 – PC7 8
2 PCU
2 PC
5 PCL PC0-PC3 5
5 PCL
5
PB PB0 – PB7 PB PB0 – PB7
Mode 0
CS PC4-PC7
RESET
8255A
PC0-PC3
A0
A1 PB0-PB7
RD
Vcc
WR
GND
Signals of 8255
3 4 PA0-PA7
Group A Group A
control Port A(8)
1
D0-D7 Data Group A PC7-PC4
bus Port C
8 bit int data bus upper(4)
Group B PC0-PC3
2 Port C
RD Lower(4)
WR READ/
WRITE PB7-PB0
A0 Control Group B Group B
A1 Logic control Port B(8)
RESET
CS
Block Diagram of 8255
D7 D6 D5 D4 D3 D2 D1 D0
Mode for PA PC U Mode PB PC L
Port A for PB
Mode Set flag
1- active
0- BSR mode
Group - A Group - B
1 Input
PC u PCL 1 Input
0 Output
0 Output
1 Input
PA PB 1 Input
0 Output
00 – mode 0 0 Output
Mode
Select 01 – mode 1 Mode 0 mode- 0
of PA Select
10 – mode 2 1 mode- 1
PC0 INTR
PC3 INTRA
A
RD PC6 – PC7 I/O
RD
Mode 1 Control Word Group A Mode 1 Control Word Group B
I/P I/P
STB
IBF
INTR
RD
DATA
from
WR
OBF
INTR
ACK
Data OP to
Port
Mode 1 Strobed Data Output
Output control signal definitions Mode 1
1 0 1 0 1/0 X X X 1 X X X X 1 0 X
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
1 - Input
0 - Output
For PC4 – PC5
PC0 INTRB
PC3 INTRA
WR PC4 – PC5 I/O
OBF
INTR
ACK
STB
IBF
D7 D6 D5 D4 D3 D2 D1 D0
PA0-PA7
PC7 OBF
INTE 1 PC6
ACK
Mode 2 pins
8254
Pin Description
Pin Type Name and Function
Symbol
No.
D7-D0 1-8 I/O DATA: Bi-directional three state data bus
lines, connected to system data bus.
CLK 0 9 I CLOCK 0: Clock input of Counter 0.
OUT 0 10 O OUTPUT 0: Output of Counter 0.
GATE 0 11 I GATE 0: Gate input of Counter 0.
Functional Description
• The 8254 is a programmable interval timer/counter designed for use with Intel
microcomputer systems.
• It is a general purpose, multi-timing element that can be treated as an array of I/O
ports in the system software.
• The 8254 solves one of the most common problems in any microcomputer
system, the generation of accurate time delays under software control. Instead of
setting up timing loops in software, the programmer configures the 8254 to match
his requirements and programs one of the counters for the desired delay.
• After the desired delay, the 8254 will interrupt the CPU. Software overhead is
minimal and variable length delays can easily be accommodated.
• Some of the other counter/timer functions common to microcomputers which can
be implemented with the 8254 are:
• Real time clock
• Event-counter
• Digital one-shot
• Programmable rate generator
• Square wave generator
• Binary rate multiplier
• Complex waveform generator
• Complex motor controller
Block Diagram
• DATA BUS BUFFER: This 3-state, bi-directional, 8-bit buffer is used to
interface the 8254 to the system bus, see the figure : Block Diagram Showing
Data Bus Buffer and Read/Write Logic Functions.
• READ/WRITE LOGIC : The Read/Write Logic accepts inputs from the system
bus and generates control signals for the other functional blocks of the 8254. A1
and A0 select one of the three counters or the Control Word Register to be read
from/written into.
• A ``low'' on the RD input tells the 8254 that the CPU is reading one of the
counters.
Figure 3. Block Diagram Showing Data Bus Buffer and Read/Write Logic Functions
• A ``low'' on the WR input tells the 8254 that the CPU is writing either a Control
Word or an initial count. Both RD and WR are qualified by CS; RD and WR are
ignored unless the 8254 has been selected by holding CS low.
• CONTROL WORD REGISTER :The Control Word Register (see Figure 4) is
selected by the Read/Write Logic when A1,A0 = 11. If the CPU then does a write
operation to the 8254, the data is stored in the Control Word Register and is
interpreted as a Control Word used to define the operation of the Counters.
Figure 4. Block Diagram Showing Control Word Register and Counter Functions
• The Control Word Register can only be written to; status information is available
with the Read-Back Command.
• COUNTER 0, COUNTER 1, COUNTER 2 :These three functional blocks are
identical in operation, so only a single Counter will be described. The internal
block diagram of a single counter is shown in Figure 5.
• The Counters are fully independent. Each Counter may operate in a different
Mode.
• The Control Word Register is shown in the figure; it is not part of the Counter
itself, but its contents determine how the Counter operates.
• The status register, shown in Figure 5, when latched, contains the current contents
of the Control Word Register and status of the output and null count flag. (See
detailed explanation of the Read-Back command.)
• The actual counter is labelled CE (for ``Counting Element''). It is a 16-bit
presettable synchronous down counter. OLM and OLL are two 8-bit latches. OL
stands for ``Output Latch''; the subscripts M and L stand for ``Most significant
byte'' and ``Least significant byte'‘ respectively.
Figure 5. Internal Block Diagram of a Counter
• Both are normally referred to as one unit and called just OL. These latches
normally ``follow'‘ the CE, but if a suitable Counter Latch Command is sent to
the 8254, the latches ``latch'' the present count until read by the CPU and then
return to ``following'' the CE.
• One latch at a time is enabled by the counter's Control Logic to drive the internal
bus. This is how the 16-bit Counter communicates over the 8-bit internal bus.
Note that the CE itself cannot be read; whenever you read the count, it is the OL
that is being read.
• Similarly, there are two 8-bit registers called CRM and CRL (for ``Count
Register''). Both are normally referred to as one unit and called just CR.
• When a new count is written to the Counter, the count is stored in the CR and
later transferred to the CE. The Control Logic allows one register at a time to be
loaded from the internal bus. Both bytes are transferred to the CE simultaneously.
• CRM and CRL are cleared when the Counter is programmed. In this way, if the
Counter has been programmed for one byte counts (either most significant byte
only or least significant byte only) the other byte will be zero.
• Note that the CE cannot be written into, whenever a count is written, it is written
into the CR.
• The Control Logic is also shown in the diagram.
• CLK n, GATE n, and OUT n are all connected to the outside world through the
Control Logic.
• 8254 SYSTEM INTERFACE :The 8254 is a component of the Intel
Microcomputer Systems and interfaces in the same manner as all other
peripherals of the family.
• It is treated by the system's software as an array of peripheral I/O ports; three are
counters and the fourth is a control register for MODE programming.
• Basically, the select inputs A0,A1 connect to the A0,A1 address bus signals of the
CPU. The CS can be derived directly from the address bus using a linear select
method. Or it can be connected to the output of a decoder, such as an Intel 8205
for larger systems.
• Programming the 8254 :Counters are programmed by writing a Control Word
and then an initial count.
• The Control Words are written into the Control Word Register, which is selected
when A1,A0 = 11. The Control Word itself specifies which Counter is being
programmed.
NOTE: Don't care bits (X) should be 0 to insure compatibility with future Intel products.
Figure 7. Control Word Format
• A new initial count may be written to a Counter at any time without affecting the
Counter's programmed Mode in any way. Counting will be affected as described
in the Mode definitions. The new count must follow the programmed count
format.
• If a Counter is programmed to read/write two-byte counts, the following
precaution applies: A program must not transfer control between writing the first
and second byte to another routine which also writes into that same Counter.
Otherwise, the Counter will be loaded with an incorrect count.
Figure 8. A Few Possible Programming Sequences
• The count is then unlatched automatically and the OL returns to ``following'' the
counting element (CE).
• This allows reading the contents of the Counters ``on the fly'' without affecting
counting in progress.
• Multiple Counter Latch Commands may be used to latch more than one Counter.
Each latched Counter's OL holds its count until it is read.
• Counter Latch Commands do not affect the programmed Mode of the Counter in
any way.
• If a Counter is latched and then, some time later, latched again before the count is
read, the second Counter Latch Command is ignored. The count read will be the
count at the time the first Counter Latch Command was issued.
• With either method, the count must be read according to the programmed format;
specifically, if the Counter is programmed for two byte counts, two bytes must be
read. The two bytes do not have to be read one right after the other, read or write
or programming operations of other Counters may be inserted between them.
• Another feature of the 8254 is that reads and writes of the same Counter may be
interleaved.
• Example: If the Counter is programmed for two byte counts, the following
sequence is valid.
1) Read least significant byte.
2) Write new least significant byte.
3) Read most significant byte.
4) Write new most significant byte.
• If a Counter is programmed to read/write two-byte counts, the following
precaution applies: A program must not transfer control between reading the first
and second byte to another routine which also reads from that same Counter.
Otherwise, an incorrect count will be read.
• READ-BACK COMMAND: The third method uses the Read-Back Command.
This command allows the user to check the count value, programmed Mode, and
current states of the OUT pin and Null Count flag of the selected counter (s).
• The command is written into the Control Word Register and has the format shown
in Figure 10. The command applies to the counters selected by setting their
corresponding bits D3, D2, D1 = 1.
• The read-back command may be used to latch multiple counter output latches
(OL) by setting the COUNT bit D5 = 0 and selecting the desired counter (s).
This single command is functionally equivalent to several counter latch
commands, one for each counter latched.
• Each counter's latched count is held until it is read (or the counter is
reprogrammed).
• The counter is automatically unlatched when read, but other counters remain
latched until they are read. If multiple count read-back commands are issued to
the same counter without reading the count, all but the first are ignored; i.e., the
count which will be read is the count at the time the first read-back command was
issued.
• The read-back command may also be used to latch status information of selected
counter (s) by setting STATUS bit D4 = 0. Status must be latched to be read;
status of a counter is accessed by a read from that counter.
• The counter status format is shown in Figure 11.
• Bits D5 through D0 contain the counter's programmed Mode exactly as written in
the last Mode Control Word. OUTPUT bit D7 contains the current state of the
OUT pin.
• This allows the user to monitor the counter's output via software, possibly
eliminating some hardware from a system. NULL COUNT bit D6 indicates when
the last count written to the counter register (CR) has been loaded into the
counting element (CE).
• The exact time this happens depends on the Mode of the counter and is described
in the Mode Definitions, but until the count is loaded into the counting element
(CE), it can't be read from the counter.
• If the count is latched or read before this time, the count value will not reflect the
new count just written. The operation of Null Count is shown in Figure 12.
• If multiple status latch operations of the counter (s) are performed without reading
the status, all but the first are ignored; i.e., the status that will be read is the status
of the counter at the time the first status read-back command was issued.
• Both count and status of the selected counter (s) may be latched simultaneously
by setting both COUNT and STATUS bits D5,D4 = 0. This is functionally the
same as issuing two separate read-back commands at once, and the above
discussions apply here also.
• Specifically, if multiple count and/or status read-back commands are issued to the
same counter (s) without any intervening reads, all but the first are ignored. This
is illustrated in Figure 13.
• If both count and status of a counter are latched, the first read operation of that
counter will return latched status, regardless of which was latched first. The next
one or two reads (depending on whether the counter is programmed for one or
two type counts) return latched count. Subsequent reads return unlatched count.
Figure 13. Read-Back Command Example
• Mode 0 is typically used for event counting. After the Control Word is written,
OUT is initially low, and will remain low until the Counter reaches zero.
• OUT then goes high and remains high until a new count or a new Mode 0 Control
Word is written into the Counter.
• GATE = 1 enables counting; GATE = 0 disables counting. GATE has no effect on
OUT.
• After the Control Word and initial count are written to a Counter, the initial count
will be loaded on the next CLK pulse. This CLK pulse does not decrement the
count, so for an initial count of N, OUT does not go high until N a 1 CLK pulses
after the initial count is written.
• If a new count is written to the Counter, it will be loaded on the next CLK pulse
and counting will continue from the new count. If a two-byte count is written, the
following happens:
1) Writing the first byte disables counting. OUT is set low immediately (no clock
pulse required).
2) Writing the second byte allows the new count to be loaded on the next CLK pulse.
• This allows the counting sequence to be synchronized by software. Again, OUT
does not go high until Na1 CLK pulses after the new count of N is written.
• If an initial count is written while GATE e 0, it will still be loaded on the next
CLK pulse. When GATE goes high, OUT will go high N CLK pulses later; no
CLK pulse is needed to load the Counter as this has already been done.
Figure 15. Mode 0
Note:
1. Counters are programmed for binary (not BCD) counting and for reading/writing
least significant byte (LSB) only.
2. The counter is always selected (CS always low).
3. CW stands for ``Control Word''; CW = 10 means a control word of 10 HEX is
written to the counter.
4. LSB stands for ``Least Significant Byte'' of count.
5. Numbers below diagrams are count values. The lower number is the least
significant byte. The upper number is the most significant byte. Since the counter is
programmed to read/write LSB only, the most significant byte cannot be
read. N stands for an undefined count. Vertical lines show transitions between count
values.
• When half the initial count has expired, OUT goes low for the remainder of the
count. Mode 3 is periodic; the sequence above is repeated indefinitely.
• An initial count of N results in a square wave with a period of N CLK cycles.
GATE = 1 enables counting; GATE = 0 disables counting. If GATE goes low
while OUT is low, OUT is set high immediately; no CLK pulse is required.
• A trigger reloads the Counter with the initial count on the next CLK pulse. Thus
the GATE input can be used to synchronize the Counter.
• After writing a Control Word and initial count, the Counter will be loaded on the
next CLK pulse. This allows the Counter to be synchronized by software also.
• Writing a new count while counting does not affect the current counting
sequence. If a trigger is received after writing a new count but before the end of
the current half-cycle of the square wave, the Counter will be loaded with the new
count on the next CLK pulse and counting will continue from the new count.
Otherwise, the new count will be loaded at the end of the current half-cycle.
• Mode 3:Even counts: OUT is initially high. The initial count is loaded on one
CLK pulse and then is decremented by two on succeeding CLK pulses.
• When the count expires OUT changes value and the Counter is reloaded with the
initial count. The above process is repeated indefinitely.
• Odd counts: OUT is initially high. The initial count minus one (an even number)
is loaded on one CLK pulse and then is decremented by two on succeeding CLK
pulses.
• One CLK pulse after the count expires, OUT goes low and the Counter is
reloaded with the initial count minus one.
• Succeeding CLK pulses decrement the count by two.
• When the count expires, OUT goes high again and the Counter is reloaded with
the initial count minus one. The above process is repeated indefinitely.
• So for odd counts, OUT will be high for (N - 1)/2 counts and low for (N - 1)/2
counts.
• MODE 4: SOFTWARE TRIGGERED STROBE :
• OUT will be initially high. When the initial count expires, OUT will go low for
one CLK pulse and then go high again. The counting sequence is ``triggered'‘ by
writing the initial count.
• GATE = 1 enables counting; GATE = 0 disables counting. GATE has no effect on
OUT. After writing a Control Word and initial count, the Counter will be loaded
on the next CLK pulse.
• This CLK pulse does not decrement the count, so for an initial count of N, OUT
does not strobe low until N + 1 CLK pulses after the initial count is written.
• If a new count is written during counting, it will be loaded on the next CLK pulse
and counting will continue from the new count. If a two-byte count is written, the
following happens:
1) Writing the first byte has no effect on counting.
2) Writing the second byte allows the new count to be loaded on the next CLK pulse.
• This allows the sequence to be ``retriggered'' by software. OUT strobes low N a 1
CLK pulses after the new count of N is written.
• COUNTER: New counts are loaded and Counters are decremented on the falling
edge of CLK.
• The largest possible initial count is 0, this is equivalent to 216 for binary counting
and 104 for BCD counting. The Counter does not stop when it reaches zero.
• In Modes 0, 1, 4, and 5 the Counter ``wraps around'' to the highest count, either
FFFF hex for binary counting or 9999 for BCD counting, and continues counting.
• Modes 2 and 3 are periodic; the Counter reloads itself with the initial count and
continues counting from there.
NOTE: 0 is equivalent to 216 for binary counting and 104 for BCD counting.
DB0-DB7 RD WR CS A0
TIMING
AND
DISPLAY CONTROL SCAN Return
REGISTERS UNIT COUNTER
SHIFT
OUT A0-A3 BD SL0 – SL3 RL0 – RL7 CNTL/
OUT B0-B3 STB
8279 Internal Architecture
RL2 1 40 Vcc
RL3 2 39 RL1
CLK 3 38 RL0
IRQ 4 37 CNTL/STB
RL4 5 36 SHIFT
RL5 6 35 SL3
RL6 7 34 SL2
RL7 8 33 SL1
RESET 9 32 SL0
8279
RD 10 31 OUT B0
WR 11 30 OUT B1
DB0 12 29 OUT B2
DB1 13 28 OUT B3
DB2 14 27 OUT A0
DB3 15 26 OUT A1
DB4 16 25 OUT A2
DB5 17 24 OUT A3
DB6 18 23 BD
DB7 19 22 CS
Vss 20 21 A0
IRQ RL0-7 8
CNTL/
STB
RD
CLK BD
Vss
• The signal discription of each of the pins of 8279 as follows :
• DB0-DB7 : These are bidirectional data bus lines. The data and command words
to and from the CPU are transferred on these lines.
• CLK : This is a clock input used to generate internal timing required by 8279.
• RESET : This pin is used to reset 8279. A high on this line reset 8279. After
resetting 8279, its in sixteen 8-bit display, left entry encoded scan, 2-key lock out
mode. The clock prescaler is set to 31.
• CS : Chip Select – A low on this line enables 8279 for normal read or write
operations. Other wise, this pin should remain high.
• A0 : A high on this line indicates the transfer of a command or status information.
A low on this line indicates the transfer of data. This is used to select one of the
internal registers of 8279.
• RD, WR ( Input/Output ) READ/WRITE – These input pins enable the data
buffers to receive or send data over the data bus.
• IRQ : This interrupt output lines goes high when there is a data in the FIFO
sensor RAM. The interrupt lines goes low with each FIFO RAM read operation
but if the FIFO RAM further contains any key-code entry to be read by the CPU,
this pin again goes high to generate an interrupt to the CPU.
• Vss, Vcc : These are the ground and power supply lines for the circuit.
• SL0-SL3-Scan Lines : These lines are used to scan the key board matrix and
display digits. These lines can be programmed as encoded or decoded, using the
mode control register.
• RL0 - RL7 - Return Lines : These are the input lines which are connected to one
terminal of keys, while the other terminal of the keys are connected to the
decoded scan lines. These are normally high, but pulled low when a key is
pressed.
• SHIFT : The status of the shift input lines is stored along with each key code in
FIFO, in scanned keyboard mode. It is pulled up internally to keep it high, till it is
pulled low with a key closure.
• BD – Blank Display : This output pin is used to blank the display during digit
switching or by a blanking closure.
• OUT A0 – OUT A3 and OUT B0 – OUT B3 – These are the output ports for
two 16*4 or 16*8 internal display refresh registers. The data from these lines is
synchronized with the scan lines to scan the display and keyboard. The two 4-bit
ports may also as one 8-bit port.
• CNTL/STB- CONTROL/STROBED I/P Mode : In keyboard mode, this lines is
used as a control input and stored in FIFO on a key closure. The line is a strobed
lines that enters the data into FIFO RAM, in strobed input mode. It has an
interrupt pull up. The lines is pulled down with a key closer.
iv. Sensor Matrix Mode : In the sensor matrix mode, the debounce logic is
inhibited. The 8-byte FIFO RAM now acts as 8 * 8 bit memory matrix. The status
of the sensor switch matrix is fed directly to sensor RAM matrix. Thus the sensor
RAM bits contains the row-wise and column wise status of the sensors in the
sensor matrix.
• The IRQ line goes high, if any change in sensor value is detected at the end of a
sensor matrix scan or the sensor RAM has a previous entry to be read by the CPU.
The IRQ line is reset by the first data read operation, if AI = 0, otherwise, by
issuing the end interrupt command. AI is a bit in read sensor RAM word.
Display Modes
• There are various options of data display. For example, the command number of
characters can be 8 or 16, with each character organised as single 8-bit or dual 4-
bit codes. Similarly there are two display formats.
• The first one is known as left entry mode or type writer mode, since in a type
writer the first character typed appears at the left-most position, while the
subsequent characters appear successively to the right of the first one. The other
display format is known as right entry mode, or calculator mode, since in a
calculator the first character entered appears at the rightmost position and this
character is shifted one position left when the next characters is entered.
• Thus all the previously entered characters are shifted left by one position when a
new characters is entered.
i. Left Entry Mode : In the left entry mode, the data is entered from left side of the
display unit. Address 0 of the display RAM contains the leftmost display
characters and address 15 of the RAM contains the right most display characters.
It is just like writing in our address is automatically updated with successive reads
or writes. The first entry is displayed on the leftmost display and the sixteenth
entry on the rightmost display. The seventeenth entry is again displayed at the
leftmost display position.
ii. Right Entry Mode : In this right entry mode, the first entry to be displayed is
entered on the rightmost display. The next entry is also placed in the right most
display but after the previous display is shifted left by one display position. The
leftmost characters is shifted out of that display at the seventeenth entry and is
lost, i.e. it is pushed out of the display RAM.
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 0 D D D K K K 1
D D Display modes
0 0 Eight 8-bit character Left entry
0 1 Sixteen 8-bit character left entry
K K K Keyboard modes
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 0 1 P P P P P 1
c) Read FIFO / Sensor RAM : The format of this command is given below.
• This word is written to set up 8279 for reading FIFO/ sensor RAM. In scanned
keyboard mode, AI and AAA bits are of no use. The 8279 will automatically
drive data bus for each subsequent read, in the same sequence, in which the data
was entered.
• In sensor matrix mode, the bits AAA select one of the 8 rows of RAM. If AI flag
is set, each successive read will be from the subsequent RAM location.
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 1 0 AI X A A A 1
X – don’t care
AI – Auto Increment Flag
AAA – Address pointer to 8 bit FIFO RAM
d) Read Display RAM : This command enables a programmer to read the display
RAM data. The CPU writes this command word to 8279 to prepare it for display
RAM read operation. AI is auto increment flag and AAAA, the 4-bit address
points to the 16-byte display RAM that is to be read. If AI=1, the address will be
automatically, incremented after each read or write to the Display RAM. The
same address counter is used for reading and writing.
D7 D6 D5 D4 D3 D2 D1 D0 A0
0 1 1 AI A A A A 1
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 0 0 AI A A A A 1
f) Display Write Inhibit/Blanking : The IW ( inhibit write flag ) bits are used to
mask the individual nibble as shown in the below command word. The output
lines are divided into two nibbles ( OUTA0 – OUTA3 ) and ( OUTB0 – OUTB3
), those can be masked by setting the corresponding IW bit to 1.
• Once a nibble is masked by setting the corresponding IW bit to 1, the entry to
display RAM does not affect the nibble even though it may change the unmasked
nibble. The blank display bit flags (BL) are used for blanking A and B nibbles.
• Here D0, D2 corresponds to OUTB0 – OUTB3 while D1 and D3 corresponds to
OUTA0-OUTA3 for blanking and masking.
• If the user wants to clear the display, blank (BL) bits are available for each nibble
as shown in format. Both BL bits will have to be cleared for blanking both the
nibbles.
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 0 1 X IW IW BL BL 1
g) Clear Display RAM : The CD2, CD1, CD0 is a selectable blanking code to clear
all the rows of the display RAM as given below. The characters A and B
represents the output nibbles.
• CD2 must be 1 for enabling the clear display command. If CD2 = 0, the clear
display command is invoked by setting CA=1 and maintaining CD1, CD0 bits
exactly same as above. If CF=1, FIFO status is cleared and IRQ line is pulled
down.
• Also the sensor RAM pointer is set to row 0. if CA=1, this combines the effect of
CD and CF bits. Here, CA represents Clear All and CF as Clear FIFO RAM.
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 1 0 CD2 CD1 CD0 CF CA 1
h) End Interrupt / Error mode Set : For the sensor matrix mode, this command
lowers the IRQ line and enables further writing into the RAM. Otherwise, if a
change in sensor value is detected, IRQ goes high that inhibits writing in the
sensor RAM.
• For N-Key roll over mode, if the E bit is programmed to be ‘1’, the 8279 operates
in special Error mode. Details of this mode are described in scanned keyboard
special error mode. X- don’t care.
D7 D6 D5 D4 D3 D2 D1 D0 A0
1 1 1 E X X X X 1
INT2 Shift Key
INTR 8259
Control board
Interru
pt Return 8 columns
controll lines 8 rows
er
8
• If we are working with an 8086, we have a problem here because the 8086 has
only two interrupt inputs, NMI and INTR.
• If we save NMI for a power failure interrupt, this leaves only one interrupt for all
the other applications. For applications where we have interrupts from multiple
source, we use an external device called a priority interrupt controller ( PIC ) to
the interrupt signals into a single interrupt input on the processor.
RD Read/
WR Write IR0
Interrupt
A0 Logic IN Service Priority Request IR1
Register Resolver Register
CS ISR IRR
CAS0 IR7
Cascade
CAS1 Buffer/
CAS2 Comparator
Interrupt Mask Register
SP / EN IMR
Internal Bus
Fig:1 8259A Block Diagram
• Priority Resolver : This unit determines the priorities of the interrupt requests
appearing simultaneously. The highest priority is selected and stored into the
corresponding bit of ISR during INTA pulse. The IR0 has the highest priority
while the IR7 has the lowest one, normally in fixed priority mode. The priorities
however may be altered by programming the 8259A in rotating priority mode.
• Interrupt Mask Register (IMR) : This register stores the bits required to mask
the interrupt inputs. IMR operates on IRR at the direction of the Priority Resolver.
• Interrupt Control Logic: This block manages the interrupt and interrupt
acknowledge signals to be sent to the CPU for serving one of the eight interrupt
requests. This also accepts the interrupt acknowledge (INTA) signal from CPU
that causes the 8259A to release vector address on to the data bus.
• Data Bus Buffer : This tristate bidirectional buffer interfaces internal 8259A bus
to the microprocessor system data bus. Control words, status and vector
information pass through data buffer during read or write operations.
• Read/Write Control Logic: This circuit accepts and decodes commands from the
CPU. This block also allows the status of the 8259A to be transferred on to the
data bus.
• Cascade Buffer/Comparator: This block stores and compares the ID’s all the
8259A used in system. The three I/O pins CASO-2 are outputs when the 8259A is
used as a master. The same pins act as inputs when the 8259A is in slave mode.
The 8259A in master mode sends the ID of the interrupting slave device on these
lines. The slave thus selected, will send its preprogrammed vector address on the
data bus during the next INTA pulse.
• CS: This is an active-low chip select signal for enabling RD and WR operations
of 8259A. INTA function is independent of CS.
• WR : This pin is an active-low write enable input to 8259A. This enables it to
accept command words from CPU.
• RD : This is an active-low read enable input to 8259A. A low on this line enables
8259A to release status onto the data bus of CPU.
• D0-D7 : These pins from a bidirectional data bus that carries 8-bit data either to
control word or from status word registers. This also carries interrupt vector
information.
• CAS0 – CAS2 Cascade Lines : A signal 8259A provides eight vectored
interrupts. If more interrupts are required, the 8259A is used in cascade mode. In
cascade mode, a master 8259A along with eight slaves 8259A can provide upto
64 vectored interrupt lines. These three lines act as select lines for addressing the
slave 8259A.
• PS/EN : This pin is a dual purpose pin. When the chip is used in buffered mode, it
can be used as buffered enable to control buffer transreceivers. If this is not used
in buffered mode then the pin is used as input to designate whether the chip is
used as a master (SP =1) or slave (EN = 0).
• INT : This pin goes high whenever a valid interrupt request is asserted. This is
used to interrupt the CPU and is connected to the interrupt input of CPU.
• IR0 – IR7 (Interrupt requests) :These pins act as inputs to accept interrupt
request to the CPU. In edge triggered mode, an interrupt service is requested by
raising an IR pin from a low to a high state and holding it high until it is
acknowledged, and just by latching it to high level, if used in level triggered
mode.
CS 1 28 Vcc
WR 2 27 A0
RD 3 26 INTA
D7 4 25 IR7
D6 5 24 IR6
D5 6 23 IR5
D4 7 22 IR4
D3 8 8259A 21 IR3
D2 9 20 IR2
D1 10 19 IR1
D0 11 18 IR0
CAS0 12 17 INT
CAS1 13 16 SP / EN
GND 14 15 CAS2
ICW2
NO (IC4 =0)
B B : IS ICW4 NEEDED ?
YES (IC4 = 1)
ICW4
Ready to Accept
Interrupt Request
Fig 3: Initialisation Sequence of 8259A
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 T7 T6 T5 T4 T3 A10 A9 A8
1 S7 S6 S5 S4 S3 S2 S1 S0
• ICW4: The use of this command word depends on the IC4 bit of ICW1. If IC4=1,
IC4 is used, otherwise it is neglected. The bit functions of ICW4 are described as
follow:
• SFNM: If BUF = 1, the buffered mode is selected. In the buffered mode, SP/EN
acts as enable output and the master/slave is determined using the M/S bit of
ICW4.
• M/S: If M/S = 1, 8259A is a master. If M/S =0, 8259A is slave. If BUF = 0, M/S
is to be neglected.
• AEOI: If AEOI = 1, the automatic end of interrupt mode is selected.
• µPM : If the µPM bit is 0, the Mcs-85 system operation is selected and if µPM=1,
8086/88 operation is selected.
• Operation Command Words: Once 8259A is initialized using the previously
discussed command words for initialisation, it is ready for its normal function, i.e.
for accepting the interrupts but 8259A has its own way of handling the received
interrupts called as modes of operation. These modes of operations can be
selected by programming, i.e. writing three internal registers called as operation
command words.
• In the three operation command words OCW1, OCW2 and OCW3 every bit
corresponds to some operational feature of the mode selected, except for a few
bits those are either 1 or 0. The three operation command words are shown in fig
with the bit selection details.
• OCW1 is used to mask the masked and if it is 0 the request is enabled. In OCW2
the three bits, R, SL and EOI control the end of interrupt, the rotate mode and
their combinations as shown in fig below.
• The three bits L2, L1 and L0 in OCW2 determine the interrupt level to be selected
for operation, if SL bit is active i.e. 1.
• The details of OCW2 are shown in fig.
• In operation command word 3 (OCW3), if the ESMM bit, i.e. enable special mask
mode bit is set to 1, the SMM bit is neglected. If the SMM bit, i.e. special mask
mode. When ESMM bit is 0 the SMM bit is neglected. If the SMM bit. i.e. special
mask mode bit is 1, the 8259A will enter special mask mode provided ESMM=1.
• If ESMM=1 and SMM=0, the 8259A will return to the normal mask mode. The
details of bits of OCW3 are given in fig along with their bit definitions.
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 M7 M6 M5 M4 M3 M2 M1 M0
1 – Mask Set
0 – Mask Reset
Fig (a) : OCW1
A0 D7 D6 D5 D4 D3 D2 D1 D0
Fig (b) :
0 0 1 – Poll 0 0 No Action
No
Command 0 1
Reset Special 0 1
0 – No Poll 1 0 Read IRR on
Mask 1 0 next RD pulse
Set Special 1 1 Command 1 1
Read IRR on
Mask
next RD pulse
Fig : Operation Command Words
Fig (c) :OCW2
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 R SL EOI 0 0 L2 L1 L0
0 1 2 3 4 5 6 7
0 1 0 0 0 1 0 1
0 0 1 1 0 0 1 1
0 0 0 0 1 1 1 1
END OF
INTERRUPT 0 0 1 NON-SPECIFIC EOI COMMAND
0 1 1 SPECIFIC EOI COMMAND
1 0 1 ROTATE ON NON-SPECIFIC EOI MODE (SET)
AUTOMATIC 1 0
0 ROTATE IN AUTOMATIC EOI MODE (SET)
ROTATION 0 0 0 ROTATE IN AUTOMATIC EOI (CLEAR)
SPECIFIC 1 1 1 ROTATE ON SPECIFIC EOI COMMAND
ROTATION 1 1 0 SET PRIORITY COMMAND*
0 1 0 NO OPERATION
* - In this Mode L0 – L2 are used
1 x x x x w2 w1 w0
Binary code of
If = 1, there is an interrupt highest priority
level
Fig : Data Word of 8259
• Special Fully Nested Mode : This mode is used in more complicated system,
where cascading is used and the priority has to be programmed in the master
using ICW4. this is somewhat similar to the normal nested mode.
• In this mode, when an interrupt request from a certain slave is in service, this
slave can further send request to the master, if the requesting device connected to
the slave has higher priority than the one being currently served. In this mode, the
master interrupt the CPU only when the interrupting device has a higher or the
same priority than the one current being served. In normal mode, other requests
than the one being served are masked out.
• When entering the interrupt service routine the software has to check whether this
is the only request from the slave. This is done by sending a non-specific EOI can
be sent to the master, otherwise no EOI should be sent. This mode is important,
since in the absence of this mode, the slave would interrupt the master only once
and hence the priorities of the slave inputs would have been disturbed.
• Buffered Mode: When the 83259A is used in the systems where bus driving
buffers are used on data buses. The problem of enabling the buffers exists. The
8259A sends buffer enable signal on SP/ EN pin, whenever data is placed on the
bus.
• Cascade Mode : The 8259A can be connected in a system containing one master
and eight slaves (maximum) to handle upto 64 priority levels. The master controls
the slaves using CAS0-CAS2 which act as chip select inputs (encoded) for slaves.
• In this mode, the slave INT outputs are connected with master IR inputs. When a
slave request line is activated and acknowledged, the master will enable the slave
to release the vector address during second pulse of INTA sequence.
• The cascade lines are normally low and contain slave address codes from the
trailing edge of the first INTA pulse to the trailing edge of the second INTA
pulse. Each 8259A in the system must be separately initialized and programmed
to work in different modes. The EOI command must be issued twice, one for
master and the other for the slave.
• A separate address decoder is used to activate the chip select line of each 8259A.
• Following Fig shows the details of the circuit connections of 8259A in cascade
scheme.
ADDRESS BUS
A1 A1
A1
CONTROL BUS
DATA BUS
INT
CAS0-CAS2
INT
A0
• When you press a key on your computer, you are activating a switch. There are
many different ways of making these switches. An overview of the construction
and operation of some of the most common types.
1. Mechanical key switches: In mechanical-switch keys, two pieces of metal are
pushed together when you press the key. The actual switch elements are often
made of a phosphor-bronze alloy with gold platting on the contact areas. The key
switch usually contains a spring to return the key to the nonpressed position and
perhaps a small piece of foam to help damp out bouncing.
2. Some mechanical key switches now consist of a molded silicon dome with a
small piece of conductive rubber foam short two trace on the printed-circuit board
to produce the key pressed signal.
3. Mechanical switches are relatively inexpensive but they have several
disadvantages. First, they suffer from contact bounce. A pressed key may make
and break contact several times before it makes solid contact.
4. Second, the contacts may become oxidized or dirty with age so they no longer
make a dependable connection.
• Higher-quality mechanical switches typically have a rated life time of about 1
million keystrokes. The silicone dome type typically last 25 million keystrokes.
2. Membrane key switches: These switches are really a special type of mechanical
switches. They consist of a three-layer plastic or rubber sandwich.
• The top layer has a conductive line of silver ink running under each key position.
The bottom layer has a conductive line of silver ink running under each column of
keys.
• When u press a key, you push the top ink line through the hole to contact the
bottom ink line.
• The advantages of membrane keyboards is that they can be made as very thin,
sealed units.
• They are often used on cash registers in fast food restaurants. The lifetime of
membrane keyboards varies over a wide range.
3. Capacitive key switches: A capacitive keyswitch has two small metal plates on
the printed circuit board and another metal plate on the bottom of a piece of foam.
• When u press the key, the movable plate is pushed closer to fixed plate. This
changes the capacitance between the fixed plates. Sense amplifier circuitry detects
this change in capacitance and produce a logic level signal that indicates a key has
been pressed.
• The big advantages of a capacitive switch is that it has no mechanical contacts to
become oxidized or dirty.
• A small disadvantage is the specified circuitry needed to detect the change in
capacitance.
• Capacitive keyswitches typically have a rated lifetime of about 20 million
keystrokes.
4. Hall effect keyswitches: This is another type of switch which has no mechanical
contact. It takes advantage of the deflection of a moving charge by a magnetic
field.
• A reference current is passed through a semiconductor crystal between two
opposing faces. When a key is pressed, the crystal is moved through a magnetic
field which has its flux lines perpendicular to the direction of current flow in the
crystal.
• Moving the crystal through the magnetic field causes a small voltage to be
developed between two of the other opposing faces of the crystal.
• This voltage is amplified and used to indicate that a key has been pressed. Hall
effect sensors are also used to detect motion in many electrically controlled
machines.
• Hall effect keyboards are more expensive because of the more complex switch
mechanism, but they are very dependable and have typically rated lifetime of 100
million or more keystrokes.
Key
Motion
HALL
VOLTAGE
Reference
Current
Magnetic Field
HALL EFFECT
• Once the columns are found to be all high, the program enters another loop, which
waits until a low appears on one of the columns, indicating that a key has been
pressed. This second loop does the detect task for us. A simple 20-ms delay
procedure then does the debounce task.
• After the debounce time, another check is made to see if the key is still pressed. If
the columns are now all high, then no key is pressed and the initial detection was
caused by a noise pulse or a light brushing past a key. If any of the columns are
still low, then the assumption is made that it was a valid keypress.
• The final task is to determine the row and column of the pressed key and convert
this row and column information to the hex code for the pressed key. To get the
row and column information, a low is output to one row and the column are read.
If none of the columns is low, the pressed key is not in that row. So the low is
rotated to the next row and the column are checked again. The process is repeated
until a low on a row produces a low on one of the column.
• The pressed key then is in the row which is low at that time.
• The connection fig shows the byte read in from the input port will contain a 4-bit
code which represents the row of the pressed key and a 4-bit code which represent
the column of the pressed key.
• Error trapping: The concept of detecting some error condition such as “ no match
found” is called error trapping. Error trapping is a very important part of real
programs. Even in simple programs, think what might happen with no error trap if
two keys in the same row were pressed at exactly at the same time and a column
code with two lows in it was produced.
• This code would not match any of the row-column codes in the table, so after all
the values in the table were checked, assigned register in program would be
decremented from 0000H to FFFFH. The compare decrement cycle would
continue through 65,536 memory locations until, by change the value in a
memory location matched the row-column code. The contents of the lower byte
register at hat point would be passed back to the calling routine. The changes are
1 in 256 that would be the correct value for one of the pressed keys. You should
keep an error trap in a program whenever there is a chance for it.
2. Keyboard Interfacing with Hardware: For the system where the CPU is too
busy to be bothered doing these tasks in software, an external device is used to do
them.
• One of a MOS device which can be do this is the General Instruments AY5-2376
which can be connected to the rows and columns of a keyboard switch matrix.
• The AY5-2376 independently detects a keypress by cycling a low down through
the rows and checking the columns. When it finds a key pressed, it waits a
debounce time.
• If the key is still pressed after the debounce time, the AY5-2376 produces the 8-
bit code for the pressed key and send it out to microcomputer port on 8 parallel
lines. The microcomputer knows that a valid ASCII code is on the data lines, the
AY5-2376 outputs a strobe pulse.
• The microcomputer can detect this strobe pulse and read in ASCII code on a
polled basis or it can detect the strobe pulse on an interrupt basis.
• With the interrupt method the microcomputer doesn’t have to pay any attention to
the keyboard until it receives an interrupt signal.
• So this method uses very little of the microcomputer time. The AY5-2376 has a
feature called two-key rollover. This means that if two keys are pressed at nearly
the same time, each key will be detected, debounced and converted to ASCII.
• The ASCII code for the first key and a strobe signal for it will be sent out then the
ASCII code for the second key and a strobe signal for it will be sent out and
compare this with two-key lockout.
+ 5V
Output port 01 C D E F
D0
8 9 A B
D1
4 5 6 7
D2
0 1 2 3
D3
10KΩ
Input port
02 D7
D
7 6
D
6 5
D
5 4
D
4 3
D
3 2
D
2 1
D0
Fig: (a) Port connections
Example
• Interface a 4 * 4 keyboard with 8086 using 8255 an write an ALP for detecting a
key closure and return the key code in AL. The debounce period for a key is
10ms. Use software debouncing technique. DEBOUNCE is an available 10ms
delay routine.
• Solution: Port A is used as output port for selecting a row of keys while Port B is
used as an input port for sensing a closed key. Thus the keyboard lines are
selected one by one through port A and the port B lines are polled continuously
till a key closure is sensed. The routine DEBOUNCE is called for key
debouncing. The key code is depending upon the selected row and a low sensed
column.
+ 5V
10 10 10 10
RESET K K K K
Ω Ω Ω Ω
LOWR
C D E F 10KΩ
IORD PA3
8 9 A B 10KΩ
D0-D7 PA2
8255 PA1 4 5 6 7 10KΩ
A2 A1 0 1 2 3 10KΩ
PA0
A1 A0
PB3
PB2
A15 PB1
A12 CS
A13
A14 PB0
A0
Interfacing 4 * 4 Keyboard
• The higher order lines of port A and port B are left unused. The address of port A
and port B will respectively 8000H and 8002H while address of CWR will be
8006H. The flow chart of the complete program is as given. The control word for
this problem will be 82H. Code segment CS is used for storing the program code.
• Key Debounce : Whenever a mechanical push-button is pressed or released once,
the mechanical components of the key do not change the position smoothly, rather
it generates a transient response .
START
Initialise 8255 row,
column counter and key
code reg.
No Key
Closed
Yes
Wait for Debounce
Set row counter
row
Ground one row Counter =0 ?
• These transient variations may be interpreted as the multiple key pressure and
responded accordingly by the microprocessor system.
• To avoid this problem, two schemes are suggested: the first one utilizes a bistable
multivibrator at the output of the key to debounce .
• The other scheme suggests that the microprocessor should be made to wait for the
transient period ( usually 10ms ), so that the transient response settles down and
reaches a steady state.
• A logic ‘0’ will be read by the microprocessor when the key is pressed.
• In a number of high precision applications, a designer may have two options- the
first is to have more than one 8-bit port, read (write) the port one by one and then
from the multibyte data, the second option allows forming 16-bit ports using two
8-bit ports and use 16-bit read or write operations.
+5V Logic 1
V0
Logic 0 Logic 0
Key released Key released
Key pressed
150 Ω
Each
13 12 11 10 9 15 14 +5V
a b c d e f g
+5V Vcc
BI 5
7447
RBI 4
GND
A B C D LT 3
7 1 2 6
BCD INPUTS
Circuit for driving single 7-segment LED display with 7447
D0
D1
D2
D3
D4 + 5V
D5
D6
R5 R7
R1 R2 R3 R4 R6
OUTPUT
PORT Q1 Q2 Q3 Q4 Q5 Q6 Q7
A
+5V
Vcc
OUTPUT 7447
PORT GND D C B A
B
D0
D1
D2
D3
2to4
A1 DS1 2 bit Decoder
Latch
A2 DS2
Enable Enable
Back
Oscillator Plane
74LS138 CS1 16KHz Free / 128 Driver Back Plane
Y2 One Output
Shot Running Enable
CS2
+5 V OSC Enable
Enable Detector
Fig : Circuit for interfacing four LCD digits to an SDK-86 bus using ICM7211M
• In most of the cases, the PIO 8255 is used for interfacing the analog to digital
converters with microprocessor.
• We have already studied 8255 interfacing with 8086 as an I/O port, in previous
section. This section we will only emphasize the interfacing techniques of analog
to digital converters with 8255.
• The analog to digital converters is treaded as an input device by the
microprocessor, that sends an initialising signal to the ADC to start the analogy to
digital data conversation process. The start of conversation signal is a pulse of a
specific duration.
• The process of analog to digital conversion is a slow process, and the
microprocessor has to wait for the digital data till the conversion is over. After the
conversion is over, the ADC sends end of conversion EOC signal to inform the
microprocessor that the conversion is over and the result is ready at the output
buffer of the ADC. These tasks of issuing an SOC pulse to ADC, reading EOC
signal from the ADC and reading the digital output of the ADC are carried out by
the CPU using 8255 I/O ports.
• The time taken by the ADC from the active edge of SOC pulse till the active
edge of EOC signal is called as the conversion delay of the ADC.
• It may range any where from a few microseconds in case of fast ADC to even a
few hundred milliseconds in case of slow ADCs.
• The available ADC in the market use different conversion techniques for
conversion of analog signal to digitals. Successive approximation techniques and
dual slope integration techniques are the most popular techniques used in the
integrated ADC chip.
• General algorithm for ADC interfacing contains the following steps:
1. Ensure the stability of analog input, applied to the ADC.
2. Issue start of conversion pulse to ADC
3. Read end of conversion signal to mark the end of conversion processes.
4. Read digital data output of the ADC as equivalent digital output.
5. Analog input voltage must be constant at the input of the ADC right from the start
of conversion till the end of the conversion to get correct results. This may be
ensured by a sample and hold circuit which samples the analog signal and holds it
constant for a specific time duration. The microprocessor may issue a hold signal
to the sample and hold circuit.
6. If the applied input changes before the complete conversion process is over, the
digital equivalent of the analog input calculated by the ADC may not be correct.
ADC 0808/0809 :
• The analog to digital converter chips 0808 and 0809 are 8-bit CMOS, successive
approximation converters. This technique is one of the fast techniques for analog
to digital conversion. The conversion delay is 100µs at a clock frequency of 640
KHz, which is quite low as compared to other converters. These converters do not
need any external zero or full scale adjustments as they are already taken care of
by internal circuits. These converters internally have a 3:8 analog multiplexer so
that at a time eight different analog conversion by using address lines -
ADD A, ADD B, ADD C. Using these address inputs, multichannel data acquisition
system can be designed using a single ADC. The CPU may drive these lines using output
port lines in case of multichannel applications. In case of single input applications, these
may be hardwired to select the proper input.
• There are unipolar analog to digital converters, i.e. they are able to convert only
positive analog input voltage to their digital equivalent. These chips do no contain
any internal sample and hold circuit.
Analog /P Address lines
selecte C B A
I/P0 0 0 0
I/P1 0 0 1
I/P2 0 1 0
I/P3 0 1 1
I/P4 1 0 0
I/P5 1 0 1
I/P6 1 1 0
I/P7 1 1 1
• If one needs a sample and hold circuit for the conversion of fast signal into
equivalent digital quantities, it has to be externally connected at each of the
analog inputs.
I/P 1 EOC
Control and
I/P2 Timing unit
and .A.R.
I/P3 8 Channel
Analog
Multiplexer
I/P4 8-bit
O/P O/P
Latch
256 R
I/P5 Register
ladder and
Switch tree
I/P6
O/P
I/P7 Enable
V ref + V ref _
C B A
Address
Block Diagram of ADC 0808 / 0809
CLOCK
START
ALE
EO C
OE
O/P
Vref +
Vref +
CS +5V
D0 – D 7 PA7 – PA0 O7 – O 0
Analog
PC7 EOC ADC I/P
A2
PC0 SOC
0808 Voltage
A1
OE GND
Reset 8255 +5V
ALE
A B C
IORD PB0
PB1
IOWR PB2
• The pin diagram of AD7523 is shown in fig the supply range is from +5V to
+15V, while Vref may be any where between -10V to +10V. The maximum
analog output voltage will be any where between -10V to +10V, when all the
digital inputs are at logic high state.
• Usually a zener is connected between OUT1 and OUT2 to save the DAC from
negative transients. An operational amplifier is used as a current to voltage
converter at the output of AD to convert the current out put of AD to a
proportional output voltage.
• It also offers additional drive capability to the DAC output. An external feedback
resistor acts to control the gain. One may not connect any external feedback
resistor, if no gain control is required.
• EXAMPLE: Interfacing DAC AD7523 with an 8086 CPU running at 8MHZ and
write an assembly language program to generate a sawtooth waveform of period
1ms with Vmax 5V.
• Solution: Fig shows the interfacing circuit of AD 74523 with 8086 using 8255.
program gives an ALP to generate a sawtooth waveform using circuit.
ASSUME CS:CODE
CODE SEGMENT
START :MOV AL,80h ;make all ports output
OUT CW, AL
AGAIN :MOV AL,00h ;start voltage for ramp
BACK : OUT PA, AL
INC AL
CMP AL, 0FFh
JB BACK
JMP AGAIN
CODE ENDS
END START
+5V +10V
15 14
16
RFB
PA7 MSB 4
OUT1 1 -
8255A VZ V0
LSB 2 +
PA0 11 OUT2
AD7523
CS
GND
3
• In the above program, port A is initialized as the output port for sending the
digital data as input to DAC. The ramp starts from the 0V (analog), hence AL
starts with 00H. To increment the ramp, the content of AL is increased during
each execution of loop till it reaches F2H.
• After that the saw tooth wave again starts from 00H, i.e. 0V(analog) and the
procedure is repeated. The ramp period given by this program is precisely
1.000625 ms. Here the count F2H has been calculated by dividing the required
delay of 1ms by the time required for the execution of the loop once. The ramp
slope can be controlled by calling a controllable delay after the OUT instruction.
M. Krishna Kumar MAM/M7/MKK18/V1/2004 1
Contents
Processors Coprocessors
Control Unit
Execution Unit
Vcc
CLK 79 0 TAG TAG
0 register
BHE/S7 TAG 7
Bus
tracking Floating point arithmetic module
AD15 - AD0 control
logic, Status Register 16 bit
A19/S6 __ A16/S3 instruction
queue Control Register
QS1-QS0
____ ____ 16 LBS of instruction address
RQ/GT
____ ____0 4MSB inst address 0 11 LSB of op code
RQ/GT1 16 LSB of operand address
Busy
Ready 4 MSB of operand address 0
Reset vss
¾ This unit has a Control word and Status word and Data Buffer
B C3 ST C2 C1 C0 ES PE UE OE ZE DE IE
¾ ZE-A Zero error indicates the divisor was zero while the
dividend is a non-infinity or non-zero number.
IC RC PC PM UM OM ZM DM IM
• IC Infinity control
• RC Rounding control
• PC Precision control
• PM Precision control
• UM Underflow mask
• OM Overflow mask
• ZM Division by zero mask
• DM Denormalized operand mask
• IM Invalid operand mask
M. Krishna Kumar MAM/M7/MKK18/V1/2004 16
¾ IC –Infinity control selects INFINITY CONTROL
either affine or projective
infinity. Affine allows 0 = Projective
positive and negative 1 = Affine
infinity, while projective
assumes infinity
is unsigned. ROUNDING CONTROL
00=Round to nearest or even
01=Round down towards minus infinity
¾ RC –Rounding control 10=Round up towards plus infinity
determines the type of 11=Chop or truncate towards zero
rounding.
INT INTR
8259A
8086 CPU
PIC Multi
CLK
____ ____ 8086
RQ/GT1 master
Multi
BUS System
_______
IRn
QS0 QS1 TEST master INTER- bus
FACING
local
COMPO-
8284A bus
QS1 BUSY NENTS
QS0
CLICK ____ _____
RQ/GT0
GENERATOR
CLK CLK 8087
____ _____
INT RQ/GT1
M. Krishna Kumar MAM/M7/MKK18/V1/2004 20
¾ Multiplexed address-data bus lines are connected directly
from the 8086 to 8087.
¾ The status lines and the queue status lines connected directly
from 8086 to 8087. __ ___
¾ The Request/Grant signal RQ/GT0 of 8087 is connected to
___ ___
RQ/GT1 of 8086. ______
¾ The 8087 continues the process until it has transferred all the
data words required by the instruction to/from memory.
(a)
(b)
1) INVALID OPERATION
2) OVERFLOW
3) ZERO DIVISOR
4) UNDERFLOW
5) DENORMALIZED OPERAND
6) INEXACT RESULT
We have 3 types.
S 0 d17 d1 d0
79 78 72 0
S E F
79 78 63 0
= 4006B2A0000000000000h
01111111(7FH) ,single
2 1100100.01 = 1.10010001 * 26
precision no use 7F and
3 110+01111111=10000101
double precision no use
4 Sign = 0 3FFFH.
Exponent =10000101
• IN step 4 the information
Significand = found in prior step is
10010001000000000000000 combined to form the
floating point no.
¾ REAL TRANSFER
FLD Load real
FST Store real
FSTP Store real and pop
FXCH Exchange registers
¾ INTEGER TRANSFER
FILD Load integer
FIST Store integer
FISTP Store integer and pop
M. Krishna Kumar MAM/M7/MKK18/V1/2004 46
¾ PACKED DECIMAL TRANSFER(BCD)
¾ Addition
¾ Comparison
¾ Transcendental
Data types
Interfacing
Overview
Each processor in the 80x86 family has a corresponding coprocessor with which it is
compatible.
Processors
Coprocessors
1. 8087
2. 80287,80287XL
3. 80287,80387DX
4. 80387SX
5. It is Inbuilt
6. 80487SX
GND 1 40 Vcc
(A14) AD14 2 39 AD15
(A13) AD13 3 38 A16/S3
(A12) AD12 4 37 A17/S4
(A11) AD11 5 36 A18/S5
(A10) AD10 6 35
(A9) AD9 7 34 ________
(A8) AD8
AD7
8 8087 33 RQ/GT1
9 32 INT
AD6 10 NPX 31
_______
RQ/GT0
AD5 11
AD4 30 NC
12
AD3 29 NC _
13
28 __ S2
AD2 14 S1
27 __
AD1 15 26 S0
AD0 16 25 QS0
NC 17 24 QS1
NC 18 23 BUSY
CLK 19 22 READY
GND 20 21 RESET
Architecture of 8087
Control Unit
Execution Unit
+5V
Vcc
CLK 79 0 TAG TAG
0 register
8-register stack, each has 80 bits
INT to
_____
BHE/S7 TAG 7
Bus
tracking Floating point arithmetic module
AD15 - AD0 control
logic, Status Register 16 bit
A19/S6 __
A16/S3 instruction
queue Control Register
QS1-QS0
____ ____ 16 LBS of instruction address
RQ/GT0
____ ____ 4MSB inst address 0 11 LSB of op code
RQ/GT1
16 LSB of operand address
Busy
Ready 4 MSB of operand address 0
Reset vss
This unit has a Control word and Status word and Data Buffer
Status Register
15 0
B C3 ST C2 C1 C0 ES PE UE OE ZE DE IE
B-Busy bit indicates that coprocessor is busy executing a task. Busy can be tested by
examining the status or by using the FWAIT instruction. Newer coprocessor
automatically synchronize with the microprocessor, so busy flag need not be tested
before performing additional coprocessor tasks.
TOP- Top of the stack (ST) bit indicates the current register address as the top of the
stack.
ES-Error summary bit is set if any unmasked error bit (PE, UE, OE, ZE, DE, or IE) is
set. In the 8087 the error summary is also caused a coprocessor interrupt.
PE- Precision error indicates that the result or operand executes selected precision.
UE-Under flow error indicates the result is too large to be represent with the current
precision selected by the control word.
OE-Over flow error indicates a result that is too large to be represented. If this error is
masked, the coprocessor generates infinity for an overflow error.
ZE-A Zero error indicates the divisor was zero while the dividend is a non-infinity or
non-zero number.
CONTROL REGISTER
It also masks an unmasks the exception bits that correspond to the rightmost Six bits of
status register.
Instruction FLDCW is used to load the value into the control register.
Control Register
15 0
IC RC PC PM UM OM ZM DM IM
INFINITY CONTROL
0 = Projective
1 = Affine
ROUNDING CONTROL
00=Round to nearest or even
01=Round down towards minus infinity
10=Round up towards plus infinity
11=Chop or truncate towards zero
PRECISION CONTROL
Exception Masks – It Determines whether the error indicated by the exception affects
the error bit in the status register. If a logic1 is placed in one of the exception control bits,
corresponding status register bit is masked off.
This performs all operations that access and manipulate the numeric data in the
coprocessor’s registers.
Numeric data is routed into two parts ways a 64 bit mantissa bus and
a 16 bit sign/exponent bus.
INT INTR
8259A
PIC 8086 CPU
CLK Multi
____ ____ 8086 master
RQ/GT1 BUS System
Multi
IRn
_______ INTER- bus
QS0 QS1 TEST master FACING
local
COMPO-
bus
8284A NENTS
CLICK QS0 QS1 BUSY
____ _____
GENERATOR
RQ/GT0
CLK 8087
CLK
____ _____
INT RQ/GT1
Multiplexed address-data bus lines are connected directly from the 8086 to 8087.
The status lines and the queue status lines connected directly from 8086 to 8087.
__ ___
The Request/Grant signal RQ/GT0 of 8087 is connected to
___ ___
RQ/GT1 of 8086.
______
BUSY signal 8087 is connected to TEST pin of 8086.
Interrupt output INT of the 8087 to NMI input of 8086. This intimates an error
condition.
The main purpose of the circuitry between the INT output of 8087 and the NMI input is
to make sure that an NMI signal is not present upon reset, to make it possible to mask
NMI input and to make it possible for other devices to cause an NMI interrupt.
BHE pin is connected to the system BHE line to enable the upper bank of memory.
The RQ/GT1 input is available so that another coprocessor such as 8089 I/O processor
can be connected and function in parallel with the 8087.
One type of Cooperation between the two processors that you need
to know about it is how the 8087 transfers data between memory and its internal registers.
When 8086 reads an 8087 instruction that needs data from memory or wants to send
data to memory, the 8086 sends out the memory address code in the instruction and sends
out the appropriate memory read or memory write signal to transfer a word of data.
In the case of memory read, the addressed word will be kept on the data bus by the
memory. The 8087 then simply reads the word of data bus. The 8086 ignores this word
.If the 8087 only needs this one word of data, it can then go on and executes its
instruction.
Some 8087 instructions need to read in or write out up to 80-bit word. For these cases
8086 outputs the address of the first data word on the address bus and outputs the
appropriate control signal.
The 8087 reads the data word on the data bus by memory or writes a data word to
memory on the data bus. The 8087 grabs the 20-bit physical address that was output by
the 8086.To transfer additional words it needs to/from memory, the 8087 then takes over
the buses from 8086.
To take over the bus, the 8087 sends out a low-going pulse on
___ ____
RQ/GT0 pin. The 8086 responds to this by sending another low
___ ____
going pulse back to the RQ/GT0 pin of 8087 and by floating its buses.
The 8087 then increments the address it grabbed during the first transfer and outputs
the incremented address on the address bus. When the 8087 output a memory read or
memory write signal, another data word will be transferred to or from the 8087.
The 8087 continues the process until it has transferred all the data words required by
the instruction to/from memory.
When the 8087 is using the buses for its data transfer, it
____ ___
sends another low-going pulse out on its RQ/ GT0 pin to
8086 to know it can have the buses back again.
Taking one situation, in the case where the 8086 needs the data produced by the
execution of an 8087 instruction to carry out its next instruction.
In the instruction sequence for example the 8087 must complete the FSTSW
STATUS instruction before the 8086 will have the data it needs to execute the
MOV AX , STATUS instruction.
Without some mechanism to make the 8086 wait until the 8087 completes the FSTSW
instruction, the 8086 will go on and execute the MOV AX , STATUS with erroneous
data .
We solve this problem by connecting the 8087 BUSY output to the TEST pin of the
8086 and putting on the WAIT instruction in the program.
While 8087 is executing an instruction it asserts its BUSY pin high. When it is finished
with an instruction, the 8087 will drop its BUSY pin low. Since the BUSY pin from 8087
is connected to the TEST pin 8086 the processor can check its pin of 8087 whether it
finished it instruction or not.
You place the 8086 WAIT instruction in your program after the 8087 FSTSW
instruction .When 8086 executes the WAIT instruction it enters an internal loop where it
repeatedly checks the logic level on the TEST input. The 8086 will stay in this loop until
it finds the TEST input asserted low, indicating the 8087 has completed its instruction.
The 8086 will then exit the internal loop, fetch and execute the next instruction.
Example
(a)
In this set of instructions we are not using WAIT instruction. Due to this the flow of
execution of command will takes place continuously even though the previous
instruction had not finished it’s completion of its work .so we may lost data .
(b)
In this code we are adding up of FWAIT instruction so that it will stop the execution of
the command until the above instruction is finishes it’s work .so that you are not loosing
data and after that you will allow to continue the execution of instructions.
Another case where you need synchronization of the processor and the coprocessor is
the case where a program has several 8087 instructions in sequence.
The 8087 are executed only one instruction at a time so you have to make sure that
8087 has completed one instruction before you allow the 8086 to fetch the next 8087
instruction from memory. ________
Here again you use the BUSY-TEST connection and the FWAIT instruction to solve
the problem. If you are hand coding, you can just put the 8086 WAIT(FWAIT)
instruction after each instruction to make sure that instruction is completed before going
on to next.
If you are using the assembler which accepts 8087 mnemonics, the assembler will
automatically insert the 8-bit code for the WAIT instruction ,10011011 binary (9BH), as
the first byte of the code for 8087 instruction.
INTERFACING
Multiplexed address-data bus lines are connected directly from the 8086 to 8087.
The status lines and the queue status lines connected directly from 8086 to 8087.
__ ___
The Request/Grant signal RQ/GT0 of 8087 is connected to
___ __
RQ/GT1 of 8086.
______
BUSY signal 8087 is connected to TEST pin of 8086.
Interrupt output INT of the 8087 to NMI input of 8086. This intimates an error
condition. ______
A WAIT instruction is passed to keep looking at its TEST pin, until it finds pin Low to
indicates that the 8087 has completed the computation.
a) The execution of an ESC instruction that require the participation of the NUE
must not be initiated if the NUE has not completed the execution of the previous
instruction.
The 8087 detects six different types of exception conditions that occur during
instruction execution. These will cause an interrupt if unmasked and interrupts are
enabled.
1)INVALID OPERATION
2)OVERFLOW
3)ZERO DIVISOR
4)UNDERFLOW
5)DENORMALIZED OPERAND
6)INEXACT RESULT
Data Types
Internally, all data operands are converted to the 80-bit temporary real format.
We have 3 types.
Packed BCD
Example
Converting a decimal number into a Floating-point number.
1) Converting the decimal number into binary form.
2) Normalize the binary number
3) Calculate the biased exponent.
4) Store the number in the floating-point format.
Example
Step Result
1 100.25
21100100.01 = 1.10010001 * 26
3110+01111111=10000101
4 Sign = 0
Exponent =10000101
Significand = 10010001000000000000000
•In step 3 the biased exponent is the exponent a 26 or 110,plus a bias of 01111111(7FH)
,single precision no use 7F and double precision no use 3FFFH.
•IN step 4 the information found in prior step is combined to form the floating point no.
INSTRUCTION SET
The 8087 instruction mnemonics begins with the letter F which stands for Floating
point and distinguishes from 8086.
The 8087 detects an error condition usually called an exception when it executing an
instruction it will set the bit in its Status register.
Types
REAL TRANSFER
FLD Load real
FST Store real
FSTP Store real and pop
FXCH Exchange registers
INTEGER TRANSFER
FILD Load integer
FIST Store integer
FISTP Store integer and pop
Example
FLD Source- Decrements the stack pointer by one and copies a real number from a
stack element or memory location to the new ST.
FILD Source – Integer load. Convert integer number from memory to temporary-real
format and push on 8087 stack.
FIST Destination- Integer store. Convert number from ST to integer and copy to
memory.
FISTP Destination-Integer store and pop. Identical to FIST except that stack pointer is
incremented after copy.
FBLD Source- Convert BCD number from memory to temporary- real format and
push on top of 8087 stack.
Arithmetic Instructions.
Addition
Subtraction
Multiplication
Advanced
Example
FADD – Add real from specified source to specified destination Source can be a stack
or memory location. Destination must be a stack element. If no source or destination is
specified, then ST is added to ST(1) and stack pointer is incremented so that the result of
addition is at ST.
•FADD ST(3), ST ;Add ST to ST(3), result in ST(3)
•FADD ST,ST(4) ;Add ST(4) to ST, result in ST.
•FADD ;ST + ST(1), pop stack result at ST
•FADDP ST(1) ;Add ST(1) to ST. Increment stack
;pointer so ST(1) become ST.
•FIADD Car_Sold ;Integer number from memory + ST
FSUB - Subtract the real number at the specified source from the real number at the
specified destination and put the result in the specified destination.
•FSUB ST(2), ST ;ST(2)=ST(2) – ST.
•FSUB Rate ;ST=ST – real no from memory.
•FSUB ;ST=( ST(1) – ST)
FSUBP - Subtract ST from specified stack element and put result in specified stack
element .Then increment the pointer by one.
•FSUBP ST(1) ;ST(1)-ST. ST(1) becomes new ST
FISUB – Integer from memory subtracted from ST, result in ST.
•FISUB Cars_Sold ;ST becomes ST – integer from memory
Compare Instructions.
Comparison
Transcendental Instruction.
Transcendental
Example
FPTAN – Compute the values for a ratio of Y/X for an angle in ST. The angle must be
in radians, and the angle must be in the range of 0 < angle < π/4. F2XM1 – Compute
Y=2x-1 for an X value in ST. The result Y replaces X in ST. X must be in the range
0≤X≤0.5.
Constant Instructions.
ALGORITHM
Program:
Program to calculate x to the power of y
.MODEL SMALL
.DATA
x Dq 4.567 ;Base
y Dq 2.759 ;Power
temp DD
temp1 DD
temp2 DD ;final real result
tempint DD
tempint1 DD ;final integer result
two DW
diff DD
trunc_cw DW 0fffh
.STACK 100h
.CODE
start: mov ax, @DATA ;init data segment
mov ds, ax
•
load: fld y ;load the power
fld x ;load the base
•
comput: fyl2x ;compute (y * log2(x))
fst temp ;save the temp result
• Introduction
• Inside 8051
• Instructions
• Interfacing
• Definition of a Microcontroller
• Difference with a Microprocessor
• Microcontroller is used where ever
• It is a single chip
• Consists of Cpu, Memory
• I/O ports, timers and other peripherals
CPU
CPU MEMORY
MEMORY
• Small size
• Low cost
• Low power
• Harvard university
CPU
FFFFH
:
EXTERNAL
EXTERNAL
INTERNAL
FFH:
EA=0 EA=1
EXTERNAL INTERNAL 0000H
00
:
0000
RD W
PSEN R
7FH
Scratch Pad
30H
Bit Memory
20H
Bank 3 (R0-R7)
18H
Bank 2 (R0-R7)
10H
INSTRUCTIONS
• Mov A, Rn
• Mov A, Direct
• Mov A, @Ri
• Mov A, #Data8
• Mov Dptr, #Data16
• Mov Rn, A
• Mov Rn, Direct
• Mov Rn, #Data8
• Mov Direct, A
• Mov Direct, Rn
• Mov Direct, #Data8
• Mov Direct, Direct
• Movx A, @Ri
• Movx A, @Dptr
• Movx @Ri, A
• Movx @dptr, A
• Movc A, @A+Dptr
• Movc A, @A+Pc
• Push Direct
• Pop Direct
• Xch A, Rn
• Xch A, Direct
• Xch A, @Ri
• Xchd A, @Ri
• Clr C
• Clr Bit
• Setb C
• Setb Bit
• Cpl C
• Cpl Bit
• Anl C, Bit
• Anl C, /Bit
• Orl C, Bit
• Orl C, /Bit
• Mov C, Bit
• Mov Bit, C
• Jc Reladdr
• Jnc Reladdr
• Jb Bit, Reladdr
• Jnb Bit, Reladdr
• Jbc Bit, Reladdr
• Add A, Rn
• Add A, Direct
• Add A, @Ri
• Add A, #Data8
• Addc A, Rn
• Addc A, Direct
• Addc A, @Ri
• Addc A, #Data8
• Subb A, Rn
• Subb A, Direct
• Subb A, @Ri
• Subb A, #Data8
• Inc A
• Inc Rn
• Inc Direct
• Inc @Ri
• Inc Dptr
• Dec A
• Dec Rn
• Dec Direct
• Dec @Ri
• Mul AB
• Div AB
• DA A
• Anl A, Rn
• Anl A, Direct
• Anl A, @Ri
• Anl A, #Data8
• Anl Direct, A
• Anl Direct, #Data8
• Orl A, Rn
• Orl A, Direct
• Orl A, @Ri
• Orl A, #Data8
• Orl Direct, A
• Orl Direct, #Data8
• Xrl A, Rn
• Xrl A, Direct
• Xrl A, @Ri
• Xrl A, #Data8
• Xrl Direct, A
• Xrl Direct, #Data8
• Clr A
• Cpl A
• Rl A
• Rlc A
• Rr A
• Rrc A
• Swap A
• Acall Addr11
• Lcall Addr16
• Ret
• Reti
• Ajmp Addr11
• Ljmp Addr16
• Sjmp Reladdr
• Jmp @A+Dptr
• Jz Reladdr
• Jnz Reladdr
89C51 Vcc
VCC
DS 1307
10k 10k
5
P1.0 SDA 8
6 1
P1.1 SCL X1
32.768KHz
3 2
+ BAT X2
3.6V
- 4 7
INTB\SQW
GND
74374 7486 KY CS
7408
1
EN
11 C1 7400 R0\
KEY MATRIX
P2.0
8 3 2 WR\
18 19 ROW0
9 4 5 ROW1
C 17 16
6
5 7
14 15
1 8 9
18 12
P2.7 ROW7
Vcc
7430 COL-1 1
P10
COL-2 2 P11
3 P12
4
5 P13
6 P14
P15
COL-6
+5V 8
9
7486 C
1 14 INT1 5
3
2
1
89C51 +
74F138 10uF
P1.7 A2 KBM
74C922
P1.6 A1
X4
P1.5 A0
X3
Vcc
E3 X2
ALE E2 O2 X1
E1 Y1 0 1 2 3
OE
RD
Y2 4 5 6 7
Data Available Y3
8 9 A B
INT1
Y4 C D E F
0.01uF
X7 inhibit
X6
X5
5V
X4 X INT1
X3
X2 C P1.5
X1 B P1.4
P1.3
X0 A
C P1.2
74ALS138 B P1.1
A P1.0
5V
P1.6 D0 VREF
VIN
0.1uF 10uF 1K 1K
89C51 AD7703
VDD
fail
P4.0 SCLK
VOUT A +
P4.1 DIN LM393A Pass
+
P4.2 SYNC VOUT B LM393A
74HC05
GND REF
0.1uF
¾ Has 16 bit input registers, 8 bit for data and 8 bit for
control
2 x Vref x N
¾ Out put voltage =
255
¾ Interface is shown to realize window detector
+12Vdc +5Vdc
Trickle-
1N194 Vcc of 89C51
Charge
diode
Circuit
MAX690 2
10 Vcc
K
8 Vbatt 1
Vout
4.8 V
+
Ni-Cad battery
Vcc of memory
Varta Aafetronic 7
(100 mAh) Reset
Reset
Vss
3
Vss GND
8 9
-12V
89C51
+5V
Max 232
16
1
TX 11 14
D 6 Transmitted data
RX 10 7
R Received data
1 4
+ + 22uf
22uf 3 5
2 6
+
22uf 22uf
15 +
WR R\W
74F373
LE
O0 RS
AD7-AD0
D7-D0
OE
DB7-DB0
+5V MC14489
A
VCC
B
C
8
D
R
X E 8 8 8 8 8
F
3.6K G
H
89C51
P1.2 Data IO
P1.1 Clock
Bank
5
Bank 4
P1.0 Enable
Bank 3
Bank 2
Bank 1
Next page
• The Bus control unit has a prioritizer to resolve the priority of
the various bus requests. This controls the access of the bus.
The address driver drives the bus enable and address signal
A0 – A31. The pipeline and dynamic bus sizing unit handle the
related control signals.
• The data buffers interface the internal data bus with the system
bus.
Signal Descriptions of 80386
• CLK2 :The input pin provides the basic system clock timing
for the operation of 80386.
• D0 – D31:These 32 lines act as bidirectional data bus during
different access cycles.
• A31 – A2: These are upper 30 bit of the 32- bit address bus.
• BE0 to BE3: The 32- bit data bus supported by 80386 and the
memory system of 80386 can be viewed as a 4- byte wide
memory access mechanism. The 4 byte enable lines BE0 to
BE3, may be used for enabling these 4 blanks. Using these 4
enable signal lines, the CPU may transfer 1 byte / 2 / 3 / 4 byte
of data simultaneously.
Next page
PIN DIAGRAM OF 80386
CLK 2 ADDRESS
2 X CLOCK A 2 – A 31
BUS
BE 3 #
32 BIT
DATA DATA BE 2 #
D 0 – D 31 32 – BIT
BUS BYTE ADDRESS
BE 1 # ENABLI
NES
BE 0 #
ADS #
W / R #
NA #
D / C#
BS 16 #
M / IO BUS CYCLE
BUS
DEFINATION
CONTROL
READY
80386 LOCK #
PROCESSOR
HOLD PEREQ
INTR
V CC
NMI
POWER
INTERRUPTS CONNECTIO
GND
RESET NS
• W/R#: The write / read output distinguishes the write and read
cycles from one another.
• D/C#: This data / control output pin distinguishes between a
data transfer cycle from a machine control cycle like interrupt
acknowledge.
• M/IO#: This output pin differentiates between the memory
and I/O cycles.
• LOCK#: The LOCK# output pin enables the CPU to prevent
the other bus masters from gaining the control of the system
bus.
• NA#: The next address input pin, if activated, allows address
pipelining, during 80386 bus cycles.
Next page
• ADS#: The address status output pin indicates that the address
bus and bus cycle definition pins( W/R#, D/C#, M/IO#, BE0#
to BE3# ) are carrying the respective valid signals. The 80383
does not have any ALE signals and so this signals may be used
for latching the address to external latches.
• READY#: The ready signals indicates to the CPU that the
previous bus cycle has been terminated and the bus is ready
for the next cycle. The signal is used to insert WAIT states in a
bus cycle and is useful for interfacing of slow devices with
CPU.
• VCC: These are system power supply lines.
• VSS: These return lines for the power supply.
Next page
• BS16#: The bus size – 16 input pin allows the interfacing of 16
bit devices with the 32 bit wide 80386 data bus. Successive 16
bit bus cycles may be executed to read a 32 bit data from a
peripheral.
• HOLD: The bus hold input pin enables the other bus masters
to gain control of the system bus if it is asserted.
• HLDA: The bus hold acknowledge output indicates that a
valid bus hold request has been received and the bus has been
relinquished by the CPU.
• BUSY#: The busy input signal indicates to the CPU that the
coprocessor is busy with the allocated task.
Next page
• ERROR#: The error input pin indicates to the CPU that the
coprocessor has encountered an error while executing its
instruction.
• PEREQ: The processor extension request output signal
indicates to the CPU to fetch a data word for the coprocessor.
• INTR: This interrupt pin is a maskable interrupt, that can be
masked using the IF of the flag register.
• NMI: A valid request signal at the non-maskable interrupt
request input pin internally generates a non- maskable
interrupt of type2.
Next page
• RESET: A high at this input pin suspends the current
operation and restart the execution from the starting location.
• N / C : No connection pins are expected to be left open while
connecting the 80386 in the circuit.
Register Organisation
• The 80386 has eight 32 - bit general purpose registers which
may be used as either 8 bit or 16 bit registers.
• A 32 - bit register known as an extended register, is
represented by the register name with prefix E.
• Example : A 32 bit register corresponding to AX is EAX,
similarly BX is EBX etc.
• The 16 bit registers BP, SP, SI and DI in 8086 are now
available with their extended size of 32 bit and are names as
EBP,ESP,ESI and EDI.
• AX represents the lower 16 bit of the 32 bit register EAX.
• BP, SP, SI, DI represents the lower 16 bit of their 32 bit
counterparts, and can be used as independent 16 bit registers.
Next page
GENERAL DATA AND ADDRESS REGISTERS
31 16 15 0
AX EAX
BX EBX
CX ECX
DX EDX
SI ESI
DI EDI
BP EBP
SP ESP
FS
GS
INSTRUCTION POINTER AND FLAG REGISTER
31 16 15 0
IP EIP
FLAGS EFLAGS
Next page
• The six segment registers available in 80386 are CS, SS, DS,
ES, FS and GS.
• The CS and SS are the code and the stack segment registers
respectively, while DS, ES, FS, GS are 4 data segment
registers.
• A 16 bit instruction pointer IP is available along with 32 bit
counterpart EIP.
• Flag Register of 80386: The Flag register of 80386 is a 32 bit
register. Out of the 32 bits, Intel has reserved bits D18 to D31,
D5 and D3, while D1 is always set at 1.Two extra new flags are
added to the 80286 flag to derive the flag register of 80386.
They are VM and RF flags.
Next page
FLAGS
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
F
L
A RESERVED FOR VM RF 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
INTEL
G
S
Next page
• ADDRESSING MODES: The 80386 supports overall eleven
addressing modes to facilitate efficient execution of higher
level language programs.
• In case of all those modes, the 80386 can now have 32-bit
immediate or 32- bit register operands or displacements.
• The 80386 has a family of scaled modes. In case of scaled
modes, any of the index register values can be multiplied by a
valid scale factor to obtain the displacement.
• The valid scale factor are 1, 2, 4 and 8.
Next page
• The different scaled modes are as follows.
• Scaled Indexed Mode: Contents of the an index register are
multiplied by a scale factor that may be added further to get
the operand offset.
• Based Scaled Indexed Mode: Contents of the an index register
are multiplied by a scale factor and then added to base register
to obtain the offset.
• Based Scaled Indexed Mode with Displacement: The
Contents of the an index register are multiplied by a scaling
factor and the result is added to a base register and a
displacement to get the offset of an operand.
Real Address Mode of 80386
OFFSET
19 0
SEGMENT
SELECTOR 0000
MAX LIMIT FIXED
AT 64 K IN REAL
MODE
c
c
+ MEMORY OPERAND SELECTED
c 64 K
SEGMENT
BYTES
c c
SEGMENT BASE
Next page
Protected Mode of 80386
SELECTOR OFFSET
SELECTOR OFFSET
47 / 31 31 / 15 0
SEGMENT LIMIT
ACCESS RIGHT
c
c
LIMIT
c
c
BASE ADDRESS
+ MEMORY OPERAND
UP TO SELECTED
c 4 GB
SEGMENT DESCRIPTOR SEGMENT
c
SEGMENT BASE ADDRESS
Next page
• DESCRIPTORS: The 80386 descriptors have a 20-bit
segment limit and 32-bit segment address. The descriptor of
80386 are 8-byte quantities access right or attribute bits along
with the base and limit of the segments.
• Descriptor Attribute Bits: The A (accessed) attributed bit
indicates whether the segment has been accessed by the CPU
or not.
• The TYPE field decides the descriptor type and hence the
segment type.
• The S bit decides whether it is a system descriptor (S=0) or
code/data segment descriptor ( S=1).
Next page
31 0
ADDR ES S 0
BYTE
SEGMENT 15
BASE
...0 SEGMENT BASE 15….0
LIMIT BASE
TYPE +4
BASE 31..24 G D 0 AVL P DPL S A
19….16 23….26
Structure of An Descriptor
READ / WRITE
0 0 NONE
READ / WRITE
1 1 READ - WRITE
Next page
• The upper 20 bit page frame address is combined with the
lower 12 bit of the linear address. The address bits A12- A21 are
used to select the 1024 page table entries. The page table can
be shared between the tasks.
• The P bit of the above entries indicate, if the entry can be used
in address translation.
• If P=1, the entry can be used in address translation, otherwise
it cannot be used.
• The P bit of the currently executed page is always high.
• The accessed bit A is set by 80386 before any access to the
page. If A=1, the page is accessed, else unaccessed.
Next page
INSIDE 80386 IN THE MEMORY
31 22 12 0
10 10 +
12
0 31 0
31
CR 31 DIRECTORY 0
0
CR 1 +
+
CR
2
PAGE TABLE
CR DBA
3
CONTROL
REGISTERS
386
PAGE N DX CPU OS
MEMORY
TASK 2
MEMORY
8086OS
TASK 1
EMPTY MEMORY
TASK 1
PAGE N
MEMORY
PAGE
1
AVAILABLE
8086OS
`
TASK 1
PAGE EMPTY MEMORY
DIRECTORY
ROOT TASK1 PAGE 8086 OS
TABLE
VIRTUAL MODE MEMORY
8086 TASK PAGE DIRECTORY TASK
1
000000000 H
Next page
____
• BLAST: The burst last output shows that the burst bus cycle is
complete on the next activation of BRDY# signal.
_____
• BOFF : The Back-off input causes the microprocessor to
place its buses at their high impedance state during the next
cycle. The microprocessor remains in the bus hold state until
the BOFF# pin is placed at a logic 1 level.
Next page
____
• BRDY : The burst ready input is used to signal the
microprocessor that a burst cycle is complete.
____
• KEN : The cache enable input causes the current bus to be
stored in the internal.
_____
• LOCK : The lock output becomes a logic 0 for any instruction
that is prefixed with the lock prefix.
__
• W / R : current bus cycle is either a read or a write.
Next page
______
• IGNNE : The ignore numeric error input causes the
coprocessor to ignore floating point error and to continue
processing data. The signal does not affect the state of the
FERR pin.
______
• FLUSH : The cache flush input forces the microprocessor to
erase the contents of its 8K byte internal cache.
_____
• EADS: The external address strobe input is used with AHOLD
to signal that an external address is used to perform a cache
invalidation cycle.
Next page
_____
• FERR : The floating point error output indicates that the
floating point coprocessor has detected an error condition. It is
used to maintain compatibility with DOS software.
___
• BS8 : The bus size 8, input causes the 80486 to structure itself
with an 8-bit data bus to access byte-wide memory and I/O
components.
____
• BS16: The bus size 16, input causes the 80486 to structure
itself with an 16-bit data bus to access word-wide memory and
I/O components.
_____
• PCHK : The parity check output indicates that a parity error
was detected during a read operation on the DP3 – DP0 pin.
______
• PLOCK : The pseudo-lock output indicates that current
operation requires more than one bus cycle to perform. This
signal becomes a logic 0 for arithmetic coprocessor operations
that access 64 or 80 bit memory data.
• PWT: The page write through output indicates the state of the
PWT attribute bit in the page table entry or the page directory
entry.
Next page
____
• RDY : The ready input indicates that a non-burst bus cycle is
complete. The RDY signal must be returned or the
microprocessor places wait states into its timing until RDY is
asserted.
__ __
• M / IO : Memory / IO defines whether the address bus
contains a memory address or an I/O port number. It is also
combined with the W/ R signal to generate memory and I/O
read and write control signals.
80486 Signal Group
• The 80486 data bus, address bus, byte enable, ADS#, RDY#,
INTR, RESET, NMI, M/IO#, D/C#, W/R#, LOCK#, HOLD,
HLDA and BS16# signals function as we described for 80386.
• The 80486 requires 1 clock instead of 2 clock required by
80386.
• A new signal group on the 486 is the PARITY group DP0-DP3
and PCHK#.
• These signals allow the 80486 to implement parity detection /
generation for memory reads and memory writes.
• During a memory write operation, the 80486 generates an even
parity bit for each byte and outputs these bits on the DP0-DP3
lines.
Next page
Next page
• These bits will store in a separate parity memory bank.
• During a read operation the stored parity bits will be read from
the parity memory and applied to the DP0-DP3 pins.
• The 80486 checks the parities of the data bytes read and
compares them with the DP0-DP3 signals. If a parity error is
found, the 80486 asserts the PCHK# signal.
• Another new signals group consists of the BURST ready
signal BRDY# and BURST last signal BLAST#.
• These signals are used to control burst-mode memory reads
and writes.
Next page
• A normal 80486 memory read operation to read a line into the
cache requires 2 clock cycles. However, if a series of reads is
being done from successive memory locations, the reads can
be done in burst mode with only 1 clock cycle per read.
• To start the process the 80486 sends out the first address and
asserts the BLAST# signal high. When the external DRAM
controller has the first data bus, it asserts the BRDY# signal.
• The 80486 reads the data word and outputs the next address.
Since the data words are at successive addresses, only the
lower address bits need to be changed. If the DRAM controller
is operating in the page or the static column modes then it will
only have to output a new column address to the DRAM.
Next page
• In this mode the DRAM will be able to output the new data
word within 1 clock cycle.
• When the processor has read the required number of data
words, it asserts the BLAST# signal low to terminate the burst
mode.
• The final signal we want to discuss here are the bus request
output signal BREQ, the back-off input signal BOFF#, the
HOLD signal and the hold-acknowledge signal HLDA.
• These signals are used to control sharing the local 486 bus by
multiple processors ( bus master).
• When a master on the bus need to use the bus, it asserts its
BERQ signal .
Next page
• An external parity circuit will evaluate requests to use the bus
and grant bus use to the highest – priority master. To ask the
486 to release the bus , the bus controller asserts the 486
HOLD input or BOFF# input.
• If the HOLD input is asserted, the 486 will finish the current
bus cycle, float its buses and assert the HLDA signal.
• To prevent another master from taking over the bus during a
critical operation, the 486 can assert its LOCK# or PLOCK#
signal.
EFLAG Register Of The 80486
Next page
GENERAL PURPOSE REGISTERS
31 16 15 0
AX EAX
BX EBX
CX ECX
DX EDX
SI ESI
DI EDI
BP EBP
SP ESP
SEGMENT REGISTERS
CODE SEGMENT
CS
SS STACK SEGMENT
DS
ES DATA SEGMENT
FS
GS
INSTRUCTION POINTER AND FLAG REGISTER
31 16 15 0
IP EIP
FLAGS EFLAGS
Next page
Flag Register of 80486
FLAGS
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
E
F RESERVED
L FOR INTEL AC VM RF 0 NT IOPL OF DF IF TF SF ZF 0 AF 0 PF 1 CF
A
G
P P P P
A A
R A A
1G X 8 R R R
I I 1G X 8 I 1G X 8 I 1G X 8
T T T T
Y Y
Y Y
Next page
• Parity is generated by the 80486 during each write cycle.
Parity is generated as even parity and a parity bit is provided
for each byte of memory. The parity check bits appear on pins
DP0-DP3, which are also parity inputs as well as parity
outputs.
• These are typically stored in memory during each write cycle
and read from memory during each read cycle.
• On a read, the microprocessor checks parity and generates a
parity check error, if it occurs on the PCHK# pin. A parity
error causes no change in processing unless the user applies
the PCHK signal to an interrupt input.
Next page
• Interrupts are often used to signal a parity error in DS-based
computer systems. This is same as 80386, except the parity bit
storage.
• If parity is not used, Intel recommends that the DP0 – DP3
pins be pulled up to +5v.
• CACHE MEMORY: The cache memory system stores data
used by a program and also the instructions of the program.
The cache is organised as a 4 way set associative cache with
each location containing 16 bytes or 4 doublewords of data.
• Control register CR0 is used to control the cache with two new
control bits not present in the 80386 microprocessor.
Next page
31 16 15 0
PG CE WT AM WP
NE TS E M MP PE
PAGE TABLE
OS P
P U
O O A C W R
OR D S W P
BITS D T
PAGE FRAME
Next page
• The PWT controls how the cache functions for a write
operation of the external cache memory. It does not control
writing to the internal cache. The logic level of this bit is found
on the PWT pin of the 80486 microprocessor. Externally, it
can be used to dictate the write through policy of the external
caching.
• The PCD bit controls the on-chip cache. If the PCD = 0, the
on-chip cache is enabled for the current page of memory.
• Note that 80386 page table entries place a logic 0 in the PCD
bit position, enabling caching. If PCD = 1, the on-chip cache is
disable. Caching is disable regard less of condition of KEN#,
CD, and NW.
Cache Test Registers
TR 3
31 11 7 3 0
Valid
LRU
Valid Bits bits
Tag
31 11 10 4 3 2 0
Next page
GENERAL PURPOSE REGISTERS
31 16 15 0
AX EAX
BX EBX
CX ECX
DX EDX
SI ESI
DI EDI
BP EBP
SP ESP
SEGMENT REGISTERS
CODE SEGMENT
CS
STACK
SS SEGMENT
DS
ES
DATA
FS SEGMENT
GS
FLAGS EFLAGS
• The control bits in TR5 enable the fill buffer or read buffer
operation ( 00 )
• Perform a cache write ( 01 ), Perform a cache read ( 10 )
• Flush the cache ( 11 ).
• The cache status register (TR4) hold the cache tag, LRU bits
and a valid bit. This register is loaded with the tag and valid bit
before a cache a cache write operation and contains the tag,
valid bit, LRU bits, and 4 valid bits on a cache test read.
• Cache is tested each time that the microprocessor is reset if the
AHOLD pin is high for 2 clocks prior to the RESET pin going
low. This causes the 486 to completely test itself with a built in
self test or BIST.
Next page
• The BIST uses TR3, TR4, TR5 to completely test the internal
cache. Its outcome is reported in register EAX. If EAX is a
zero, the microprocessor, the coprocessor and cache have
passed the self test.
• The value of EAX can be tested after reset to determine if an
error is detected. In most of the cases we do not directly access
the test register unless we wish to perform our own tests on the
cache or TLB.
Architecture of 80386
BUS CONTROL
RESET,
CONTROL
DESCRIPTOR HLDA
PAGE CACHE
REGISTER
A2 – A31
ADDRESS
PAGE FETCH
CODE FETCH/
DRIVER
BUS
M/IO#, D/C#,
PIPELINE/ W/R#, LOCK#,
INTERNAL CONTROL BUS BUS SIZE ADS#, NA#
CONTROL BS16 #, READY#
PROJECTION
TEST UNIT MUX /
TRANS –
DISPLACEMENT
D0-D31
RECIVERS
PERFECTCHER/
LIMIT
CHECKER
BARREL INSTRUCTION
SHIFTER, DECODE AND DECODER
ADDER SEQUENCING
STATUS
FLAGS
MULTIPLY/ CODE 16 BYTE
DIVIDE STREAM CODE
3-DECODED
CONTROL
INSTRUCTION
ROM
REGISTER FILE QUEUE
ALU INSTRUCTION
ALU CONTROL CONTROL INSTRUCTION PREFETCHER
PREDECODE
•The Memory management unit consists of a Segmentation unit and a Paging unit.
•Segmentation unit allows the use of two address components, viz. segment and offset for
relocability and sharing of code and data.
•Segmentation unit allows segments of size 4Gbytes at max.
•The Paging unit organizes the physical memory in terms of pages of 4kbytes size each.
•Paging unit works under the control of the segmentation unit, i.e. each segment is further
divided into pages. The virtual memory is also organizes in terms of segments and pages
by the memory management unit.
•The Segmentation unit provides a 4 level protection mechanism for protecting and
isolating the system code and data from those of the application program.
•Paging unit converts linear addresses into physical addresses.
•The control and attribute PLA checks the privileges at the page level. Each of the pages
maintains the paging information of the task. The limit and attribute PLA checks segment
limits and attributes at segment level to avoid invalid accesses to code and data in the
memory segments.
•The Bus control unit has a prioritizer to resolve the priority of the various bus requests.
This controls the access of the bus. The address driver drives the bus enable and address
signal A0 – A31. The pipeline and dynamic bus sizing unit handle the related control
signals.
•The data buffers interface the internal data bus with the system bus.
PIN DIAGRAM OF 80386
A B C D E F G H J K L M N P
VCC VSS A8 A11 A14 A15 A16 A17 A20 A21 A23 A26 A27 A30
1
1
VSS A5 A7 A10 A13 VSS VCC A18 VSS A22 A24 A29 A31 VCC
2 2
A3 A4 A6 A9 A12 VSS VCC A19 VSS A25 A28 A17 VSS A30
3
3
NC NC A2 VSS VCC D29
4
4
VCC VSS VCC D31 D27 D26
5
5
VSS NC NC D28 D25 VSS
6
6
VCC INTR NC VCC VCC D24
7 7
ERROR# NMI PEREQ METAL LID VSS D23 VCC
8 8
11 11
M/IO# NC VCC VCC BED# CLK VCC D0 VSS D7 VCC D10 D12 D14
2
12 12
13 13
14 14
A B C D E F G H J K L M N P
Signal Descriptions of 80386
•CLK2 :The input pin provides the basic system clock timing for the operation of 80386.
•D0 – D31:These 32 lines act as bidirectional data bus during different access cycles.
•A31 – A2: These are upper 30 bit of the 32- bit address bus.
•BE0 to BE3: The 32- bit data bus supported by 80386 and the memory system of 80386
can be viewed as a 4- byte wide memory access mechanism. The 4 byte enable lines BE0
to BE3, may be used for enabling these 4 blanks. Using these 4 enable signal lines, the
CPU may transfer 1 byte / 2 / 3 / 4 byte of data simultaneously.
•ADS#: The address status output pin indicates that the address bus and bus cycle
definition pins( W/R#, D/C#, M/IO#, BE0# to BE3# ) are carrying the respective valid
signals. The 80383 does not have any ALE signals and so this signals may be used for
latching the address to external latches.
•READY#: The ready signals indicates to the CPU that the previous bus cycle has been
terminated and the bus is ready for the next cycle. The signal is used to insert WAIT
states in a bus cycle and is useful for interfacing of slow devices with CPU.
•VCC: These are system power supply lines.
•VSS: These return lines for the power supply.
•BS16#: The bus size – 16 input pin allows the interfacing of 16 bit devices with the 32
bit wide 80386 data bus. Successive 16 bit bus cycles may be executed to read a 32 bit
data from a peripheral.
•HOLD: The bus hold input pin enables the other bus masters to gain control of the
system bus if it is asserted.
•HLDA: The bus hold acknowledge output indicates that a valid bus hold request has
been received and the bus has been relinquished by the CPU.
•BUSY#: The busy input signal indicates to the CPU that the coprocessor is busy with
the allocated task.
•ERROR#: The error input pin indicates to the CPU that the coprocessor has
encountered an error while executing its instruction.
•PEREQ: The processor extension request output signal indicates to the CPU to fetch a
data word for the coprocessor.
•INTR: This interrupt pin is a maskable interrupt, that can be masked using the IF of the
flag register.
•NMI: A valid request signal at the non-maskable interrupt request input pin internally
generates a non- maskable interrupt of type2.
•RESET: A high at this input pin suspends the current operation and restart the execution
from the starting location.
•N / C : No connection pins are expected to be left open while connecting the 80386 in
the circuit.
CLK 2 ADDRESS
2X CLOCK A2 – A 31
BUS
BE 3#
32 BIT
DATA DATA BE 2#
D –D BUS BYTE 32 – BIT
0 31 ADDRESS
BE 1# ENABLI
NES
BE 0#
ADS # W/R#
NA # D / C#
BS 16# M / IO
BUS BUS CYCLE
CONTROL DEFINATION
READY
80386 LOCK #
PROCESSOR
HOLD PEREQ
INTR
V CC
NMI
POWER
INTERRUPTS GND CONNECTIO
RESET NS
Register Organisation
•The 80386 has eight 32 - bit general purpose registers which may be used as either 8 bit
or 16 bit registers.
•A 32 - bit register known as an extended register, is represented by the register name
with prefix E.
•Example : A 32 bit register corresponding to AX is EAX, similarly BX is EBX etc.
•The 16 bit registers BP, SP, SI and DI in 8086 are now available with their extended size
of 32 bit and are names as EBP,ESP,ESI and EDI.
•AX represents the lower 16 bit of the 32 bit register EAX.
• BP, SP, SI, DI represents the lower 16 bit of their 32 bit counterparts, and can be used
as independent 16 bit registers.
•The six segment registers available in 80386 are CS, SS, DS, ES, FS and GS.
•The CS and SS are the code and the stack segment registers respectively, while DS, ES,
FS, GS are 4 data segment registers.
•A 16 bit instruction pointer IP is available along with 32 bit counterpart EIP.
SEGMENT SELECTOR
CS CODE
SS STACK SEGMENT
DS
ES DATA
SEGMENT
FS
GS
INSTRUCTION POINTER AND FLAG
31 16 15 0
IP EI
FLAG EFLA
FLAGS
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
F
L RESERVED 1
VM RF 0 NT IOPL OF D IF T SF ZF 0 A 0 PF C
A FOR INTEL
F F F F
G
S
•After reset, the 80386 starts from memory location FFFFFFF0H under the real address
mode. In the real mode, 80386 works as a fast 8086 with 32-bit registers and data types.
•In real mode, the default operand size is 16 bit but 32- bit operands and addressing
modes may be used with the help of override prefixes.
•The segment size in real mode is 64k, hence the 32-bit effective addressing must be less
than 0000FFFFFH. The real mode initializes the 80386 and prepares it for protected
mode.
15 0
OFFSET
19 0
SEGMENT
SELECTOR 0000 MAX LIMIT
FIXED
AT 64 K IN REAL
MODE
c
c SELECTED
+ MEMORY SEGMENT
c 64 K
BYT
ES
c c
SEGMENT
•Memory Addressing in Real Mode: In the real mode, the 80386 can address at the most
1Mbytes of physical memory using address lines A0-A19.
•Paging unit is disabled in real addressing mode, and hence the real addresses are the
same as the physical addresses.
•To form a physical memory address, appropriate segment registers contents (16-bits) are
shifted left by four positions and then added to the 16-bit offset address formed using one
of the addressing modes, in the same way as in the 80386 real address mode.
•The segment in 80386 real mode can be read, write or executed, i.e. no protection is
available.
•Any fetch or access past the end of the segment limit generate exception 13 in real
address mode.
•The segments in 80386 real mode may be overlapped or non-overlapped.
•The interrupt vector table of 80386 has been allocated 1Kbyte space starting from
00000H to 003FFH.
SELECTOR
SELECT OFFSET
OFFSE
47 / 31 31 / 15 0
SEGMENT
LIMIT
ACCESS RIGHT
c
LIMIT c
c
c
BASE
+ MEMORY UP TO SELECTED
c 4 GB SEGMENT
SEGMENT DESCRIPTOR
c
SEGMENT BASE ADDRESS
•The effective address (offset) is added with segment base address to calculate linear
address. This linear address is further used as physical address, if the paging unit is
disabled, otherwise the paging unit converts the linear address into physical address.
•The paging unit is a memory management unit enabled only in protected mode. The
paging mechanism allows handling of large segments of memory in terms of pages of
4Kbyte size.
•The paging unit operates under the control of segmentation unit. The paging unit if
enabled converts linear addresses into physical address, in protected mode.
Segmentation
•DESCRIPTOR TABLES: These descriptor tables and registers are manipulated by the
operating system to ensure the correct operation of the processor, and hence the correct
execution of the program.
•Three types of the 80386 descriptor tables are listed as follows:
•GLOBAL DESCRIPTOR TABLE ( GDT )
•LOCAL DESCRIPTOR TABLE ( LDT )
•INTERRUPT DESCRIPTOR TABLE ( IDT )
•DESCRIPTORS: The 80386 descriptors have a 20-bit segment limit and 32-bit segment
address. The descriptor of 80386 are 8-byte quantities access right or attribute bits along
with the base and limit of the segments.
•Descriptor Attribute Bits: The A (accessed) attributed bit indicates whether the segment
has been accessed by the CPU or not.
•The TYPE field decides the descriptor type and hence the segment type.
•The S bit decides whether it is a system descriptor (S=0) or code/data segment descriptor
( S=1).
•The DPL field specifies the descriptor privilege level.
•The D bit specifies the code segment operation size. If D=1, the segment is a 32-bit
operand segment, else, it is a 16-bit operand segment.
•The P bit (present) signifies whether the segment is present in the physical memory or
not. If P=1, the segment is present in the physical memory.
•The G (granularity) bit indicates whether the segment is page addressable. The zero bit
must remain zero for compatibility with future process.
•The AVL (available) field specifies whether the descriptor is for user or for operating
system.
•The 80386 has five types of descriptors listed as follows:
1.Code or Data Segment Descriptors.
2.System Descriptors.
3.Local descriptors.
4.TSS (Task State Segment) Descriptors.
5.GATE Descriptors.
•The 80386 provides a four level protection mechanism exactly in the same way as the
80286 does.
A
D
D B
R Y
E T
S E
S
0
31 0
LIMIT BASE
BAS 3.2 G D TYPE A +4
0 AV 19…
. 16 P DPL S 23….2
Structure of An Descriptor
Paging
•PAGING OPERATION: Paging is one of the memory management techniques used for
virtual memory multitasking operating system.
•The segmentation scheme may divide the physical memory into a variable size segments
but the paging divides the memory into a fixed size pages.
•The segments are supposed to be the logical segments of the program, but the pages do
not have any logical relation with the program.
•The pages are just fixed size portions of the program module or data.
•The advantage of paging scheme is that the complete segment of a task need not be in
the physical memory at any time.
•Only a few pages of the segments, which are required currently for the execution need to
be available in the physical memory. Thus the memory requirement of the task is
substantially reduced, relinquishing the available memory for other tasks.
•Whenever the other pages of task are required for execution, they may be fetched from
the secondary storage.
•The previous page which are executed, need not be available in the memory, and hence
the space occupied by them may be relinquished for other tasks.
•Thus paging mechanism provides an effective technique to manage the physical memory
for multitasking systems.
•Paging Unit: The paging unit of 80386 uses a two level table mechanism to convert a
linear address provided by segmentation unit into physical addresses.
•The paging unit converts the complete map of a task into pages, each of size 4K. The
task is further handled in terms of its page, rather than segments.
•The paging unit handles every task in terms of three components namely page directory,
page tables and page itself.
•Paging Descriptor Base Register: The control register CR2 is used to store the 32-bit
linear address at which the previous page fault was detected.
•The CR3 is used as page directory physical base address register, to store the physical
starting address of the page directory.
•The lower 12 bit of the CR3 are always zero to ensure the page size aligned directory. A
move operation to CR3 automatically loads the page table entry caches and a task switch
operation, to load CR0 suitably.
•Page Directory : This is at the most 4Kbytes in size. Each directory entry is of 4 bytes,
thus a total of 1024 entries are allowed in a directory.
•The upper 10 bits of the linear address are used as an index to the corresponding page
directory entry. The page directory entries point to page tables.
•Page Tables: Each page table is of 4Kbytes in size and many contain a maximum of
1024 entries. The page table entries contain the starting address of the page and the
statistical information about the page.
•The upper 20 bit page frame address is combined with the lower 12 bit of the linear
address. The address bits A12- A21 are used to select the 1024 page table entries. The page
table can be shared between the tasks.
•The P bit of the above entries indicate, if the entry can be used in address translation.
•If P=1, the entry can be used in address translation, otherwise it cannot be used.
•The P bit of the currently executed page is always high.
•The accessed bit A is set by 80386 before any access to the page. If A=1, the page is
accessed, else unaccessed.
•The D bit ( Dirty bit) is set before a write operation to the page is carried out. The D-bit
is undefined for page director entries.
•The OS reserved bits are defined by the operating system software.
•The User / Supervisor (U/S) bit and read/write bit are used to provide protection. These
bits are decoded to provide protection under the 4 level protection model.
•The level 0 is supposed to have the highest privilege, while the level 3 is supposed to
have the least privilege.
•This protection provide by the paging unit is transparent to the segmentation unit.
PAGE TABLE O R
0 0 U -
31….1 RESERV 0 0 D A - W P
S
PAGE FRAME OS
U R
ADDRESS 31….1 0 0 D A 0 0 - - P
RESERVE S W
READ / WRITE
0 0 NONE
READ
1 0 READ / WRITE
READ / WRITE
1 1 READ- WRITE
INSIDE 80386 IN THE MEMORY
31 22 12 0
DIRECTOR TABL OFFSET
USER
MEMORY
10 10 +
12
31
0 0
31
C 0 31 DIRECTORY0
C 1 +
+
C
2
PAGE TABLE
C 3 DB
CONTROL
REGISTERS
•In its protected mode of operation, 80386DX provides a virtual 8086 operating
environment to execute the 8086 programs.
•The real mode can also used to execute the 8086 programs along with the capabilities of
80386, like protection and a few additional instructions.
•Once the 80386 enters the protected mode from the real mode, it cannot return back to
the real mode without a reset operation.
•Thus, the virtual 8086 mode of operation of 80386, offers an advantage of executing
8086 programs while in protected mode.
•The address forming mechanism in virtual 8086 mode is exactly identical with that of
8086 real mode.
•In virtual mode, 8086 can address 1Mbytes of physical memory that may be anywhere in
the 4Gbytes address space of the protected mode of 80386.
•Like 80386 real mode, the addresses in virtual 8086 mode lie within 1Mbytes of
memory.
•In virtual mode, the paging mechanism and protection capabilities are available at the
service of the programmers.
•The 80386 supports multiprogramming, hence more than one programmer may be use
the CPU at a time.
PHYSICAL MEMORY 020000000H
386 DX CPU OS
PAGE
MEMORY
TASK 2
8086 OS MEMORY
TASK 1
EMPTY MEMORY
PAGE 1 AVAILABLE
8086 OS
`
TASK 1
PAGE EMPTY MEMORY
DIRECTORY
ROOT TASK 1PAGE 8086 OS
TABLE
VIRTUAL MEMORY
8086 TASK PAGE DIRECTORY 1
0000000 H
Memory Management In Virtual 8086
•Paging unit may not be necessarily enable in virtual mode, but may be needed to run the
8086 programs which require more than 1Mbyts of memory for memory management
function.
•In virtual mode, the paging unit allows only 256 pages, each of 4Kbytes size.
•Each of the pages may be located anywhere in the maximum 4Gbytes physical memory.
The virtual mode allows the multiprogramming of 8086 applications.
•The virtual 8086 mode executes all the programs at privilege level 3.Any of the other
programmes may deny access to the virtual mode programs or data.
•However, the real mode programs are executed at the highest privilege level, i.e. level 0.
•The virtual mode may be entered using an IRET instruction at CPL=0 or a task switch at
any CPL, executing any task whose TSS is having a flag image with VM flag set to 1.
•The IRET instruction may be used to set the VM flag and consequently enter the virtual
mode.
•The PUSHF and POPF instructions are unable to read or set the VM bit, as they do not
access it.
•Even in the virtual mode, all the interrupts and exceptions are handled by the protected
mode interrupt handler.
•To return to the protected mode from the virtual mode, any interrupt or execution may
be used.
•As a part of interrupt service routine, the VM bit may be reset to zero to pull back the
80386 into protected mode.
Features of 80386
•This 80386 is a 32bit processor that supports, 8bit/32bit data operands.
•The 80386 instruction set is upward compatible with all its predecessors.
•The 80386 can run 8086 applications under protected mode in its virtual 8086 mode of
operation.
•With the 32 bit address bus, the 80386 can address upto 4Gbytes of physical memory.
The physical memory is organised in terms of segments of 4Gbytes at maximum.
•The 80386 CPU supports 16K number of segments and thus the total virtual space of
4Gbytes * 16K = 64 Terrabytes.
•The memory management section of 80386 supports the virtual memory, paging and
four levels of protection, maintaining full compatibility with 80286.
•The 80386 offers a set of 8 debug registers DR0-DR7 for hardware debugging and
control. The 80386 has on-chip address translation cache.
•The concept of paging is introduced in 80386 that enables it to organise the available
physical memory in terms of pages of size 4Kbytes each, under the segmented memory.
•The 80386 can be supported by 80387 for mathematical data processing.
80486 Microprocessor
•The 32-bit 80486 is the next evolutionary step up from the 80386.
•One of the most obvious feature included in a 80486 is a built in math coprocessor. This
coprocessor is essentially the same as the 80387 processor used with a 80386, but being
integrated on the chip allows it to execute math instructions about three times as fast as a
80386/387 combination.
•80486 is an 8Kbyte code and data cache.
•To make room for the additional signals, the 80486 is packaged in a 168 pin, pin grid
array package instead of the 132 pin PGA used for the 80386.
Pin Definitions
•A 31-A2 : Address outputs A31-A2 provide the memory and I/O with the address during
normal operation. During a cache line invalidation A31-A4 are used to drive the
microprocessor.
_____
•A20M3 : The address bit 20 mask causes the 80486 to wrap its address around from
location 000FFFFFH to 00000000H as in 8086. This provides a memory system that
functions like the 1M byte real memory system in the 8086 processors.
____
•ADS : The address data strobe become logic zero to indicate that the address bus
contains a valid memory address.
•AHOLD: The address hold input causes the microprocessor to place its address bus
connections at their high-impedance state, with the remainder of the buses staying active.
It is often used by another bus master to gain access for a cache invalidation cycle.
BREQ: This bus request output indicates that the 486 has generated an internal bus
request.
____ ____
• BE3-BE0 : Byte enable outputs select a bank of the memory system when information is
transferred between the microprocessor and its memory and I/O.
The BE3 signal enables D31 – D24 , BE2 enables D23-D16, BE1
enables D15 – D8 and BE0 enables D7-D0.
____
•BLAST: The burst last output shows that the burst bus cycle is complete on the next
activation of BRDY# signal.
_____
•BOFF : The Back-off input causes the microprocessor to place its buses at their high
impedance state during the next cycle. The microprocessor remains in the bus hold state
until the BOFF# pin is placed at a logic 1 level.
____
•BRDY : The burst ready input is used to signal the microprocessor that a burst cycle is
complete.
____
•KEN : The cache enable input causes the current bus to be stored in the internal.
_____
•LOCK : The lock output becomes a logic 0 for any instruction that is prefixed with the
lock prefix.
__
•W / R : current bus cycle is either a read or a write.
______
•IGNNE : The ignore numeric error input causes the coprocessor to ignore floating point
error and to continue processing data. The signal does not affect the state of the FERR
pin.
______
•FLUSH : The cache flush input forces the microprocessor to erase the contents of its 8K
byte internal cache.
_____
•EADS: The external address strobe input is used with AHOLD to signal that an external
address is used to perform a cache invalidation cycle.
_____
•FERR : The floating point error output indicates that the floating point coprocessor has
detected an error condition. It is used to maintain compatibility with DOS software.
___
•BS8 : The bus size 8, input causes the 80486 to structure itself with an 8-bit data bus to
access byte-wide memory and I/O components.
____
•BS16: The bus size 16, input causes the 80486 to structure itself with an 16-bit data bus
to access word-wide memory and I/O components.
_____
•PCHK : The parity check output indicates that a parity error was detected during a read
operation on the DP3 – DP0 pin.
______
•PLOCK : The pseudo-lock output indicates that current operation requires more than
one bus cycle to perform. This signal becomes a logic 0 for arithmetic coprocessor
operations that access 64 or 80 bit memory data.
•PWT: The page write through output indicates the state of the PWT attribute bit in the
page table entry or the page directory entry.
____
•RDY : The ready input indicates that a non-burst bus cycle is complete. The RDY signal
must be returned or the microprocessor places wait states into its timing until RDY is
asserted.
__ __
•M / IO : Memory / IO defines whether the address bus contains a memory address or an
I/O port number. It is also combined with the W/ R signal to generate memory and I/O
read and write control signals.
•The 80486 data bus, address bus, byte enable, ADS#, RDY#, INTR, RESET, NMI,
M/IO#, D/C#, W/R#, LOCK#, HOLD, HLDA and BS16# signals function as we
described for 80386.
•The 80486 requires 1 clock instead of 2 clock required by 80386.
•A new signal group on the 486 is the PARITY group DP0-DP3 and PCHK#.
•These signals allow the 80486 to implement parity detection / generation for memory
reads and memory writes.
•During a memory write operation, the 80486 generates an even parity bit for each byte
and outputs these bits on the DP0-DP3 lines.
•The final signal we want to discuss here are the bus request output signal BREQ, the
back-off input signal BOFF#, the HOLD signal and the hold-acknowledge signal HLDA.
•These signals are used to control sharing the local 486 bus by multiple processors ( bus
master).
•When a master on the bus need to use the bus, it asserts its BERQ signal .
•An external parity circuit will evaluate requests to use the bus and grant bus use to the
highest – priority master. To ask the 486 to release the bus , the bus controller asserts the
486 HOLD input or BOFF# input.
•If the HOLD input is asserted, the 486 will finish the current bus cycle, float its buses
and assert the HLDA signal.
•To prevent another master from taking over the bus during a critical operation, the 486
can assert its LOCK# or PLOCK# signal.
•The extended flag register EFLAG is illustrated in the figure. The only new flag bit is
the AC alignment check, used to indicate that the microprocessor has accessed a word at
an odd address or a double word boundary.
•Efficient software and execution require that data be stored at word or doubleword
boundaries.
GENERAL PURPOSE
3 1 1 0
A EA
B EB
C EC
D ED
S ES
D ED
B EB
S ES
SEGMENT
CODE
C
S STACK
D
E DATA
F
G
INSTRUCTION POINTER AND FLAG
3 1 1 0
I EI
FLAG EFLA
Flag Register of 80486
FLAGS
31 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
E
F RESERVED IOP
L FOR A V RF 0 NT L OF DF IF TF SF ZF 0 A 0 PF 1 CF
A INTEL C M F
G
•The memory system for the 486 is identical to 386 microprocessor. The 486 contains 4G
bytes of memory beginning at location 00000000H and ending at FFFFFFFFH.
•The major change to the memory system is internal to 486 in the form of 8K byte cache
memory, which speeds the execution of instructions and the acquisition of data.
•Another addition is the parity checker/ generator built into the 80486 microprocessor.
•Parity Checker / Generator : Parity is often used to determine if data are correctly read
from a memory location. INTEL has incorporated an internal parity generator / decoder.
•Parity is generated by the 80486 during each write cycle. Parity is generated as even
parity and a parity bit is provided for each byte of memory. The parity check bits appear
on pins DP0-DP3, which are also parity inputs as well as parity outputs.
•These are typically stored in memory during each write cycle and read from memory
during each read cycle.
•On a read, the microprocessor checks parity and generates a parity check error, if it
occurs on the PCHK# pin. A parity error causes no change in processing unless the user
applies the PCHK signal to an interrupt input.
•Interrupts are often used to signal a parity error in DS-based computer systems. This is
same as 80386, except the parity bit storage.
•If parity is not used, Intel recommends that the DP0 – DP3 pins be pulled up to +5v.
BE3 BE2 BE1 BE0
P P P P
A A A A
R R
I 1G X8 R 1G X 8 1G X 8 R 1G X 8
I I I
T T T T
Y Y Y Y
•CACHE MEMORY: The cache memory system stores data used by a program and also
the instructions of the program. The cache is organised as a 4 way set associative cache
with each location containing 16 bytes or 4 doublewords of data.
•Control register CR0 is used to control the cache with two new control bits not present
in the 80386 microprocessor.
•The CD ( cache disable ) , NW ( non-cache write through ) bits are new to the 80486
and are used to control the 8K byte cache.
•If the CD bit is a logic 1, all cache operations are inhibited. This setting is only used for
debugging software and normally remains cleared. The NW bit is used to inhibit cache
write-through operation. As with CD, cache write through is inhibited only for testing.
For normal operations CD = 0 and NW = 0.
•Because the cache is new to 80486 microprocessor and the cache is filled using burst
cycle not present on the 386.
80486 Memory Management
•The 80486 contains the same memory-management system as the 80386. This includes a
paging unit to allow any 4K byte block of physical memory to be assigned to any 4K byte
block of linear memory. The only difference between 80386 and 80486 memory-
management system is paging.
•The 80486 paging system can disabled caching for section of translation memory pages,
while the 80386 could not.
31 12 11 10 9 8 7 6 5 4 3 2 1 0
PAGE TABLE
OS
O O D P P U
A C W R
OR BITS T S W P
D
PAGE FRAME
•If these are compared with 80386 entries, the addition of two new control bits is
observed ( PWT and PCD ).
•The page write through and page cache disable bits control caching.
•The PWT controls how the cache functions for a write operation of the external cache
memory. It does not control writing to the internal cache. The logic level of this bit is
found on the PWT pin of the 80486 microprocessor. Externally, it can be used to dictate
the write through policy of the external caching.
•The PCD bit controls the on-chip cache. If the PCD = 0, the on-chip cache is enabled for
the current page of memory.
•Note that 80386 page table entries place a logic 0 in the PCD bit position, enabling
caching. If PCD = 1, the on-chip cache is disable. Caching is disable regard less of
condition of KEN#, CD, and NW.
•The control bits in TR5 enable the fill buffer or read buffer operation ( 00 )
•Perform a cache write ( 01 ), Perform a cache read ( 10 )
•Flush the cache ( 11 ).
•The cache status register (TR4) hold the cache tag, LRU bits and a valid bit. This
register is loaded with the tag and valid bit before a cache a cache write operation and
contains the tag, valid bit, LRU bits, and 4 valid bits on a cache test read.
•Cache is tested each time that the microprocessor is reset if the AHOLD pin is high for 2
clocks prior to the RESET pin going low. This causes the 486 to completely test itself
with a built in self test or BIST.
31 0
TR 3
31 11 7 3 0
LR Vali
Tag Valid Bit bit
31 11 10 4 3 2 0
M1 ARCHITECTURE OF MICROPROCESSORS
Q1. What are the advantages and the limitations microcontroller over a microprocessor?
Q2. Describe the main blocks in a digital signal processor that are not in a general microprocessor
Q1. List the internal registers in 8085 microprocessor and their abbreviations and lengths.
Q6. Explain the timing diagrams of 8085 when it is executing Memory mapped I/O and I/O
Q1. List all the registers associated with the four segment registers
Q1. How do you configure 8086 into minimum and maximum modes
Q2. Bring out the differences between 8086 and 8088 processors
Q4. Why and when wait states are required. How do you insert wait states
a. Description of Instructions
Q1. If BH = 0F3H what is the value of BH in hex after the instruction SAR BH, 1
Q2. IF AL = 78H and BL=73H explain how DAS instruction ( after subtracting BL from AL )
Q3. If CL=78H what is the value of CL after the instruction ROL CL, 3
Q4. Why AAD is to be executed before DIV instruction while converting unpacked BCD to
Binary number
Q6. Explain intra segment and inter segment branch instructions with examples the instructions
Q7. Explain all addressing modes with the assembler syntax and how effective address is
calculated
b. Assembly directives.
Q1. Write an algorithm to compute Fibonacci numbers using a recursive procedure. Write 8086
Q2. Write an algorithm and assembly program to convert an unpacked 4 digit number to Binary
number.
Q3. Write an algorithm and assembly program to convert a 16 bit number to a maximum of 5
unpacked digits
Q4. Write an algorithm and assembly program to convert an unpacked 4 digit number to Binary
number.
Q5. Write an algorithm and assembly program to find the square root of a 16 bit number using
Q6. Write an algorithm and assembly program to reverse the bits in a 16 bit number and check
whether it is a palindrome.
Q7. Write an algorithm and assembly program for a cash bill of n materials. Rupees is a 4 digit
and paisa is a 2 digit number which are stored in two different arrays. Find the total amount
for the n materials. Subtract 10% discount on the total and give the actual amount to be paid.
Hint Shift the total amount by one digit to get the 10% discount and get the actual amount.
Q1. What are the differences in interfacing RWMs while 8086 is in minimum and maximum
modes
Q2. Sketch and explain the interface of 32K x 16 RWMs using a decoder in minimum mode.
What is the maximum access time of ROMs such that it does not require wait states when
Q3. Sketch and explain the timing diagrams in the above interface Question 2
Q4. Sketch and explain the 8086 bus activities during write machine cycle
Q1. What are the steps in interfacing peripherals with the micro processor
Q2. Sketch and explain the interface of PPI 8255 to the 8086 microprocessor in minimum mode.
Q3. In the above question Q2 interface two keys UP and DOWN to the PPI. Write an 8086
assembly program segment such that when UP is pressed the counter counts up every second.
Similarly when DOWN key is pressed the counter decrements every second
Q4. Sketch and explain the interface of 8279 to the 8086 microprocessor in minimum mode.
Interface 8x8 key pad and 16x 7 Seg LED display. Write an 8086 assembly program to read
Q5. Sketch and explain the interface of PIT 8254 to the 8086 microprocessor in minimum mode.
Cascade two counters in the PIT. Write a program segment two get one minute delay
a. Architecture of 8087
Q1. Give five differences between the main processor and the coprocessor
Q2. How does 8086 distinguish its instructions from 8087 instructions as it fetches from memory
Q3. What is the role of busy pin 8087, when it is interfaced with 8086
Q1. What are the minimum and maximum values can be represented in all types of data
Q2. What are the different steps involved in converting a short real number to a decimal number
Q3. What are the different steps involved in converting a decimal number to a long real number
Q4. Write an 8086/87 assembly program to compute the total surface area of a sphere. The
Q5. What are the differences between rounding and truncation. Explain with examples
Q1. What are the advantages and disadvantages of using Harvard architecture in 8051
Q3. Explain PSW SFR. Give the application differences between Carry and Overflow flags
Q4. What are the power consumptions in power down and idle modes
Q7. What is the maximum delay the Timer0 produces when 8051 is operated at 12MHz
Q8. Explain how in Serial communication mode 0 expands I/O lines with the help of shift
Q3. How much program memory is in the chip and how much more can be interfaced externally
Q6. What is the maximum delay the Timer0 produces when 8096 is operated at 12MHz
a. Description of instructions
Q2. What are the values of RS0 and RS1 of PSW when 19H location is treated as a register
Q4. Does DA A instruction converts binary number to BCD number? Explain under what
Q6. What are program branch ranges of SJMP, AJMP and LJMP instructions
b. Assembly Directives
Q1. List all the header files required to cross compile C program
Q1. Write an 8051 assembly program to check a byte is a palindrome. Palindrome is a byte or a
word or words when read left or right it will be the same. Like for e.g. C3H
( 11000011b) or MALAYALAM.
Q3. Write an 8051 assembly program to multiply two 16 bit numbers, using shift left and add
algorithm
Q4. Write an 8051 assembly program to compute the square root of a 16 bit number using shift
Q5. Write an 8051 assembly program to find LCM of two 16 bit numbers.
Q6. Write an 8051 assembly program to search a key in a array of 16 bit numbers using Binary
search algorithm
a. Interfacing with peripherals like keyboards, LEDs, 7 segment LEDs, LCDs, ADCs, etc,.
Q1. Sketch and explain the interface of 5x4 key matrix using 74923.
Q2. Sketch and explain the interface of 4X7Segment LEDs in multiplexed mode.
Q3. Sketch the interface of a 16ch x 1line LCD to the 8051 microcontroller. Write an 8051
Q4. Sketch the interface of a serial ADC MAX 192 to the 8051 microcontroller. Write an 8051
Q5. Sketch the interface of a dual DAC 7303 to the 8051 microcontroller. Output the DAC
outputs are connected to an analog comparator. A LED is connected to the output of the
comparator for indication. Write an 8051 assembly program segment to flash if one analog
Q6. Sketch the interface of a RTC 1302 to the 8051 microcontroller. Write an 8051 assembly
program segment to read and write real time into the RTC.
Q1. List all the additional features that the 80386 microprocessor has over 8086
Q2. What is the main difference between the 80386 DX and 80386 SX microprocessor
Q3. How much the physical memory can 80386 address in real mode and in protected mode?
Q4. How are the tasks in 80386 system protected from each other.
Q5. How is an 80386 switched into virtual 8086 mode during task switch.
Q6. Describe three major additions or improvements that the 80486 processor has over 80386
processor.
M1 ARCHITECTURE OF MICROPROCESSORS
Q1. List the internal registers in 8085 microprocessor and their abbreviations and lengths.
Describe the primary function of each register.
Q2. List five levels of interrupts in 8085 microprocessor with priority.
Q3. Interface a key to SID pin of 8085 Microprocessor.
Q4. Interface a LED to SOD pin of 8085 Microprocessor.
Q5. In 8085 microprocessor which has higher the priority NMI or DMA
Q6. What are the differences between Memory mapped I/O and I/O mapped I/O
a. Description of Instructions
Q1. If AL = -9 and BL = 4710 after IDIV BL what are the values of AL and AH.
Q2. IF AX = -20010 and CX = 670H after IMUL CX what are the values of AX and DX
Q3. Explain AAA, AAD, AAM, AAS instructions with examples.
Q4. Explain DAA, DAS instructions with examples.
Q5. Explain the instructions related to the fixed and variable ports.
Q6. Explain the instructions related to arithmetic and logical shift.
Q7. How REP instruction is used along with string instructions.
b. Assembly directives.
Q1. What is the length of bytes reserved for the following directive STORE DW 100
DUP(0)
Q2. What is the difference between ENDS and ENDP directives.
Q3. Explain PTR directive
Q1. Write an algorithm to convert BCD to Binary numbers. Write 8086 assembly
program to convert two digit BCD number to hexadecimal number
Q2. Write an algorithm to convert Binary number to BCD number. Write 8086 assembly
program to convert one byte Binary number to BCD.
Q3. Write an algorithm to evaluate a factorial of an integer number N. Write an assembly
program using recursive procedure.
Q4. Write an algorithm to find GCD of two numbers. Write an assembly program to find
GCD of two words.
Q5. Write an algorithm and assembly program to sort the numbers in an array in
descending order using bubble sort method
Q1. Sketch and explain the interface of 32K x 16 ROMs using a decoder in minimum
mode. What is the maximum access time of ROMs such that it does not require wait
states when 8086 operates at 8 MHz
Q2. Sketch and explain the interface of 8K x 16 RAMs using a decoder in minimum
mode. What is the maximum access time of RAMs such that it does not require wait
states when 8086 operates at 8 MHz
Q3. Sketch and explain the 8086 bus activities during read machine cycle
Q1. Sketch and explain the interface of PPI 8255 to the 8086 microprocessor in minimum
mode. Interface 8 LEDs to the port B of 8255. Interface 8 keys to the port A. Write an
8086 assembly program to read the key status and output on to the 8 LEDs
i) Interface an 8 bit ADC 808 to port A. Derive control signals from port C. Write an
8086 assembly program segment to read an analog signal.
ii) Interface an 8 bit DAC 08 to port A. Write an 8086 assembly program segment to
output a ramp.
iii) Interface 16 ch x 1Line LCD to port A. Derive control signals from port C. Write
an 8086 assembly program segment to flash WELCOME TO CEDT
Q2. Sketch and explain the interface of PIT 8254 to the 8086 microprocessor in minimum
mode. Write an 8086 assembly program to generate a clock of 10 Hz on the OUT 0
pin. Write an 8086 assembly program to generate a hardware triggerable mono-shot
of 1 msec pulse width.
Q3. Sketch and explain the interface of 8279 to the 8086 microprocessor in minimum
mode. Interface 8x8 key pad and 16x 7 Seg LED display. Write an 8086 assembly
program to read the key codes of keys and display -IISc-BANGALORE-
Q4. Sketch and explain the interface of PIC 8259 to the 8086 microprocessor in minimum
mode. Show the cascading of additional eight 8259s to provide 64 external interrupts.
Write an 8086 assembly program to initialize master 8259 and slaves.
a. Architecture of 8087
Q1. List all data types supported by 8087 and their ranges
Q2. Convert 278.375 to short real
Q3. Convert 4332A000H to real number
Q4. List all the mathematical instructions in 8087
Q5. Write an 8086/87 assembly program to compute X Y where X and Y are real numbers
Q6. Write an 8086/87 assembly program to find the hypotenuse of a right angled triangle
with two sides given.
a. Description of instructions
b. Assembly Directives
Q1. Explain 8051 assembler directives EQU, SET and BIT with one example each.
Q2. Explain 8051 assembler directives DBIT and DS with one example each.
Q1. Write an 8051 assembly program to exchange the data using PUSH and POP
instructions.
Q2. Write an 8051 assembly program to convert two digit BCD number to hexadecimal
number
Q3. Write an 8051 assembly program to convert one byte Binary number to BCD.
Q4. Write an 8051 assembly program to evaluate the factorial of an integer number N
using recursive procedure.
Q5. Write an 8051 assembly program to find GCD of two numbers.
Q6. Write an 8051 assembly program to sort the number in an array using bubble sort
method
Q1. Sketch and explain the interface of 8x4 key matrix using 8:1 multiplexer, and a 3:8
decoder to 8051 microcontroller. Write an 8051 assembly program segment to input
the code of keys.
Q2. Switch the interface of a single red LED to 8051 microcontroller. Write an 8051
assembly program segment to blink the LED at 5Hz.
Q3. Sketch the interface of a 4x7 segment LEDs to the 8051 microcontroller. Write an
8051 assembly program segment to display I.I.Sc
Q4. Sketch the interface of a 16ch x 1line LCD to the 8051 microcontroller. Write an
8051 assembly program segment to display NPTEL
Q5. Sketch the interface of an ADC 808 to the 8051 microcontroller. Write an 8051
assembly program segment to read an analog signal through the ADC
Q6. Sketch the interface of a DAC 08 to the 8051 microcontroller. Write an 8051
assembly program segment to output a ramp signal through the DAC.
Q7. Sketch the interface of a RTC 1307 to the 8051 microcontroller. Write an 8051
assembly program segment to read and write real time into the RTC.
Q1. List all the additional features that the 80386 microprocessor has over 8086
Q2. What is the main difference between the 80386 DX and 80386 SX microprocessor
Q3. How much the physical memory can 80386 address in real mode and in protected
mode.
Q4. How are the tasks in 80386 system protected from each other.
Q5. How is an 80386 switched into virtual 8086 mode during task switch.
Q6. Describe three major additions or improvements that the 80486 processor has over
80386 processor.