7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
1/254
1
33 Days Just an analysis about
MICROPROCESSORS AND
MICROCONTROLLERS
(Designed as per Anna University Syllabus)
B.E. IV Semester CSE
MODULE I
By
Y. SYED SHA MUHAMED M.E., Ph.D*.
Associate Professor
Department of Computer Science and Engineering,
National College of Engineering, Maruthakulam
Tirunelveli.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
2/254
2
PREFACE
Dear Reader,
This book is designed for IV Sem B.E. CSE of Anna University Syllabus. It has 5
module. Every module is one unit. It is also helpful for MCA Students (Module 2, 3, 4) for
Unit 1, 2 & 3. It is also designed for dedication purpose to help the student community. If a
student (especially college first rank) who is not affordable to pay (or) a student who makes
the laudable comment for the improvement of this book. He will be given book for free of
cost.
Hope you might be one among them with regards.
Author.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
3/254
3
This book is dedicated especially for student
community who are my jewels
By
Y. SYED SHA MUHAMED
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
4/254
4
SYLLABUS
UNITI
THE 8085 AND 8086 MICROPROCESSORS:
8085Microprocessors Architecture addressing modesinstruction set
programming it 8085.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
5/254
5
DAYI
Hello ! if you want to become tyro to adept in Microprocessor you
probe this book.
p
Day - I
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
6/254
6
DAY 1
MICROPROCESSOR:
Single Chip CPU.
Processors has two giants
(i) Intel(8085,8086etc)(ii) Motorola (6800, 68000 etc)
Evolution:
1. Intel 4004 (4 bit p)2. Intel 8085 and 8080 (8 bit p)3. Intel 8086 (16 bit p)4. Intel (802686)
5.
Intel (80386)
6. Intel (80486)7. PentiumIII, IV etc8. Core Processor
Forfast computation numeric coprocessor are used
i) 8087, 808107 etc.About 8085:
8 bit p NMOS device.
6200 transistor,
IC has 40 pins.
8085 can accept process 8 bit data simultaneously. That is why it is called 8 bitprocessor.
5 V power supply needed.
SX
DX
SX
DX
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
7/254
7
It can operates on 3MHz clockfree 8085A on 5MHz It has 16 Address lines.
150AA
kb12222610616
= 64 kb
8 bit I/O addresses2562
8 I/O Ports.
70
ADAD
It has the following addresses modesi) Immediateii) Registeriii) Directiv) Indirectv) Implied
It can perform Arithmetic and Logical Operations.Arithmetic:
i) 8 bit binary addition (with carry)ii) 16 bit binary additioniii) 8 bit binary subtraction (with borrow)iv) AND, OR, X-OR, Complement (NOT) and Shift operationShift leftMultiply by 2
Shift rightdivided by 2
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
8/254
8
QUESTION ANSWERS
I) TWO MARKS QUESTIONS
1) What is Microprocessor? Give example.
Ans:
Single Chip CPU
8085 etc.
2) What is Numeric coprocessor?
Ans:
For CPUs fast computation it needs numeric coprocessor
Eg. 8087 etc.
3) Why 8085 is called 8bit processor?
Ans:
It can accept, process 8 bit data simultaneously.
4) What are the addressing modes in 8085?
Ans:
i)
Immediate ii) Register iii) Direct iv) Indirect v)Implied
II) ESSAY QUESTION
1. Explain evolution of Microprocessor.Ans:-
From Intel 4004 to core processor.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
9/254
9
III) OBJECTIVE QUESTIONS:
1. Who are the two giants in Microprocessor family?
a) Motorola, Apple b) Intel, Motorola2. Which is 4 bit processor?
a) 4004 b) 8085 A
3. What is bit number Motorola chip starts with?
a) 80. b) 68
4. Which is called Numeric coprocessor?
a) 6800 b)8087
5. 8085 is _________________ devices
a) NMOS b) CMOS
6. 8085 has _____________________ transistors
a) 6100 b) 6200
7. 8085 A needs _______________ clock frequency
a) 3 MHz b) 5 MHz
8. 8085 maps how many address lines
a) 8 address lines b) 16 address lines
9. 8085 has _____________ I/O ports.
a) 8 b) 256
10. What mechanism happens in shift left?
a) Multiply by 2 b) divided by 2.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
10/254
10
RESULT ANALYSIS
III) Objectives question carries / mark for every questions
810 MarksExcellent
< 8Poor
If your score less than 8 repeat day 1. Otherwise go to Day 2.
Answer:
1) b 2) a 3) b 4) b 5) a 6) b 7) b 8) a 9) b 10) a.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
11/254
11
DAYII
If you want to become meticulous with acumen in Microprocessor read DayII.
p
Day - II
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
12/254
12
DAYII (INTROD)
8085 has
i) Accumulator (8 bit)ii) 6 GPR (8 bit each, BC, DE, HL)iii) Two 16 bit register
SPStack Pointer
PCProgram counter
8085 has software and hardware interrupts.
The hardware interrupts are
TRAP
RST 7.5 RST 6.5 RST 5.5 and INTR.
It has
Opcode Operand
1) Opcode Fetch cycle ( 4 T)(i.e. 4 time cycles)
2) Memory Read Cycle (3 T)3) Memory Write Cycle (3 T)
It has DMA (Direct Memory Access) facilities.Architecture of 8085:
8085 has following a functional blocks.
1) Registers.2) ALU3) Instruction decoded and machine cycle encoded4) Address buffer5) Address / Data buffer6) Increment / Decrement Address latch7) Interrupt control
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
13/254
13
8) Serial I/O control9) Timing and Control circuitry.
QUESTIONS AND ANSWERS
I) Two marks questions:
1) What are 6 GPRegisters in 8085?
Ans:
BC, DE, HL
2) What are 2 16 bit register in 8085?
Ans:
i) PC ii) SP
3) What are the interrupts in 8085?
Ans:
*TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR
4) What is DMA?
Ans:
Direct Memory Access
OBJECTIVE QUESTIONS
1) Accumulator in 8085 has ___________?a) 8 bits b) 16 bits
2) GPR B&D register are ___________?a) 8 bits b) 16 bits
3) Who is the brightest priority interrupt?a)
TRAP b) RST 7.5
4) What is the address location of RST 6.5?a) 003 C x b) 0042 x
5) How many time cycles for OFC?a) 3 T b) 4 T
6) How many time cycle for memory read?a) 3 T b) 4 T
7) How many time cycle for memory write?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
14/254
14
a) 3 T b) 4 T8) DMA has _________________ ?
a) Cycle stealing b) Page replacements9) How many functional blocks in 8085?
a) 9 b) 1010)What is buffer?
a) Temporary storage b) RAM and ROM
Answers:
1) a 2) a 3) a 4) a 5) b 6) a 7) a 8) a 9) a 10) a
RESULT ANALYSIS
810 MarksExcellent
< 8Poor
If your score less than 8 repeat day 1. Otherwise go to Day 3
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
15/254
15
DAYIII
If you want to bag with accolades in Microprocessor you better read dayIII.
p
Day - III
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
16/254
16
Interrupt Control
INTR
INTA
RST
5.5
RST
6.5
RST
7.5
TRAP
Interrupt & High
priority interrupt
Serial I/O Control
STD SIO
8 Bit Internal Data Bus
AccumulatorTemporary
re ister Flag RegisterInstruction Reg.
ALU Instruction
decoder and m/c
cycle encoder
B C
D E
H L
W Z
SP
PC
Increment/
Decrement Counter
Timing and Control
Clk READY RD W ALE
OutSo S1 I/M HOLD HOLD A Reset In Reset Out
X1
Clk
InX2
Control Status DMA Reset
Address
Buffer
Address / Data
Buffer
A8A15
Hi her bit
AD0AD7
Lower bit
Data bus
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
17/254
17
8085 Architecture has 9 functional block.
1) Registers:
a) General Purpose registers
B, C, D, E, H, L
b) Temporary Register
w, z
c) Special purpose registers
Accumulator, Flag, Instruction register.
Flag
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X Cy
Zero Auxillary Carry Parity Carry
d) Sixteen Bit registers
SP, PC
II) ALU: (8 Bit)
i) Arithmetic Unit +, - (Add, Sub)
ii) Logical Unit AND, OR, XOR, ROTATE, CLEAR
III) Instruction Decoder:
Fetches by opcode fetch cycle.
IV) Address Buffer:
8 bit unidirectional buffer (A8A15)
V) Address / Data Buffer:
8 bit bidirectional buffer (ALE)
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
18/254
18
QUESTION AND ANSWERS:
Two mark questions
1) What are the GPR?
Ans:
B, C, D, E, H, L registers
2) What are the special purpose registers?
Ans:
Accumulator, Flag, Instruction register.
3) Draw the flag register?
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X Cy
Auxillary Carry
4) What are the functions performed by ALU?
i) Add ii) Sub iii) AND iv) OR v) X-OR vi) ROTATE vii) CLEAR
5) What is ALE?Address Latch Enable
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
19/254
19
OBJECTIVES QUESTIONS
1) HL is what type register?a) GPR b) Special purpose register
2) w, z is what type register?a) GPR b) Temporary register
3) Following is Special purpose register?a) Accumulator b) w, z
4) SP, PC are what type register?a) 8 bit b) 16 bit
5)
Following are the logical operations?a) ADD b) AND, X-OR
6) What are the address lines for address buffer?a) AD0AD7 (bidirectional) ii) A8A15 (Unidirectional)
7) What is the Flip Flop used in ALE?a) DEF b) JK
Answer:1) a 2) b 3) c 4) b 5) b 6) b 7) a
If your score is 6 (or) more excellent. You can go to Day 4. Otherwise repeat Day 3
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
20/254
20
DAYIV
To become unconquerable in Microprocessor read dayIV
p
Day - IV
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
21/254
21
DAY4
vi) Incrementer / Decrementer Address Latch 16 bit register
vii) Interrupt Control:
RST 5.5, 6.5, 7.5, TRAP & INTA
viii) Serial I/O control:
STD, SOD
ix) Timing and Control:
i) STATUSii) DMAiii)
RESET
The pin diagram (8085A):
1
2
3
4
5
6
7
8
9
10
11
12
19
20
X1X2
Reset
SOD
SID
TRAP
RST 7.5
RST 6.5
RST 5.5
INR
INTA
AD0
AD7VSS
40
39
38
37
36
35
34
33
32
31
30
29
28
21
Vcc
Hold
Hold A
Clk
Reset INRec 4
IO/M
S
RP
WR
ALE
S0A15
A0
8085 A
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
22/254
22
QUESTION AND ANSWERS
Two Marks question:
1) What is the mechanism of incrementer / Decrementer Address Latch?
Increment (or) Decrement the contains of program counter or stack pointer.
2) What is Interrupt? Say priority?
Temporary stop Tray
Essay Questions:
Explain the architecture of 8085?
Answer:
Say the functional blocks with diagram.
RST 7.5
RST 6.5
RST 5.5
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
23/254
23
DAYV
To become primitive to sophisticated in microprocessor read dayV.
p
Day - V
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
24/254
24
DAY5
Instruction formats:
i) One Byte:
ii) Two Byte:
iii)Three byte
i) Immediate:
OPCODE Operand ADD B
Operand 2OPCODE Operand 1 MOV A, B
Immediate
Addressing Modes
Register Direct Indirect Implied
M V I A , 10 H
IMust Coon Destination
data
OPCODE PUSH
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
25/254
25
ii) Register Addressing Mode:
- (GPR is used)
iii)Direct addresses mode:L D A 1000
A (1000)
iv) Indirect Addresses Mode:Contend of conforms.
L D A X B
A ( (BC) )
v) Implied Addressing Mode:CMA
A Complement A
M O V A , B
Destination
Source
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
26/254
26
QUESTION AND ANSWERS
1) What is one address instruction?Answer:
Opcode - Instruction
Operand - address
Ex: 7
ADD B
SUB B2) What is two address instructions?
Answer:
MOV A, B
3) What is zero address instruction?Answer:
PUSH
POP
ESSAY QUESTIONS:
1) Discuss the different addressing modes in 8085?Answer:
i) Immediate ii) Register iii) Direct iv) Indirect v) Implied
OPCODE Operand
OPCODE Operand1 Operand2
OPCODE
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
27/254
27
OBJECTIVES QUESTIONS
i) PUSH is ___________ Address instruction
a) Zero b) One
ii) SUB A is ___________ Address instruction
a) Zero b) Oneiii) ADD A, B is _______ Address instruction
a) One b) Twoiv) In immediate address mode contains register and ___________ (source)
a) Register b) Datav) MOV B, C is ___________ addressing mode
a) RegisterRegister b) RegisterMemoryvi) The difference between direct and indirect is ___________
a) Direct is content of indirect is content of contentb) Indirect is content of direct is content of content
RESULT ANALYSIS
Answer:
1) a 2) b 3) b 4) b 5) a 6) aIf your score is greater than 5 go to day 6 otherwise repeat day5.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
28/254
28
If you want to bombard in microprocessor read this dayVI.
p
Day - VI
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
29/254
29
DAY - 6
Data Transfer Arithmetic
Increment /
Decrement Branch Group Logic Rotate Stack
1
2
3
4
5
6
7
8
9
10
11
12
13
MVI r, data
MVI M, data
MOV rd, rs
MOV M, rs
MOV rd, M
LXI rp, data
STA addr
LDA addr
SHLD addr
LHLD addr
STAX rp
LDAX rp
XCHL
1
2
3
4
5
6
7
8
9
10
11
12
13
ADD r
ADD M
ADI data
ADC r
ADC M
ACI data
DAD rp
SUB r
SUB M
SUI data
SOB r
SOB M
SOI data
1
2
3
4
5
6
INR r
INR M
INX rp
DCR r
DCR M
DCX rp
1
2
3
JMP addr
J condn addr
PCHL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ANA r
ANA M
ANI data
XRA r
XRA M
XRI data
ORA r
ORA M
ORI data
CMP rCMP M
CPI data
STC
CMC
CMA
1
2
3
4
RLC
RRC
RAC
RAR
1
2
PUS
POF
Instruction Set
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
30/254
30
IData Transfer:
1) MVI A, 08- 2 byte instruction
Note: (Within GPR no need of MR, MW 3 time cycles)
H or OF (opcode fetch) - 4T
MR (data) - 3T
7 Time cycles.
Immediate addressing mode.
2) MVI M, 4OH(H L Pair) H F 20 L = 10
2010
OF - 4T
MR - 3T (data read)
MW - 3T (write)
10 T
3) MOV A,B
Register (B) Register (A)
40
Stack of I/O and M/C control group
PUSH
POP
CALL
RET
IN addr
OUT addr
EI
DT
PORT (I/O) Interrupt
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
31/254
31
(within GPR so no need of MR, MV)
OFC - 4T
TOTAL - 4T
4) MOV M, B
(H = 20) (L) = 50
2050
OF + MW =
4T + 3T = 7 T
5) MOV C,MH = 20 L = 50
2050
OF + MR
4T + 3T = 7 T
6) L X I B, 1020 HX - for register pair
Ifor I monodial
B C
10
1515
10 20
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
32/254
32
OF - 4 T Data read 3 T (10) & 4 T (10)
= 10 T
7) STA 2000 H
A (10) 2000
OF 4T MW 30 (3T) MW 00 (3T)
8) LDA 2000 H
2000 A
OF 4T + MR 20 (2T) + MR 00 (3T) + (2000) MR3T
= 13 T
9) SHLD 2500 H(L) (2500)
(H) (2501)
H = 30 L = 20
10
15 15
20
30
2500
2501
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
33/254
33
MR
+
MR
+
MW
+
MW
OF (H) (L) 2500 2501 = 16 T
(4T) 3T 3T 3T 3T
10)LHLD 2500 H
+(2500) = 20 (2501) = 30
(H) (H)
OF + MW + MW + MR + MR= 16 T
(4T) 3T 3T 3T 3T
11)STAX B A = 10
BC = 1020
OF 4T Register pair so 3T
= 7T
12)LDAX B
BC = 1030
= 7T
13)XCHGH D
L E
101020
151030 A
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
34/254
34
4T
Small Program:
1) Store 16 bin in location 3000 isAnswer:
MVI A, 16 H,
STA 3000 H
HLT
(example for direct address)
Another method:
LXI H, 3000 H
MVI M, 16 H
HLT
(example for indirect addressing)
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
35/254
35
QUESTION AND ANSWERS
Two Mark Questions:
1) How many time cycles for OF, MR, MW?Answer:
OF 4T MR 3T MW 3T
2) Write a program to store 20 in location 5000 HAnswer:
MVI A, 20 H
STA 5000 H
HLT
Essay Questions:
1) Write all data transfer instruction?(1 to 13) instructions.
2) Swap the content of location 2000 and 5000?Answer:
LDA 2000 H
MOV B,A
LDA 5000 H
STA 2000 H
MOV A,B
STA 5000 H
HLT
3) Swap the content of location 2000 and 5000 in indirect address?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
36/254
36
Now introduction anchors.
p
Day - VII
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
37/254
37
DAYVII
Arithmetic Group:
In 8085 it has only ADD & SUBTRACT.
1) ADD BA (A) + (B)
OF 4T
(B) source destination A is implied
2) ADD M
A (A) + (M) M = H L Pair
OF 4T MR 3T H (20) L (10)
= 7T
3) ADI 08H
A (A) + 08
OF MR = 7T
4T 3T
4) ADC BA
(A) + (cy) + (B)OF 4T
5) ADC MA (A) + (cy) + (M)
152010 A 25A+
10
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
38/254
38
HL
OF4T MR 3T = 7T
6) ACI 20 H
A (A) + (cy) + 20
HL
= OF + data read
= 4T + 3T = 7 T
7) DAD BDouble Add
(HL) (H) (L)
+ +
(B) (C)
Result
H L
Similarly Subtract:
1) SUB BA (A)(B)
OF 4 T
2) SUB MA (A)(M)
OF 4T MR 3T = 7T
3) SUI 08HA (A)08
OF / 4T + Data Read (3T) = 7T
4) SBB BA (A)(B)cy
OF = 4T
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
39/254
39
5) SBB MA (A)(M)cy
OF data read
4T 3T = 7T
6) SBI 08A (A)08cy
OF + data read
4T + 3T = 7T
7) DAA (Decimal Adjust Accumulator)A = 0100 1010 = 4 A
DAA
0100 1010
0000 0110
0101 0000
AD = 50 (BCD)
Increment (or) Decrement
1) INR B(B) (B) + 1
OF = 4T
2) INR M(H L)
20 50
2050 2
OF + MR + MW
10 11
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
40/254
40
4T + 3T + 3T = 10 T
3) INX rpINX H
rp register pair
if H = 20 L = 10
= 6T
4) DCR B(B) (B)1
4T
5) DCR M
H L 2050 2
10 T
6) DCX BB = 20 C = 10
6 T
10 9
20 9
20 11H L
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
41/254
41
QUESTION AND ANSWERS
Two Marks questions:
1) B = FF C = FF What is the value of INRB & INX B?INR B =
FF
01 B = 00 C = FF
00
INX B =
FF FF
01 01
00 00
B C
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
42/254
42
Essay Questions
1) Explain Arithmetic operations is 8085?Answer:
ADD and Subtract discuss 6 + 6 instructions.
2) Discuss the different increment and decrement operator?Answer:
3 Increment 3 Decrement
3) Write a program Add two 8 Bit numbers? 5000 Location 5001 Location Add shot inlocation 5002.
Answer:
LXI H, 5000 H
MOV A, M
INX H
ADD M
INX H
MOV M, A
HLT
4) Write a program to subtract two 8 bit numbers?Answer:LXI OH 5000
MOV A, M
INX H
SUB M
INX H
MOV M, A
HLT
5) Add two 16 bit numbers?Answer:
LHLD 5000
XCHGLHLD 5002
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
43/254
43
DAD D
SHLD 5004
HLT
6) Sub two 16 bit numbers?Answer:
LHLD 5000
XCHG
LHLD 5002
MOV A, E
SUB L
MOV L, A
MOV A, D
SBB H
MOV H,A
LHLD 5004
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
44/254
44
To become no to know in microprocessors read dayVIII
p
Day - VIII
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
45/254
45
DAY8
IV Branch Group
(i) JMP 2000
PC 2000 is assigned to PC (Program Counter)
OF + MR + MR
4T + 3T + 3T = 10 T
ii) a) JC 2000 jump if carry = 1 at loc 2000b) JNC 2000 jump if carry = 0 at loc 2000
c) JP 2000 jump on possible at loc 2000
d)JM 2000 jump on Minus at loc 2000
e) JPE 2000 jump on parity odd at loc 2000
f) JZ 2000 jump on zero at loc 2000
g) JNZ 2000 jump on not zero at loc 2000
iii) PCHLPC HL
6 T
A B
A N D Clamp
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
46/254
46
V Logical Group:
(i) ANA BA A ^ B
4 T
Application: Maskid
(ii)ANA MO A X (M)
7T
(iii)ANI 60
A A X 60
7 T
(iv)XRA AA A X A
4T
Clear Accumulator
Or gate:
1 0 1 0 1 1 1 1A
1 1 1 1 0 0 0 0B
1 0 1 0 0 0 0 0A
A
B
C
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
47/254
47
(v) XRA MA A + M
7T
(vi)XRI 40A A + 40
7 T
(vii)ORA AA A V A
4T
(viii) ORA MA A V M
7T
(ix)ORI 107 T
A A V 10 V
(x)CMP B (Compare B)A AB
4 T
(xi)CMP M7T
A A(HL)
(xii) CPI 10 (Compare immedial with data 10)A A10
7 T
(xiii) STCSet carry = 1
Cy 1 (4T)
(xiv) CMC Complement Carry (4 T)(xv) CMA Complement Accumulator (4 T)
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
48/254
48
QUESTIONS
Essay Questions:
1) Discuss Branch group instructions?Answer:
i) JMP ii) Conditional Group iii) PCHL
2) Discuss logical group instruction?Answer:
AND, OR, XOR, Compare, Complement etc.
OBJECTIVE TYPE QUESTIONS
1) What is the mechanism of JMP 2000?i) PC 2000 ii) HL 2000
2) JC _________i) Jump on carry ii) jump on carry = 1
3) JNC ________i) Jump no carry ii) Jump on carry = 0
4) JP _____________i) Jump on positive ii) Jump zero
5) JM ______________i) Jump on HL ii) Jump on negative
6) JZ _______________i) Jump on zero ii) Jump on HL
7) JNZ _____________Jump no zero ii) Jump on HL
8) What is XRA A?i) Clears accumulators ii) Adds accumulator
9) CMP A ___________i) Clear Accumulator ii) Adds accumulator
10) CMA _____________i) 1s Complement Accumulator ii) 2s Complement
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
49/254
49
RESULT ANALYSIS
1) i 2) ii 3) ii 4) i 5) ii 6) i 7) i 8) i 9) i 10) i
If your score is 8 (or) more you are excellent. If less than 8 please repeat Day 8.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
50/254
50
Now it is dayIX.
p
Day - IX
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
51/254
51
DAY9
V) Rotate group
i) R L C
Rotate Accumulator left where B7 goes to carry and B0
ii) R R C:
Rotate Accumulator right. B0 goes to cy and B7
Reverse of RLC
B7 B0
cy
4 T
B7 B0
cy
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
52/254
52
iii) R A L:
Rotate Accumulator left through carry.
iv) R A R:
Programs:
i) Computer 1s complement of 54 in 1000 left loc?
Answer:
LDA 1000
CMA
STA 1000
HLT
B7 B0
cy
4 TB7 B0
cy
4 T
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
53/254
53
VI) Stack Operations:
i) L X I sp, data
(or) sp data
S P H L
SP HL
6 T
i) PUSH rp
eg. PUSH D
ii) P O P rp
P O P D
E 20
D 10
iii) C A L L 2000 H
D 10 C 20
Sp - 2 20
Sp - 1 10
Sp
SP 1000 1000 10
20
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
54/254
54
pc 2000 H
R E T
iv) C C 2000
Call on carry = 1 to 2000
v) C N C 2000
call on no carry
similarly return
v) R C return on carry
vi ) R N C return on no carry
vii) R S T r (restart o to n)
R S T 0 = 0 x 8 = 0000
R S T 5.5 = 5 x 8 + 5 x 8 = 2 C H
R S T 6.5 = 3 C H (Address)
R S T 7.5 = 4 C H (Address)
viii) I/O:
a) I N 80 H
80 H (device no) to Accumulator
b) O U T 50 H
Acc 50 H (device)
ix) X T H L:
Change top of stack with H L
L
H
x) i) E I: (Enable interrupt)
F F: (flip flop enabled)
F F 1
ii) D I (Disable)
F F 0
iii) N O P (No operation)
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
55/254
55
iv) H L T
Hales
v) S I M:
Set interrupt mask interrupts R S T 7.5, 6.5, 5.5 are masked
Read Interrupt Mask: (R I M)
It display left status of interrupt
1Mask
O - Unmask
1 1
7.5 6.5 R S T 5.5
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
56/254
56
QUESTION ANSWERS
Two marks:
1) What is R L C?
Answer:
2) What R A L?
3) STACK definition?
Stores left data and retriew left data by PUSH and POP operation.
4) Explain Restart n ?
Answer:
R S T nR S T 5.5 = 5.5 x 8 = 2 CH
R S T 6.5 = 6.5 x 8 = 3 CH
R S T 7.5 = 7.5 x 8 = 4 CH
B7 B0
cy
B7 B0
cy
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
57/254
57
5) What are the port operation?
Answer:
Port mean carry
a) IN 50H
Acc 50 H
b) OUT 50 H
50 H Acc
6) Define E I and DI?
Answer:
i) EI: Enable Interrupt
FF 1
ii) DI: Disable Interrupt
FF 0
2) How initialize SP?
i) LXI SP ii) LDAX
3) What are the operation in stack?
i) CALL ii) PUSH, POP
4) What is CNC 2000?
i) Call on carry ii) Call no carry
5) What is the vector address of RST 5.5?
a) 2 CH b) 3 CH
6) What is in port?
a) (device no to accumulator) b) (Accumulator to device number)
7) What is EI?
i) FF 1 ii) FF - 1
8) What is DI?
i) FF 0 ii) ALE 0
9) What is S I M?
i) Set interrupt mask ii) Reset interrupt mask
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
58/254
58
Essay Questions:
I. Explain rotate group instruction?
Answer:R L C, R R C, R A L, R A R
II. Explain Stack, call sub routine, I/O, Interrupt masking instruction?
Answer:
Condition
PUSH, POP, Call , EI, DT, STM, etc.
Uncondition
OBJECTIVE QUESTIONS
i) R A L is _________________
a) Rotate accumulator through carry
b) Without carry rotation.
RESULT ANALYSIS
1) a 2) a 3) ii 4) ii 5) a 6) a 7) 1 8) 1 9) i
If your score is 8 or more you can go to Day 10. Otherwise repeat day 9.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
59/254
59
The laudable module finishes.
p
Day - X
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
60/254
60
DAY10
Programs:
1) Shift right 8 bit data?
Answer:
MOV A,C
RAR
RAR
RAR
RAR
MOV C, A
H L T2) Shift left 16 bit data?
Answer:
MOV A,B
RAL
MOV B,A
MOV A,C
RAL
MOV C,A
HLT
3) Sum of series of number?
LDA 3000 H
MOV C, A
XRA A
LXI H, 3000 H
Loop ADD MINX HDCR C
JNZ Loop
STA 3004
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
61/254
61
4) Data Transfer (Block)
MVI C, 05H
LXI H 2200
LXI D 2300
Loop MOV A, M
STA X, D
INX H
INX D
DCR C
JNZ Loop
HLT
4) Find number of negative numbers in block?
Answer:
MSB is 1 then negative
LDA 3000
MOV C, A
MVI B, 00
LXI H 3001
Loop MOV A, M
ANI 80 H
JZ Ship
INR B
Ship INX H
DCR C
JNZ Loop
MOV A,B
STA 4000
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
62/254
62
QUESTION AND ANSWERS (ESSAY)
1) Find the largest of given number?
Answer:
CMP M2) Calculate the sum of odd number
Answer:
ANI 01, H
JZ
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
63/254
63
Annexure
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
64/254
64
PROGRAMS FOR 8085 MICROPROCESSOR LEARNERS
1. Store 8-bit data in memory of 8085 microprocessor2. Exchange the contents of memory locations in a 8085 microprocessor3.
Add two 8-bit numbers in a 8085 microprocessor
4. Subtract two 8-bit numbers in a 8085 microprocessor5. Add two 16-bit numbers in a 8085 microprocessor6. Add contents of two memory locations in a 8085 microprocessor7. Subtract two 16-bit numbers in a 8085 microprocessor.8. Finding one's complement of a number9. Finding Two's complement of a number10.Pack the unpacked BCD numbers11.Unpack a BCD number12.Execution format of instructions13.Right shift bit of data14.Left Shifting of a 16-bit data15.Alter the contents of flag register in 8085
1.Store 8-bit data in memory of 8085 microprocessor
MVI A, 52H : Store 32H in the accumulator
STA 4000H : Copy accumulator contents at address 4000H
HLT : Terminate program execution
2.Exchange the contents of memory locations in a 8085 microprocessor
LDA 2000H : Get the contents of memory location 2000H into accumulator
MOV B, A : Save the contents into B register
LDA 4000H : Get the contents of memory location 4000Hinto accumulator
STA 2000H : Store the contents of accumulator at address 2000H
MOV A, B : Get the saved contents back into A register
STA 4000H : Store the contents of accumulator at address 4000H
3.Add two 8-bit numbers in a 8085 microprocessor
Sample problem
http://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Subtract-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Subtract-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Add-contents-of-two-memory-locations.aspxhttp://www.8085projects.info/post/Add-contents-of-two-memory-locations.aspxhttp://www.8085projects.info/post/Subtract-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Subtract-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Finding-ones-complement-of-a-number.aspxhttp://www.8085projects.info/post/Finding-ones-complement-of-a-number.aspxhttp://www.8085projects.info/post/Finding-Twos-complement-of-a-number.aspxhttp://www.8085projects.info/post/Finding-Twos-complement-of-a-number.aspxhttp://www.8085projects.info/post/Pack-the-unpacked-BCD-numbers.aspxhttp://www.8085projects.info/post/Pack-the-unpacked-BCD-numbers.aspxhttp://www.8085projects.info/post/Pack-the-unpacked-BCD-numbers.aspxhttp://www.8085projects.info/post/Unpack-a-BCD-number.aspxhttp://www.8085projects.info/post/Unpack-a-BCD-number.aspxhttp://www.8085projects.info/post/Unpack-a-BCD-number.aspxhttp://www.8085projects.info/post/Execution-format-of-instructions.aspxhttp://www.8085projects.info/post/Execution-format-of-instructions.aspxhttp://www.8085projects.info/post/Execution-format-of-instructions.aspxhttp://www.8085projects.info/post/Right-shift-bit-of-data%28-8-bit-and-16-bit%29.aspxhttp://www.8085projects.info/post/Right-shift-bit-of-data%28-8-bit-and-16-bit%29.aspxhttp://www.8085projects.info/post/Right-shift-bit-of-data%28-8-bit-and-16-bit%29.aspxhttp://www.8085projects.info/post/Left-shifting-of-a-16-bit-data.aspxhttp://www.8085projects.info/post/Left-shifting-of-a-16-bit-data.aspxhttp://www.8085projects.info/post/Left-shifting-of-a-16-bit-data.aspxhttp://www.8085projects.info/post/Alter-the-contents-of-flag-register-in-8085.aspxhttp://www.8085projects.info/post/Alter-the-contents-of-flag-register-in-8085.aspxhttp://www.8085projects.info/post/Alter-the-contents-of-flag-register-in-8085.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspxhttp://www.8085projects.info/post/Alter-the-contents-of-flag-register-in-8085.aspxhttp://www.8085projects.info/post/Left-shifting-of-a-16-bit-data.aspxhttp://www.8085projects.info/post/Right-shift-bit-of-data%28-8-bit-and-16-bit%29.aspxhttp://www.8085projects.info/post/Execution-format-of-instructions.aspxhttp://www.8085projects.info/post/Unpack-a-BCD-number.aspxhttp://www.8085projects.info/post/Pack-the-unpacked-BCD-numbers.aspxhttp://www.8085projects.info/post/Finding-Twos-complement-of-a-number.aspxhttp://www.8085projects.info/post/Finding-ones-complement-of-a-number.aspxhttp://www.8085projects.info/post/Subtract-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Add-contents-of-two-memory-locations.aspxhttp://www.8085projects.info/post/Add-two-16-bit-numbers.aspxhttp://www.8085projects.info/post/Subtract-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Add-two-8-bit-numbers.aspxhttp://www.8085projects.info/post/Exchange-the-contents-of-memory-locations.aspxhttp://www.8085projects.info/post/Store-8-bit-data-in-memory.aspx7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
65/254
65
(4000H) = 14H
(4001H) = 89H
Result = 14H + 89H = 9DH
Source program
LXI H 4000H : HL points 4000H
MOV A, M : Get first operand
INX H : HL points 4001H
ADD M : Add second operand
INX H : HL points 4002H
MOV M, A : Store result at 4002H
HLT : Terminate program execution
Flowchart
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
66/254
66
Program - 4: Subtract two 8-bit numbers
Sample problem:
(4000H) = 51H
(4001H) = 19H
Result = 51H - 19H = 38H
Source program:
LXI H, 4000H : HL points 4000H
MOV A, M : Get first operand
INX H : HL points 4001H
SUB M : Subtract second operand
INX H : HL points 4002H
MOV M, A : Store result at 4002H.
HLT : Terminate program execution
Flowchart
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
67/254
67
Program - 5.a: Add two 16-bit numbers - Source Program 1
Sample problem:
(4000H) = 15H
(4001H) = 1CH
(4002H) = B7H
(4003H) = 5AH
Result = 1C15 + 5AB7H = 76CCH
(4004H) = CCH
(4005H) = 76H
Source Program 1:
LHLD 4000H : Get first I6-bit number in HL
XCHG : Save first I6-bit number in DE
LHLD 4002H : Get second I6-bit number in HL
MOV A, E : Get lower byte of the first number
ADD L : Add lower byte of the second number
MOV L, A : Store result in L register
MOV A, D : Get higher byte of the first number
ADC H : Add higher byte of the second number with CARRY
MOV H, A : Store result in H register
SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H.
HLT : Terminate program execution
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
68/254
68
Flowchart
6.Sample problem:
(4000H) = 7FH
(400lH) = 89H
Result = 7FH + 89H = lO8H
(4002H) = 08H
(4003H) = 0lH
Source program:
LXI H, 4000H :HL Points 4000H
MOV A, M :Get first operand
INX H :HL Points 4001H
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
69/254
69
ADD M :Add second operand
INX H :HL Points 4002H
MOV M, A :Store the lower byte of result at 4002H
MVIA, 00 :Initialize higher byte result with 00H
ADC A :Add carry in the high byte result
INX H :HL Points 4003H
MOV M, A :Store the higher byte of result at 4003H
HLT :Terminate program execution
Flowchart
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
70/254
70
7. Sample problem:
(4000H) = 19H
(400IH) = 6AH
(4004H) = I5H (4003H) = 5CH
Result = 6A19H - 5C15H = OE04H
(4004H) = 04H
(4005H) = OEH
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
71/254
71
Source program:
LHLD 4000H : Get first 16-bit number in HL
XCHG : Save first 16-bit number in DE
LHLD 4002H : Get second 16-bit number in HL
MOV A, E : Get lower byte of the first number
SUB L : Subtract lower byte of the second number
MOV L, A : Store the result in L register
MOV A, D : Get higher byte of the first number
SBB H : Subtract higher byte of second number with borrow
MOV H, A : Store l6-bit result in memory locations 4004H and 4005H.
SHLD 4004H : Store l6-bit result in memory locations 4004H and 4005H.
HLT : Terminate program execution.
Flowchart
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
72/254
72
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
73/254
73
8.Sample problem:
(4400H) = 55H
Result = (4300B) = AAB
Source program:LDA 4400B : Get the number
CMA : Complement number
STA 4300H : Store the result
HLT : Terminate program execution
Flowchart
9. Sample problem:
(4200H) = 55H
Result = (4300H) = AAH + 1 = ABH
Source program:
LDA 4200H : Get the number
CMA : Complement the number
ADI, 01 H : Add one in the number
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
74/254
74
STA 4300H : Store the result
HLT : Terminate program execution
Flowchart
10. Sample problem:
(4200H) = 04
(4201H) = 09
Result = (4300H) = 94
Source program:
LDA 4201H : Get the Most significant BCD digit RLC RLC RLC RLC : Adjust the position of the second digit (09 is changed to 90) ANI FOH : Make least significant BCD digit zero MOV C, A : store the partial result LDA 4200H : Get the lower BCD digit ADD C : Add lower BCD digit
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
75/254
75
STA 4300H : Store the result HLT : Terminate program execution
Flowchart
11. Sample problem:
(4200H) = 58
Result = (4300H) = 08 and
(4301H) = 05
Source program:
LDA 4200H : Get the packed BCD number
ANI FOH : Mask lower nibble
RRC
RRC
RRC
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
76/254
76
RRC : Adjust higher BCD digit as a lower digit
STA 4301H : Store the partial result
LDA 4200H : .Get the original BCD number
ANI OFH : Mask higher nibble
STA 4201H : Store the result
HLT : Terminate program execution
Flowchart
12. Main program:
4000H LXI SP, 27FFH
4003H LXI H, 2000H
4006H LXI B, 1020H
4009H CALL SUB
400CH HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
77/254
77
Subroutine program:
4100H SUB: PUSH B
4101H PUSH H
4102H LXI B, 4080H
4105H LXI H, 4090H
4108H SHLD 2200H
4109H DAD B
410CH POP H
410DH POP B
410EH RET
13. Statement: Write a program to shift an eight bit data four bits right. Assume data is in register
C.
Sample problem:
(4200H) = 58
Result = (4300H) = 08 and
(4301H) = 05
Source program 1:
MOV A, C
RAR RAR RAR RAR MOV C, A HLT
Flowchart for Source program1
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
78/254
78
14. Statement: Write a program to shift a 16 bit data, 1 bit right. Assume that data is in BC
register pair.
Source program 2
MOV A, B RAR MOV B, A MOV A, C RAR MOV C, A HLT
Flowchart for Source program1
15. PUSH PSW: Save flags on stack
POP H: Retrieve flags in 'L' MOV A, L :Flags in accumulator CMA:Complement accumulator MOV L, A:Accumulator in 'L' PUSH H:Save on stack POP PSW:Back to flag register HLT:Terminate program execution
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
79/254
79
16.8085 Program to calculate GCD of two numbers.
OBJECTIVE :-
To Determine GCD of two numbers. The Two Numbers are stored at consecutive memory
locations :8000H and 8001H. The GCD of two numbers is stored at memory location 8003H.
LOGIC:-
STEP 1:-Compare number 1(no1) with number 2(no2).If no1==no2,go to step 3.
Else if no1
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
80/254
80
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
81/254
81
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
82/254
82
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
83/254
83
MODULE II
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
84/254
84
SYLLABUS
UNITII
8086 SOFTWARE ASPECT:
Intel 8086 Microprocessor - Architecture
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
85/254
85
Slowly you are mincing towards exemplary in microprocessor
Day XI in
Microprocessor
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
86/254
86
Day11
Introduction to 8086 Microprocessor
Year 1978, HMOS
Flavors:ALU, internal registers all are 16 bit. So it is called 16 bit microprocessor.
Reads or writes data to port in 16 bit
It has 20 address lines, so it can map 220
1 mb
216
I/O devices (port)
i) 10 MHz 80861ii) 8 MHz 80862iii) 8 MHz 8086
It functions in MIN & MAX mode.
In micro computer only one 8086 microprocessor is available then it is min mode.
If multiprocessor max mode.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
87/254
87
3
6
5
4
2
1
ES
CS
SS
DS
IPControl
systems
AL
BL
CL
DL
SP
BP
SI
DI
AX
BX
CX
DX
AH
CH
BH
DHOperands
Flags
A - BusEu
BIU
B - bus
Memory Interface
C - Bus
Instructionstream byte
queue
Architecture of 8086
ALU
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
88/254
88
Register organization:
(i) GPR
All are 16 bit register.
Accumulator AX is 16 bit. AL can be 8 bit.
(ii) Segment Registers:
(iii) Pointers and Index Registers:IP points code segment
BP points data segment
SP Points stock segment
SI, DI used in addressing.
SISource Index
DIDestination Index
ES
SS
DS
CS
Base address(or) segment
base
64 K
64 K
64 K
64 K
1 Mb Physical
Memory
AX AH AL
BX BH BL
CX CH CL
DX DH DL
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
89/254
89
iv) Flag register:
OOverflow flag SSign
DDirection ZZero
IInterrupt ACAuxillary carry
TTrap PParity
CyCarry
Questions and Answers
Two Marks:
1) How many address and data line in 8086?Answer:
Address - 20
Data - 16
2) What is the clock frequency of 8086 -1 , 80862?Answer:
80861 10 MHz
80862 8 MHz
3) What is MIN Mode?Answer:
In micro computer if only one 8086 microprocessor is there
than min mode.
4) How many GPR define in 8086?Answer:
4 GPR
AX, BX, CX, DX
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
X X X X O D I T S Z X AC X P X cy
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
90/254
90
5) IP, BP and SP points to which segment?Answer:
IP points to code segment
BP points to data segment
SP points to stock segment
Objective Question
1) Which MOS technology in 8086?
i)
HMOS ii) CMOS
2) 8086 Maps ____________i) 1 Mb ii) 64 K
3) The clock frequency of 8086 _________________i) 8 MHz ii) 5 MHz
4) Min mode 8086 microprocessor is _______________i) Many ii) One
5) Multiprocessor functions in __________________i) Min mode ii) Max mode
6) What is AX and AL?i) AX16 bit
AL8 bit
ii)AX16 bitAL16 bit
7) BP points __________ segmenti) Code segment ii) Data segment
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
91/254
91
8) SI, DI used in _________________i) Interrupt ii) Addressing
Result analysis
Answers:
1) i 2) i 3) ii 4) ii 5) ii 6) i 7) ii 8) iiIf your score is more than 7 go to day 12 otherwise repeat day 11.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
92/254
92
It is ineffable to say about 8086 microprocessorplease go to Day XII
Day XII
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
93/254
93
DAY12
Architecture continuation:
In 8086 it has two units i) Bus interface unit ii) Execution unit
i) BIU:Interface with outer world
The jobs of BIU is
1) Sends address of I/O and memory2) Fetches instruction from memory3) Reads data4) Writes data5) Executes instruction queue6) Address relocation
Hence when you pass the light on BIU it has i) segment register ii) IP iii) summer
iv) instruction queue
Instruction queue:
BIU fetches six instruction bytes. Feature of fetching the next instruction.
While the current instruction execution is called pipelines.
BU F1 F2 F3
U1 U2 etc
F + U + X + ST
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
94/254
94
Describe about segmentation
i) Direct Addressing: IP 2000
MOV AL, [ 2000 H]
ii) Register Indirect: (IP)MOV BX, (CX)
Content of content
10
DS 1000 X 10 10,000
+
3000 HCX
16
15
BX
13,000
ADDRESSING MODES (8086)
Direct
Addressing
mode
Register Indirect
Addressing mode
Based
Addressing
Mode
Indexed
Addressing
Mode
Based Indexed
Addressing
Mode
String
Addressing
Mode
x 101000 + 2000
1012,000
DS/Ppr
10,000
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
95/254
95
iii)Base plusindex ( BP )MOV CX, (BX + DI)
Question and Answers
Essay Question:
1) Explain the architecture of 8086?2) Discuss the functioning mechanism of BIU and EU?
BX 2000
12,000
+
3000 HCX
20
10
CX13,500
1000DSX 10
+
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
96/254
96
It is ineffable to say microprocessor now please read day XIII.
Microprocessor
Day XIII
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
97/254
97
Day13
Addressing Mode8086
4) Register relative addressing:
MOV CX, [BX + 003 H]
5) Base relative plus index address
MOV AL, [BX + SI + 10H]
DS 5000
+1000BX
10
20
SP / CX
50,000
51,003
3
51,004
51,003
10 20
BX 1000
SI
10
2000
AL 10
22,010
+
DS
+ 22,010
1000
2000
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
98/254
98
6) String Addresses mode:
MOV S BYTE
7) I/O Ports accessing by address modes:
i) Direct
IN AX, 80 H
ii) Indirect
IN AL, DX
8) STACK Memory addressing mode:
PUSH & POP
Instruction set
Here it is like 8086 by multiplication and division also instruction are available.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
99/254
99
Instruction Set
DAA
DAS
Data Movement
Instruction
Add Sub
CompareMVL
DIVBCD &ASCII
Arithmetic
Logic
Instruction JumpM/C Control
MOV
PUSH
POP
XCHG
XLOT
ADD
ADC
INC
SUB
SBB
DEC
NEG
CMP
MVL
IMUL
DIV
CALL
RET
JMP
JCON
INT
INTO
RET
NOT
AND
OR
XORTEST
Shift and
Rotate
SAL/SHL
SHR
SAR
String
Compare
REP
MOVS
CMPS
STC
CLC
CMC
STDCLD
Interrupt
instruction
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
100/254
100
Data Transfer (8086) Day 17
i) MOV BX, AX ( 5 addresses modes) implement itii) PUSH BX ( Copy BX to Stack)iii) POP CX (top of stock to CX)iv) XCHG BX, CX
I) Arithmetic instruction:
i) ADD AX, BX [ AX AX + BX ]ii) ADC DX, BX, DX DX + BX + Cyiii) INC BXiv) ADD AL, BLv) DAA
II) Subtract Instruction:
i) SUB AX, BX [ AX AXBX]ii) SBB DX, BX [ DX DXBXCy]iii) DEC BXiv) NEG AL ( zs complements)v) CMP BX (AXBX)vi) SUB AL, BL
DAS (Decimal After Sub)
AL = 0010 0011
CL = 0101 1000
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
101/254
101
1100 1011
Decimal After Sub 1100 0110
1100 01 01
Sub 0110 0001
0110 01 01
- (65)
III) Multiplication:
i) MUL BXAX AX, BX
ii) IMUL (signed byte)
IMUL CX
IV) DIVISION:
i) DIV BXAX AX / BX
Quotient in AX remainder in BX
IV ) Logical Instruction: (Prefer 8 bit data)
i) NOT CXNOT CL
ii) AND BXAND AL, BL
iii)OR CX
OR AL CL
iv)XOR:XOR AL, BL
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
102/254
102
v)i) SAL / SHL:
Cy B7 B1 B0
0 1 0 . 1 0
1 0 1 ..... 1 0
ii) SHR:SHR destination, count
Cy
1 0 . 1 0
0 1 0 ..... 0 1
iii)RCL:RCL destination, count
Cy0 0
iv)RCR:B Cy
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
103/254
103
Question Answers
Essay:
i) Explain the addressing modes in 8086?ii) Discuss Data Transfer instruction in 8086?iii) Discuss Arithmetic and Logic instruction in 8086?iv) Discuss about shift and rotate in 8086?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
104/254
104
The laudable man is reading the laudable microprocessor
Microprocessor
Day XIV
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
105/254
105
Day14
Near Intra segment
i) CALL :Far Inter segment
CALL PRO Name of the procedure
ii) Res returniii)JMP: (Unconditional)
JMP NEXT
iv)J (Condition)VI) Processor control instruction:
i) STC - Set carryii) CLC - Reset the carry flag to zeroiii) CMC - Complements the carry flagiv) STD - Set direction flagv) CLD - Reset the direction flag to zero
VII) Interrupt instruction
1)
2) INT OOver Flow flag is set
3) RET
INT Type
Far
(0255 type)
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
106/254
106
VIII) String instructions:
1) REP C X = 02) MOV S BX, CX3) CMP BX, CX
Essay questions
1) Discuss about Jump, processor instruction, interrupt instruction and stringinstruction?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
107/254
107
This book makes you as Man with meticulous awards (accolades) in
microprocessor
DAY
XV
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
108/254
108
DAY15
Assembler Directives (Pseudo operations)
1) ALIGN 8 (numbers)2) ASSUME
ASSUME CS: Code Segment;
3) CODE4) DATA
DB - Define byte
BW - Define word
DD - Define double word
DQ - Define qued word
DT - Define Ten Bytes
Eg: COST DB 10,20,30
5) DUP: InitializeTABLE BW 10 DUP (0)
6) END7) EQU8) EXTRN
10
20Cost
50
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
109/254
109
9) Groups: All segment of same data byte10)Label11)MACRO
END M
12)Name: Name of each module13)OFF set: Displacement14)ORG:
ORG 1000
Start with 1000
15)PTR16)PAGE [ length] [ width ]17)Proc and End P18)Public19)Segment and End S20)Short: Short address21)STACK STACK [ SIZE]22)TITLE:
TITLE rent
ALP : (Assembly Language Programs)
Addition of two numbers
NAME addition
PAGE 52, 80
TITLE Add of two numbers
Model Small
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
110/254
110
Stack 100
Data
N1 DB 42H
N2 DB 43H
Result DW ?
Code
START MOV AX, @data (Initialize data segment)
MOV DS, AX
MOV AL, N1
ADD AL, N2
ADC AH, 00
MOV Result, AX
END Stack
Question and Answers
Essay question:
1) Discuss the different assembler directives?
Objective Type questioni) Assembler directives are also called _____________________
a) Pseudo operations b) conditional operationii) Four physical segments are
a) Code b) data c) stack iv) ?iii)DB is in ________________in assembler directive
a) Data buffer b) Define byteiv)DT ___________
a) Define Terminals ii) Define Ten bytes
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
111/254
111
v) DUP ___________a) Initialize b) duplicate
vi)EQU is __________a) Equate numeric b) Equate numeric and string
vii)MACRO means ____________ subroutinea) Null sub routine b) Open subroutine
Result Analysis
1) a 2) b 3) b 4) b 5) a 6) b 7) bIf your score is greater than 6 go to day 16 otherwise repeat day 15.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
112/254
112
The erudite lured by this microprocessor
DAY XVI
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
113/254
113
DAY 16
Open (Macro)
1. Procedures:
Closed
Near
2. Procedure
Far
But for far procedures CALL instruction pushes lot IP and CS on the stack.
Parameter passing mechanism in procedure
i) Using registersii) Using general memoryiii) Using pointersiv) Using stack
i) Parameter passing using register:Main Prog
CS
MOV AL, d1;
:
CALL PRO 1
:
; procedure
PRO 1 PROC NEAR
MOV INPUT , AL;
:
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
114/254
114
RET
PRO 1 END P
CODE END
ii) Parameter passing using memory:
Main Program
DS
BCD _ INPUT DB 42; storage
HEX _ VALUE DB 2; storage
DATA END,
CS
CALL PRO 1
Procedure
PRO 1 PROC NEAR
MOV AL, BCD, INPUT
iii) Passing parameter using pointers:
BCD_INPUT DB 42;
:
MOV SI, BCD _ INPUT
MOV AL, [SI]iv) Passing parameters using array:
BCD _ INPUT DW 4209;
MOV AX, OFFSET BCD_INPUT
--
-
MOV AX, [BTR]
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
115/254
115
ii) Reentrant Procedure
iii) Recursive procedure
Macros:
INI T MACRO
MOV AX, @ data
MOV DS
:
END M
MAIN LINE PROC 1 PROC 2
RET main
prog
RET
Cal PL
PROC 2 re enters PROC 1
Call pro
Call Call Cc
RET
Important
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
116/254
116
i) Passing parameters in Macro:
INT T MACRO HEY
LEA HEY
ii) Local
iii) Global
Question and Answers
Two mark question:
i) What are the two types of procedure?
Answer:
i) Open ii) Closed
ii) What are the parameter passing mechanism in procedures?
Answer:
i) Using registersii) Using general memoryiii)Using pointersiv)Using stack
Essay questions:
1) Describe about procedure and parameter passing mechanism?2) Describe about Macros and Parameter passing in macros?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
117/254
117
You are reaching to the apex of 8086 microprocessor
Day
XVII
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
118/254
118
Day 17
Please probe about 8086 expeditely
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
119/254
119
Day 17
Assembly language prog:
i) . IF _ ELSE END IF
. IF (Condn)
.
. ELSE (Optional)
:
. END IF
ii) WHILE _ END W
. WHILE
. END Wiii) REPEAT E
iv) WHILE
v) FOR
Interrupts
Normal program can be interrupted by three ways
An interrupt caused by an external signal is referred as a hardware interrupts.
Conditional interrupts (or) interrupts cased by special instructions are called software
interrupt.
i) By external signalii) By a special instruction in the programiii)By the occurrence of some condition
i) External Signal: (Hardware signals)
i) NMI input pin
ii) INTR input pin
ii) Special instruction:
It (8086) supports a special instruction, INT to execute special program.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
120/254
120
iii) Condition produced by instruction:
DIV by zero
PUSH FLAG
PUSH CS
PUSH IP
POP IPPOP CS
POP FLAG
ISR
Push register
Pop register
INT
MAIN prog
Type 255 points
.
.
.
Type 2
NMI
Type 1
Single - step
DIV by zero
Type 0
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
121/254
121
Interrupt (Vector) Pointer tabe.
Type 0 : Divide by zero interrupt
Type 1: Single step interrupt
The single step mode, systems will execute one instruction and
wait for further direction from user.
Type 2 : NMI
Type 3 : Break point
Type 4 : Over flow
Software interrupts:
TYPE 0255 ;
INT 2 instruction from NMI ISR
With the software interrupts you can call the desired routines from many different
programs in a system by BIOS.
Priorities:
Div error High
Int A, Int 0
NMI
INTRSINGLESTEP Lower
Question and Answers
Two mark questions:
1) What are the ways the normal program was interrupted?Answer:
3 ways
2) What is hardware interrupt?Answer:
By external signal
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
122/254
122
3) What is software interrupt?Answer:
Special instruction
4) What are the hardware signal interrupt pin?Answer:
i) NMIii) INTR
5) Write the priority of interrupt?Essay question:
1) Discuss about the interrupts and its priorites?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
123/254
123
The second unit concludes
Day - 18
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
124/254
124
Day18
I. 8086 Minimum mode: ((i) to (ii) Common Signals for Min and Max)
i) AD0AD15
ii) A16 / S3A19 / S4
S3 S4 Register
0 0 ES
0 1 SS
1 0 CS
1 1 DS
iii)B HE / S7 : (Bus High Enable)BHE A0 Data accesses
0 0 Word
0 1 Upper byte from odd address
1 0 Lower byte from even address
1 1 NON
iv)NMIv)INTN
MODES (8086)
Minimum Maximum
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
125/254
125
vi)Clock8086 5Mhz
vii)Resetviii)Readix)TEST: wait signalx)RD (o/p)xi)MN / MX (input) For min mode onlyxii)INTA (Min mode only)xiii)ALE:
AD0AD15
xiv) DEN : This signal informs the transceivers that the CPU is ready tosend or receive data.
xv)DR / R (Data transmit / receive)xvi) M / IO xvii)WR xviii)HOLD:
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
126/254
126
MAXIMUM MODE ONLY:
1)
QS1 QS0 Status
0 0 No operation
0 1 First byte of an opcode
1 0 Queue is empty
2 2Subsequent byte of an
opcode
2)
2S
1S
0S M/c Cycle
0 0 0 Interrupt Ack
0 0 1 I/O read
0 1 0 I/O unit
0 1 1 Halt
1 0 0 Instruction fetch
1 0 1 Memory read
1 1 0 Memory unit
1 1 1 inactive
3) LOCK : Bus not for another processor
4)1TG
RQand
0TG
RQ
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
127/254
127
Question and Answers
Essay question
1) Explain common in Min and Max mode?2) Explain pin only in Min mode?3) Explain pin only in Max mode?
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
128/254
128
ANNEXURE FOR 8086 DIAGRAM
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
129/254
129
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
130/254
130
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
131/254
131
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
132/254
132
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
133/254
133
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
134/254
134
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
135/254
135
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
136/254
136
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
137/254
137
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
138/254
138
ANNEXURE FOR 8086
MICROPROCESSOR
PROGRAMMING
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
139/254
139
Ex. No: 1 32 BIT ADDITION AND SUBTRACTON
AIM:
To write an assembly language program to add and subtract two 32-bitnumbers using 8086 microprocessor kit.
APPARATUS REQUIRED:
8086 Microprocessor Kit
Power Chord
Key Board
33- BIT ADDITION:
ALGORITHM:
Step1: Start the program.
Step2: Move immediately the number 0000H to CX
register. Step3: Copy the contents of the memory 3000 to
AX register.
Step4: Add the content of the memory 3004 with the content of AX
register. Step5: Copy the content to AX register to two memories from
2000.
Step6: Copy the contents of the memory 3002 to AX register.
Step7: Add the content of the memory 3006 with the content of AX
register. Step8: Jump to specified memory location if there is no carry i.e.
CF=0. Step9: Increment the content of CX register once.
Step10: Copy the content to AX register to two memories from
2002. Step11: Copy the content to CX register to two memories
from 2004. Step12: End.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
140/254
140
MNEMONICS:
MOV CX, 0000
MOV AX, [3000]
ADD AX, [3004]
MOV [2000], AX
MOV AX, [3002]
ADC AX, [3006]
JNC loop1
INC CX
Loop1 MOV [2002], AX
MOV [2004], CX
HLTTABLE: 1
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV CX,0000Move immediately 0000H to CXregister
1004 MOV AX, [3000] Copy contents of 3000 to AX register
1008 ADD AX, [3004]Add content of memory 3004 with
content of AX register
100C MOV [2000], AXCopy content to AX register to two
memories from 2000
1010 MOV AX, [3002]Copy contents of memory 3002 to
AX register
1014 ADC AX, [3006]Add content of memory 3006 with
content of AX register
1018 JNC loop1 Jump to specified memory CF=0
101A INC CX Increment content of CX registeronce
101B Loop1 MOV [2002], AXCopy content to AX register to two
memories from 2002
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
141/254
141
101F MOV [2004], CXCopy content to CX register to two
memories from 2004
1023 HLT Halt
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 9999 2000: 3332
3002: 9999 2002: 3333
3004: 9999 2004: 1
3006: 9999
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
142/254
142
32 - BIT SUBTRACTION:
ALGORITHM:
Step1: Start the program.
Step2: Move immediately the number 0000H to CX register.
Step3: Copy the contents of the memory 3000 to AX register.
Step4: Add the content of the memory 3004 with the content of AX register.
Step5: Copy the content to AX register to two memories from 2000.
Step6: Copy the contents of the memory 3002 to AX register.
Step7: Subtract the content of the memory 3006 from AX register.
Step8: Jump to specified memory location if there is no carry i.e. CF=0.
Step9: Increment the content of CX register once.
Step10: Copy the content to AX register to two memories from 2002.
Step11: Copy the content to CX register to two memories from 2004.
Step12: End.
MNEMONICS:
MOV CX, 0000
MOV AX, [3000]ADD AX, [3004]
MOV [2000], AX
MOV AX, [3002]
SBB AX, [3006]
JNC loop1
INC CX
Loop1 MOV [2002], AX
MOV [2004], CX
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
143/254
143
TABLE: 2
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV CX,0000
Move immediately 0000H to CX
register
1004 MOV AX, [3000] Copy contents of 3000 to AX register
1008 ADD AX, [3004]Add content of memory 3004 with
content of AX register
100C MOV [2000], AXCopy content to AX register to two
memories from 2000
1010 MOV AX, [3002]Copy contents of memory 3002 to
AX register
1014 SBB AX, [3006]Subtract content of memory 3006
from content of AX register
1018 JNC loop1 Jump to specified memory CF=0
101A INC CXIncrement content of CX register
once
101B Loop1 MOV [2002], AXCopy content to AX register to two
memories from 2002
101F MOV [2004], CXCopy content to CX register to two
memories from 2004
1023 HLT Halt
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 9999 2000: 0000
3002: 9799 2002: FE00
3004: 9999
3006: 9999
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
144/254
144
RESULT:
Thus an assembly language program to add and subtract two 32-bit numbers
as written and executed using 8086 microprocessor kit.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
145/254
145
Ex. No: 2 16 BIT MULTIPLICATION AND DIVISION
AIM:
To write an assembly language program to multiply and divide twounsigned 16-bit numbers using 8086 microprocessor kit.
APPARATUS REQUIRED:
8086 Microprocessor Kit
Power Chord
Key Board
MULTIPLICATION:
ALGORITHM:
Step 1: Start the program.
Step2: Copy the contents of the memory 3000 to AX
register. Step3: Copy the contents of the memory 3002
to CX register.
Step4: Multiply the content of the CX register with the content of
accumulator. Step5: Copy the content to AX register to the memory
2000.
Step6: Copy the contents of DX register to the memory
2002. Step7: End.
MNEMONICS:
MOV AX, [3000]
MOV CX, [3002]
MUL CX
MOV [2000], AX
MOV [2002], DX
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
146/254
146
HLT
TABLE: 1
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV AX, [3000] Copy contents of 3000 to AX register
1004 MOV CX, [3002] Copy contents of 3002 to CX register
1008 MUL CX
Multiply the content of the CX
register
with the content of
accumulator
100A MOV [2000], AXCopy content to AX registerto the
memory 2000
100E MOV [2004], DX
Copy content to DX registerto the
memory 2002
1012 HLT Halt
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 1234 2000: 0060
3002: 5678 2002: 0626
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
147/254
147
DIVISION:
ALGORITHM:
Step 1: Start the program.
Step2: Copy the contents of the memory 3000 to AXregister. Step3: Copy the contents of the memory
3002 to CX register.
Step4: Divide the content of the CX register from the content of
accumulator. Step5: Copy the content to AX register to the memory
2000.
Step6: Copy the contents of DX register to the
memory 2002. Step7: End.
MNEMONICS:
MOV AX, [3000]
MOV CX, [3002]
DIV CX
MOV [2000], AX
MOV [2002], DX
HLT
TABLE: 2
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV AX, [3000] Copy contents of 3000 to AX register
1004 MOV CX, [3002] Copy contents of 3002 to CX register
1008 DIV CX
Divide thecontent of the CXregisterwith the content ofaccumulator
100A MOV [2000], AXCopy content to AX register to the
memory 2000
100E MOV [2004], DXCopy content to DX register to the
memory 2002
1012 HLT Halt
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
148/254
148
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 1234 2000: 0000
3002: 5678 2002: 4444
RESULT:
Thus an assembly language program to multiply and divide two
unsigned 16-bit numbers was written and executed using 8086
microprocessor kit.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
149/254
149
Ex. No: 3 FACTORIAL
AIM:
To write an assembly language program to calculate factorial of n-numbers using 8086 microprocessor kit.
APPARATUS REQUIRED:
8086 Microprocessor Kit
Power Chord
Key Board
ALGORITHM:
Step 1: Start the program.
Step2: Move immediately the number 0000H to AX
register. Step3: Copy the contents of the memory 3000
to CX register. Step4: Move immediately the number
0001H to AX register.
Step5: Multiply the content of the CX register with the content of
accumulator. Step6: Decrement the content of CX register once.
Step7: Jump to specified memory location if there is no zero in CX
register. Step8: Copy the content to AX register to two memories
from 2000. Step10: End.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
150/254
150
MNEMONICS:
MOV AX, 0001
MOV CX, [3000]
MOV AX, 0001
Loop1 MUL CX
DEC CX
JNZ loop1
MOV [2000], AX
HLT
TABLE: 1
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV AX, 0001Move immediately the number
0001H to AX register
1004 MOV CX, [3000]Copy the contents of memory 3000 to
CX register
1006 MOV AX, 0001Move immediately the number
0000H to AX register
100A loop1 MUL CX
Multiply content of CX registerwithcontent ofaccumulator
100B DEC CXDecrement content of CX register
once
100C JNZ loop1Jump to specified memory location if
there is no zero in CX register
100E MOV [2000], AXCopy content to AX register to
memory 2000
1012 HLT Halt
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
151/254
151
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 0008 2000: 9d80
RESULT:
Thus an assembly language program to calculate factorial of n-
numbers was written and executed using 8086 microprocessor kit.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
152/254
152
Ex. No: 4 SORTING IN ASCENDING ORDER
AIM:
To write an assembly language program to sort n-numbers inascending order using 8086 microprocessor kit.
APPARATUS REQUIRED:
8086 Microprocessor Kit
Power Chord
Key Board
ALGORITHM:
Step 1: Start the program.
Step2: Load datas into the memory.
Step3: Set the conditions to sort n-numbers in ascending order.
Step4: Sort the n given numbers in ascending order.
Step5: Store the result in the memory.
Step6: Display the sorted result from memory.
Step7: End.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
153/254
153
MNEMONICS:
MOV BX, 2000
MOV CX, [BX]
MOV CH, CL
Loop2 INC BX
INC BX
MOV AX, [BX]
INC BX
INC BX
CMP AX, [BX]
JC loop1
MOV DX, [BX]
MOV [BX], AX
DEC BX
DEC BX
MOV [BX], DX
INC BX
INC BX
Loop1 DEC BX
DEC BX
DEC CL
JNZ loop2
MOV BX, 2000
MOV CH, CL
DEC CH
JNZ loop2
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
154/254
154
TABLE: 1
Memory LabelMnemonics Description
Instruction Operand
1000 MOV BX, 2000 Move2000 to BX register
1004 MOV CX, [BX] Move BX memory data to CX register1006 MOV CH, CL Move data from CL to CH
1008 Loop2 INC BX Increment BX register content once
1009 INC BX Increment BX register content once
100A MOV AX, [BX]Move BX memory data to AX
register
100C INC BX Increment BX register content once
100D INC BX Increment BX register content once
100E CMP AX, [BX]Compare AX register content and
BX memory
1011 JC loop1Jump to specified memory location
if carry is 1
1013 MOV DX, [BX]Move BX memory data to DX
register
1015 MOV [BX], AXMove data from AX register to BX
memory data
1017 DEC BX Decrement BX register content once
1018 DEC BX Decrement BX register content once
1019 MOV [BX], DXMove data from DX register to BX
memory data
101B INC BX Increment BX register content once
101C INC BX Increment BX register content once
101D Loop1 DEC BX Decrement BX register content once
101E DEC BX Decrement BX register content once
101F DEC CL Decrement CL register content once
1020 JNZ loop2Jump to specified memory location
if there is no zero in CX register
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
155/254
155
1022 MOV BX, 2000 Move2000 to BX register
1026 MOV CH, CL
Copy CL register data to CH
register
1028 DEC CH Decrement CH register content once
1029 JNZ loop2 Jump to specified memory location
if there is no zero in CX register
102B HLT Halt
OUTPUT:
INPUT DATA: OUTPUT DATA:
2000: 0004 2002: 0001
2002: 0003 2004: 0002
2004: 0005 2006: 0003
2006: 0004 2008: 0004
2008: 0002 200A: 0005
200A: 0001
RESULT:
Thus an assembly language program to sort n-numbers in ascending
order was written and executed using 8086 microprocessor kit.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
156/254
156
Ex. No: 5 SOLVING AN EXPRESSION
AIM:
To write an assembly language program for solving an expressionusing 8086 microprocessor kit.
APPARATUS REQUIRED:
8086 Microprocessor Kit
Power Chord
Key Board
ALGORITHM:
Step 1: Start the program.
Step2: Load datas from memory to AX
register. Step3: Set the conditions to solve
an expression.
Step4: Solve the expression given below using the conditions
assumed. Step5: Store the result in the memory.
Step6: Display the sorted result from
memory. Step7: End.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
157/254
157
MNEMONICS:
MOV BX, [2000]
MUL AX
MOV BX, [2002]
MUL BX
MOV [3000], AX
MOV AX, [2000]
MOV BX, [2004]
MUL BX
ADD AX, [3000]
ADD AX, 0001
MOV [2006], AX
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
158/254
158
TABLE: 1
Memory LabelMnemonics
DescriptionInstruction Operand
1000 MOV AX, [2000]Move data from memory 2000 to
AX register
1004 MUL AX
Multiply content of AX register
with
content of AX register
1005 MOV BX, [2002]Move data from memory 2002 to
BX register
1009 MUL BX
Multiply content of BX registerwith
content of AX register
100A MOV [3000], AXCopy content to AX register to
memory 3000
100E MOV AX, [2000]Move data from memory 2000 to
AX register
1012 MOV BX, [2004]Move data from memory 2004 to
BX register
1016 MUL BX
Multiply content of BX register
with
content of AX register
1017 ADD AX, [3000]Add content of memory 3000 with
content of AX register
101B ADD AX, 0001Add the number 0001 to AX
register
101F MOV [2006], AXCopy content to AX register to
memory 2006
1023 HLT Halt
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
159/254
159
OUTPUT:
INPUT DATA: OUTPUT DATA:
2000: 0002 2006: 1F
2002: 0004
2004: 0007
RESULT:
Thus an assembly language program for solving an expression was
written and executed using 8086 microprocessor kit.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
160/254
160
Ex No: 6 SUM OF N NUMBERS IN AN ARRAY
AIM:
To write a program to find sum of n numbers in an array.
APPARATUS REQUIRED:
8085 Microprocessor Kit
Power Chord
ALGORITHM:
Step1: Start the program.
Step2: Initialize the counter.
Step3: Get the first number.
Step4: Decrement the
counter.
Step5: Load the base address of an array in to BX
Step6: By using the loop get the next number in to DX and add it with
AX. Step7: Increment the pointer and decrement the counter.
Step8: If the counter value is not equal to zero then go to
step6 Step9: Else store the result.
Step10:Stop the program.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
161/254
161
MNEMONICS:
MOV CL,[2000]
MOV AX,[2002]
DEC CL
XOR D1,D1
LEA BX,[2004]
LOOP1 MOV DX,[BX+D1]
ADD AX,BX
INC D1
INC D1
DEC CL
JNZ LOOP1
MOV [3000],AX
HLT
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
162/254
162
TABLE:
LABEL OPCODE OPERAND DESCRIPTION
MOV CL,[2000] Move the memory content to CL.
MOV AX,[2002] Move the memory content to AX
DEC CL Decrement the CL register.
XOR D1,D1 XOR,D1 registers
LEA BX,[2004] Move the content of 2004 to BX
MOV DX,[BX+DI] Move the content of BX+D1 to DX
ADD AX,BX Add AX with DX content.
INC DI Increment D1
INC DI Increment D1
DEC CL Decrement CL
LOOP 1 JNZ LOOP 1 If zero flag is reseted go to loop1
MOV [3000],AX Move the content to memory
location
HLT Halt
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
163/254
163
OUTPUT:
INPUT DATA: OUTPUT DATA:
2000:0003 3000:0006
2002:0002
2004:0003
2006:0001
RESULT:
Thus the sum of n numbers in an array has been done using 8086 microprocessor and the
output is verified.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
164/254
164
MODULE III
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
165/254
165
Unit III
Multiprocessor configurations
Coprocessor configuration closely coupled configuration Loosely coupled
configuration8087 Numeric data processorData typesArchitecture8089 I/O processor
ArchitectureCommunication between CPU and IOP.
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
166/254
166
Leaping as well as engrossing microprocessor
Day 19th
Microprocessor
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
167/254
167
Day 19
a) Bus contension:More than one processor shares the system memory and I/O devices through acommon system bus.
b) IPC:Interprocessor communication
c) Resource sharing:Deadlock may occur. If two processors unknowingly waiting for other processors.
Coprocessor configuration
Both the CPU and external (Coprocessor) Share entire memory and the I/O subsystem
ESCAPEMonitor
8086
Deactivate
TEST exec
Activate
TESTWait
Execute the
8086
COP
Call the
CPU COP
8086/888087
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
168/254
168
Check S6 if S6 = 0 then it is main processor. S6 = 1 then it is 8089 (I/O processor)
BHC/ S7 is zero then COP
i) Closely coupled configuration
ii) Loosely coupled configuration:It contains different modules.
Each mode may consists of an 8086.
8086
8087
Bus controllog.c
System
M
I/O
Clock
7/28/2019 Microprocessors and Microcontrollers Module 1 - 5[1]
169/254
169
Local
I/O
device
s
Local
Memory
Local Bus
Localbus
control
System bus
control log
8086 +
8087Clock
S
stem
bus
MODULE 1
Similarly Module 2
System
Memory
SystemI/O
7/28/2019 Microprocessors and Microcontroller