Professional Documents
Culture Documents
MuP Slides
MuP Slides
OUT = CLK
Count
Count – 16-bit
BCD/ Binary
RD CLK1
WR Counter GATE1
R/W
A0 1
Control OUT1
A1
Logic
CS
CLK2
Counter GATE2
Control 2 OUT2
Reg
8253 Internal
Device Interface of 8253/8254
CLK0 –CLK2
– External clock – carries input frequency signal (square
wave, 33% duty cycle)
OUT0 – OUT2
– Can program wave shape: square wave, one-shot
– Various duty cycles
– No sine waves or saw-tooth shapes
GATE0 – GATE2
– Enables or disables the counter
– Sometimes needs a 0-1 pulse to enable
0 0 0 Counter 0
0 0 1 Counter 1
0 1 0 Counter 2
0 1 1 Control Register
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control Register
Group A Group B
0 –BSR 1 – I/O
Affects only Port C
A0
System PB0 – PB7
A1
I/f Device
RD
8255
WR I/f
CS
PC0 – PC3
RESET
PC4 – PC7
A0 CS
A3
A4
M/IO’
A5
8255
A6
A7 RD RD
WR WR
D0 – D7 D0 – D7
Ex: LED
A R
1
Ex: LED
A R
0 Vcc
1 0 1 PC1
0 1 PC0
5V
8255
PC0
PB7
8255 PC3 5V
PA0
PC4
PA7
PC7
5V
Interface to the I/O Devices
BITS Pilani, Pilani Campus
A1 A0
A2 A1
A0 CS
A3
A4
M/IO’
A5
8255
A6
A7 RD RD
WR WR
D0 – D7 D0 – D7
.DATA
TABLE DB 3FH, 06H, 5BH, 4FH, 66H, 6DH
DB 7DH, 07H, 7FH, 67H
.CODE
.STARTUP
IN AL, 05H
LEA BX, TABLE
XLAT
OUT 50H,AL
.EXIT
END
IRQ
IRQ7
IRQ’ Interrupt
7 6 5 4 3 2 1 0 Type
1 1 1 1 1 1 1 0 FEH
1 1 1 1 1 1 0 1 FDH
1 1 1 1 1 0 1 1 FBH
1 1 1 1 0 1 1 1 F7H
1 1 1 0 1 1 1 1 EFH
1 1 0 1 1 1 1 1 DFH
1 0 1 1 1 1 1 1 BFH
0 1 1 1 1 1 1 1 7FH
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
INTA from CPU to INT to CPU at
Data
INTA of 8259 INTR i/p
Bus
D0-D7 Buffer Control Logic
RD Read/
WR Write
Control IR0
A0 IR1
Logic
IR2
CS ISR Priority IRR IR3
Interrupt
In-service
Register
Resolver Request IR4
Register
CAS0 IR5
CAS1 Cascade
IR6
CAS2 Buffer/
IR7
Comparator
SP/EN IMR Interrupt Mask Register
Mainline
STI
IR4-ISR
IR2-ISR
Priority
Resolver
0 0 0 0
1 0 1
0 0 0
IRR IMR
0 0 0 1
0 0 1
0 0 0 0 0 0 0 0 0 1 1
IR7
IR6
IR5
IR4
IR3
IR2
IR1
IR0
Priority
Resolver
0 0 0 0
1 0 0
1 0 0
IRR IMR
0 0 0 1
0 0 1
0 0 0 0 0 0 0 0 0 1 1
IR7
IR6
IR5
IR4
IR3
IR2
IR1
IR0
ICW2
NO (SNGL=1) In Cascade
Mode?
YES (SNGL=0)
ICW3
NO (ICW4=0) Is ICW4
needed?
YES (ICW4=1)
ICW4
8259M INT
CAS0 CAS0
CAS1 CAS1
CAS2 CAS2
SP/EN 8259S
5V
INTA
SP/EN
1 1
INT IR0
0 INTA
8259M INT
0
CAS0 CAS0 Interrupt type
CAS1 0
CAS1 to CPU
CAS2 0 CAS2
SP/EN 8259S
5V
INTA
SP/EN
ICWx A0 D7 D6 D5 D4 D3 D2 D1 D0
3M 1 S7 S6 S5 S4 S3 S2 S1 S0
1 1 M7 M6 M5 M4 M3 M2 M1 M0
2 0 R SL EOI 0 0 L2 L1 L0
R SL EOI Purpose
0 0 1 Non-specific EOI
0 1 1 Specific EOI
1 0 1 Rotate on non-specific EOI
1 0 0 Rotate on AEOI
1 1 1 Rotate on specific EOI
1 1 0 Set priority
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 0 0 0 0
7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0
2 1 0 7 6 5 4 3
Purpose P RR RIS
Read IRR on next RD 0 1 0
Read ISR on next RD 0 1 1
Poll 1 x x
Interrupt Handling
INT nn instruction BITS Pilani
Hardware Interrupt
External input applied at non-maskable interrupt NMI
External input applied at maskable interrupt INTR
Software Interrupt
Execution of INT instruction
Exception in program execution
Trap
BITS Pilani
The contents of the flag register are pushed onto the stack.
Both the interrupt (IF) and trap (TF) flags are cleared. This disables the INTR pin and the
trap or single-step feature.
The contents of the code segment register (CS) are pushed onto the stack.
The contents of the instruction pointer (IP) are pushed onto the stack.
The interrupt vector contents are fetched, and then placed into both IP and CS so that the
next instruction executes at the interrupt service procedure addressed by the vector.
Eg: INT 4H, CS:1P- 0100:0400, Flag: 0080
BITS Pilani
SP-6 00
SP-5 04
SP-4 00
SP-3 01
SP-2 80
SP-1 00
0010 00
IP
0011 08
0012 00
0013 02 SEG
0200:0800
How to exit from ISR ?
BITS Pilani
Entry to ISR
PUSHF
FAR CALL
▪If trap flag is set 80X86 will do a type 1 interrupt after every instruction execution
PUSHF
PUSH AX
MOV BP,SP
MOV AX,[BP+2]
OR AX, 0000000100000000H
MOV [BP+2],AX
POP AX
POPF
▪The system execute instruction up to break point and then goes to break point routine debugging
Interrupt Handling
Interrupts - 8086
BITS Pilani
D0
D1
D2
D3
D4
D5
D6
O7 O6 O5 O4 O3 O2 O1 O0
D7 LS 244
I7 I6 I5 I4 I3 I2 I1 I0 G1 ’ G2 ’
INTA’
IRQ0
INTR
IRQ7
BITS Pilani
IRQ’ Vector
7 6 5 4 3 2 1 0 No.
1 1 1 1 1 1 1 0 FEH
1 1 1 1 1 1 0 1 FDH
1 1 1 1 1 0 1 1 FBH
1 1 1 1 0 1 1 1 F7H
1 1 1 0 1 1 1 1 EFH
1 1 0 1 1 1 1 1 DFH
1 0 1 1 1 1 1 1 BFH
0 1 1 1 1 1 1 1 7FH
BITS Pilani
BITS Pilani
Pilani | Dubai | Goa | Hyderabad
RD
Read/
WR Write
A0 Control IR0
Logic IR1
IR2
CS Priority IR3
ISR IRR
Resolver IR4
CAS0 IR5
CAS1 Cascade
IR6
CAS2 IR7
Buffer/
SP/ Comparator
IMR
EN
8259 Architecture
BITS Pilani
The (Interrupt Request Register) IRR is used to store all the interrupt levels which
are requesting service.
Interrupt Mask Register (IMR) The IMR stores the bits which mask the interrupt
lines. The IMR operates on the IRR
The In-Service Register (ISR) is used to store all the interrupt levels which are being
serviced.
Priority Resolver logic block determines the priorities of the bits set in the IRR. The
highest priority is selected and strobed into the corresponding bit of the ISR during
INTA pulse.
Data INTA INT
BITS Pilani
Bus
D0-D7 Buffer Control Logic
RD
Read/
WR Write
A0 Control IR0
Logic IR1
IR2
CS Priority IR3
ISR IRR
Resolver IR4
CAS0 IR5
CAS1 Cascade
IR6
CAS2 IR7
Buffer/
SP/ Comparator
IMR
EN
8259 Architecture
BITS Pilani
WR’
To output
Initialization command words (ICW)-4
Operation command words (OCW)-3
RD’
To send the status of the Interrupt Request Register (IRR), In Service Register (ISR),
the Interrupt Mask Register (IMR) onto the Data Bus.
Data INTA INT
BITS Pilani
Bus
D0-D7 Buffer Control Logic
RD
Read/
WR Write
A0 Control IR0
Logic IR1
IR2
CS Priority IR3
ISR IRR
Resolver IR4
CAS0 IR5
CAS1 Cascade
IR6
CAS2 IR7
Buffer/
SP/ Comparator
IMR
EN
INT IR0 BITS Pilani
INTA
8259M INT
CAS0 CAS0
CAS1 CAS1
CAS2 CAS2
SP/EN 8259S
5V
INTA
SP/EN
1 1
INT IR0 BITS Pilani
0 INTA
8259M INT
0
CAS0 CAS0 Interrupt type
CAS1 0
CAS1 to CPU
CAS2 0 CAS2
SP/EN 8259S
5V
INTA
SP/EN
8259 Architecture
BITS Pilani
CAS0-CAS2
These pins are outputs for a master 8259A and inputs for a slave 8259A.
SP’/EN’
When in the Buffered Mode it can be used as an output to control buffer transceivers
(EN).
When not in the buffered mode it is used as an input to designate a master (SP = 1)
or slave (SP = 0).
INTA’
BITS Pilani
INT
Priority
Resolver
0 0 0 0
1 0 0
1 0 0
IRR IMR
0 0 0 0
1 0 0
1 0 0 0 0 0 0 0 0 1 1
IR7
IR6
IR5
IR4
IR3
IR2
IR1
IR0
Mainline
STI
BITS Pilani
IR4-ISR- STI
IR2-ISR- STI
Mainline
STI
BITS Pilani
IR4-ISR
IR2-ISR
Initializing 8259
BITS Pilani
4 ICWs
3 OCWs
Base Address 00h – 2 addresses are 00H, 02H
Order of writing important
ICW2
Cascade?
ICW3
ICW4?
ICW4
ICWx A0 D7 D6 D5 D4 D3 D2 D1 D0
ICWx A0 D7 D6 D5 D4 D3 D2 D1 D0
3M 1 S7 S6 S5 S4 S3 S2 S1 S0
Thank you
BITS Pilani
BITS Pilani
Pilani | Dubai | Goa | Hyderabad
BITS Pilani
Minimum Mode
Single processor based system
Simpler/Smaller systems
Maximum Mode
Larger systems – to be used when a co-processor exists in the system
Co-processor supplements the functions of the primary processor
Numeric Data processor (8087) –coprocessor
BITS Pilani
BITS Pilani
Pilani | Dubai | Goa | Hyderabad
A0 Add
Bus
A19
D0 Data
Bus
8086 D15
Control
signals
8086 BITS Pilani
Address bus
BIU
I/o Discs
ROM RAM
Ports Video
Data Bus
ALU
CLK
Control
& Timing
EU
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 8086 31 HOLD RQ/GT0
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 8086 31 HOLD RQ/GT0
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
Clock
BITS Pilani
CLK is provided to 8086 from an external clock
generator device such as 8284
One cycle of this clock is called a T-state
A T-state is measured as falling edge of one
clock pulse to falling edge of next clock pulse
Different versions of 8086 have maximum clock
frequencies of between 5MHz and 10MHz
The minimum time of one state will be between
200nS - 100nS
Clock Generator- 8284
BITS Pilani
Reset
BITS Pilani
Reset input causes the microprocessor to reset
itself if this pin is held high for a minimum of
four clocking periods.
Whenever the 8086 is reset, it begins executing
instructions at memory location FFFF0H
Disables future interrupts by clearing the IF
flag bit
Instruction Cycle BITS Pilani
Bus/Machine Cycle
T states
MOV AX, BX
Machine code: 89D8
Machine cycle: 1
BITS Pilani
MOV CX,[1234H]
Machine code: 8B0E 3412
Machine cycle: 3
BITS Pilani
CBW
Machine code: 98
Machine cycle: 1
BITS Pilani
ADD [1234H], AX
Machine code : 0106 3412
Machine cycle: 4
BITS Pilani
Instruction Cycle
Bus/Machine Cycle
T states
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 31 HOLD RQ/GT0
8086
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7 MN/MX’ –
logic 1
AD8 8 33 MN/MX (Minimum
AD7 9 32 RD mode)
AD6 10 31 HOLD RQ/GT0
8086 MN/MX’ –
AD5 11 30 HLDA RQ/GT1 logic 0
29 WR LOCK (Maximum
AD4 12
mode)
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
BITS Pilani BITS Pilani
Pilani | Dubai | Goa | Hyderabad
74LS273
Octal Latch
G OE
ALE
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 31 HOLD RQ/GT0
8086
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
ALE/BHE’
BITS Pilani
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
BHE’/S7 BHE S7 1
A16-A19
S6-S3 A16-A19
BITS Pilani
LS373
BHE’/S7 BHE’
G OE’
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
A Bus B Bus
Input Output
0
Bidirectional Buffer
BITS Pilani
A Bus
B Bus
E DIR
0 0
1
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 31 HOLD RQ/GT0
8086
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
Bidirectional Buffer – 8086 Data bus
BITS Pilani
A Bus B Bus
Inputs/Outputs Inputs/Outputs
E DIR
DEN DT/R
BITS Pilani
8086
MN/MX’ 5V
RD’
M/IO’ RD’ WR’ Bus cycle
1 0 1 MEMR’
WR’ 0 0 1 IOR’
0 1 0 IOW’
M/IO’ MEMR’
RD’
M/IO’ MEMW’
WR’
RD
MEMR
BITS Pilani
MN/MX’ 5V
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
8086
AD8-AD15 LS245 D8-D15
DT/R’ DIR OE’
DEN’
MN/MX’ 5V
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
8086
AD8-AD15 LS245 D8-D15
DT/R’ DIR OE’
DEN’
MN/MX’ 5V
ALE
DT/R’
RD’
DEN’
200 ns
800 ns
(600-110-30)ns= 460ns
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 31 HOLD RQ/GT0
8086
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
READY Signal & WAIT States
BITS Pilani
ALE
DT/R’
RD’
DEN’
200 ns
1000 ns
ALE
DT/R’
WR’
DEN’
200 ns
800 ns
NMI
INTR
INTA’
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3 BITS Pilani
AD12 4 37 A17/S4
AD11 5 36 A18/S5
AD10 6 35 A19/S6
AD9 7 34 BHE/S7
AD8 8 33 MN/MX
AD7 9 32 RD
AD6 10 31 HOLD RQ/GT0
8086
AD5 11 30 HLDA RQ/GT1
AD4 12 29 WR LOCK
AD3 13 28 M/IO S2
AD2 14 27 DT/R S1
AD1 15 26 DEN S0
AD0 16 25 ALE QS0
NMI 17 24 INTA QS1
INTR 18 23 TEST
CLK 19 22 READY
GND 20 21 RESET
DMA Access
BITS Pilani
HOLD
HLDA
TEST’
BITS Pilani
Bus/Machine Cycle
T states
MOV AX, BX
Machine code: 89D8
Machine cycle: 1
1 MEMR
BITS Pilani
MOV CX,[1234H]
Machine code: 8B0E 3412
2 MEMR
1 MEMR
BITS Pilani
2 MEMR
BITS Pilani
CBW
Machine code: 98
Machine cycle: 1
1 MEMR
BITS Pilani
ADD [1234H], AX
Machine code : 0106 3412
Machine cycle: 4
G OE’
ALE
8088
A8- A15 A8-A15
MN/MX’ 5V
RD
MEMR
8088
AD0-AD7 LS245 D0-D7
DT/R’ DIR OE’
DEN’
MN/MX’ 5V
Address Bus
Data Bus
Control Signals
Address
D
Bus
E
C
O
D
E
R
Data Bus
A 2K Memory Chip
A0 -
A10
D0 -
D7 2K x 8
RD
WR
CS
No of Memory chips
Address Space
Decoding logic
8K Memory – 4 – 2K chips of memory
Memory Mapping
Remaining Address CS
address lines of Decoding
CPU Logic
Memory Address Decoding
INPUT OUTPUT
S O0
A E ENABLE SELECT
L O1
G1 G2A G2B A B C O0 O1 O2 O3 O4 O5 O6 O7
B E 0 X X X X X 1 1 1 1 1 1 1 1
C O2 X 1 X X X X 1 1 1 1 1 1 1 1
C T
X X 1 X X X 1 1 1 1 1 1 1 1
O3
1 0 0 0 0 0 0 1 1 1 1 1 1 1
LS138 O
4 1 0 0 0 0 1 1 0 1 1 1 1 1 1
E 1 0 0 0 1 0 1 1 0 1 1 1 1 1
O5
G1 N 1 0 0 0 1 1 1 1 1 0 1 1 1 1
G2A A O6 1 0 0 1 0 0 1 1 1 1 0 1 1 1
B
G2B L 1 0 0 1 0 1 1 1 1 1 1 0 1 1
O7
E 1 0 0 1 1 0 1 1 1 1 1 1 0 1
1 0 0 1 1 1 1 1 1 1 1 1 1 0
RAM1 00000H – 007FFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
RAM2 00800H- 00FFFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
RAM3 01000H-017FFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1
RAM4 01800H-01FFFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
S O0
A E RAM1
A13
L O1 RAM2
A12 B E
A11 C O2 RAM3
C T
A16 O3 RAM4
A17 LS138 O
A18 4
A19 E
O5
G1 N unused
A14 G2A A O6
A15 B
G2B L
O7
E
Absolute Addressing
S O0
A E RAM1
L O1 RAM2
A12 B E
A11 C O2 RAM3
C T
O3 RAM4
LS138 O
4
E
O5
5V G1 N unused
G2A A O6
B
G2B L
O7
E
Incremental Addressing
8088
For the memory chips available each do the
interfacing for 8088
Ex: Interface
4K - 2716 (ROM) starting at 00000H
8K - 6116 (SRAM) starting at 08000H
Memory Requirements
2716 – ROM - size 2K (16/8)
ROM – 4k
Number of 2716 required – 2
6116 – RAM size 2k (16/8)
RAM – 8k
Number of 6116 required - 4
Memory Map
ROM 1 - 00000H – 007FFH
ROM2 - 00800H – 00FFFH
RAM1 - 08000H – 087FFH
RAM2 - 08800H – 08FFFH
RAM3 - 09000H – 097FFH
RAM4 - 09800H – 09FFFH
ROM1 00000H – 007FFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
RAM1 08000H-087FFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
RAM2 08800H- 08FFFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
RAM3 09000H-097FFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1
RAM4 09800H-09FFFH
1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
S O0
A E ROM1
A15
L O1 ROM2
A12 B E
A11 C O2
C T unused
A16 O3
A17 LS138 O
A18 4 RAM1
A19 E
O5 RAM2
G1 N
A14 G2A A O6 RAM3
A13 B
G2B L
O7 RAM4
E
Absolute Addressing
D0-D7
A0-A10
O7
RAM1 RAM2 RAM3 RAM4
Ex: Interface
4K 2716 (ROM) starting at 00000H
8K 6116 (SRAM) starting at 08000H
Memory Requirements
2716 – size 2K
ROM – 4k
Number of 2716 – 2 ROM – 4k
6116 – size 2k
RAM – 8k
RAM – 8k
Number of 6116 -4
ROM – 4k
2k even 2k odd
RAM – 8k
4K 4K
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
RAM2 09000H-09FFFH
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
BHE
A0
S ROM1 ROM1E
O0
A16 A E
L O1 ROM1O
A15 B E
A12 C O2 RAM1 RAM1E
C T
O RAM2
A17 3
RAM1O
A18 LS138 O
4
A19 E
O5
G1 N RAM2E
A14 G2A A O6
A13 B RAM2O
G2B L
O7
E
Absolute Addressing
A11 A10 D15 –D8 A11 D7 –D0
A10
2K
2K
A1 A0 A1
A17 CS A0
A18 CS
A19
G1
7
A12 C 4 A0
BHE
A15 B 1
3 3
A16 A 2
8
0
G2A G2B
A13 A14
8086-80286
Interface 1M of SRAM to 8086
Chips available are of size 256K each
A19A18A17A16 A15A14A13A12 A11A10A9A8 A7A6A5A4 A3A2A1A0
0 0 0 0 0 0 0 0 0 0 00 0000 0000
512KB
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1
1 0 0 0 0 0 0 0 0 0 00 0000 0000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 512KB
A18 A17 D15 –D8 D7 –D0
A18 A17
256K
256K
A1 A0
CS A1 A0
CS
VCC VCC
GND GND
G1 G1
7 7
C 4 C 4
B 1 B 1
3 3
A19 A 1 A19 A 1
8 8
G2A G2B 0 G2A G2B 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
S O0 RAM1
A14 A E
L RAM2
O1
A13 B E
A12 C O2
C T
O3 RAM3
A17
A18 LS138 O
4
A19 E
O5
G1 N
A15 G2A A O6
A16 B
G2B L
O7
E
Absolute Addressing
4K 4K
A11 A10 D15 –D8 A11 D7 –D0
A
A1010
A1 A0 2K A1
WR A
A00 2K
2K WR
2K
BHE WR’ WR’
A17 RD’ CS A0
RD’ CS
A18
A19
G2A RD BHE
7 A0 RD
A12 C 4
A13 B 1 3
2
A 3
A16 1
8 0
G1 G2B
A14
M/IO’ A15
80286
Interface 4K of ROM to 80286 starting at 080000H
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
A11 A10 D15 –D8
A11 A10 D7 –D0
2K
2K
A1 A0
CS A1 A0
CS
A19 A19
7 7
A12 C 4 A12 C 4
A13 B 1 A13 B 1
A14 3 A14 3
A 1 A 1
8 8
0 0
BHE A0
A15A16A17A18
80286
Interface 8K of ROM to 80286 starting at 080000H
Chips available are 2 KB each
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1
A11 A10 D15 –D8 D7 –D0
A11 A10
2K
2K
A1 A0
CS A1 A0
CS
A19 A19
7 7
A12 C 4 A12 C 4
A13 B 1 A13 B 1
A14 3 A14 3
A 1 A 1
8 8
0 0
BHE A0
Parameters are data values or addresses passed back and forth between the
mainline program and the procedure
Four ways to pass parameters
In Registers
In Dedicated memory locations accessed by name
With pointers passed in registers
With stack
-------------
-------------
MOV AL, BCDINPUT
The BCD number is copied from
CALL BCD_BIN memory to the AL and then
MOV BIN_VAL, AL passed to the procedure in the
----------- AL register.
------------------
Conversion example:
BCD – 16
Bin/hex -10h
(01 * 0ah ) + 6
In the preceding example, why didn’t we simply access the BCD_INPUT and
BIN_VALUE by name from the procedure?
BCD_BIN PROC NEAR
PUSHF
PUSH AX
PUSH BX
PUSH CX
MOV AL, BCD_INPUT
MOV BL , AL
AND BL , 0FH
AND AL , 0F0H
MOV CL , 04
ROR AL, CL
MOV BH , 0AH
MUL BH
ADD AL, BL
MOV BIN_VALUE, AL
POP CX
POP BX
POP AX
POPF
RET
BCD_BIN ENDP
BITS Pilani, Pilani Campus
Can be done but with severe limitation!!
Procedure will always look for the named memory location BCD_INPUT to get its
data and will always put the result in BIN_VALUE.
Or, we cant use this procedure to convert the BCD no stored somewhere else in
memory.
MEMORY
Real & Protected Modes
REAL MEMORY
▪ First 1 MB
▪ conventional memory
▪ DOS Memory
▪ 8086/8088 – operate only in real mode
▪ Segment Registers & Monitors
▪ Code
▪ Data
▪ Stack
▪ Extra
▪ FS & GS
▪ Maximum segment size 64 K
▪ Segments - Relocatability
MEMORY
Protected Modes- Descriptor
DESCRIPTOR
▪ 8 bytes
▪ Total memory for GDT /LDT – 64K
▪ 80286 – upward compatible
MEMORY
Protected Modes- Descriptor-The
Access Right Byte
ACCESS RIGHT BYTES
FORMAT
E ED/C R/W ?
0 0 0 Data- Expands Upward –
Read Only
0 0 1 Data- Expands Upward - Write
0 1 0 Data - Expand Downward –
Read Only
0 1 1 Data- Expand Downward - Write
1 0 0 Code – Ignore DPL – Execute Only
1 0 1 Code – Ignore DPL – Read allowed
1 1 0 Code – Abide DPL – Execute Only
1 1 1 Code – Abide DPL – Read allowed BITS Pilani, Pilani Campus
BITS Pilani
Pilani Campus
MEMORY
Protected Modes- Descriptor- Address
Translation
ACCESS RIGHT BYTES
FORMAT
GDTR
IDTR
▪ DS starts at – 00 20 00 00
▪ Linear Address
MEMORY
Protected Modes- Descriptor- Address
Translation
EXAMPLES 00
00
▪ MOV AX,[1000H] 93
40
▪ DS:1000
00
▪ DS = 001C 00
FF
▪ 1st 13 bits – 0000 0000 0001
3 FF
1100 - LDT
▪ Selector – LDTR
▪ LDTR – 0018 – 0000 0000 0001
1000
▪ GDTR + 0018 (entry no. 3) 2
▪ GDTR – 00 00 00
▪ LDT starts at – 40 00 00
GDTR
IDTR
MEMORY
Real & Protected Modes- Paging
MEMORY-8086 TO 80486
▪ Segment (SR) - Offset
▪ 8086 /8088 – Real mode
▪ 80286
▪ Real Mode
▪ Protected Mode
▪ Segment Register – Selector – points to descriptor (LDT/GDT) – descriptor has
starting address of segment – Starting Address + Offset
▪ Virtual address – Physical Address (24-bits)
▪ Segmentation
▪ Total no.pages
▪ 1024 * 1024 = 1 M
▪ Page block of 4k
00 00 20 00
P P
Address (31-12) D A CWUWP
DT
OUT = CLK
Count
Count – 16-bit
BCD/ Binary
RD CLK1
WR Counter GATE1
R/W
A0 1
Control OUT1
A1
Logic
CS
CLK2
Counter GATE2
Control 2 OUT2
Reg
8253 Internal
Device Interface of 8253/8254
CLK0 –CLK2
– External clock – carries input frequency signal (square
wave, 33% duty cycle)
OUT0 – OUT2
– Can program wave shape: square wave, one-shot
– Various duty cycles
– No sine waves or saw-tooth shapes
GATE0 – GATE2
– Enables or disables the counter
– Sometimes needs a 0-1 pulse to enable
0 0 0 Counter 0
0 0 1 Counter 1
0 1 0 Counter 2
0 1 1 Control Register
WR WR
D0 – D7 D0 – D7
4 3 2 1 0 FF FE FD FC FB
CLK
GATE
OUT
5V
2.3 V
Port
7407
LM139
L
P
E 5V
0V
D
D comparator
WR’
CW LSB = 4
4 3 2 2 2 2 2 1 0 FF FE
CLK
GATE
OUT
WR’
CW LSB = 4 LSB = 4
4 3 2 4 3 2 1 0 FF FE
CLK
GATE
OUT
➢ Mode 0
➢ Interrupt on terminal count (event counter)
➢ Out pin goes low when mode word or new count is written
➢ Now if clock is applied and gate=1, countdown begins
➢ Countdown stops if gate=0: resumes if gate=1
➢ If count written is N then OUT becomes high after N+1
clocks
➢ OUT remains high till a new count is written
➢ Countdown continues as FFFFH, FFFEH if gate =1
➢ Application – object counting
CLK
GATE
OUT
WR’
CW LSB = 4
4 3 2 1 4 3 2 1 0
CLK
GATE
OUT
WR’
CW LSB = 4 LSB = 2
4 3 2 1 0 FF FE 2 1
CLK
GATE
OUT
➢ Mode 1
➢ Programmable one-shot- also h/w retriggerable one-shot
➢ Two step process
➢ Load count registers
➢ Send 0-to-1 pulse on GATE to trigger it
➢ When triggered o/p goes low after one clock cycle & stays
low for N clock cycles goes high
➢ If gate is made low it does not stop counter
➢ A +ve transition at gate reloads the counter & countdown
begins afresh
➢ A new count is not loaded till gate is triggered
➢ Application – detect ac power failure
Rate Generator
(Divide-by-N Counter)
WR’
CW LSB = 3
3 2 1 3 2 1 3 2 1 3 2
CLK
GATE
OUT
WR’
CW LSB = 3
3 2 1 3 2 2 3 2 1 3 2
CLK
GATE
OUT
WR’
CW LSB = 4 LSB = 5
4 3 2 1 5 4 3 2 1 5 4
CLK
GATE
OUT
➢ Mode 2
➢ Rate generator or divide-by-N counter
➢ Countdown starts one clock cycle after the gate is made high (or
one cycle after the count is written if gate is already high)
➢ On reaching a count of one the OUT goes low for one cycle. If
the counter is loaded with a number N, then OUT pin will go low
for one clock cycle every N input clock pulses.
➢ Now count is automatically reloaded and whole process repeats
➢ If a new count is written then it is loaded only after previous
countdown finishes
➢ If gate is made low during countdown then counting stops and
OUT is made immediately high
➢ Application : frequency generation, real time clock
4 2 4 2 4 2 4 2 4 2 4
CLK
GATE
OUT
WR’
CW LSB = 5
4 2 0 4 2 4 2 0 4 2 4
CLK
GATE
OUT
Mode 3
➢ Square wave generator
➢ If GATE = 1, OUT is a square wave (50% duty, or slightly off
if N is odd)
➢ If N is odd then will be high for (N+1)/2 and low for (N-1)/2
➢ Each clock pulse decrements the counter by 2
➢ Count is automatically reloaded on 2
➢ If gate is made low during countdown then counting stops
and when gate is made high again, counting continues.
➢ Application: clock input generation for other devices,
audio tone generator
4 3 2 1 0 FF FE
CLK
GATE
OUT
WR’
CW LSB = 4
4 3 2 2 2 2 2 1 0 FF FE
CLK
GATE
OUT
WR’
CW LSB = 4 LSB = 4
4 3 2 4 3 2 1 0 FF FE
CLK
GATE
OUT
Mode 4
– Software triggered strobe
– If GATE =1, OUT goes low N+1 cycles after the count is
written.
– OUT is low for one clock cycle
– Count must be reloaded to repeat the strobe
– not automatically reloaded
– If GATE→low, the OUT → high and count stops; count
resumes (from where it stopped) when GATE→high
– Application : I/O strobe
CLK
GATE
OUT
WR’
CW LSB = 4
4 3 2 1 4 3 2 1 0 FF
CLK
GATE
OUT
WR’
CW LSB = 4 LSB = 2
4 3 2 1 0 FF FE 2 1
CLK
GATE
OUT
Mode 5
– Hardware triggered strobe
– Like mode 4, but triggering is done with GATE instead
– Count begins when 0-1 pulse hits GATE
– OUT goes low N+1 cycles after gate is triggered.
– OUT is low for one clock cycle
– Gate must be triggered again to repeat the strobe
– not automatically reloaded
– If GATE→low, it does not stop countdown
– A trigger on gate in between countdown will reload the
count and keep OUT high
– Appln: I/O handshake
1 1 Count Status C2 C1 C0 0
8259
Problem-1
Work out the 8259 interfacing connections with 8086 given that
the 8259 address is 074X. Write an ALP (Assembly language
procedure) to initialize the 8259A with following functionalities
[IR0 is of type 80H]
• single level triggered mode
• non-buffered on special fully nested mode.
• Set the 8259A to operate with IR6 masked,
• Set IR4 as bottom priority level with rotate on specific EOI mode.
• Set special mask mode of 8259A.
• Also, read IRR and ISR into registers BH and BL respectively.
Step-1: FindingAddress
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 Address of Port
A1 connected to A0
Again the same even bus/
odd bus funda !!!
Step-2: Finding the ICW1
Don’t cares
A0 A7 A6 A5 1 LTIM ADI SNGL IC4
0 0 0 0 1 1 1 1 1 ICW1= 1FH
Don’t cares
1 0 0 0 0 0 0 0 ICW2=80H
Don’t cares
Fixed Non-buffered
A0=1, forICW4 mode For 8086
For special fully microprocessor
nested mode
masking Normal
EOI
Step-5: Finding OCW1
A0 D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 0 0 0 0 0 0
OCW1= 40H
IR6 is masked
Step-6: Finding the OCW2
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 1 0 0 1 0 0 OCW2= E4H
The OCW3 sets the special mask mode and reads ISR and IRR using the following control words-
For reading IRR:
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 1 0 1 0 1 0
A0 D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 1 0 1 0 1 1
Val address
ICW1 1Fh 0740h
ICW2 80h 0742h
ICW4 11h 0742h
OCW1 40h 0742h
OCW2 E4h 0740h
OCW3 6Ah (IRR) 0740h
OCW3 6Bh (ISR) 0740h
INTERRUPT PROC NEAR
MOV AL, 1FH ; Loading ICW1 to AL
MOV DX, 0740H ; Loading Address of ICW1 to DX (Variable port addressing)
OUT DX, AL ; Sending ICW1 to port (address: 0740H ) of 8259A
MOV DX, 0742H ; address of ICW2
Val address
MOV AL, 80H ; Loading ICW2 to AL which select the vector address
ICW1 1Fh 0740h
OUT DX, AL ; Sending ICW2 to port (address: 0742H ) of 8259A
ICW2 80h 0742h
MOV AL, 11H ; Loading ICW4 to AL
ICW4 11h 0742h
OUT DX, AL ; Sends ICW4 to 0742H
OCW1 40h 0742h
MOV AL, 40H ; Loading OCW1 to AL
OUT DX, AL ; Sends OCW1 to 0742H OCW2 E4h 0740h
MOV AL, E4H ; Loading OCW2 to AL OCW3 6Ah (IRR) 0740h
MOV DX, 0740H ; Address of OCW2 OCW3 6Bh (ISR) 0740h
MOV DX, AL ; Sending OCW2 to 0740H address.
MOV AL, 6AH ; Loading OCW3 for reading IRR
OUT DX, AL; Sending OCW3 to 0740H address.
IN AL, DX ; Reading IRR and store to AL
MOV BH, AL; Store IRR into BH
MOV AL, 6BH ; Loading OCW3 for reading ISR
OUT DX, AL; Sending OCW3 to 0740H address.
IN AL, DX ; Reading ISR and store to AL
MOV BL, AL; Store ISR into BL
RET
INTERRUPT ENDP
Solution of same qn from original source
https://books.google.co.in/books?id=KJNpD2KimEsC&pg=PA259&lpg=PA259&dq=8259+solved+problem+microprocessor&source=bl&ots=eNuvVGs5Uc&sig=tvWq94QTG8Ev_LmGwTpNbHcKTHA&hl=en&sa=X&ved=0ahUKEwinveKd98LaAhVJtI
8KHRcNCyIQ6AEIXzAF#v=onepage&q&f=false