Ilovepdf Merged-4 Compressed
Ilovepdf Merged-4 Compressed
Pilani Campus
MPI@Meetha V Shenoy
Tutorial Instructors
MPI@Meetha V Shenoy
General Purpose Computers/ Embedded Systems &
Microprocessors
In today’s world, we have Embedded Systems all around us. Almost all modern electronic systems
can be considered as Embedded Systems.
MPI@Meetha V Shenoy
Microprocessor Vs Microcontroller
Instruction
Memory I/O Instruction
Memory I/O
Microprocessor Microprocessor
Data Memory
I/O Data Memory
I/O
Timers Timers
MPI@Meetha V Shenoy
Von-Neumann/ Princeton Memory architecture
MPI@Meetha V Shenoy
Harvard Memory architecture
MPI@Meetha V Shenoy
Registers
• Assembly level Instruction
MPI@Meetha V Shenoy
• What do you understand by the term
8-bit, 16-bit , 32 or 64 bit processor?
MPI@Meetha V Shenoy
Microcontroller Vs SOC
BCM2385,
Raspberry Pi 3
MPI@Meetha V Shenoy
OMAP 4430- SOC
MPI@Meetha V Shenoy
Complex Instruction Set Computer
CISC Vs RISC Reduced Instruction Set Computer
c=a x b
CISC
• MUL C, A, B
RISC
• LOAD R1,A
• LOAD R2, B
• MUL R1, R1,R2
• STORE R1, C
MPI@Meetha V Shenoy
CISC Vs RISC
MPI@Meetha V Shenoy
Module 1
MPI@Meetha V Shenoy
BITS Pilani, Pilani Campus
Microprocessor
Instruction
Memory I/O
Microprocessor
Data Memory
I/O
Timing, RTC
MPI@Meetha V Shenoy
Module 2
MPI@Meetha V Shenoy
BITS Pilani, Pilani Campus
Motherboard
MPI@Meetha V Shenoy
Module 3
MPI@Meetha V Shenoy
Evaluation Scheme
Lab (regular): 2 marks for each lab. 1 mark for attendance, 1 for right answers, Best 7 will be
taken of 9 labs
Tutorial exams: Best 8 will be taken of 10 tuts
MPI@Meetha V Shenoy
Thank You
MPI@Meetha V Shenoy
BITS Pilani
Pilani Campus
MPI@Meetha V Shenoy
BITS Pilani, Pilani Campus
Module 2
MPI@Meetha V Shenoy
BITS Pilani, Pilani Campus
ADC
Analog
to
Digital
Converter
MPI@Meetha V Shenoy
DAC
Digital
to
Analog
Converter
MPI@Meetha V Shenoy
Module 3
MPI@Meetha V Shenoy
Motherboard
MPI@Meetha V Shenoy
Module 3
MPI@Meetha V Shenoy
Evaluation Scheme
Lab (regular): 2 marks for each lab. 1 mark for attendance, 1 for right answers, Best 7 will be
taken of 9 labs
Tutorial exams: Best 8 will be taken of 10 tuts
MPI@Meetha V Shenoy
Complex Instruction Set Computer
CISC Vs RISC Reduced Instruction Set Computer
c=a x b
CISC
• MUL C, A, B
RISC
• LOAD R1,A
• LOAD R2, B
• MUL R1, R1,R2
• STORE R1, C
MPI@Meetha V Shenoy
CISC Vs RISC
MPI@Meetha V Shenoy
• Assembly Level Instruction- ADD R1,R2,R3
MPI@Meetha V Shenoy
SIZE OF MACHINE CODE
• ADD R1,R2, R3
• ADD A,B,C
MPI@Meetha V Shenoy
Handling of Instruction by processor
• Instruction Fetch (IF)- Machine code is fetched from Instruction memory
• Instruction Decode (ID)- Identify the type of operation (opcode) and the
operands from the fetched machine code
ADD R1,R2,R3
• Write back (WB): The results of the instruction are written back to a
destination register or memory.
MPI@Meetha V Shenoy
Single Cycle Implementation
LDR R0, A
LDR R0,[R1]
LDR R0, [R1, R2]
STR R0, [R1,R2]
ADD R1,R1,R2
MPI@Meetha V Shenoy
Multicycle Implementation
MPI@Meetha V Shenoy
Pipelined Implementation
MPI@Meetha V Shenoy
SCALAR PIPELINED ARCHITECTURES
MPI@Meetha V Shenoy
Thank You
MPI@Meetha V Shenoy
Microprocessors programming
and Interfacing
CS/EEE/ECE/INSTR F241- Lect-3
Prof. Meetha V Shenoy, Prof. Vinay Chamola
CISC
• MUL C, A, B
RISC
• LOAD R1,A
• LOAD R2, B
• MUL R1, R1,R2
• STORE R1, C
ADD R1,R2,R3
RISC CISC
(Optimize) (Optimize)
CISC
Complex Instruction Decoder
1,048,576/(1024*1024)
16-bit processor
The instruction
pointer (IP) in an
8086 microprocessor
is a 16-bit register
that points to the
address of the next
instruction to be
fetched
16 bit registers
• Memory Organization
– Each byte in memory has a 20 bit address starting with 0 to 220-1 or 1M of
addressable memory
– Addresses are expressed as 5 hex digits from 00000 – FFFFF
– Problem: But 20 bit addresses are TOO BIG to fit in 16 bit registers!
• The BIU has a dedicated adder for determining physical memory addresses
Adder
BITS Pilani
Pilani Campus BIU & EU
16-bit processor
16 bit registers
• Memory Organization
– Each byte in memory has a 20 bit address starting with 0 to 220-1 or 1M of
addressable memory
– Addresses are expressed as 5 hex digits from 00000 – FFFFF
– Problem: But 20 bit addresses are TOO BIG to fit in 16 bit registers!
The instruction
pointer (IP) in an
8086 microprocessor
is a 16-bit register
that points to the
address of the next
instruction to be
fetched
• The BIU has a dedicated adder for determining physical memory addresses
Adder
• The stack segment defines the area of memory used for the
stack.
Facilitates
Segment Relocation
Registers
18
8086 Microprocessor
Architecture Bus Interface Unit (BIU)
Segment
Registers Code Segment Register
16-bit
19
8086 Microprocessor
Architecture Bus Interface Unit (BIU)
20
8086 Microprocessor
Architecture Bus Interface Unit (BIU)
21
8086 Microprocessor
Architecture Bus Interface Unit (BIU)
22
8086 Microprocessor
Architecture Bus Interface Unit (BIU)
23
8086 Microprocessor
Architecture Execution Unit (EU)
EU decodes and
executes instructions.
and
24
Default segment-offset combinations
8086 Microprocessor
Architecture Execution Unit (EU)
EU decodes and
executes instructions.
and
Some of the 16 bit registers can be
Index registers (Source used as two 8 bit registers as :
Index, Destination Index)
each of 16-bits AX can be used as AH and AL
BX can be used as BH and BL
CX can be used as CH and CL 26
DX can be used as DH and DL
8086 Microprocessor
Architecture Execution Unit (EU)
27
8086 Microprocessor
Architecture Execution Unit (EU)
28
8086 Microprocessor
Architecture Execution Unit (EU)
29
8086 Microprocessor
Architecture Execution Unit (EU)
30
8086 Microprocessor
Architecture Execution Unit (EU)
EU
Registers
31
8086 Microprocessor
Architecture Execution Unit (EU)
32
8086 Microprocessor
Architecture Execution Unit (EU)
33
Microprocessors programming
and Interfacing
CS/EEE/ECE/INSTR F241
Prof.Meetha V Shenoy/Prof. Vinay Chamola
BITS Pilani
Pilani Campus
This flag is set, when the This flag is set, if the result of This flag is set to 1, if the lower
result of any computation the computation or comparison byte of the result contains even
is negative performed by an instruction is number of 1’s ; for odd number
zero of 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Trap Flag
Over flow Flag If this flag is set, the processor
This flag is set, if an overflow occurs, i.e, if the result of a signed enters the single step execution
operation is large enough to accommodate in a destination
mode by generating internal
register. The result is of more than 7-bits in size in case of 8-bit
signed operation and more than 15-bits in size in case of 16-bit interrupts after the execution of
sign operations, then the overflow will be set. each instruction
Direction Flag Interrupt Flag
This is used by string manipulation instructions. If this flag bit
is ‘0’, the string is processed beginning from the lowest Causes the 8086 to recognize
address to the highest address, i.e., auto incrementing mode. external mask interrupts; clearing IF
Otherwise, the string is processed from the highest address disables these interrupts.
towards the lowest address, i.e., auto incrementing mode. 3
P1: 44+52
2CH , 34H
1 1 1 1
0 0 1 0 1 1 0 0 Auxiliary Carry – 1
0 0 1 1 0 1 0 0
0 1 1 0 0 0 0 0 No Carry
Result Not Zero
Positive Number
No overflow
Parity - Even
8086 registers
categorized
into 4 groups
7
8086 Internal registers
Flags
• Register Addressing
MOV AL,’A’
• Register Addressing
MOV AL,’A’
CS/EEE/ECE/INSTR F241
Lecture -9
BITS Pilani
Pilani Campus
ADDRESSING MODES
&
Instruction set
Addressing modes
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
MOV AX, [BX+ 34H]
MOV [BX+SI+600H], BH
SS
00 – x1
01 – x2
10 – x4
11 – x8
CS/EEE/ECE/INSTR F241
Lecture -10
BITS Pilani
Pilani Campus
ADDRESSING MODES
&
Instruction set
Addressing modes
Caution: From online source:
For details and accurate template see barry brey book: Appendix B
MOV [1008H], AH - THIS MACHINE CODE TEMPLATE NOT APPLICABLE (as AH used)
MOV [BX], AX - THIS MACHINE CODE TEMPLATE NOT APPLICABLE (as not direct addressing)
MOV [1240H], AL
101000 00 40H 12H
A0 40 12 H
A3 40 12 H
CS/EEE/ECE/INSTR F241
Lecture -11
BITS Pilani
Pilani Campus
Addressing modes
CS/EEE/ECE/INSTR F241
Lecture -12
BITS Pilani
Pilani Campus
EXAMPLE
.model tiny
.data
count equ 5
DATA1 DB 11h,22h,33h,44h,55h
DATA2 DB 5 DUP (?) Not required
.code
.startup
LEA SI, DATA1
MOV DI,300h
MOV CL, count
l1:MOV AL,[SI]
MOV [DI], AL
INC SI
INC DI
DEC CL
JNZ l1
.exit
end
BITS Pilani, Pilani Campus
CONDITIONAL JUMPS in 8086
JZ Label
CS/EEE/ECE/INSTR F241
Lecture -13
BITS Pilani
Pilani Campus
INC/DEC Instructions
JZ Label
(Status)
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
Add with Carry (ADC)
CS/EEE/ECE/INSTR F241
Lecture -14
BITS Pilani
Pilani Campus
BITS Pilani, Pilani Campus
CONDITIONAL JUMP INSTRUCTIONS
CS/EEE/ECE/INSTR F241
BITS Pilani
BITS Pilani
Pilani
Pilani Campus
Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
REP Prefix
BITS Pilani
Pilani Campus Lecture -16
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
PREFIX
BITS Pilani
Pilani Campus Lecture -17
OF???
BITS Pilani
Pilani Campus Lecture -18
BITS Pilani
Pilani Campus
BITS Pilani, Pilani Campus
JMP 2856H
JMP WORD PTR [BX], JMP BX
BITS Pilani
Pilani Campus Lecture -19
BITS Pilani
Pilani Campus
MUL SOURCE
Works on AL/AX
Quotient =0
Reminder =5
Lect-20
BITS Pilani
Pilani Campus
BITS Pilani, Pilani Campus
Push immediate is also possible.
Lect-21
BITS Pilani
Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
Passing Parameters to Procedures
-------------
-------------
MOV AL, BCDINPUT
The BCD number is copied
CALL BCD_BIN
from memory to the AL and
MOV BIN_VAL, AL then passed to the
----------- procedure in the AL
------------------ register.
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
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 can use this procedure to convert the BCD
no stored somewhere else in memory.
BITS Pilani
Pilani Campus
Write a procedure SUMS that sums EAX, EBX, ECX, and EDX. If a carry
occurs, place a logic 1 in EDI. If no carry occurs, place a 0 in EDI. The sum
should be found in EAX after the execution of your procedure.
•At the end of the procedure, these registers will be popped back,
restoring their original values.
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
Dual In-line Package (DIP)
8086 BITS Pilani
Address bus
BIU Discs
I/o
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
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 8086 31 HOLD
HLDA
RQ/GT0
AD5 11 30 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’ –
AD8 8 33 MN/MX logic 1
(Minimum
AD7 9 32 RD mode)
AD6 10 8086 31 HOLD
HLDA
RQ/GT0
MN/MX’ –
AD5 11 30 RQ/GT1 logic 0
AD4 12 29 WR LOCK (Maximum
AD3 13 28 M/IO S2 mode)
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 8086 31 HOLD
HLDA
RQ/GT0
AD5 11 30 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
Byte even 1 0
Byte odd 0 1
A16-A19
S6-S3
A16-A19
LS373
BITS Pilani
BHE’/S7 BHE’
G OE’
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
System Bus of 8086 (Address)
BITS Pilani
Signal Address Status
BHE’/S7 BHE S7 1
A16-A19
S6-S3
A16-A19
LS373
BITS Pilani
BHE’/S7 BHE’
G OE’
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
System Bus of 8086 (Address)
BITS Pilani BITS Pilani
Pilani | Dubai | Goa | Hyderabad
A Bus B Bus
Input Output
0
Bidirectional Buffer
BITS Pilani
A Bus
B Bus
E DIR
0 1/0
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
HLDA
RQ/GT0
AD5 11 30 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
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
Instruction Cycle
Bus/Machine Cycle
T states
ADD [1234H], AX
Machine code : 0106 3412
Machine cycle: 4
BITS Pilani
CBW
Machine code: 98
Machine cycle: 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 MN/MX’ –
AD8 8 33 MN/MX logic 1
(Minimum
AD7 9 32 RD mode)
AD6 10 8086 31 HOLD
HLDA
RQ/GT0
MN/MX’ –
AD5 11 30 RQ/GT1 logic 0
AD4 12 29 WR LOCK (Maximum
AD3 13 28 M/IO S2 mode)
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
Memory Access BHE’ A0
Word (16-bit) at 0 0
Even Address
Byte even 1 0
Byte odd 0 1
The BHE’ pin enables data bus bits (D15–D8) during a read or a write
operation.
A16-A19
S6-S3
A16-A19
LS373
BITS Pilani
BHE’/S7 BHE’
G OE’
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
System Bus of 8086 (Address)
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
LOGIC MEMW
BITS Pilani
WR LS244
CIRCUIT IOR
IO/M OE’
IOW
MN/MX’ 5V
System Bus of 8086( Control)
A16-A19
S6-S3
A16-A19
LS373
BITS Pilani
BHE’/S7 BHE’
G OE’
ALE
8086
AD8-AD15 LS373 A8-A15
G OE’
MN/MX’ 5V
System Bus of 8086 (Address)
MEMR
RD
LOGIC MEMW
BITS Pilani
WR LS244
CIRCUIT IOR
IO/M OE’
IOW
8086
AD8-AD15 LS245 D8-D15
DT/R’ DIR OE’
DEN’
MN/MX’ 5V
System Bus of 8086(Data + Control)
Signals of 8086 used during a bus transfer
AD15 – AD0 – Multiplexed Address & Data BITS Pilani
ALE
DT/R’
RD’
DEN’
200 ns
800 ns
ALE
DT/R’
RD’
DEN’
200 ns
800 ns
(600-110-30)ns= 460ns
ALE
DT/R’
RD’
DEN’
200 ns
800 ns
ALE
DT/R’
RD’
DEN’
200 ns
1000 ns
ALE
DT/R’
WR’
DEN’
200 ns
800 ns
NMI
INTR
INTA’ (output)
GND 1 40 VCC
AD14 2 39 AD15
AD13 3 38 A16/S3
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
31
AD6 10
11
8086 30
HOLD
HLDA
RQ/GT0
AD5 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
HOLD
HLDA (output)
Data Bus
Control Signals
A0 -
A10
D0 -
2K x 8
D7
RD
WR
CS
8K Memory – 4 – 2K chips of memory
Memory Mapping
Remaining Address CS
address lines of Decoding
CPU Logic
Interfacing to Processor
8088
Address Bus
Data Bus
Control Signals
Memory Mapping
A0 -
A10
D0 -
2K x 8
D7
RD
WR
CS
MEMW WR
MEMR RD
Data Bus of CPU D0-D7
Remaining Address CS
address lines of Decoding
CPU Logic
Memory Address Decoding
INPUT OUTPUT
S O0 ENABLE SELECT
A E
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
O3 X X 1 X X X 1 1 1 1 1 1 1 1
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
G2B B O7 1 0 0 1 0 1 1 1 1 1 1 0 1 1
L
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
Memory Address Decoding
INPUT OUTPUT
S O0 ENABLE SELECT
A E
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
O3 X X 1 X X X 1 1 1 1 1 1 1 1
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 O7 1 0 0 1 0 1 1 1 1 1 1 0 1 1
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
S O0 RAM1
A13 A E
L O1 RAM2
A12 B E
A11 C O2 RAM3
C T
A16 O3 RAM4
A17 LS138 O
A18 4
E
A19 O5
G1 N unused
A14 G2A A O6
B
A15 G2B L O7
E
Absolute Addressing
S O0 RAM1
A E
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
MEMW WR
MEMR RD
Data Bus of CPU D0-D7
Remaining Address CS
address lines of Decoding
CPU Logic
No of Memory chips
Address Space
Decoding logic
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
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 ROM1
A15 A E
L O1 ROM2
A12 B E
A11 C O2
C T unused
A16 O3
A17 LS138 O RAM1
A18 4
E
A19 O5 RAM2
G1 N
A14 G2A A O6 RAM3
B
A13 G2B L O7 RAM4
E
Absolute Addressing
D0-D7
A0-A10
ROM1 ROM2
A15 A OO CS’
A12 B
CS’
O1
A11 C O2
OE’ OE’
O3
Unused
MEMR’
LS138
O4 MEMW’
A13 G2A
O5
A14 G2B CS’ RD’ WR’ CS’ RD’ WR’ CS’ RD’ WR’ CS’ RD’ WR’
G1 O6
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 ROM – 4k
Number of 2716 – 2
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
O3 RAM2
A17 RAM1O
A18 LS138 O
4
A19 E
O5
G1 N RAM2E
A14 G2A A O6
B RAM2O
A13 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
Example 2:
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 O RAM2
1
A13 B E
A12 C O2 RAM3
C T
O3 RAM3
A17
A18 LS138 O
4
A19 E
O5
G1 N
A15 G2A A O6
B
A16 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 A0
7 RD
A12 C 4
A13 B 1 3
2
A 3
A14 1
8 0
G1 G2B
A16
M/IO’ A15
80286
Example 1:
Interface 4K of ROM to 80286 starting at 080000H
080000H - 080FFFH
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
A0
A1 CS A1 A0
CS
A A’
19 19
A12 7 A12 7
C 4 C 4
A13 B 1 A13 B 1
A14 3 A14 3
A 1 A 1
8 8
0 0
BHE A0
A15A16A17A18
Example 2:
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
081000H - 081FFFH
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 1 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
A11 A10 D15 –D8 D7 –D0
A11 A10
2K
2K
A0
A1 CS A1 A0
CS
A19 A19
A12 7 A12 7
C 4 C 4
A13 B 1 A13 B 1
A14 3 A14 3
A 1 A 1
8 8
0 0
BHE A0
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
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
0 Vcc
1 0 1 PC1
0 1 PC0
5V
8255
CS 8255A Internal
BITS Pilani, Pilani Campus
CS’ A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control Register
0 –BSR 1 – I/O
Affects only Port C
Group A Group B
0 –BSR 1 – I/O
Affects only Port C
CS’ A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control Register
1 X X 8255 Not Selected
BITS Pilani, Pilani Campus
D0 – D7 PA0 – PA7
System A0
PB0 – PB7
A1
I/f
Device
RD
8255
WR I/f
CS
PC0 – PC3
RESET
PC4 – PC7
A0 CS
A3
A4
M/IO’
8255
A5
A6
A7 RD RD
WR WR
D0 – D7 D0 – D7
Ex: LED
A R
0 Vcc
PC1
PC0
5V
8255
D7 D6 D5 D4 D3 D2 D1 D0
1 – I/O Port A Mode Port A Port C Port B Port B Port C
Mode 0 0 - Mode 0 1 – i/p Upper Mode 1 – i/p Lower
0 1 - Mode 1 0 – o/p 1 – i/p 0- Mode0 0 – o/p 1 – i/p
1 x – Mode2 0 – o/p 1- Mode1 0 – o/p
Group A Group B
PA
PC47
PC7
5V
Interface to the I/O Devices
BITS Pilani, Pilani Campus
A1 A0
A2 A1
A0 CS
A3
A4
M/IO’
8255
A5
A6
A7 RD RD
WR WR
D0 – D7 D0 – D7
f b
g
e c
h
A0
System PC4 – PC7 Row O/ps
A1
I/f
RD
8255
WR
CS
PB0 – PB7 7407
RESET (02 no)
Hex buffer
Current
limiting
resistors Vcc
Key Debounce
When a mechanical key is pressed or released- the metallic
contacts bounce before they make steady state contact
Bouncing is noise and should not be treated as i/p
Debounce RC-debouncer
X1 rows
encode
NO
NO All Keys Key found?
Open ?
yes
yes
Read Convert
X3
rows to hex
detect
NO return
Key pressed ?
X2
yes
Wait 20 De-bounce
ms
Read rows
NO
Key pressed ?
yes
E.g. Mode 0 – Keypad I/f
5V
0 1 2 3
1
O0
4 5 6 7
0
1
O1
8255 I/P port 8 9 A B
Pc4 – Pc7 1
O2
C D E F
O3 1
8255 O/P port
Pc0 – Pc3
I0
I1
I2
I3
Key O3 O2 O1 O0 I3 I2 I1 I0 HEX
0 1 1 1 0 1 1 1 0 EE
1 1 1 1 0 1 1 0 1 ED
2 1 1 1 0 1 0 1 1 EB
3 1 1 1 0 0 1 1 1 E7
4 1 1 0 1 1 1 1 0 DE
5 1 1 0 1 1 1 0 1 DD
6 1 1 0 1 1 0 1 1 DB
7 1 1 0 1 0 1 1 1 D7
8 1 0 1 1 1 1 1 0 BE
9 1 0 1 1 1 1 0 1 BD
A 1 0 1 1 1 0 1 1 BB
B 1 0 1 1 0 1 1 1 B7
C 0 1 1 1 1 1 1 0 7E
D 0 1 1 1 1 1 0 1 7D
E 0 1 1 1 1 0 1 1 7B
F 0 1 1 1 0 1 1 1 77
f b
g
e c
h
Debounce
s/w – using software delay of 10-20 ms
X1 rows
encode
NO
NO All Keys Key found?
Open ?
yes
yes
Read Convert
X3
rows to hex
detect
NO return
Key pressed ?
X2
yes
Wait 20 De-bounce
ms
Read rows
NO
Key pressed ?
yes
Column I/ps
D0 – D7 PC0 – PC3
A0
System PC4 – PC7 Row O/ps
A1
I/f
RD
8255
WR
CS
PB0 – PB7 7407
RESET (02 no)
Hex buffer
Current
limiting
resistors Vcc
.Model Tiny
.DATA
TABLE_D DB 3FH, 06H, 5BH, 4FH, 66H, 6DH ;Common cathode display codes
TABLE_K DB EEH,, EDH, EBH, E7H, DEH, DDH, ;Keyboard key-press codes
.DATA
TABLE_D DB 3FH, 06H, 5BH, 4FH, 66H, 6DH ;Common cathode display codes
TABLE_K DB EEH,, EDH, EBH, E7H, DEH, DDH, ;Keyboard key-press codes
X
1
:
.CODE
.STARTUP
MOV AL,10011000B
Initialize
OUT 06H,AL 8255
X0: MOV AL,00H
OUT 04H,AL
X1: IN AL, 04H Check for key
release
AND AL,F0H
CMP AL,F0H
JNZ X1
MOV AL,00H
OUT 04H ,AL
X2: IN AL, 04H Check for
AND AL,F0H Key press
CMP AL,F0H
JZ X2
Debounce
CALL DELAY_20ms time
MOV AL,00H
OUT 04H ,AL
IN AL, 04H Check for
AND AL,F0H Key press
CMP AL,F0H
JZ X2
MOV AL, 0EH
MOV BL,AL
OUT 04H,AL Check for
IN AL,04H
Key press
AND AL,F0H
CMP AL,F0H Column1
JNZ X3
MOV AL, 0DH
MOV BL,AL
OUT 04H ,AL Check for
IN AL,04H
AND AL,F0H Key press
CMP AL,F0H Column2
JNZ X3
MOV AL, 0BH
MOV BL,AL
OUT 04H,AL Check for
IN AL,04H
Key press
AND AL,F0H
CMP AL,F0H Column3
JNZ X3
MOV AL, 07H
MOV BL,AL
OUT 04H,AL Check for
IN AL,04H
AND AL,F0H Key press
CMP AL,F0H Column4
JZ X2
X3: OR AL,BL
MOV CX,0FH
MOV DI,00H Decode
X4: CMP AL,TABLE_K[DI]
JZ X5 key
INC DI
LOOP X4
X5: MOV AX,DI
LEA BX, TABLE_D Display
XLAT
OUT 02H,AL
JMP X0
.EXIT
END
The XLAT instruction replaces the value in
AL with the value found at DS:[BX + AL]
Column I/ps
D0 – D7 PC0 – PC3
A0
System PC4 – PC7 Row O/ps
A1
I/f
RD
8255
WR
CS
PB0 – PB7 7407
RESET (02 no)
Hex buffer
Current
limiting
resistors Vcc
BITS Pilani
Interrupt Handling
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
10 31
AD6
11
8086 HOLD
HLDA
RQ/GT0
AD5 30 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
19 22 READY
CLK
GND 20 21 RESET
8086 Interrupt sources
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
BITS Pilani
Interrupt Handling
ISR Handling in Real Mode
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.
Interrupts - 8086
BITS Pilani
▪ 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
CLI - clears IF
STI - sets IF flag