Copy of Microprocessor Systems
Copy of Microprocessor Systems
Memory and Peripheral interfacing: Basic interfacing concepts - Memory space partitioning
- Buffering of buses – Timing constraints - Memory control signals - Read and write cycles,
Interfacing RAM, ROM, 8255PPI, Interfacing applications using 8255. Need for direct memory
access - DMA transfer types
Freescale 32 bit ColdFire Processor:-Introduction to ColdFire Core, Comparison with 8085 &
8086 Architecture, Introduction to MCF5223X Microprocessor Architecture & Functional Blocks
Course Outcome
CO No. Course Outcome
CO1 The student will be able to analyze, specify, design, write and test assembly language
programs for 8085 microprocessor and basic programs to run on 8086 microprocessor
based systems.
CO2 The student will be able to understand the various aspects of the internal architecture of
the 8085 microprocessor and will be able to design hardware circuits to interface the 8085
microprocessor to various ICs like RAM, ROM, 8255 etc.
CO3 The student will be able to calculate the worst-case execution time of programs or parts of
programs, and to design and build, or to modify, software to maximize its run time memory
or execution-time behavior.
CO4 The student will be able to compare the architecture design for 8085, 8086 & Coldfiree 32
bit microprocessor
Pedagogy
1. Flipped Class – Pre-loaded Video Lectures which you will view before coming
to the live class
2. Live Classes - For discussions and doubt clearing
3. Quizzes – Multiple Choice Types
4. Assignments - Zero plagiarism policy – Copying will get you a zero
5. Lab Work – To the extent possible
6. Project – Simulation Based
Microprocessors System
74LS374
8085 Microprocessor
Consists of:
1. CPU + ALU + Registers
2. 8 bit Data Bus (Multiplexed)
3. 16 bit Address Bus (8 bit Multiplexed with Data Bus)
4. 5 Sources of hardware Interrupt
5. 02 Serial Data Lines
6. DMA Interface
7. Control lines for interfacing
8085 Microprocessor
Fetch-Decode-Execute Cycle
A microprocessor, till the time it is ON and is not in HALT mode, will continuously follow the
Fetch Decode Execute Cycle
1. Fetch the Instruction from the ROM into the Instruction Register (IR)
2. Decode the Instruction i.e. understand what the instruction is
3. Execute the Instruction i.e. perform all micro-steps needed to complete the task
mentioned by the instruction
Then go back to Step No. 1 and repeat the process infinite number of times
8085 Microprocessor – Pin Description
Pins Direction Description
X1, X2 IN This is where the Crystal is connected to the Oscillator circuit inside 8085 where Clock is
generated. Typically 6MHz crystal is connected and internal clock is 3MHz (Crystal
frequency/2)
CLK OUT OUT The Clock signal generated inside the 8085 is also available as an output at this pin and
can be connected to external device, if needed
Vcc, GND IN Voltage Supply and Ground. As IC is TTL, Supply is Typically 5V
AD7-AD0 IN & Multiplexed Address and Data Bus (LSB of Address Bus A7-A0 is time multiplexed with
OUT Data Bus D7-D0
A8-A15 OUT MSB of Address Bus
ALE OUT Used to demultiplex the time multiplexed Address and Data Bus AD7-AD0 to A7-A0 &
D7-D0
RD, WR, OUT Signal used for Reading a byte or Writing a byte from/to external Input/Output Device or
IO/M Memory
RESETIN, IN, OUT Applying a 0 on RESETIN RESETS the 8085 and simultaneously generates a 1 on
RESET OUT RESET OUT which could be used to REST other external devices if needed.
HOLD, IN, OUT Hold & Hold Acknowledge (Active Low) are used for Direct Memory access (DMA)
HLDA
8085 Microprocessor – Pin Description
Pins Direction Description
S0,S1 OUT These Status signals indicate the status of thee internal circuit of the 8085
READY IN Slow external devices use this signal to convey to 8085 that they are ready for the next
operation
TRAP, RST IN, OUT First 05 are the Interrupt Signals while INTA is the Interrupt Acknowledgement Signal
7.5, RST 6.5, generated by 8085 in response to receipt of INTR interrupt
RST 5.5,
INTR, INTA
SID, SOD IN, OUT These are used to Serially receive or transmit 01 byte of data, bit by bit
8085 Microprocessor – Memory Read Cycle
8085 Microprocessor – Memory Write Cycle
e.g. STA 2022H
In T1:
Address available on A8-A15 & A7-A0
ALE Pulse
Io/M =0
WR=1
In T2:
A7-A0 becomes tri-state
ALE=0
Put Data on Data Bus D7-D0
Io/M=0
WR=0
In T3:
After some time WR=1
Remove Data from D7-D0, Bus is tri-state
Complete the Cycle
8085 Microprocessor – De-multiplexing of AD7-AD0
8085 Microprocessor – De-multiplexing of AD7-AD0
8085 Microprocessor – RAM Interface
A14
A12 /WR /WR
A1 A13
A9 A5
A8 A3
A7 A11
A6 /RD
/RD
A4 A10
A2 /CS
A0 D4
D0 D3
D1 D7
D5 D2
D6
/RD /WR
8085 Microprocessor – Address Space
Address Space means the total unique addresses that can be generated by the 8085 microprocessors on its 16 address
lines. Since 8085 has 16 address lines thus a total of 2^16 = 65536 addresses
2^4 = 16
2^7 =128
2^8 = 256
2^9 =512
2^10 =1024 (1KB)
2^11 =2048 (2KB)
2^12 =4096 (4KB)
2^13 =8192 (8KB)
2^14 =16384 (16KB)
2^15 =32768 (32KB)
2^16 =65536 (64KB)
8085 Microprocessor – Address Space
Q1. 01 ROM IC of 32KB and 01 RAM IC of 32KB are to be interfaced with the 8085. Assuming the starting address of
ROM IC is 0000H what will be address map for the ROM and RAM?
Q2. 02 ROM ICs of 8KB each and 01 RAM IC of 16KB is interfaced to 8085. Assuming the starting address of first ROM
IC is 0000H what will be address map for the ROMs and RAM?
Q3. 01 ROM IC of 2KB and on ROM IC of 8KB and 02 RAM IC of 8KB each is interfaced to 8085. Assuming the starting
address of first ROM IC is 0000H what will be address map for the ROMs and RAM?
Q4. IO/M is used by microprocessor to indicate if its doing a Rad or write operation with Input/Output Device or
Memory. This signal along with /RD and /WR signal is used to perform the Memory Rad/Write or IO Read/write
operations. Design a circuit which accepts these three signals as input and generates four outputs namely /IOR,
/IOW, /MEMR,/MEMW8085.
8085 Microprocessor – Memory Interface
0000H
A0-A14
/CS1 A15
D0-D7
/RD
7FFFH
A15
8000H
A0-A14
/CS2
D0-D7
/RD
/WR
FFFFH
8085 Microprocessor – Memory Interface
8KB ROM
A0-A12 0000H
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 D0-D7
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 /RD 1FFFH
0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1
/CS1
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
8KB ROM
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
A0-A12 2000H
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 1 1 D0-D7
/RD 3FFFH
A15 /CS1 /CS2
A14
A13 16KB RAM
4000H
A15 /CS2 A0-A13
A14 /CS3
A13 D0-D7
/RD
A15 /WR
/CS3
A14
A13 7FFFH
8085 Microprocessor – Memory Interface 2KB ROM
0000H
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 A0-A10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D0-D7
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1
/RD 07FFH
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 /CS1
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8KB ROM
A0-A12 2000H
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 1 1 D0-D7
/RD 3FFFH
0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
/CS2
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
A15 /CS1 8KB RAM
A14 4000H
A15 /CS2 A0-A12
A13
A14 /CS3
A13 D0-D7
/RD
A15 /CS3 /WR
A14 5FFFH
A13 8KB RAM
6000H
A15 /CS4 A0-A12
A14 /CS4
D0-D7
A13 /RD
/WR
7FFFH
74138 3 to 8 Decoder
8085 Microprocessor – Memory Interface
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
8KB ROM
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 A0-A12 0000H
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 D0-D7
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 /RD 1FFFH
/CS1
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 1 1 1 8KB ROM
A0-A12 2000H
A13 D0-D7
A14
/CS1 /RD 3FFFH
/CS2 /CS2
A15
GND 16KB RAM
/CS3 4000H
A0-A13
/CS3
D0-D7
Vcc /RD
/WR
7FFFH
Instruction Set of 8085 Microprocessor
Instruction Format: Instruction consists of 01 Opcode (Operation Code) and either 0, 1 or 2 operands
We already know that reading one byte of memory takes 3 T States. This combination of 3 T states is
called a Machine Cycle represented by M
The Instructions are stored in the ROM and need to be fetched from the ROM to the Microprocessor
Fetching the Opcode (1 Byte) takes 3 T states and 01 additional T state is taken to decode the Opcode
Therefore, the Machine cycle for Opcode Fetch is of 4 T-States and not 3 T states
This is called M1 Machine cycle – Machine cycle for fetching the OpCode
So with this logic how many machine cycles will be required to fetch the complete instruction LDA
2000H? The answer is 3 Machine cycles M1, M2 & M3
How many total t states to fetch this instructions?
4 T states in M1, 3 T States in M2 & 3 T states in M3 – Total of 10 T States to fetch this instruction
Instruction Fetch Cycle of 8085 – Part –A – Op-code Fetch
M1 Machine Cycle – Opcode Fetch & Decode
LDA 2000H //Read number from memory location 2000H and copy into Accumulator (A)
MOV B,A //Copy the contents of Register A (Source) into Register B (Destination)
LDA 2001H //Read number from memory location 2001H and copy into Accumulator (A)
ADD B //Perform the addition of the two bytes stored in A and B and store sum in A
STA 2002H //Store the value in A into memory location 2002H
HLT //Stop
Registers in 8085
Flag register in 8085
1. CY Flag – Carry Flag - This flag becomes 1 when addition or subtraction of two bytes results in
generation of carry or borrow else it is 0. This carry or borrow is reflected in the Carry flag.
2. P Flag - Parity Flag - If after any arithmetic or logical operation the result has even parity, an
even number of 1 bits, the parity flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
3. Z Flag – Zero Flag - If after any arithmetic or logical operation the result is zero, the Zero
flag is set i.e. 1, otherwise it is reset i.e. 0.
4. S Flag – Sign Flag – The S flag corresponds to the Most Significant Bit of the Accumulator
after arithmetic or logical operation is carried out. If signed number representation is being
used then a 1 would indicate that the number is negative and 0 would indicate that number is
positive
5. AC Flag – Auxiliary Carry Flag - If after any arithmetic operation there is a carry from the
lower nibble to the upper nibble then AC Flag is set i.e. becomes 1 else AC flag is reset i.e. 0
Instruction Set of 8085 Microprocessor
There are a total of 246 instructions in the instructions set of 8085 microprocessor and these can be
categorized as:
1. Data Transfer Instructions – These instructions can be used to transfer data between Register to
register, Register to memory, memory to register . e.g. LDA, STA, MOV, MVI. Execution of these
instructions have not effect on the flags.
2. Arithmetic & Logical Instructions - These instructions can be used to perform arithmetic and logical
operations. Result of the operation, in most cases is stored in Accumulator. e.g. ADD, SUB, INR, DCR,
AND, XOR, ORA etc. Execution of most of these instructions have effect on the flags.
3. Branching Instructions – These instructions can be used to change the sequence of flow of the
program. This change in flow can be conditional or unconditional. e.g. JMP, JZ, JNZ, CALL, RET
4. Control Instructions - These instruction control the basic functioning of the microprocessor. e.g.
HLT, NOP, SIM, RIM, DI, EI
Data Transfer Instructions
L Data
Data Transfer Instructions (MVI reg/M, 8 bit value)
MVI destination, source
Destination can be a register of M (Memory)
E.g. MVI A,2FH Move immediately into A the value 2FH A 2FH
MVI C, 77H Move immediately into C the value 77H C C 77H
MVI M, 8CH Move immediately into the Memory location the number 8CH. location
is Memory the one whose address is in [HL] 8CH
Register H Register L
2000H 5AH
20H 03H
2001H 2FH
If Register H has the value 20H & L has the value 03H then the Register pair HL has
the value 2003H 2002H 39H
2003H 1FH / 8CH
Now on execution of MVI, 8CH, the data at memory location 2003H will be
2004H 22H
replaced with 8CH
Data Transfer Instructions (MVI)
MVI reg/M, 8 bit number
Operand
Instruction Fetch & Execute Cycle for MVI M, 8 bit number
M1 Machine Cycle – Opcode Fetch, Decode
Operand Operand A
Data Transfer Instructions (LXI Rp, 16 bit number)
LXI Rp, 16 bit number
Load into Register Pair (BC, DE, HL,SP) the 16 bit number given in the instruction itself
E.g. LXI H, 2100H Copy 21H into H, 00H into L H 21H L 00H
LXI B, 2420H Copy 24H into B, 20H into C B 21H C 00H
LXI D, 4142H Copy 41H into D, 42H into E D 21H E 00H
LXI SP, 3042H Copy 3042h in 16 bit Register SP SP 3042H
Data Transfer Instructions (LXI Rp, 16 bit number)
LXI Rp, 16 bit number e.g. LXI H, 2100H
Operand Operand
Write a program in 8085 Assembly language to read two bytes
of data from 2000H & 2001H and exchange the two bytes
LDA 2000H A < - [2000H] 3 13 LXI H, 2000H HL < - 2000H 3 10
MOV B,A B <- A 1 4 MOV B,M B <- [2000H] 1 7
B
2001H 5AH
5AH
Arithmetic Instructions
ADD R/M A <- A + R/M
ADC R/M + Carry A <- A + R/M + Carry
ADI 8 bit number A <- A + 8 bit number
ACI 8 bit number + Carry A <- A + 8 bit number + Carry
SUB R/M A <- A - R/M
SBB R/M – Carry A <- A - R/M - Carry
SUI 8 bit number A <- A - 8 bit number
SBI 8 bit number – Carry A <- A - 8 bit number – Carry
INR R/M R <-R+1 M<- M+1
DCR R/M R <-R-1 M<- M-1
INX Rp Rp <- Rp + 1
DCX Rp Rp <- Rp - 1
Arithmetic Instructions (ADD R/M)
ADD R/M (ALL FLAGS ARE AFFECTED)
Add the 8 bit number in A with the 8 bit number in other register R or memory
E.g. ADD B Add number in A with number in B and store answer in A A+B
ADD E Add number in A with number in B and store answer in A A+E
ADD M Add number in A with number in M and store answer in A A + [HL]
1. CY Flag – Carry Flag - This flag becomes 1 when addition or subtraction of two bytes results in
generation of carry or borrow else it is 0. This carry or borrow is reflected in the Carry flag.
2. P Flag - Parity Flag - If after any arithmetic or logical operation the result has even parity, an
even number of 1 bits, the parity flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
3. Z Flag – Zero Flag - If after any arithmetic or logical operation the result is zero, the Zero
flag is set i.e. 1, otherwise it is reset i.e. 0.
4. S Flag – Sign Flag – The S flag corresponds to the Most Significant Bit of the Accumulator
after arithmetic or logical operation is carried out. If signed number representation is being
used then a 1 would indicate that the number is negative and 0 would indicate that number is
positive
5. AC Flag – Auxiliary Carry Flag - If after any arithmetic operation there is a carry from the
lower nibble to the upper nibble then AC Flag is set i.e. becomes 1 else AC flag is reset i.e. 0
Let’s see how Flags are affected by ADD instruction
MVI A,09H A= 5DH CY= 0 AC= 0 S= 0 Z= 0 P= 0
MVI B, 54H
ADD B 5D = 0101 1101
E.g. ADC B Add number in A with number in B and store answer in A A + B + Carry Flag
ADC E Add number in A with number in B and store answer in A A + E + Carry Flag
ADC M Add number in A with number in M and store answer in A A + [HL] + Carry Flag
E.g. ADI 20H Add number in A with the number 20H A A + 20H
Register A Register A
0FH 2FH
If Register A has the value 0FH, then after execution of the instruction ADI 20H, the new value in A shall be 2FH.
Arithmetic Instructions (ADI 8 bit number)
ADI 8 bit number
Data
Arithmetic Instructions (ACI 8 bit number)
ACI 8 bit number (ALL FLAGS ARE AFFECTED)
Add the 8 bit number in A with the 8 bit number given in the instruction + Carry Flag
E.g. ACI 20H Add number in A with the number 20H A A + 20H + Carry Flag
Register A CY Register A CY
0FH 1 After execution of ACI 20H 30H 0
If Register A has the value 0FH and if carry flag is 1, then after execution of the instruction ACI 20H, the new value
in A shall be 30H and new value in Carry Flag shall be 0.
Arithmetic Instructions (ACI 8 bit number)
ACI 8 bit number
Data
Arithmetic Instructions (SUB R/M)
SUB R/M (ALL FLAGS ARE AFFECTED)
Subtract from the 8 bit number in A, the 8 bit number in other register R or memory
E.g. SUB B Subtract from the number in A, number in B and store answer in A A-B
SUB E Subtract from the number in A, number in E and store answer in A A-E
SUB M subtract from the number in A, number in M and store answer in A A - [HL]
E.g. SBB B Subtract from number in A, number in B and store answer in A A - B - Carry Flag
SBB E Subtract from number in A, number in E and store answer in A A - E - Carry Flag
SBB M Subtract from number in A, number in M and store answer in A A - [HL] - Carry Flag
E.g. SUI 20H Subtract from number in A, the number 20H A A - 20H
Register A Register A
7FH 5FH
If Register A has the value 7FH, then after execution of the instruction SUI 20H, the new value in A shall be 5FH.
Arithmetic Instructions (SUI 8 bit number)
SUI 8 bit number
Data
Arithmetic Instructions (SCI 8 bit number)
SCI 8 bit number (ALL FLAGS ARE AFFECTED)
Subtract from the 8 bit number in A, 8 bit number given in the instruction - Carry Flag
E.g. SCI 20H Subtract from number in A, number 20H A A -20H - Carry Flag
Register A CY Register A CY
7FH 1 After execution of ACI 20H 5EH 0
If Register A has the value 7FH and if carry flag is 1, then after execution of the instruction SCI 20H, the new value
in A shall be 5EH and new value in Carry Flag shall be 0.
Arithmetic Instructions (SCI 8 bit number)
SCI 8 bit number
Data
Arithmetic Instructions (INR R/M
INR R/M (ALL FLAGS EXCEPT CARRY FLAG ARE AFFECTED)
Increment contents of Register or Memory by 1
XRI 8 bit number A <- A XOR 8 bit number 1. Zero flag (ZF), Sign flag (SF), Parity flag
(PF) are affected
ORA R/M A <- A OR R/M
2. Carry flag & Overflow Flags are not
ORI 8 bit number A <- A OR 8 bit number SBI
affected
CMA A <- NOT A
3. Except NOT, all logical instructions
CMP R/M A - R/M
clear carry flag (CF) and overflow flag
CPI 8 bit number A - 8 bit number (OF)
CMC COMPLEMENT CARRY FLAG 4. AC is undefined
STC CARRY FLAG=1
Logic Instructions (Contd.)
A = 0010 0111
RLC
RLC
RLC
CY = 0 A= 10011100 RLC
RLC
CY =1 A = 00111001
Logic Instructions (Contd.)
A= 10011100 CY = 0
RRC
A = 01001110 CY = 0
Logic Instructions (Contd.)
CALL Address Start Fetching Instruction from that address CALL 2050
MOV B,A //2000h & 2001H 1 4 MOV B,A //2000h & 2001H 1 4
LDA 2001H //Store sum at 2002H 3 13
LDA 2001H //Store sum at 2002H 3 13
ADD B 1 4
ADD B 1 4
STA 2002H 3 13
STA 2002H 3 13 JC up IF CY=1 then goto NXT else goto next instruction
MVI A, 00H
MVI A, 00H 2 7
STA 2003H
ACI 00H //Add carry bit to the 2 7 HLT
STA 2003H //number at 2003H 3 13 up: MVI A, 01H
18 74 STA 2003H
HLT
Write a program in 8085 assembly language to store the
number 00H in 5 memory locations starting from 2000H and
the program shall be stored from 1000H
LXI H, 2000H
A
MVI A, 00H 1000H LXI H, 2000H 3 10 00
MOV M,A 1003H MVI A, 00H 2 7
00 C
INX H 1005H MVI C, 05H 2 7
H L
MOV M,A 1007H MOV M,A 1 7
20 05
INX H 1008H INX H 1 6
MOV M,A 1009H DCR C 1 4 Z
INX H 100AH JNZ 1007H 3 7 / 10 1
MOV M,A 100DH HLT 1 4
INX H
MOV M,A
Write a program in 8085 assembly language to add the 05
numbers stored starting from memory location 2000H and
store the 16 bit sum at 2005H & 2006H
A
MVI C,04H ;Set counter for 4 loop 70
MVI D,00H ;Using as MSB
LXI H,2000H ; Initialise to starting memory
MOV A,M ;Get number from 2000H 01 D 0 C
AGAIN: INX H ;Point to next address H L
ADD M ;Perform addition
JNC AHEAD ;If carry then increment D 20 04
INR D 2000H 7F
AHEAD: DCR C ;Reduce counter
2001H 22 Z CY
JNZ AGAIN ;repeat addition
INX H ;Point to LSB location 2002H 36
CD 1 0
MOV M,A ;Store LSB 2003H 5F
INX H ;Point to MSB location
MOV M,D ;Store 2004H 4A
HLT 2005H 70
2006H 00
What will be the contents of Register A, HL, Memory and the
flags at the completion of following programs
A
LXI H, 2000H 61
MVI M, 07H
INX H C
MVI M,5AH
LDA 2000H H L
ADD M 20 02
INX H
MOV M,A
HLT 2000H 07 P S Z AC CY
2001H 5A
0 0 0 1 0
2002H 61
2003H
2004H
2005H
What will be the contents of Register A, HL and the flags at
the completion of following programs
A
LXI H, 2000H
MVI D,09H
AGAIN: MVI M, 07H 00 D
INX H
DCR D H L
JNZ AGAIN 20 09
HLT
2000H 07 P S Z AC CY
2001H 07
0 0 1 0 0
2002H 07
07
2003H 07
2004H 07
2005H
Data Transfer Instructions (LHLD 16 bit address)
LHLD 16 bit address
Load into Register L the data at memory location whose address is given in instruction and load into H
the data from the next memory location
E.g. If for the Memory locations given below execution of LHLD 2000H will result in 5A in L and 2F in H.
Execution of LHLD 2003H will result in 1FH in L and 22H in H
L (address) H (address +1)
Size of Instruction: 3 Bytes 2000H 5AH
Number of Machine Cycles to Fetch the Instruction: 03 M1, M2 & M3 (10 T)
Number of Machine Cycles to Execute the Instruction: 02 M4 & M5 (6 T) 2001H 2FH
2002H 39H
2003H 1FH
2004H 22H
Data Transfer Instructions (SHLD 16 bit address)
SHLD 16 bit address
Store the data in L into memory location whose address is given in instruction and store number in H
into the next memory location
E.g. Suppose data in HL is 379FH
Then SHLD 2000H will result in 9FH in memory location 2000H and 27H in 2001H
(address) L (address +1) H
2000H 5AH
Size of Instruction: 3 Bytes
Number of Machine Cycles to Fetch the Instruction: 03 M1, M2 & M3 (10 T) 2001H 2FH
Number of Machine Cycles to Execute the Instruction: 02 M4 & M5 (6 T) 2002H 39H
2003H 1FH
2004H 22H
Data Transfer Instructions (LDAX Rp)
LDAX Rp
Load into Accumulator the data from memory location whose address is given in the Register Pair
E.g. LDAX B
Suppose 16 bit number in BC is 2000H then the number stored in 2000H will be copied into
Accumulator
A (BC)
2000H 5AH
Size of Instruction: 1 Bytes
Number of Machine Cycles to Fetch the Instruction: 01 M1 (4 T) 2001H 2FH
Number of Machine Cycles to Execute the Instruction: 01 M2 (3 T) 2002H 39H
2003H 1FH
2004H 22H
Data Transfer Instructions (STAX Rp)
STAX Rp
Copy the number in Accumulator to memory location whose address is given in the Register Pair
E.g. STAX B
Suppose 16 bit number in BC is 2000H and number in A is 7FH then 7FH will be transferred into
memory location 2000H
(BC) A
2000H 5AH
Size of Instruction: 1 Bytes
Number of Machine Cycles to Fetch the Instruction: 01 M1 (4 T) 2001H 2FH
Number of Machine Cycles to Execute the Instruction: 01 M2 (3 T) 2002H 39H
2003H 1FH
2004H 22H
Data Transfer Instructions (XCHG)
XCHG
2000H 5AH
Size of Instruction: 1 Bytes
Number of Machine Cycles to Fetch & Execute the Instruction: 01 M1 (4 T) 2001H 2FH
2002H 39H
2003H 1FH
2004H 22H
Arithmetic Instruction (DAA)
DAA
•If the LS hex digit in A is <= 9 and AC flag is 0, the LS hex digit value will not be altered.
•If the LS hex digit is >9, or if AC flag is set to 1, it adds 6 to the LS hex digit of A. If carry results, then it
increments the MS hex digit if this addition resulted in a carry to the MS digit position. In this process,
the Cy flag will be set to 1 if the MS hex digit was incremented from F to 0.
•If the MS hex digit is <= 9 and Cy flag is 0, the MS hex digit will not be altered, and Cy flag is reset to 0.
•If the MS hex digit is > 9, or if Cy flag is set to 1, it adds 6 to the MS hex digit of A and sets Cy flag to 1.
16 bit addition of contents of HL + contents of Register Pair. Only Carry Flag is affected
HL HL + Rp
E.g.
DAD B HL HL + BC
DAD D HL HL + DE
DAD H HL HL + HL
DAD SP HL HL + SP
In 8085 microprocessor, the Stack behaves in reverse manner i.e the Top of the Stack is the highest
memory address and the memory addresses lower than that are used as part of stack. The address of
Top of Stack is stored in SP (stack Pointer) Register.
The instruction used to store data into the stack is PUSH which essentially results in two memory write
cycles as two byres are stored in the stack in response to PUSH.
The instruction used to get back data from the stack is POP which essentially results in two memory read
cycles as two bytes are read back from the stack in response to POP.
Memory Stack & Related Instructions (PUSH Rp)
PUSH Rp
Store two bytes of the Register Pair into the stack. Higher byte is stored in memory whose address is
on lower than the ToS and the lower byte is stored in memory address even one lower than that.
E.g. PUSH B Stores B & C on stack
PUSH D Stores D & E on stack
PUSH H Stores H & L on stack
PUSH PSW Stores A & FLAG REGISTER (PSW) on stack
Suppose initial value of BC=917FH, SP=2FFDH and value in 2FFD is 39H and 2FFBH 5AH
BC = 2957H
DE = 3962H 2FF9H 62H
A FLAGS = XX YYH 2FFAH 39H
2FFBH 57H
2FFCH 29H
A FLAGS = 39 62H SP 2FFDH YYH
BC = 2957H 2FFEH XXH
HL = XXYYH 2FFFH 22H
Write a program in 8085 assembly language to add the 02 16 bit
numbers stored at memory location 2000H, 2001H & 2002H, 2003H and
store the sum in 2004H, 2005H
LDA 2000H
ANI 0x0F
STA 2002H
LDA 2000H
ANI 0xF0
RLC
RLC
RLC
RLC
STA 2001H
Write a SUBROUTINE in 8085 assembly language which unpacks the packed
2 digit BCD number passed to it in H and returns the two unpacked BCD
numbers in H & L registers. Now write a program to read packed 2 digit
BCD number from 2000H and store unpacked 2 digits in 2001H and 2002H.
Call the subroutine for the unpacking
LDA 2000H Subroutine Called UNPACK
Main Program
//This subroutine will accept a packed 2 digit BCD
ANI 0x0F LXI SP, 2FFFH number in Register H, then unpack the two BCD digits and
STA 2002H store them in Register H & L. Then return to Calling
LDA 2000H
Program
MOV B,H
LDA 2000H MOV H,A MOV A,B
ANI 0xF0 CALL UNPACK ANI 0x0F
MOV H,A
RLC MOV A,H MOV A,B
STA 2001H ANI 0xF0
RLC RLC
RLC MOV A,L RLC
RLC
STA 2002H
RLC RLC
HLT MOV L,A
STA 2001H RET
Write a program in 8085 assembly language to transfer 10 bytes of
data starting from memory location 2000H onwards to memory
location starting from 3000H onwards
LXI B, 2000H //Initialize BC to 2000H 10 X 1 =10
LXI D, 3000H //Initialize DE to 3000H 10 X 1 = 10
MVI H, 0x0A //Set counter for 10 times 7 X 1 =7
AGAIN: LDAX B //Read one byte from memory whose address is in BC 7 X 10=70
STAX D //Store the byte in memory whose address is in DE 7 X 10 = 70
INX B //Increment both pointers 6 X 10 =60
INX D 6 X 10 = 60
DCR H //Reduce counter and check to run the loop 10 times 4 X 10 = 40
JNZ AGAIN 10 X9 + 7 X 1 = 97
HLT 4 X 1 =4
Write a program in 8085 assembly language to transfer 10 bytes of
data starting from memory location 2000H onwards to memory
location starting from 3000H onwards
JNZ AGAIN
HLT
Write a program in 8085 assembly language to add the 05
numbers stored starting from memory location 2000H and
store the 16 bit sum at 2005H & 2006H
A
MVI C,04H ;Set counter for 4 loop 70
MVI D,00H ;Using as MSB
LXI H,2000H ; Initialise to starting memory
MOV A,M ;Get number from 2000H 01 D 0 C
AGAIN: INX H ;Point to next address H L
ADD M ;Perform addition
JNC AHEAD ;If carry then increment D 20 04
INR D 2000H 7F
AHEAD: DCR C ;Reduce counter
2001H 22 Z CY
JNZ AGAIN ;repeat addition
INX H ;Point to LSB location 2002H 36
CD 1 0
MOV M,A ;Store LSB 2003H 5F
INX H ;Point to MSB location
MOV M,D ;Store 2004H 4A
HLT 2005H 70
2006H 00
Write a SUBROUTINE in 8085 assembly language which unpacks the packed
2 digit BCD number passed to it in H and returns the two unpacked BCD
numbers in H & L registers. Now write a program to read packed 2 digit
BCD number from 2000H and store unpacked 2 digits in 2001H and 2002H.
Call the subroutine for the unpacking
LDA 2000H Subroutine Called UNPACK
Main Program
//This subroutine will accept a packed 2 digit BCD
ANI 0x0F LXI SP, 2FFFH number in Register H, then unpack the two BCD digits and
STA 2002H store them in Register H & L. Then return to Calling
LDA 2000H
Program
MOV B,H
LDA 2000H MOV H,A MOV A,B
ANI 0xF0 CALL UNPACK ANI 0x0F
MOV H,A
RLC MOV A,H MOV A,B
STA 2001H ANI 0xF0
RLC RLC
RLC MOV A,L RLC
RLC
STA 2002H
RLC RLC
HLT MOV L,A
STA 2001H RET
Program Counter (PC) 010AH A 03 B 38 C 0
H L
08 03
Main Program Addres Instruction
Addres Instruction s
s 0200H MOV B,H
0100H LXI SP, 2FFFH
0201H MOV A,B
0103H LDA 2000H
0202H ANI 0x0F
0106H MOV H,A
0204H MOV H,A
0107H CALL 0200H 2000H 38
0205H MOV A,B
010AH MOV A,H 2001H 00
0206H ANI 0xF0
010BH STA 2001H 2002H 00 0208H RLC
010EH MOV A,L
0209H RLC
010FH STA 2002H 2FFCH 5F
020AH RLC
0112H HLT 2FFDH 0A (PCL)
SP 020BH RLC
2FFEH 01 (PCH)
020CH MOV L,A
2FFFH 2FFFH 00
020DH RET
Program Counter (PC) 010AH A 03 B 38 C 0
H L
08 03 Subroutine Unpack Subroutine SWAP
Main Program
Addres Instruction Addres Instruction
Addres Instruction s s
s
2000H 38 0200H PUSH B 0300H RLC
0100H LXI SP, 2FFFH
2001H 00 0201H MOV B,H 0301H RLC
0103H LDA 2000H
2002H 00 0202H MOV A,B 0302H RLC
0106H MOV H,A
0203H ANI 0x0F 0304H RLC
0107H CALL 0200H
00 0205H MOV H,A 0305H RET
010AH MOV A,H 2FF9H
0206H MOV A,B
010BH STA 2001H 2FFAH 00
0208H ANI 0xF0
010EH MOV A,L 2FFBH 0B (PCL)
020BH CALL 0300H
010FH STA 2002H 2FFCH 02 (PCH)
020EH MOV L,A
0112H HLT 2FFDH 0A (PCL)
SP 020FH POP B
2FFEH 01 (PCH)
2FFFH 0210H RET
2FFFH 00
Interrupts in 8085
Hardware Interrupts
Some pins on the 8085 allow, peripheral device to interrupt the main program for I/O operations. When an
interrupt occurs, the 8085 completes the instruction it is currently executing and transfers the program control to a
subroutine’ that services the peripheral device. Upon completion of the service routine, the CPU returns to the
main program. These Types of Interrupts in 8085, where CPU pins are used to receive interrupt requests, are
called hardware interrupts. Hardware Interrupts in 8085 are TRAP, RST 7.5, RST 6.5, RST 5.5, INTR
Software Interrupts
In software interrupts, the cause of the interrupt is an execution of the instruction. These are special instructions
supported by the microprocessor. After execution of these instructions microprocessor completes the execution of
the instruction it is currently executing and transfers the program control to the subroutine program. Upon
completion of the execution of the subroutine program, program control returns to the main program. Software
Interrupts in 8085 are RST 0, RST 1, RST 2, RST 3, RST 4, RST 5, RST 6, RST 7
Interrupt Architecture of 8085
What happens because of Occurrences of Interrupt?
1. Create a subroutine which finds out the highest and number out of the two numbers passed to it. It will
accept the two numbers in B & C and return the highest number in B. Also write a Main program to test the
sub-routine.
2. Create a subroutine which finds out the highest and lowest number out of the 10 numbers stored in memory
whose starting address is passed to the sub-routine in HL Register. The subroutine will return the highest and
smallest number in register H & L. Also write a Main program to test the sub-routine.
3. Create a subroutine which will generate a delay of 250 microseconds. Also write a Main program to test the
sub-routine.
4. Create a subroutine which performs the multiplication of two 8 bit numbers returns the 16 bit product. The
subroutine accepts two 8 bit numbers in register H & L and returns their 16 bit product in register H&L. Also
write a Main program to test the sub-routine.
5. Create a subroutine which performs division of one 8 bit number by another, The subroutine accepts the
dividend 8 bit number in H and the 8 bit divisor in L and returns the quotient in H & remainder in L.
6. Write a program to transmit a 8 bit number using SOD pin and then receive a 8 bit number using SID pin.
Lab Questions
1. Write a program to find the sum of 2, 02 digit Packed BCD numbers at 2000H & 2001H and
store their BCD sum at 2003H.
2. Write a program to read packed 2 digit BCD number from 2000H and store unpacked 2 digits in
2001H and 2002H. The program will call a subroutine for the unpacking which unpacks the
packed 2 digit BCD number passed to it in H and returns the two unpacked BCD numbers in H
& L registers.
3. Write a program which finds out the highest and smallest number out of 10 numbers stored
starting from memory location 2000H and store the highest number at 200AH and smallest at
200BH. The program will call a subroutine which finds out the highest and lowest number out
of the 10 numbers stored in memory whose starting address is passed to the sub-routine in HL
Register. The subroutine will return the highest and smallest number in register H & L.
4. Create a subroutine which will generate a delay of 250 microseconds. Also write a Main
program to test the sub-routine.
Write a program to find the sum of 2, 02 digit Packed BCD numbers at
2000H & 2001H and store their BCD sum at 2003H.
LDA 2000H
MOV B,A
LDA 2001H
ADD B
DAA
STA 2002H
Write a program to read packed 2 digit BCD number from 2000H and store unpacked 2 digits in 2001H
and 2002H. The program will call a subroutine for the unpacking which unpacks the packed 2 digit
BCD number passed to it in H and returns the two unpacked BCD numbers in H & L registers.
1.Enable Interrupt (EI) – The interrupt enable flip-flop is set and all interrupts are
enabled following the execution of next instruction followed by EI. No flags are
affected. After a system reset, the interrupt enable flip-flop is reset, thus
disabling the interrupts. This instruction is necessary to enable the interrupts
again (except TRAP).
2.Disable Interrupt (DI) – This instruction is used to reset the value of enable flip-
flop hence disabling all the interrupts. No flags are affected by this instruction.
8085 Instructions related to Interrupts
This instruction is used to read the status of the hardware interrupts (RST 7.5, RST 6.5, RST 5.5) by loading into
the A register a byte which defines the condition of the mask bits for the interrupts. It also reads the condition
of SID (Serial Input Data) bit on the microprocessor.
An Infrared based detection system is connected at the Entry Door of a
classroom and generates a pulse signal whenever a person enters the class.
This signal is connected to the TRAP Pin of 8085. Write a program in assembly
language of 8085 to count the number of students in the class and store the
same at memory location 2000H. Write ISR of TRAP accordingly.
Interrupt Service
0024H JMP 0400H Routine (ISR for
MAIN PROGRAM TRAP)
2000H FF
RD/
LD2
WR/
A1
A0 AD7-AD0
of 8085
Port A 00H
A2 Port B 01H
A3
A4 Port C 02H
CR 03H
A5
A6
A7
Interface two LEDs to 8085 microprocessor through Port A of IC 8255.
Write program such that they blink alternately infinite number of
times.
MVI A, 80H
OUT 03H //Value 80H stored in Control Register of 8255
AGAIN: MVI A, 80H
OUT 00H //Value 80H stored in Port A i.e. LD2 ON and LD1 OFF
CALL DELAY //Call delay subroutine for delay of 500 milliseconds
MVI A, 40H
OUT 00H //Value 40H stored in Port A i.e. LD2 OFF and LD1 ON
CALL DELAY
JMP AGAIN
Interface two LEDs and 01 Switch to 8085 microprocessor through Port A of IC 8255. Write
program such that LD1 is ON and LD2 OFF if key is pressed else LD1 is OFF and LD2 is ON
+5V SW1
LD1
RD/
LD2
WR/
A1
A0 AD7-AD0
of 8085
A2
A3
A4 Port A 00H
Port B 01H
A5
A6
Port C 02H
A7 CR 03H
Interface two LEDs and 01 Switch to 8085 microprocessor through
Port A of IC 8255. Write program such that LD1 is ON and LD2 OFF if
key is pressed else LD1 is OFF and LD2 is ON
MVI A, 82H
OUT 03H //Value 82H stored in Control Register of 8255 so that Port A
// & C are output Ports while Port B is configured as I/P Port
AGAIN: IN 01H //Read the Data at Port B and store in Accumulator
RLC //Copy A7 bit into Carry flag
JC NEXT //If Switch is pressed then goto NEXT
MVI A, 80H
OUT 00H //Turn ON LD1 and turn OFF LD2
JMP AGAIN
NEXT: MVI A, 40H
OUT 00H //Turn OFF LD1 and turn ON LD2
JMP AGAIN
Interface 01 Common Cathode 7 segment LED Display to 8085 microprocessor through Port B
of IC 8255. Write program to display count from 0 to 9 when the switch is pressed every time.
+5V SW1
Port A 00H
Port B 01H
Port C 02H
CR 03H
RD/ WR/
AD7-AD0
A1 of 8085
A0
A2
A3
A4
A5
A6
A7
7 Segment Interface and Codes to Display Count
A B C D E F G DP
PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
PB7 0: 1 1 1 1 1 1 0 0 = FC
PB6
PB5 1: 0 1 1 0 0 0 0 0 =60
PB4
PB3 2: 1 1 0 1 1 0 1 0 = DA
PB2
PB1 3:
PB0
Interface 01 Common Cathode 7 segment LED Display to 8085 microprocessor through
Port B of IC 8255. Write program to display count from 0 to 9 when the switch is pressed
every time.
0500H MVI A, 90H //Value 90H stored in Control Register of 8255 so that Port B
0502H OUT 03H // & C are output Ports while Port A is configured as I/P Port
0504H MVI C, 09H //Initialize Counter
0506H LXI H, 0600H //Start address of memory location where display codes are stored
0509H MOV A, M //Put Display Code on LED Display i.e. Port B
050AH OUT 01H
050CH CALL DELAY
050FH IN 00H //Read the Data at Port A and store in Accumulator
0511H RLC //Copy A7 bit into Carry flag
0513H JNC 050FH //If Switch is Not pressed then check for switch press again
0515H INX H //Point to next display code
0516H DCR C
0517H JNZ 0509H //Put Next Display Code on Port
051AH JMP 0504H //Start from Displaying Zero
0600H 0xFC 0604H 0608H
0601H 0x60 0605H 0609H
0602H 0xDA 0606H
0603H 0607H
Write program to multiply two 8 bit numbers stored at memory location 2000H & 2001H
and store the 16 bit product at 2002H & 2003H. The multiplication shall be done by a
subroutine which shall accept the two input numbers in H&L and return the product in
H&L.
Subroutine MULT
Main Program
MOV A,H Subroutine MULT
CMI 00H INC_MSB: INR H
LXI SP, 2FFFH
JZ STOR_ZERO JMP CONTINUE
LHLD 2000H MOV A,L STOR_ZERO: MVI H,00H
CALL MULT CMI 00H MVI L,00H
SHLD 2002H JZ STOR_ZERO RET
HLT MOV C, L
MOV A,H
MOV B,A
MVI H,00H
MVI L,00H
ADD_AGAIN: ADD L
JC INC_MSB
CONTINUE: MOV L,A
MOV A,B
DCR C
JNZ ADDAGAIN
Write program to DIVIDE 8 bit number stored at memory location 2000H BY 8 BIT
NUMBER stored at 2001H and store the Quotient at 2002H & remainder at 2003H. The
division will be done by a subroutine which shall accept the Divisor in H, Dividend in L and
return Quotient in H and
Subroutine DIVRemainder in L.
1. 40 Pin IC
2. 16 Data Lines Multiplexed with 16 lines of address Bus (AD15-AD0)
3. Total 20 Address Lines so can be interfaced with 1MB memory
4. Can work in Min/Max Mode (Single Processor or Multiprocessor Environment)
5. 02 Hardware Interrupts TRAP, INTR but total 256 Interrupts feasible
6. Internal Oscillator Circuit Not Available. External Clock to be connected
7. To CLK Pin (Maximum 10MHz)
8. It uses two stages of pipelining, i.e. Fetch Stage and Execute Stage,
which improves performance.
10. Fetch stage can prefetch up to 6 bytes of instructions and stores
them in the queue.
BIU: Bus Interface Unit EU: Execution Unit
8086 Execution Unit (U)
EU (Execution Unit) Execution unit gives instructions to BIU stating from where to fetch the
data and then decode and execute those instructions. Its function is to control operations on
data using the instruction decoder & ALU. EU has no direct connection with system buses as
shown in the above figure, it performs operations over data through BIU.
ALU It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND, NOT operations.
Control Unit: Controls are functional units of the 8086 Microprocessor
Flag Register It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status
according to the result stored in the accumulator. It has 9 flags and they are divided into 2
groups − Conditional Flags and Control Flags.
General Purpose Registers: AH & AL (AX), BH & BL (BX), CH & CL (CX), DH & DL (DX) – These
Registers can work as individual 8 bit Registers or together a 16 bit Registers
Pointer & Index Registers: Base Pointer (BP), Stack Pointer (SP), Source Index (SI),
Destination Index (DI)
8086 Bus Interface Unit (BIU)
BIU (Bus Interface Unit) BIU takes care of all data and addresses transfers on the buses for the EU like sending addresses,
fetching instructions from the memory, reading data from the ports and the memory as well as writing data to the ports and the
memory. EU has no direction connection with System Buses so this is possible with the BIU. EU and BIU are connected with the
Internal Bus.
It has the following functional parts −
Instruction queue − BIU contains the instruction queue. BIU gets up-to 6 bytes of next instructions and stores them in the
instruction queue. When EU executes instructions and is ready for its next instruction, then it simply reads the instruction from
this instruction queue resulting in increased execution speed.
Fetching the next instruction while the current instruction executes is called pipelining.
Segment register − BIU has 4 segment buses, i.e. CS, DS, SS& ES. It holds the addresses of instructions and data in memory,
which are used by the processor to access memory locations. It also contains 1 pointer register IP, which holds the address of the
next instruction to executed by the EU.
CS − It stands for Code Segment. It is used for addressing a memory location in the code segment of the memory, where the
executable program is stored.
DS − It stands for Data Segment. It consists of data used by the program and is accessed in the data segment by an offset
address or the content of other register that holds the offset address.
SS − It stands for Stack Segment. It handles memory to store data and addresses during execution.
ES − It stands for Extra Segment. ES is additional data segment, which is used by the string to hold the extra destination data.
Instruction pointer − It is a 16-bit register used to hold the address of the next instruction to be executed.
Pipelining & The Instruction Queue in 8086
Fetching the next instruction while the current instruction executes is known as pipelining
This is done to speed up program execution, the bus interface unit fetches as many as 6
instruction bytes ahead of time from the memory and these are held for execution unit in the
(FIFO) group of registers called QUEUE.
The BIU can fetch instruction byte while EU is decoding or executing an instruction which does
not require the use of buses. When is EU is ready for the next instruction, it simply reads the
instruction from queue in the BIU.
the Queue is filled when at least two bytes are empty as 8086 has a 16 bit data bus
Flag Register 8086
• Carry flag − This flag indicates an overflow condition for arithmetic operations.
• Auxiliary flag − When an operation is performed at ALU, it results in a carry/barrow from lower nibble (i.e. D0 – D3) to upper
nibble (i.e. D4 – D7), then this flag is set, i.e. carry given by D3 bit to D4 is AF flag. The processor uses this flag to perform binary
to BCD conversion.
• Parity flag − This flag is used to indicate the parity of the result, i.e. when the lower order 8-bits of the result contains even
number of 1’s, then the Parity Flag is set. For odd number of 1’s, the Parity Flag is reset.
• Zero flag − This flag is set to 1 when the result of arithmetic or logical operation is zero else it is set to 0.
• Sign flag − This flag holds the sign of the result, i.e. when the result of the operation is negative, then the sign flag is set to 1
else set to 0.
• Overflow flag − This flag represents the result when the system capacity is exceeded.
• Trap flag − It is used for single step control and allows the user to execute one instruction at a time for debugging. If it is set,
then the program can be run in a single step mode.
• Interrupt flag − It is an interrupt enable/disable flag, i.e. used to allow/prohibit the interruption of a program. It is set to 1 for
interrupt enabled condition and set to 0 for interrupt disabled condition.
• Direction flag − It is used in string operation. As the name suggests when it is set then string bytes are accessed from the
higher memory address to the lower memory address and vice-a-versa.
8086 Pin Description
BHE
BHE stands for Bus High Enable. It is available at pin 34 and used to indicate the transfer of data using data bus
D8-D15. This signal is low during the first clock cycle, thereafter it is active.
NMI
It stands for non-maskable interrupt and is available at pin 17. It is an edge triggered input, which causes an
interrupt request to the microprocessor.
TEST
This signal is like wait state and is available at pin 23. When this signal is high, then the processor has to wait
for IDLE state, else the execution continues.
MN /MX
It stands for Minimum/Maximum and is available at pin 33. It indicates what mode the processor is to operate in;
when it is high, it works in the minimum mode and vice-versa.
INTA
It is an interrupt acknowledgement signal and id available at pin 24. When the microprocessor receives this
signal, it acknowledges the interrupt.
8086 Pin Description
DT/R
It stands for Data Transmit/Receive signal and is available at pin 27. It decides the direction
of data flow through the transreceiver. When it is high, data is transmitted out and vice-a-
versa.
HLDA
It stands for Hold Acknowledgement signal and is available at pin 30. This signal
acknowledges the HOLD signal.
HOLD
This signal indicates to the processor that external devices are requesting to access the
address/data buses. It is available at pin 31.
DEN : Data enable. This pin is provided as an output enable for the 8286/8287 in a
minimum system which uses transceiver. DEN is active low(0) during each memory and
input-output access and for INTA cycles
8086 Pin Description
LOCK
When this signal is active, it indicates to the other processors not to ask the CPU to
leave the system bus. It is activated using the LOCK prefix on any instruction and is
available at pin 29.
RQ/GT1 and RQ/GT0
These are the Request/Grant signals used by the other processors requesting the CPU
to release the system bus. When the signal is received by CPU, then it sends
acknowledgment. RQ/GT0 has a higher priority than RQ/GT1.
8086 Pin Description
QS1 and QS0
These are queue status signals and are available at pin 24 and 25. These signals provide the status of
instruction queue. Their conditions are shown in the following table −
S2 S1 S0 Status
0 0 0 Interrupt acknowledgement
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
Memory Segmentation in 8086
Segmentation is the process in which the main memory of the computer is logically divided into
different segments and each segment has its own base address. It is basically used to enhance the
speed of execution of the computer system, so that the processor is able to fetch and execute the
data from the memory easily and fast.
The Bus Interface Unit (BIU) contains four 16 bit special purpose registers (mentioned below) called
as Segment Registers.
• Code segment register (CS): is used for addressing memory location in the code segment of the
memory, where the executable program is stored.
• Data segment register (DS): points to the data segment of the memory where the data is stored.
• Extra Segment Register (ES): also refers to a segment in the memory which is another data segment
in the memory.
• Stack Segment Register (SS): is used for addressing stack segment of the memory. The stack
segment is that segment of memory which is used to store stack data.
Need for Memory Segmentation
Physical address lines of 8086 are 20 i.e. actual memory address is 20bit wide
However, the Registers inside 8086 are not bigger than 16 bit
Thus to store the 20 bit address in the Registers inside 8086, the 20 bit address is divided into
two parts Segment Address (16 bit) and Offset Address (16 bit) and the Physical Address is
obtained by combining the two addresses as:
Physical address (20 bits) = Segment Address (16 bit) X 10H + Offset address (16 bit)
Physical Address (20 bit) Generation in 8086
Physical address (20 bits) = Segment Address (16 bit) X 10H + Offset address (16 bit)
CS: 0200H Offset: 1020H
Physical 20 bit Address = CS Shift left and add 0 at end
Physical Address: 02000H
1020H
03020H
Combinations of Segment Registers &
Offset
Segment Register Offset Register Purpose
CS IP (Instruction Pointer) To get address of Instruction
DS BX, DI, SI To get address of Data in Data
segment
SS SP, BP To get address in Stack
Segment
ES BX, DI, SI To get address of Data in Extra
Segment
Memory Segmentation in 8086
Advantages of Memory segmentation
The memory address space of the 8086-based microcomputers has different logical and physical
organizations.
Logically, memory is implemented as a single 1M × 8 memory bank. The byte-wide storage locations
are assigned consecutive addresses over the range from 00000H through FFFFFH 8086 Memory
Most the memory ICs are byte oriented i.e., each memory location can store only one byte of data.
The 8086 is a 16-bit microprocessor, it can transfer 16-bit data.
So in addition to byte, word (16-bit) has to be stored in the memory.
To implement this , the entire memory is divided into two memory banks: Bank0 and Bank1.
Bank0 is selected only when A0 is zero and Bank1 is selected only when BHE’ is zero.
A0 is zero for all even addresses, so Bank0 is usually referred as even addressed memory bank.
BHE’ is used to access higher order memory bank, referred to as odd addressed memory bank.
Memory Organization for 8086
Memory Organization for 8086
To distinguish between odd and even bytes, the CPU provides a signal called
BHE (bus high enable). BHE/ and A0 are used to select the odd and even byte,
as shown in the table below:
Types of Memory decoding Techniques
In small system hardware for the decoding logic can be eliminated by using only required
number of addressing lines (not all). Other lines are simple ignored.
This technique is referred as linear decoding or partial decoding.
Control signals BHE and A0 are used to enable odd and even memory banks, respectively.
This gives you multiple addresses (shadow addresses). This technique reduces the cost of
decoding circuit, but it gas drawback of multiple addresses.
Linear decoding
Memory Interfacing Problem
Interface two 4Kx8 EPROM and two 4Kx8 RAM chips with 8086. Select suitable mapping of
addresses.
4KB x 2 ROM ICs Will require 13 Address Lines (A12-A0)
4KB X 2 RAM ICs Will require 13 Address Lines (A12-A0)
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
FE000 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
FFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
FC000 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FDFFF 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1
Condition for Selection of the ICs
ROM- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A13=A14=A15=A16=A17=A18=A19=1
ROM- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A13=A14=A15=A16=A17=A18=A19=1
RAM- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A13=0,A14=A15=A16=A17=A18=A19=1
RAM- Odd Bank should be selected when A0=1 or 1 and BHE/=0 and A13=0, A14=A15=A16=A17=A18=A19=1
Memory IC Selection Table
Decoder Inputs <- 8086 A2 <- A13 A1 <- A0 A0 <- BHE/ Operation
Connections
16 bit (Word) transfer on D15-D0 0 0 0 Even and Odd Address from
RAM
8 bit (Byte) transfer on D7-D0 0 0 1 Only Even Address from RAM
8 bit (Byte) transfer on D15-D8 0 1 0 Only Odd Address from RAM
16 bit (Word) transfer on D15-D0 1 0 0 Even and Odd Address from
ROM
8 bit (Byte) transfer on D7-D0 1 0 1 Only Even Address from ROM
8 bit (Byte) transfer on D15-D8 1 1 0 Only Odd Address from ROM
Memory Interfacing Problem
Design an interface between 8086 CPU and two chips of 16K×8 EPROM and two chips of 32K×8
RAM. Select the starting address of EPROM suitably. The RAM address must start at 00000 H.
16KB x 2= 32KB Will require 15 Address Lines (A14-A0)
32KB x 2= 64KB Will require 16 Address Lines (A15-A0)
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
F8000 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0FFFF 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Condition for Selection of the ICs
ROM- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A15=A16=A17=A18=A19=1
ROM- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A15=A16=A17=A18=A19=1
RAM- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A16=A17=A18=A19=0
RAM- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A16=A17=A18=A19=0
Memory Interfacing Problem
It is required to interface two chips of 32K×8 ROM and four chips of 32K×8 RAM with 8086, according to
following map. ROM 1 and ROM 2 F0000H - FFFFFH, RAM 1 and RAM 2 D0000H - DFFFFH, RAM 3 and
RAM 4 E0000H – EFFFFH
32KB x 2 ROM= 64KB Will require 16 Address Lines (A15-A0)
32KB x 4 RAM=128KB Will require 17 Address Lines (A16-A0)
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
F0000 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FFFFF 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
D0000 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DFFFF 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
E0000 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EFFFF 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Condition for Selection of the ICs
ROM- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A16=A17=A18=A19=1
ROM- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A16=A16=A18=A19=1
RAM1- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A17=0 AND =A16=A18=A19=1
RAM1- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A17=0 AND =A16=A18=A19=1
RAM2- Even Bank should be selected when A0=0 and BHE/= 0 or 1 and A17=A18=A19=1
RAM2- Odd Bank should be selected when A0=1 or 0 and BHE/=0 and A17=A18=A19=1
Lab Questions for 8085
Write a program to find the factorial of a number stored in memory location 2000H (Assume number is <=8) and
store the factorial in 2001H & 2002H. Use two subroutines. One called FACT which accepts a number in Register
B and returns the factorial in BC. Another called MULT which accepts ONE 8 BIT NUMBER IN B AND ONE 16 BIT
NUMBER in H&L and returns the product in H&L.
7 X 6 =42
42 X 5 =210
210 X 4= 840
840 X 3 = 2520
2520 X 2 =
Interface ONE 7 Segment Common Cathode LED display to 8085 microprocessor through Port A of IC 8255. Write
program such that the counting 0 to 9 is displayed on the LED Segment with a delay of 1 second in between.
Write a program to find the factorial of a number stored in memory location 2000H (Assume number is
<=8) and store the factorial in 2001H & 2002H. Use two subroutines. One called FACT which accepts a
number in Register B and returns the factorial in BC. Another called MULT which accepts ONE 8 BIT
NUMBER IN B AND ONE 16 BIT NUMBER in H&L and returns the product in H&L.
MAIN FACT MULT
MOV A,B MOV D,H
LXI SP, 27FFH CPI 00H MOV E,L
LDA 2000H JZ EXIT DCR B
MOV B,A LXI H, 0001H AGAIN: DAD D HL=0001
CALL FACT MUL_AGAIN: CALL MULT DCR B B x HL =HL
MOV A,C DCR B JNZ AGAIN B=B-1
STA 2001H MOV A,B RET B x HL = HL
MOV A,B CPI 01H B=B-1
STA 2002H JNZ MUL_AGAIN B x HL = HL
HLT MOV C,L B=B-1
MOV B,H B x HL= HL
RET B=B-1
EXIT: MVI L,01H B x HL= HL
MOV H, 00H B=B-1
RET B x HL= HL
B=B-1
BC=HL
Instruction Set of 8086 Microprocessor
• MOV − Used to copy the byte or word from the provided source to the provided destination.
• PUSH − Used to put a word at the top of the stack.
• POP − Used to get a word from the top of the stack to the provided location.
• PUSHA − Used to put all the registers into the stack.
• POPA − Used to get words from the stack to all registers.
• XCHG − Used to exchange the data from two locations.
• XLAT − Used to translate a byte in AL using a table in the memory.
Instructions for input and output port transfer
• IN − Used to read a byte or word from the provided port to the accumulator.
• OUT − Used to send out a byte or word from the accumulator to the provided port.
Data Transfer Instructions
LEA – LEA Register, Source This instruction determines the offset of the variable or memory
location named as the source and puts this offset in the indicated 16-bit register. LEA does not
affect any flag.
LDS BX, [4326] Copy content of memory at displacement 4326H in DS to BL, content of 4327H to
BH. Copy content at displacement of 4328H and 4329H in DS to DS register.
LDS SI, SPTR Copy content of memory at displacement SPTR and SPTR + 1 in DS to SI register.
Copy content of memory at displacements SPTR + 2 and SPTR + 3 in DS to DS register. DS: SI now points at
start of the desired string.
LES BX, [789AH] Copy content of memory at displacement 789AH in DS to BL, content of 789BH to
BH, content of memory at displacement 789CH and 789DH in DS is copied to ES register.
LES DI, [BX] Copy content of memory at offset [BX] and offset [BX] + 1 in DS to DI register. Copy
content of memory at offset [BX] + 2 and [BX] + 3 to ES register.
Arithmetic Instructions
Instructions to perform addition
• ADD − Used to add the provided byte to byte/word to word.
• ADC − Used to add with carry.
• INC − Used to increment the provided byte/word by 1.
• AAA − Used to adjust ASCII after addition.
• DAA − Used to adjust the decimal after the addition/subtraction operation.
Instructions to perform subtraction
• SUB − Used to subtract the byte from byte/word from word.
• SBB − Used to perform subtraction with borrow.
• DEC − Used to decrement the provided byte/word by 1.
• NEG − Used to negate each bit of the provided byte/word and add 1/2’s complement.
• CMP − Used to compare 2 provided byte/word.
• AAS − Used to adjust ASCII codes after subtraction.
• DAS − Used to adjust decimal after subtraction.
ADD & ADC
ADD AL, 74H Add immediate number 74H to content of AL. Result in AL
ADC CL, BL Add content of BL plus carry status to content of CL
ADD DX, BX Add content of BX to content of DX
ADD DX, [SI] Add word from memory at offset [SI] in DS to content of DX
ADC AL, PRICES [BX] Add byte from effective address PRICES [BX] plus carry status to
content of AL
ADD AL, PRICES [BX] Add content of memory at effective address PRICES [BX] to AL
SUB & SBB
String Instructions
String is a group of bytes/words and their memory is always allocated in a sequential order.
• REP − Used to repeat the given instruction till CX ≠ 0.
• REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
• REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
• MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another.
• COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
• INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided memory location.
• OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory location to the I/O port.
• SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a byte in AL or string word with a word in
AX.
• LODS/LODSB/LODSW − Used to store the string byte into AL or string word into AX.
String Related Instructions
String Instructions
String is a group of bytes/words and their memory is always allocated in a sequential order.
• REP − Used to repeat the given instruction till CX ≠ 0.
• REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
• REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
• MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another.
• COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
• INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided memory location.
• OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory location to the I/O port.
• SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a byte in AL or string word with a word in
AX.
• LODS/LODSB/LODSW − Used to store the string byte into AL or string word into AX.
Program Execution Transfer Instructions (Branch and
Loop Instructions)
Instructions to transfer the instruction during an execution without any condition −
• CALL − Used to call a procedure and save their return address to the stack.
• RET − Used to return from the procedure to the main program.
• JMP − Used to jump to the provided address to proceed to the next instruction.
Instructions to transfer the instruction during an execution with some conditions −
• JA/JNBE − Used to jump if above/not below/equal instruction satisfies.
• JAE/JNB − Used to jump if above/not below instruction satisfies.
• JBE/JNA − Used to jump if below/equal/ not above instruction satisfies.
• JC − Used to jump if carry flag CF = 1
• JE/JZ − Used to jump if equal/zero flag ZF = 1
• JG/JNLE − Used to jump if greater/not less than/equal instruction satisfies.
• JGE/JNL − Used to jump if greater than/equal/not less than instruction satisfies.
• JL/JNGE − Used to jump if less than/not greater than/equal instruction satisfies.
Program Execution Transfer Instructions (Branch and
Loop Instructions)
•JLE/JNG − Used to jump if less than/equal/if not greater than instruction satisfies.
•JNC − Used to jump if no carry flag (CF = 0)
•JNE/JNZ − Used to jump if not equal/zero flag ZF = 0
•JNO − Used to jump if no overflow flag OF = 0
•JNP/JPO − Used to jump if not parity/parity odd PF = 0
•JNS − Used to jump if not sign SF = 0
•JO − Used to jump if overflow flag OF = 1
•JP/JPE − Used to jump if parity/parity even PF = 1
•JS − Used to jump if sign flag SF = 1
JA / JNBE (JUMP IF ABOVE / JUMP IF NOT BELOW OR EQUAL)
If, after a compare or some other instructions which affect flags, the zero flag and the carry flag
both are 0, this instruction will cause execution to jump to a label given in the instruction. If CF and
ZF are not both 0, the instruction will have no effect on program execution.
JAE / JNB / JNC (JUMP IF ABOVE OR EQUAL / JUMP IF NOT BELOW / JUMP IF NO CARRY)
If, after a compare or some other instructions which affect flags, the carry flag is 0, this instruction
will cause execution to jump to a label given in the instruction. If CF is 1, the instruction will have
no effect on program execution.
LOOPNE / LOOPNZ (LOOP WHILE CX not equal TO 0 AND ZF = 0) This instruction is used to repeat a
group of instructions some number of times, or until the zero flag becomes a 1. The number of
times the instruction sequence is to be repeated is loaded into the count register CX. Each time the
LOOPNE / LOOPNZ instruction executes, CX is automatically decremented by 1. If CX not equal TO 0
and ZF = 0, execution will jump to a destination specified by a label in the instruction. If CX = 0,
after the auto decrement or if ZF = 1, execution simply go on the next instruction after LOOPNE /
LOOPNZ.
Interrupt Instructions
These instructions are used to call the interrupt during program execution.
•INT − Used to interrupt the program during execution and calling service specified.
•INTO − Used to interrupt the program during execution if OF = 1
•IRET − Used to return from interrupt service to the main program
Write a program to copy 10 bytes from memory location 2000H
onwards to 3000H onwards inside the Data Segment
ORG 0100H //Start program from address 0100H inside Code segment. ORG is assembler
directive
MOV SI,2000H
MOV DI,3000H
MOV CX, 000AH
NEXT: MOV AL, [DS:SI]
MOV [DS:DI],AL
INC SI
INC DI
LOOP NEXT //FIRST IT DECREMENTS CX THEN JUMPS IF CX<>0
Lab Questions for 8085
Interface ONE 7 Segment Common Cathode LED display to 8085 microprocessor through Port B of IC 8255.
Write program such that the counting 0 to 9 is displayed on the LED Segment with a delay of 1 second in
between.
Interface ONE 7 Segment Common Cathode LED display to 8085 microprocessor through Port
B of IC 8255. Write program such that the counting 0 to 9 is displayed on the LED Segment
with a delay of 1 second in between.
Port A 00H
Port B 01H
Port C 02H
CR 03H
RD/ WR/
AD7-AD0
A1 of 8085
A0
A2
A3
A4
A5
A6
A7
7 Segment Interface and Codes to Display Count
A B C D E F G DP
PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0
0: 1 1 1 1 1 1 0 0 = FC
PB7 1: 0 1 1 0 0 0 0 0 =60
PB6
PB5 2: 1 1 0 1 1 0 1 0 = DA
PB4
PB3 3: 1 1 1 1 0 0 1 0 = F2
PB2
PB1 4: 0 1 1 0 0 1 1 0 = 66
PB0 5: 1 0 1 1 0 1 1 0 = B6
6: 1 0 1 1 1 1 1 0 = BE
7: 1 1 1 0 0 0 0 0 = E0
8: 1 1 1 1 1 1 1 0 = FE
9: 1 1 1 1 0 1 1 0 = F6
Interface 01 Common Cathode 7 segment LED Display to 8085 microprocessor through
Port B of IC 8255. Write program to display count from 0 to 9 when the switch is pressed
every time.
LXI SP, 27FF
MVI A, 80H //Value 80H stored in Control Register of 8255 so that Port A, B & C are o/p Ports
OUT 03H
MOV BL,[2002H]
DIV BL ;AX is divide by BL Quotient in AL, remainder in AH
MOV SI,2003H
MOV [DS:SI],AL
INC SI
MOV [DS:SI],AH
Write a program to find the smallest number out of 16
numbers stored from memory location 2000H and store the
smallest number at 2010H in DS
ORG 0100H //Start program from
address 0100H inside Code segment. ORG is assembler CODED SEGMENT
directive
CODE SEGMENT
ASSUME CS: CODE, DS:DATA
MOV SI,2000H HIGHER PROC
MOV CX, 000FH
MOV AL,[DS:SI]
HASDKJFj
AGAIN:INC SI basdjbjk
CMP AL,[DS:SI]
JLE AHEAD HIGHER ENDP
MOV AL, [DS:SI]
CALL NEAR FACTORIAL CODED ENDS
CALL FAR HIGHER
AHEAD:LOOP AGAIN
DATA SEGMENT
FACTORIAL PROC
HASDKJFj NUM1 DB 00H
basdjbjk
FACTORIAL ENDP
NUM2 DB 02H
CODE ENDS SUM DB 00H
DATA SEGMENT DATA ENDS
NUM1 DB 00H
NUM2 DB 02H
SUM DB 00H
DATA ENDS
Assembler Directives of 8086
Assembler Directives are keywords written along with the which provide additional information to the
assembler while it is converting the program written in Assembly Language to Machine Language. Assembler
Directives are not Assembly Language Instructions.
1. ORG
2. DB, DW, DD, DT
3. SEGMENT, ENDS
4. PROC, ENDP
6. ASSUME
7. PTR
8. PUBLIC
9. STACK
10. NEAR, FAR
Assembler Directives of 8086
1. ORG - This directive is used at the time of assigning starting address for a module or segment.
2. DB, DW, DD– Define variable as Byte, Word (2 Bytes), Double Word
3. SEGMENT, ENDS – Used to indicate the start and end of a Segment
4. PROC, ENDP – Used to indicate the start (PROC) and end of (ENDP) a procedure i.e. sub-routine
6. ASSUME – Provides information to the assembler regarding the name of the program or data
segment for that particular segment.
7. PTR - This directive shows information regarding the size of the operand.
8. PUBLIC -This directive is used to provide a declaration to variables that are common for different
program modules.
9. STACK- Indicates presence of Stack Segment
10. NEAR, FAR – Calling procedure within the segment (NEAR) or in some other segment (FAR)
Interrupt Architecture of 8086 – Hardware Interrupts
Hardware Interrupts
NMI (Non Maskable Interrupt) - This is a non-mask-able, edge triggered, high priority interrupt.
•On receiving an interrupt on NMI line, the microprocessor executes INT
•Microprocessor obtains the ISR address from location 2 x 4 = 00008H from the IVT.
•It reads 4 locations starting from this address to get the values for IP and CS to execute the ISR.
INTR - This is a mask-able, level triggered, low priority interrupt.
•On receiving an interrupt on INTR line, the microprocessor executes 2 INTA/ pulses.
1st INTA/ pulse – The interrupting device calculates (prepares to send) the vector number.
2nd INTA/ pulse – The interrupting device sends the vector number ‘N’ to the microprocessor.
•Now microprocessor multiplies N x 4 and goes to the corresponding location in the IVT to obtain the ISR
address. INTR is a mask-able interrupt.
•It is masked by making IF = 0 by software through CLI instruction.
•It is unmasked by making IF = 1 by software through STI instruction.
Interrupt Architecture of 8086 – Software Interrupts
Software interrupt-
These interrupts are caused by writing the software interrupt instruction INT n where ‘n’ can be any value
from 0 to 255 (00H to FFH). Hence all 256 interrupts can be invoked by software. E.g. INT 21
Interrupt Vector
Table
Interrupt Vector Table
The interrupt vector (or interrupt pointer) table is the link between an interrupt type code and the procedure that has been
designated to service interrupts associated with that code. 8086 supports total 256 types i.e. 00H to FFH.
For each type it has to reserve four bytes i.e. double word. This double word pointer contains the address of the procedure
that is to service interrupts of that type.
The higher addressed word of the pointer contains the base address of the segment containing the procedure. This base
address of the segment is normally referred as NEW CS.
The lower addressed word contains the procedure’s offset from the beginning of the segment. This offset is normally referred
as NEW IP.
Thus NEW CS: NEW IP provides NEW physical address from where user ISR routine will start.
As for each type, four bytes (2 for NEW CS and 2 for NEW IP) are required; therefore interrupt pointer table occupies up to the
first 1k bytes (i.e. 256 x 4 = 1024 bytes) of low memory.
The total interrupt vector table is divided into three groups namely,
1.A. Dedicated interrupts (INT 0…..INT 4)
2.B. Reserved interrupts (INT 5…..INT 31)
3.C. Available interrupts (INT 32…..INT 225)
Dedicated Interrupts
1.INT 0 (Divide Error)-
1. This interrupt occurs whenever there is division error i.e. when the result of a division is too large to be stored. This condition normally occurs
when the divisor is very small as compared to the dividend or the divisor is zero.
2. Its ISR address is stored at location 0 x 4 = 00000H in the IVT.
16 bit MCU
◦ 68HC12 series / 68HCS12 series / MC9S12 series / 68HC16 series / S12X series &
MC68000 MPU (1980)
32 bit MCU
◦ Power Architecure™ Processors
◦ ColdFire Processors & Controllers
◦ ARM™ Processors
Freescale™ ColdFire ™ 32 bit MCU / MPU Series
The ColdFire series has been in existence since 1994
The series consists of both 32 bit Micro-controllers as well as Microprocessors
ColdFire Series has been designed for high end applications which require fast
computations as well as various modes of connectivity
Evolution of ColdFire™ Core
Evolution of ColdFire™ Core
V1 ColdFire Core
V2 ColdFire Core
V3 ColdFire Core: Single-Issue + Pipelined Local Bus
V4 ColdFire Core: Limited Superscalar
V4e ColdFire Core: Limited Superscalar
V5 ColdFire Core: Full Superscalar
ColdFire™ Core Architecture
ColdFire core is based on Variable Length RISC Architecture
All cores (V1 till V5) share same core architecture as well as Instruction set
thus maintaining upward compatibility
ColdFire™ Core V1 Architecture
ColdFire™ Core Features
V1 ColdFire Core - Up to 150 MHz in 130-nm process technology
Multiply Accumulate Module, Hardware Division
External bus interface (16- or 32-bit)
Range of cache and local memory sizes, pipeline options
Single-pin BDM interface
Integrated peripherals
◦ 16-channel Direct Memory Access (DMA)
◦ Fast Ethernet Controller
◦ Multi-master Crossbar Switch
◦ FlexBus for external interface
◦ Interrupt Controller
◦ 4 32-bit DMA Timers
◦ 3 UARTs
◦ Queued SPI
◦ I2C
◦ On-platform peripheral expansion bus
ColdFire™ MCF5223X Series Block Diagram
ColdFire™ V2 Core Architecture
ColdFire™ V2 Core Architecture
◦ Operand Execution Pipeline – Responsible for decoding of instruction, fetching of operands and
execution of instructions
ColdFire™ V2 Core Architecture
Instruction Fetch Pipeline
◦ Instruction Address Generation Cycle
◦ Instruction Fetch Cycle
◦ Instruction Buffer Cycle
◦ The instruction Buffer serves as the FIFO type of queue for storage of instructions
which have been pre-fetched. It has the ability to store 03 nos. 32 bit longword.
ColdFire™ V2 Core Architecture
If Instruction Buffer is empty then Instruction fetched is immediately passed to Operand
Execution Pipeline for execution.
As instructions are pre-fetched, they are stored into the Instruction buffer and passed on to the
OEP as and when required.
ColdFire™ V2 Core Architecture
Operand Execution Pipeline is implemented in two stages:
◦ Decode & Select/Operand Cycle (DSOC) – Decode instructions and Select operands