Microprocessors and Microcontrollers Module 1 - 5
Microprocessors and Microcontrollers Module 1 - 5
MODULE I
By
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.
This book is dedicated especially for student community who are my jewels By Y. SYED SHA MUHAMED
SYLLABUS UNIT I
DAY I
p Day - I
Hello ! if you want to become tyro to adept in Microprocessor you probe this book.
DAY 1
MICROPROCESSOR: Single Chip CPU. Processors has two giants (i) (II) Intel (8085, 8086 etc) Motorola (6800, 68000 etc)
Evolution:
1. 2. 3. 4. Intel 4004 (4 bit p) Intel 8085 and 8080 (8 bit p) Intel 8086 (16 bit p) SX Intel (802686) DX
SX 5. Intel (80386) DX 6. 7. 8. i) Intel (80486) Pentium III, IV etc Core Processor 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 bit processor. 5 V power supply needed. It can operates on 3MHz clock free 8085A on 5MHz
6
AD0 AD7
It has the following addresses modes i) ii) iii) iv) v) Immediate Register Direct Indirect Implied
Arithmetic:
i) ii) iii) iv) 8 bit binary addition (with carry) 16 bit binary addition 8 bit binary subtraction (with borrow) AND, OR, X-OR, Complement (NOT) and Shift operation
RESULT ANALYSIS
III) Objectives question carries / mark for every questions 8 10 Marks Excellent < 8 Poor 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.
10
DAY II
p Day - II
If you want to become meticulous with acumen in Microprocessor read Day II.
11
DAY II (INTROD)
8085 has i) ii) iii) Accumulator (8 bit) 6 GPR (8 bit each, BC, DE, HL) Two 16 bit register SP Stack Pointer PC Program 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 1) 2) 3) Operand
Architecture of 8085:
8085 has following a functional blocks. 1) Registers. 2) ALU 3) Instruction decoded and machine cycle encoded 4) Address buffer 5) Address / Data buffer 6) Increment / Decrement Address latch 7) Interrupt control 8) Serial I/O control
12
OBJECTIVE QUESTIONS
1) Accumulator in 8085 has ___________? a) 8 bits a) 8 bits a) TRAP a) 003 C x a) 3 T a) 3 T a) 3 T b) 16 bits b) 16 bits b) RST 7.5 b) 0042 x b) 4 T b) 4 T b) 4 T
13
2) GPR B&D register are ___________? 3) Who is the brightest priority interrupt? 4) What is the address location of RST 6.5? 5) How many time cycles for OFC? 6) How many time cycle for memory read? 7) How many time cycle for memory write? 8) DMA has _________________ ?
a) Temporary storage
Answers:
1) a 2) a 3) a 4) a 5) b 6) a 7) a 8) a 9) a 10) a
RESULT ANALYSIS
8 10 Marks Excellent < 8 Poor If your score less than 8 repeat day 1. Otherwise go to Day 3
14
DAY III
p Day - III
If you want to bag with accolades in Microprocessor you better read day III.
15
INTA INTR
RST 5.5
RST 6.5
RST 7.5
Interrupt Control
Accumulator
Temporary register
Flag Register
Instruction Reg.
W B D
Z
C E L SP PC
ALU
Data bus X1
Clk In
X2
Clk Out
READY RD W
ALE
So S1 I/M
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 S D6 Z Zero 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 (A8 A15) V) Address / Data Buffer: 8 bit bidirectional buffer (ALE) D5 X D4 AC Auxillary Carry D3 X D2 P Parity D1 X D0 Cy Carry
17
D7 S
D6 Z
D5 X
D4 AC
D3 X
D2 P
D1 X
D0 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)
18
OBJECTIVES QUESTIONS
1) HL is what type register? a) GPR a) GPR b) Special purpose register b) Temporary register b) w, z b) 16 bit b) AND, X-OR 2) w, z is what type register? 3) Following is Special purpose register? a) Accumulator a) 8 bit a) ADD 4) SP, PC are what type register? 5) Following are the logical operations? 6) What are the address lines for address buffer? a) AD0 AD7 (bidirectional)ii) A8 A15 (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
19
DAY IV
p Day - IV
20
DAY 4
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) ii) iii) STATUS DMA RESET
X1 X2 Reset SOD SID TRAP RST 7.5 RST 6.5 RST 5.5 INR INTA AD0
1 2 3 4 5 6 7 8 9 10 11 12
8085 A
40 39 38 37 36 35 34 33 32 31 30 29 28
19 20 AD7 VSS
21 A0
21
Essay Questions:
Explain the architecture of 8085? Answer: Say the functional blocks with diagram.
22
DAY V
p Day - V
23
DAY 5
Instruction formats:
i) One Byte:
PUSH
OPCODE
Operand
ADD B
iii)
Addressing Modes
Immediate
Register
Direct
Indirect
Implied
i)
I Must Coon
Destination
24
ii)
MOV
A, B
Source
Destination
iv)
v)
25
Instruction address
PUSH POP
ESSAY QUESTIONS:
1) Discuss the different addressing modes in 8085? Answer: i) Immediate ii) Register iii) Direct iv) Indirect v) Implied
26
OBJECTIVES QUESTIONS
i) ii) iii) iv) v) vi) PUSH is ___________ Address instruction a) Zero a) Zero a) One a) Register a) Register Register b) One b) One b) Two b) Data b) Register Memory SUB A is ___________ Address instruction ADD A, B is _______ Address instruction In immediate address mode contains register and ___________ (source) MOV B, C is ___________ addressing mode The difference between direct and indirect is ___________ a) Direct is content of indirect is content of content b) Indirect is content of direct is content of content
RESULT ANALYSIS
Answer:
1) a 2) b 3) b 4) b 5) a 6) a
27
p Day - VI
28
DAY - 6
Instruction Set
Data Transfer 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
Arithmetic 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
Logic 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 r CMP M CPI data STC CMC CMA
PCHL
29
Interrupt EI DT
I Data Transfer:
1) MVI A, 08 2 byte instruction 4T 3T 7 Time cycles. Immediate addressing mode. 2) MVI M, 4OH (H L Pair) H F 20 2010 L = 10 Note: (Within GPR no need of MR, MW 3 time cycles) H or OF (opcode fetch) MR (data)
40
OF MR MW
OFC 4) MOV M, B
4T 4T
TOTAL -
(H = 20)
(L) = 50
2050
10
OF 4T 5) MOV C,M
+ +
MW 3T
= = 7T
H = 20 L = 50 2050 15
15
OF 4T
+ +
MR 3T = 7T
10
20
OF
4T
= 10 T 7) STA 2000 H
10
2000
15
15
2500 2501
20 30
MR
MR
MW
MW
32
(H) 3T
(L) 3T
2500 3T
2501 3T
= 16 T
= +
20 MW 3T
+ +
(2501 ) (H) MW 3T
= 30 + MR 3T + MR 3T
= 16 T
11) STAX B
A = 10
10
12) LDAX B
15
Small Program:
1) Store 16 bin in location 3000 is Answer: MVI A, 16 H,
33
STA HLT (example for direct address) Another method: LXI MVI HLT
3000 H
H, 3000 H M, 16 H
34
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 STA HLT 3) Swap the content of location 2000 and 5000 in indirect address? 2000 H 5000 H MOV A,B
35
p Day - VII
36
DAY VII
Arithmetic Group:
In 8085 it has only ADD & SUBTRACT. 1) ADD B A (A) + (B) OF 4T 2) ADD M A (A) + (M) OF 4T MR 3T = 7T M=H H (20) L Pair L (10) (B) source destination A is implied
2010
15
10
A 25
3) ADI
08H
A (A) + 08 OF MR = 7T 4T 3T 4) ADC B A (A) + (cy) + (B) OF 4T 5) ADC M A (A) + (cy) + (M) HL OF 4T MR 3T = 7T 6) ACI 20 H
37
A (A) + (cy) + 20 HL = OF + data read = 4T + 3T = 7 T 7) DAD B Double Add (HL) (H) (L) + (B) (C) Result H L +
Similarly Subtract:
1) SUB A (A) (B) OF 4 T 2) SUB M A (A) (M) OF 4T MR 3T = 3) SUI A (A) 08 OF / 4T + Data Read (3T) 4) SBB OF = 4T 5) SBB M A (A) (M) cy OF 4T 6) SBI data read 3T = 7T 08
38
7T
08H = 7T
A (A) (B) cy
A (A) 08 cy OF + data read 4T + 3T = 7T 7) DAA (Decimal Adjust Accumulator) A = 0100 DAA 0100 1010 0000 0110 0101 0000 AD = 50 (BCD) 1010 = 4 A
= 10 T
20
11
= 6T 4) DCR B
39
(B) 4T
(B) 1
6T
40
41
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 location 5002. Answer: LXI INX INX HLT 4) Write a program to subtract two 8 bit numbers? Answer: LXI INX SUB INX HLT 5) Add two 16 bit numbers? Answer: LHLD 5000 XCHG LHLD 5002 DAD D
42
3 Decrement
3) Write a program Add two 8 Bit numbers? 5000 Location 5001 Location Add shot in
H, H H
5000 H
OH H M H
5000
MOV A, M
MOV M, A
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
43
p Day - VIII
44
DAY 8
IV Branch Group
(i) JMP 2000 OF + MR + MR 4T + 3T + 3T ii) a) JC 2000 b) JNC c) JP d)JM e) JPE f) JZ g) JNZ iii) PCHL PC HL 6T A B 2000 2000 2000 2000 2000 2000 PC 2000 is assigned to PC (Program Counter) = 10 T
jump if carry = 1 at loc 2000 jump if carry = 0 at loc 2000 jump on possible at loc 2000 jump on Minus at loc 2000 jump on parity odd at loc 2000 jump on zero at loc 2000 jump on not zero at loc 2000
AND
Clamp
45
Application: Maskid (ii) 7T (iii) 7T (iv) 4T Clear Accumulator Or gate: B XRA AAXA A ANI A A X 60 60 ANA O A X (M) M
10100000
46
(v)
XRA AA +M 7T
(vi)
XRI A A + 40 7T
40
(vii) ORA A AAVA 4T (viii) AAVM 7T (ix) ORI 7T A A V 10 V (x) CMP AAB 4T (xi) 7T A A (HL) (xii) CPI 7T (xiii) STC Set carry = 1 Cy 1 (4T) (xiv) (xv) CMC Complement Carry (4 T) CMA Complement Accumulator (4 T) 10 (Compare immedial with data 10) A A 10 CMP M B (Compare B) 10 ORA M
47
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.
48
If your score is 8 (or) more you are excellent. If less than 8 please repeat Day 8.
49
p Day - IX
50
DAY 9
V) Rotate group i) R L C Rotate Accumulator left where B7 goes to carry and B0
B7
B0
cy
B7
B0 cy
51
B7 cy
B0
iv) R A R: B7 4T B0 cy
4T
Programs:
i) Computer 1s complement of 54 in 1000 left loc? Answer: LDA 1000 CMA STA HLT 1000
52
10
20
Sp - 2 Sp - 1 Sp
20 10
ii)
E D iii) CALL pc
2000 H 2000 H
20 10
53
Call on carry = 1 C N C 2000 call on no carry similarly return v) vi ) vii) RC RST RST RST RST RST viii) I/O: a) b) ix) IN OUT 80 H return on carry r 0 5.5 6.5 7.5
80 H (device no) to Accumulator 50 H Acc 50 H (device) X T H L: Change top of stack with H L L <sp> H <sp + 1> x) i) E I: F F: ii) iii) iv) Hales
54
v)
1 6.5 R S T 5.5
55
QUESTION ANSWERS
Two marks:
1) What is R L C? Answer: B7 B0
cy
2)
What R A L? B7 cy B0
3) 4)
STACK definition? Stores left data and retriew left data by PUSH and POP operation. Explain Restart n ? Answer: RST n R S T 5.5 R S T 6.5 R S T 7.5 = = = 5.5 x 8 6.5 x 8 7.5 x 8 = = = 2 CH 3 CH 4 CH
56
5)
What are the port operation? Answer: Port mean carry a) b) IN 50H Acc 50 H OUT 50 H 50 H Acc
6)
Define E I and DI? Answer: i) ii) EI: Enable Interrupt FF 1 DI: Disable Interrupt FF 0
2) 3) 4) 5) 6) 7) 8) 9)
How initialize SP? i) LXI SP i) CALL What is CNC 2000? i) Call on carry a) 2 CH What is in port? a) (device no to accumulator) b) (Accumulator to device number) What is EI? i) FF 1 What is DI? i) FF 0 What is S I M? i) Set interrupt mask ii) Reset interrupt mask
57
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 Uncondition , EI, DT, STM, etc.
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.
58
p Day - X
59
DAY 10
Programs:
1) Shift right 8 bit data? Answer: MOV A,C RAR RAR RAR RAR MOV C, A HLT 2) 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 INX DCR JNZ STA HLT M H C Loop 3004
60
4)
Data Transfer (Block) MVI LXI LXI STA INX INX JNZ HLT C, H D X, D H D Loop 05H 2200 2300
Loop MOV A, M
DCR C
4)
Find number of negative numbers in block? Answer: MSB is 1 then negative LDA 3000 MOV C, A MVI LXI ANI JZ INR Ship INX JNZ STA HLT B, 00 H 3001 80 H Ship B H Loop 4000
Loop MOV A, M
61
62
Annexure
63
PROGRAMS FOR 8085 MICROPROCESSOR LEARNERS 1. Store 8-bit data in memory of 8085 microprocessor 2. Exchange the contents of memory locations in a 8085 microprocessor 3. Add two 8-bit numbers in a 8085 microprocessor 4. Subtract two 8-bit numbers in a 8085 microprocessor 5. Add two 16-bit numbers in a 8085 microprocessor 6. Add contents of two memory locations in a 8085 microprocessor 7. Subtract two 16-bit numbers in a 8085 microprocessor. 8. Finding one's complement of a number 9. Finding Two's complement of a number 10. Pack the unpacked BCD numbers 11. Unpack a BCD number 12. Execution format of instructions 13. Right shift bit of data 14. Left Shifting of a 16-bit data 15. 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 (4000H) = 14H
64
(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
65
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
66
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
67
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 ADD M :Add second operand
68
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
69
7. Sample problem: (4000H) = 19H (400IH) = 6AH (4004H) = I5H (4003H) = 5CH Result = 6A19H - 5C15H = OE04H (4004H) = 04H (4005H) = OEH
70
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
71
72
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
73
STA 4300H : Store the result HLT : Terminate program execution Flowchart
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 STA 4300H : Store the result
74
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 RRC : Adjust higher BCD digit as a lower digit
75
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 4003H 4006H 4009H 400CH LXI SP, 27FFH LXI H, 2000H LXI B, 1020H CALL SUB HLT
76
Subroutine program: 4100H 4101H 4102H 4105H 4108H 4109H 410CH 410DH 410EH C. Sample problem: (4200H) = 58 Result = (4300H) = 08 and (4301H) = 05 Source program 1:
SUB: PUSH B PUSH H LXI B, 4080H LXI H, 4090H SHLD 2200H DAD B POP H POP B RET
13. Statement: Write a program to shift an eight bit data four bits right. Assume data is in register
77
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
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
78
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<no2 ,then exchange no1 and no2. STEP 2:-no1=no1-no2; go to step 1 STEP 3:-Display result as no1. STEP 4:-Stop. ASSEMBLY PROGRAM:LXI H,8000H MOV A,M INX H MOV B,M L1: CMP B JZ OUT JC L2 SUB B JMP L1 L2 : MOV C,B MOV B,A MOV A,C JMP L1 OUT: STA 8003H HLT
79
29
80
81
82
MODULE II
83
SYLLABUS UNIT II
8086 SOFTWARE ASPECT:
Intel 8086 Microprocessor - Architecture
84
Day XI in Microprocessor
85
Day 11
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) ii) iii) 10 MHz 8 MHz 8 MHz 8086 1 8086 2 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.
86
Architecture of 8086
Memory Interface C - Bus
B - bus BIU ES CS SS DS IP
AX BX CX DX
AH BH CH DH
SP BP SI DI
AL BL CL DL
ALU
Operands Flags
87
Register organization:
(i) GPR
AX BX CX DX
AH BH CH DH
AL BL CL DL
(ii)
Segment Registers:
64 K
1 Mb Physical Memory
SS
64 K
DS
64 K
CS (iii) Pointers and Index Registers: IP points code segment BP points data segment SP Points stock segment
64 K
88
SI, DI used in addressing. SI Source Index DI Destination Index iv) 15 X 14 X Flag register: 13 X 12 X 11 O 10 D 9 I 8 T 7 S 6 Z 5 X 4
AC
3 X
2 P
1 X
0 cy
2) What is the clock frequency of 8086 -1 , 8086 2? Answer: 8086 1 8086 2 3) What is MIN Mode? Answer: In micro computer if only one 8086 microprocessor is there than min mode.
89
10 MHz 8 MHz
4) How many GPR define in 8086? Answer: 4 GPR AX, BX, CX, DX
90
5) IP, BP and SP points to which segment? Answer: IP BP SP points to code segment points to data segment points to stock segment
Objective Question
1) Which MOS technology in 8086? i) HMOS ii) CMOS
6) What is AX and AL? i) AX 16 bit AL 8 bit ii) AX 16 bit AL 16 bit 7) BP points __________ segment i) Code segment ii) Data segment
91
Result analysis
Answers:
1) i 2) i 3) ii 4) ii 5) ii 6) i 7) ii 8) ii
92
Day XII
93
DAY 12
Architecture continuation:
In 8086 it has two units i) Bus interface unit i) BIU: Interface with outer world The jobs of BIU is 1) Sends address of I/O and memory 2) Fetches instruction from memory 3) Reads data 4) Writes data 5) Executes instruction queue 6) 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. F + U + X + ST ii) Execution unit
BU
F1
F2
F3
U1
U2
etc
94
Direct
i) Direct Addressing: IP
2000
10
MOV AL,
[ 2000 H] 10,000
DS/Ppr
1000
10
2000
ii)
12,000
10
Content of content
DS
1000
10
10,000 BX 16 / 15
16 + CX 3000 H 13,000 15
95
iii)
DS
1000
BX
2000 13,500 + CX
20 10 2 0 2 0
CX
3000 H
1 0 1 0
96
97
Day 13
Addressing Mode 8086 4) Register relative addressing: MOV CX, [BX + 003 H]
10 20
51,003 BX 1000 + 3
SP / CX
10
20
5) Base relative plus index address MOV AL, [BX + SI + 10H] 22,010 BX 1000 2000 + SI 1000 AL 10 + 22,010 10
DS
2000
98
6) String Addresses mode: MOV S BYTE 7) I/O Ports accessing by address modes: i) Direct IN ii) Indirect IN AL, DX AX, 80 H
8) STACK Memory addressing mode: PUSH & POP Instruction set Here it is like 8086 by multiplication and division also instruction are available.
99
Instruction Set
Add Sub Compare ADD ADC INC SUB SBB DEC NEG CMP
String Compare
REP
M/C Control
STC
SHR SAR
MOVS CMPS
100
Data Transfer (8086) Day 17 i) ii) iii) iv) MOV BX, AX ( 5 addresses modes) implement it PUSH BX ( POP Copy BX to Stack)
XCHG BX, CX
I) Arithmetic instruction: i) ii) iii) iv) v) ADD AX, BX [ AX AX + BX ] ADC DX, BX, DX DX + BX + Cy INC BX
II) Subtract Instruction: i) ii) iii) iv) v) vi) SUB SBB DEC AX, BX [ AX AX BX] DX, BX [ DX DX BX Cy] BX
DAS (Decimal After Sub) AL = 0010 0011 CL = 0101 1000 1100 1011
101
III) Multiplication: i) MUL BX AX AX, BX ii) IMUL (signed byte) IMUL CX IV) DIVISION: i) DIV BX
AX AX / BX Quotient in AX remainder in BX IV ) Logical Instruction: (Prefer 8 bit data) i) NOT NOT ii) AND CX CL BX
XOR AL, BL
102
SHR:
0 1
. .... .
iv)
RCR: B Cy
Question Answers
Essay:
i) Explain the addressing modes in 8086?
103
Discuss Data Transfer instruction in 8086? Discuss Arithmetic and Logic instruction in 8086? Discuss about shift and rotate in 8086?
104
105
Day 14
Near i) CALL : Far CALL PRO ii) iii) Res return JMP: (Unconditional) JMP iv) NEXT Inter segment Intra segment
J (Condition)
2) INT
3) RET
106
2) MOV S
3) CMP BX, CX
Essay questions
1) Discuss about Jump, processor instruction, interrupt instruction and string instruction?
107
DAY XV
This book makes you as Man with meticulous awards (accolades) in microprocessor
108
DAY 15
Assembler Directives (Pseudo operations) 1) ALIGN 2) ASSUME ASSUME CS: Code Segment; 3) CODE 4) DATA DB BW DD DQ DT Eg: COST DB 10,20,30 Define byte Define word Define double word Define qued word Define Ten Bytes 8 (numbers)
Cost
10 20 50
5) DUP: Initialize TABLE 6) END 7) EQU 8) EXTRN 9) Groups: All segment of same data byte
109
BW
10
DUP
(0)
10) Label 11) MACRO END M 12) Name: Name of each module 13) OFF set: Displacement 14) ORG: ORG 15) PTR 16) PAGE [ length] [ width ] 17) Proc and End P 18) Public 19) Segment and End S 20) Short: Short address 21) STACK 22) TITLE: TITLE rent ALP : (Assembly Language Programs) Addition of two numbers NAME PAGE TITLE Model Small Stack 100 Data
110
1000
STACK [ SIZE]
DB DB
Result DW
iii)
iv)
v)
DUP ___________
111
a) Initialize b) duplicate vi) EQU is __________ a) Equate numeric b) Equate numeric and string
vii)
Result Analysis
1) a 2) b 3) b 4) b 5) a 6) b 7) b
112
DAY XVI
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) ii) iii) iv) i) Using registers Using general memory Using pointers Using stack
Parameter passing using register: Main Prog CS MOV AL, d1; : CALL PRO 1 : ; procedure PRO 1 MOV : RET
114
PROC INPUT ,
NEAR AL;
END P END
HEX _ VALUE DATA CS CALL Procedure PRO 1 MOV AL, PROC BCD, INPUT 42; PRO 1 END,
NEAR
iii) Passing parameter using pointers: BCD_INPUT DB : MOV SI, BCD _ INPUT MOV AL, [SI] iv) Passing parameters using array: BCD _ INPUT MOV AX, [BTR] DW 4209; MOV AX, OFFSET BCD_INPUT
115
RET
Call
Call
Cc
RET
Important
116
i) Passing parameters in Macro: INT LEA ii) Local iii) Global T HEY MACRO HEY
Essay questions:
1) Describe about procedure and parameter passing mechanism? 2) Describe about Macros and Parameter passing in macros?
117
Day XVII
118
Day 17
Please probe about 8086 expeditely
119
Day 17
Assembly language prog:
i) . IF . IF _ . . ELSE (Optional) : . END IF ii) WHILE _ END W . WHILE . END W iii) 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 signal ii) iii) By a special instruction in the program By the occurrence of some condition ELSE END IF (Condn)
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.
120
121
Interrupt (Vector) Pointer tabe. Type 0 : Type 1: Divide by zero interrupt Single step interrupt The single step mode, systems will execute one instruction and wait for further direction from user. Type 2 : Type 3 : Type 4 : NMI Break point Over flow
Software interrupts: TYPE 0 255 ; 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 Int A, Int 0 NMI INTR SINGLE STEP High
Lower
Answer: Special instruction 4) What are the hardware signal interrupt pin? Answer: i) ii) NMI INTR
Essay question:
1) Discuss about the interrupts and its priorites?
123
Day - 18
124
Day 18
MODES (8086)
Minimum
Maximum
I. 8086 Minimum mode: ((i) to (ii) Common Signals for Min and Max) i) AD0 AD15 ii) A16 / S3 A19 / S4 S3 0 0 1 1 S4 0 1 0 1 Register ES SS CS DS
iii)
B HE / S7 : (Bus High Enable) BHE 0 0 1 1 A0 0 1 0 1 Data accesses Word Upper byte from odd address Lower byte from even address NON
iv)
NMI
5Mhz
viii) Read ix) TEST: wait signal x) RD (o/p) xi) MN / MX (input) For min mode only xii) INTA (Min mode only) xiii) ALE: AD0 AD15 xiv) D EN : This signal informs the transceivers that the CPU is ready to send or receive data. xv) DR / R (Data transmit / receive) xvi) M / I O xvii) W R xviii)HOLD:
126
MAXIMUM MODE ONLY: 1) QS1 0 0 1 2 QS0 0 1 0 2 Status No operation First byte of an opcode Queue is empty Subsequent byte of an opcode
2)
S2 S1
S0
M/c Cycle Interrupt Ack I/O read I/O unit Halt Instruction fetch Memory read Memory unit inactive
0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1
and RQ
GT 0
127
128
129
130
131
132
133
134
135
136
137
138
139
140
PROGRAMMING
142
Ex. No: 1
AIM:
To write an assembly language program to add and subtract two 32-bit numbers 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.
MNEMONICS:
143
MOV CX, 0000 MOV AX, [3000] ADD AX, [3004] MOV [2000], AX MOV AX, [3002] ADC AX, [3006] JNC INC loop1 CX
Loop1 MOV [2002], AX MOV [2004], CX HLT TABLE: 1 Memory Label Mnemonics
Instruction Operand
Description Move immediately 0000H to CX register Copy contents of 3000 to AX register Add content of memory 3004 with content of AX register Copy content to AX register to two memories from 2000 Copy contents of memory 3002 to AX register Add content of memory 3006 with content of AX register Jump to specified memory CF=0 Increment content of CX register once Copy content to AX register to two memories from 2002 Copy content to CX register to two memories from 2004
144
MOV MOV ADD MOV MOV ADC JNC INC Loop1 MOV
CX,0000 AX, [3000] AX, [3004] [2000], AX AX, [3002] AX, [3006] loop1 CX [2002], AX
101F
MOV
[2004], CX
1023
HLT
Halt
OUTPUT: INPUT DATA: 3000: 3002: 3004: 3006: 9999 9999 9999 9999 OUTPUT DATA: 2000: 3332 2002: 3333 2004: 1
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 INC loop1 CX
146
Description Move immediately 0000H to CX register Copy contents of 3000 to AX register Add content of memory 3004 with content of AX register Copy content to AX register to two memories from 2000 Copy contents of memory 3002 to AX register Subtract content of memory 3006 from content of AX register Jump to specified memory CF=0 Increment content of CX register once Copy content to AX register to two memories from 2002 Copy content to CX register to two memories from 2004 Halt
1000 1004 1008 100C 1010 1014 1018 101A 101B 101F 1023 OUTPUT: INPUT DATA: 3000: 9999 3002: 9799 3004: 9999 3006: 9999
MOV MOV ADD MOV MOV SBB JNC INC Loop1 MOV MOV HLT
CX,0000 AX, [3000] AX, [3004] [2000], AX AX, [3002] AX, [3006] loop1 CX [2002], AX [2004], CX
147
RESULT: Thus an assembly language program to add and subtract two 32-bit numbers was written and executed using 8086 microprocessor kit.
148
Ex. No: 2
AIM:
To write an assembly language program to multiply and divide two unsigned 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 HLT
149
TABLE: 1 Memory Label 1000 1004 1008 MOV MOV MUL Mnemonics
Instruction Operand
Description Copy contents of 3000 to AX register Copy contents of 3002 to CX register Multiply the content of the CX register with the content of accumulator Copy content to AX register to the memory 2000 Copy content to DX register to the memory 2002 Halt
[2000], AX [2004], DX
OUTPUT: INPUT DATA: 3000: 3002: 1234 5678 OUTPUT DATA: 2000: 2002: 0060 0626
DIVISION:
150
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: 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 Label 1000 1004 1008 MOV MOV DIV Mnemonics
Instruction Operand
Description Copy contents of 3000 to AX register Copy contents of 3002 to CX register Divide the content of the CX register with the content of accumulator Copy content to AX register to the memory 2000 Copy content to DX register to the memory 2002 Halt
[2000], AX [2004], DX
151
OUTPUT: INPUT DATA: 3000: 3002: 1234 5678 OUTPUT DATA: 2000: 2002: 0000 4444
RESULT:
Thus an assembly language program to multiply and divide two unsigned 16-bit numbers was written and executed using 8086 microprocessor kit.
152
Ex. No: 3
AIM:
FACTORIAL
To write an assembly language program to calculate factorial of nnumbers 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.
MNEMONICS:
153
MOV AX, 0001 MOV CX, [3000] MOV AX, 0001 Loop1 MUL CX DEC CX JNZ HLT TABLE: 1 Mnemonics
Instruction Operand
loop1
MOV [2000], AX
0001H to AX register Copy the contents of memory 3000 to CX register Move immediately the number 0000H to AX register Multiply content of CX register with content of accumulator Decrement content of CX register once Jump to specified memory location if there is no zero in CX register Copy content to AX register to memory 2000 Halt
100A
loop1
MUL
CX
CX loop1 [2000], AX
154
OUTPUT:
INPUT DATA: OUTPUT DATA:
3000: 0008
2000: 9d80
RESULT:
Thus an assembly language program to calculate factorial of nnumbers was written and executed using 8086 microprocessor kit.
Ex. No: 4
155
AIM: To write an assembly language program to sort n-numbers in ascending 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.
MOV CX, [BX] MOV CH, CL Loop2 INC INC INC INC JC BX BX BX BX loop1
CMP AX, [BX] MOV DX, [BX] MOV [BX], AX DEC BX DEC BX MOV [BX], DX INC INC BX BX
Loop1 DEC BX DEC BX DEC CL JNZ loop2 MOV BX, 2000 MOV CH, CL DEC CH JNZ HLT loop2
157
TABLE: 1 Memory Label 1000 1004 1006 1008 1009 100A 100C 100D 100E 1011 1013 1015 1017 1018 1019 101B 101C 101D 101E 101F 1020 MOV MOV MOV Loop2 INC INC MOV INC INC CMP JC MOV MOV DEC DEC MOV INC INC Loop1 DEC DEC DEC JNZ Mnemonics
Instruction Operand
Description Move2000 to BX register Move BX memory data to CX register Move data from CL to CH Increment BX register content once Increment BX register content once Move BX memory data to AX register Increment BX register content once Increment BX register content once Compare AX register content and BX memory Jump to specified memory location if carry is 1 Move BX memory data to DX register Move data from AX register to BX memory data Decrement BX register content once Decrement BX register content once Move data from DX register to BX memory data Increment BX register content once Increment BX register content once Decrement BX register content once Decrement BX register content once Decrement CL register content once Jump to specified memory location if there is no zero in CX register
BX, 2000 CX, [BX] CH, CL BX BX AX, [BX] BX BX AX, [BX] loop1 DX, [BX] [BX], AX BX BX [BX], DX BX BX BX BX CL loop2
158
Move2000 to BX register Copy CL register data to CH register Decrement CH register content once Jump to specified memory location if there is no zero in CX register Halt
OUTPUT: INPUT DATA: 2000: 2002: 2004: 2006: 2008: 0004 0003 0005 0004 0002 OUTPUT DATA: 2002: 2004: 2006: 2008: 0001 0002 0003 0004
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.
Ex. No: 5
SOLVING AN EXPRESSION
159
AIM: To write an assembly language program for solving an expression using 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.
MNEMONICS:
160
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
TABLE: 1
161
Mnemonics
Instruction Operand
Description Move data from memory 2000 to AX register Multiply content of AX register with content of AX register Move data from memory 2002 to BX register Multiply content of BX register with content of AX register Copy content to AX register to memory 3000 Move data from memory 2000 to AX register Move data from memory 2004 to BX register Multiply content of BX register with content of AX register Add content of memory 3000 with content of AX register Add the number 0001 to AX register Copy content to AX register to memory 2006 Halt
AX, [2000]
1004 1005
MUL MOV
AX BX, [2002]
OUTPUT:
162
RESULT:
Thus an assembly language program for solving an expression was written and executed using 8086 microprocessor kit.
Ex No: 6
163
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.
164
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
165
TABLE: LABEL OPCODE MOV MOV DEC XOR LEA MOV ADD INC INC DEC LOOP 1 JNZ MOV HLT OPERAND CL,[2000] AX,[2002] CL D1,D1 BX,[2004] DX,[BX+DI] AX,BX DI DI CL LOOP 1 [3000],AX DESCRIPTION Move the memory content to CL. Move the memory content to AX Decrement the CL register. XOR,D1 registers Move the content of 2004 to BX Move the content of BX+D1 to DX Add AX with DX content. Increment D1 Increment D1 Decrement CL If zero flag is reseted go to loop1 Move the content to memory location Halt
166
OUTPUT: INPUT DATA: 2000:0003 2002:0002 2004:0003 2006:0001 OUTPUT DATA: 3000:0006
RESULT: Thus the sum of n numbers in an array has been done using 8086 microprocessor and the output is verified.
167
MODULE III
168
Unit III
Multiprocessor configurations
Coprocessor configuration closely coupled configuration Loosely coupled configuration 8087 Numeric data processor Data types Architecture 8089 I/O processor Architecture Communication between CPU and IOP.
169
170
Day 19
a) Bus contension: More than one processor shares the system memory and I/O devices through a common 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 8086/88 Call the 8087
COP ESCAP E
Monitor 8086
Wait
CPU
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
8086
Clock
Bus control
log.c
System
8087
I/O
ii)
Loosely coupled configuration: It contains different modules. Each mode may consists of an 8086.
172
Local Memory
System Memory
System bus
Local Bus
Clock
8086 + 8087
MODULE 1
Similarly Module 2
173
Essay Questions:
1) Explain about mechanism of coprocessor and its configurations.
174
Day 20 in Microprocessor
175
Day 20
In loosely coupled system each processor runs independently. If more than one processor by to access these common resources at same time there is problem of bus contention. To set out of this head ache. There are i) ii) iii) Daisy chaining Polling method Independent request.
i) Daily chaining:
Bus was requested. If bus is granted bus busy will be set. So other masters have to wait Module 1
Bus access
Module 2
Bus access
Module m .
Bus access
log c
log c
log c
Bus grant
Controller with generate the address for master. If 4 markers are there then 2 address lines 00 01 10 11 Master 0 Master 1 Master 2 Master 3
176
M0
Module Address
M1
M2
M3
0 Controller 0
Bus request Bus busy
0 1
1 1
Master 2
Bus access
Master 3 .
Bus access
log c
Bus grant 1 Bus request 1 Bus grant 2 Bus request 2
log c
log c
Controller
177
Architecture of 8087
8 Register Stack
TAG reg TAG (0) (1) (2) (3) (4) (5) (6) (7)
U S0, Q S1
Operand pointer
178
Control Register:
DIV by zero, interrupt TAG Data is there or not Data formats and conversion * * * * * * * Word integer 2 byte Shot integer 4 byte Long integer 8 byte Packed DCD 10 byte Short read Long read 4 byte 8 byte
179
180
Day 21 in Microprocessor
181
DAY 21
I/O Processor:
I/O is the mechanism of transferring data with I/O ports. The execution of I/O handled by microprocessor.
Memory
8251 USAR T
CPU
8255 PPI
182
Memory
8272 Data and Intn Data 8089 IOP
8086 p
Data 8255
Finally
8089
Memory
8086
183
DRQ2
EXT2 GA GB GC TP PP
STNTRL
RESET
CA
TA G
Channel 1
GA GB GC
CCP
TP PP
IX BC MC CC
AL U
IX BC MC CC
PSW
PSW
CLK
Ready
184
Pointers points address. Tag says the pointer has got info or not. But GA, GB, GC, IX, MC can be used as GPR to do arithmetic and logic operation and also it does DMA.
PSO:
Current status of the channel
185
Essay Questions
I. II. Explain completely above I/O processor? Explain completely about IOP communication mechanism?
187
6. GA and GB are used for _____________ i) General purpose register ii) Interrupts
7) MC is _______________ i) Compiler i) 8251 ii) mask comperator ii) 8237 8) DMA number is __________ 9) Task pointer contains address of __________________ i) Current instruction ii) next instruction 10) PP is _____________ i) address of parameter block ii) Address of ISR 11) PSW says ________________ i) Interrupt status ii) Current status of channel
188
MODULE IV
189
190
Day 22 in Microprocessor
If you want to explore the nexus with microprocessor you read and complete module
191
Day 22
Memory & I/O interfacing Port means carry
Trans means across by coining the above two words transport word was created. Similarly in computer from one microprocessor to I/O or memory to interconnect we should have port. Using the port pins we can transmits (or) receive data from one microprocessor to another I/O (or) memory. So the concept of port is happening through transmit and receive data by the port command out (port) and in (port). The interfacing mechanism is i) ii) Serial communication interface Parallel communication interface
First I will just pass the light on memory interface. From memory we can read and write into the memory. Memory is combination of registers which were selected by addressing. Memory is bifurcated into RAM & ROM.
i)
ROM: eg EPROM
Consider 2 K EPROM: Here only we can read to. O/P data
O/P Buffer
CS RD
A10
Internal Decode
2 K EPROM
A0
192
A10.A0 = 11 address lines 10 address line will map 210 = 1 K EPROM 11 address line map 211 = 210 x 2 = 2 K EPROM
ii)
FOR RAM:
O/P Buffer
CS RD
Internal Decode
A0
1 K EPROM
A9
I/P Buffer
WR
I/P data A0 A9 = 1 K RAM For write (or) Read memory interfacing. So we need address decoding technique (i) (ii) Absolute decoding Linear decoding
i) Absolute decoding:
After addressing remaining address line is meant for chip select. Eg: Interface 1 K RAM, 2 K EPROM with 8085: For 2 K EPROM and 1 K RAM
193
A0 A10 A0 A9
RD WR
74S138
IO / M
I OR I OW MR MW
Vcc
CS
A13 A14 A15 74LS138 is low power shottkey 74LS138 Decoder n input 2n O/P
CS
G2
A12
G2
A11
194
Linear decoding:
Higher address line only used for addressing (A15) For 1K EPROM and 4K RAN interface with 8085 by linear decoding. L A T C H
AD0 AD7 D0 D7
IO/M A B C
G1 G2
A15 So address mapping for 1k EPROM A15 Starting Ending Address 0 A14 0 A13 0 A12 0 A11 0 A10 0 A9 0 A8 0 A7 0 A6 0 A5 0 A4 0 A3 0 A2 0 A1 0 A0 0 0000 0 X X X 0 0 1 1 1 1 1 1 1 1 1 1 03FF Similarly 4k RAM
195
0 8000
1 9 F F FH
Essay questions
I) Interface 8085 p with 4k RAM using linear decoding technique.
196
Day 23
I/O Interfacing
197
I/O interfacing
Actually for I/O is the communication between p and I/O. For the input keyboard to port to Data lines. Similarly for output, data lines to port than port to display devices The mechanism of read is kbd Similarly the O/P port is latch I/P port Tri-state buffer to 8085 p
198
i) I/O Mapped I/O: It uses IO/M pins the mechanism of input port it,
A0 A1 A2 A4 A6 A3
IOR
A7
199
D0 From 8085
D0 . D7
O/P port
A0 A1 A2 A4 A6 A3
Y1
A7 Now we will see If IOR, IOW is selected. It is I/O we can mapped with I/O port. If MEMR, MEW is selected.
IO/M WR IO/ W
It is memory we can mapped with I/O port. The first one we say I/O mapped I/O. The Second one is memory mapped I/O.
200
R 8085 P D0 I0 . . .
IOR RD IOW 5V W R D7 I7
IO/M
A0 A1 A2 A4 A6 A3 D E C O D E R Y0 O/P Port O0 . . .
Y1 O7
A7
5V In memory mapped I/O Address lines are A0 A15 Memory Mapped I/O
R 8085 P D0 I0 . . .
I7
MEMR RD MEM W 5V W R D7
IO/M
Y1 O7
A8 . . . . A15
202
kbd
to 8085 p
ii)
Ans: Watch Essay questions i) Explain I/O mapped I/O in interfacing of 8085? ii) iii) Explain memory mapped I/O in interfacing of 8085? Explain the mechanism of Input port and output port?
203
204
Day 24
Parallel communication interface:
8255 (Programmable peripheral Interface) Designed by intel. It has i) ii) iii) iv) Port A Port B Port C (Upper) Port C (Lower)
TTL Combatable (Just like junction box) It has i) ii) iii) iv) v) vi) vii) viii) ix) D0 D7 Data bus PA0 PA7 (Port A) PB0 PB7 (Port B) PC0 PC7 (Port C)
RD
WR CS
205
A3 A2 A1 PA
0
A4 A5 A6 PA
7
RD C S GND A1 A0 PC
7
W R
D0
Rese t
D1 D2
D3 D4 D5 D6 D7 Vcc B7 B6 B5 PB PB
3 4
PC
6
C5 C4
PC
0
PC
1
PC
2
PC PB
0 3
B1 B2
206
A1 0 0 1 0 0 1 1
A0 0 1 0 0 1 0 1
RD
WR
CS
0 0 0 1 1 1 1
1 1 1 0 0 0 0
0 0 0 0 0 0 0
RD
Functions = 0 to 1
Port A to bus Port B to bus Port C to bus Bus to Port A Bus to Port B Bus to Port C Bus to CWR (Control Word Register)
So the block diagram is FABULOUS BLOCK DIAGRAM OF 8255 Group A Control PA0-A7 Group A PCU Data Bus Buffer PC7PC4 PC0PC3 PB0PB7
Port A
PCL
Group B
Group B Control RD WR A0 A1
Reset
PBL
The group A and Group B control blocks receives control words from CPU and issues appropriate commands to the ports associated with it.
1) What are the ports in 8255? Ans: i) ii) iii) iv) Port A Port B Port C upper Port C lower
2) What is the use of A0 and A1 in 8255? Ans: RD, write control inputs
Essay questions:
1) Explain the pin and block diagram of 8255?
208
209
Day 25
Operation Modes
I) BSR Mode:
Set and reset port C by the mode. II) I/O Modes: i) ii) iii) Mode 0 : Simple I/O: Port A, Port B, Simple 8 bit I/O port Mode 1 : I/O will hand shake Mode 2 : Bidirectional I/O data transfer
BSR
For I/O
i) BSR: CWF 0 D6 X X Here port C will be activated D5 X D4 D3 D2 D1 D0 Bit set = 1 Reset = 0 Bit select
210
D6
D5
D4
D3
D2
D1
D0
PC0 P1
1 = Input 0 = Output
Interfacing 8255 in I/O mapped I/O with 8085: CWR has A1 0 0 1 1 A0 0 1 0 1 Port A Port B Port C Control register
211
D0-D7 A0 A1 IO R IO W Reset A7 A6 A5 A4 A3 A2 Interfacing 8255 in memory mapped I/O with 8085: D0-D7 A0 A1 MR M W Reset A7 . . . . . . A2 8255 8255
PA
PB
PC
CS
PA
PB
PC
CS
212
Solution: D6 1 So MVI OUT Essay questions: 1) Discuss I/O interfacing 8255 with 8085? Ans: I/O mapped I/O Memory mapped I/O A, 0 D5 0 83 H 83 H 83 D4 0 D3 0 D2 0 D1 1 D0 1
213
214
Day 26 & 27
The timer 8253 / 54 The generation of accurate time delays under software control. The timer will count the delay and interrupt CPU when the task was completed. 8253 8254 ( 0 to 2.6 MHz) (N Mos) (0 to 10 MHz) (H Mos)
Block diagram:
D0-D7
Counter 0
RD W A0 A1 C
Counter 1
Counter 2 CWR
215
80 Pin diagram is
D7 D6 D5 D4 D3 D2 D1 D0 Clk 0 OUT 1 GATE 0 GND Vcc WR
8254
Using the address lines A1 0 0 1 1 Operation modes: Note will be in annexure Interfacing 8254 with 8085 I/O Mapped I/O A0 0 1 0 1 Counter 0 Counter 1 Counter 2 CWR
216
D0 D7
Clk 0 GATE 0
8085 A0 A1
8254
IOR
RD WR
IOW
A2 A3 A4 A5 A6 A7
217
D0 D7
8085
MR
RD WR
MW A2
. . . . .
CS
A15 Interfacing 8254 with 8086 I/O Mapped I/O: Similarly 8085 interfacing Interfacing 8254 with 8086 Memory Mapped I/O: Address lines for chip select A3 to A19
218
Essay questions:
1) Draw and explain the block diagram of 8254? 2) Explain interfacing of 8254 with 8085 in I/O mapped I/O and memory mapped I/O? 3) Explain interfacing of 8254 with 8086 in I/O Mapped I/O and memory mapped I/O?
Objective questions:
1) The following is programmable interval times i) 555 ii) 8254 ii) DMA ii) 0 to 10 MHz ii) 0 to 10 MHz ii) NMOS ii) HMOS ii) A1A0 = 1 1 2) 8254 does ________ i) Accurate time delays 3) Clock frequency of 8253 ________ i) 0 to 2.6 MHz i) 0 to 2.6 MHz 5) 8253 is _______ i) CMOS 6) 8254 is _________ i) CMOS i) A1 A0 = 0 0 7) Address lines to select CWR 4) Clock frequency of 8254 __________
RESULT ANALYSIS
Answer: 1) ii 2) i 3) i 4) ii 5) ii 6) ii 7) ii
219
220
Day 28
Keyboard
When key is pressed 5 +v
Log <1
Log <1
221
C3
C2
C1
C0
R3 I/P Port A R2 R1 R0
f g
e d
They are two types i) Common Anode type ii) Common Cathode type
222
Common Anode:
Vcc
Common Cathode:
A B C D E F G
Multiplexed Display:
We need port A and Port B also
223
a b c d e f g Segment Bus
Q4 Output Port B
Q3
Q2
Q1 5V
224
SHIFT CNTL RL0-L7 RD 8279 WR S0S5 A0A5 INT B0B5 CS Return lines
A7 . . . . A1 Interfacing 8279 in I/O Mapped I/O with 8086: A2.A15 Address lines
225
Vcc
Vss Major functional groups are CPU interface Key data Display data Seen
226
CS
A1 . . . . A15 8086 Interfacing 8279 in Memory Mapped I/O: A2.A19 Address lines Similarly like 8085 interfacing
227
228
229
Day 29
Interrupt Controller (8259 A)
By connecting such a device it is possible to increase the interrupt handling capacity of the microprocessor. AD0 Microprocessor 8085 D0 8259 A IR0 1 2 3 4 5 6 7
AD7
INTA INTA
D7
INTA
Block Diagram:
It has eight blocks i) ii) iii) iv) v) vi) Data bus buffer R/W logic Control logic IRR, ISR and IMR Priority resolver Cascade buffer
230
INT
INTERNAL
RD WR A0
R/W Logic
Priority Resolver
BUS
IRR:
To store all the interrupt levels which are requesting the service.
ISR:
Store all the levels that are currently being serviced. ii) 8259 interfacing with 8086: same as 8086. Address line A4A15
231
8259
D7 . . D0
Priority Resolver:
Highest priority interrupt is set in ISR during the INTA input cascade buffer. Cascading 8259 A interfacing
232
i) Interfacing with 8085: A7 . . A4 A3 A2 A1 IO/M 8085 Contro l bus RD WR INTR INTE D0 D1 Data bus D2 D3 D4 D5 D6 D7 CAS
2
5V 74LS138
Address bus
8259 A
IR0 . . IR7
CAS
0
CAS
1
233
IR00
. . . . .
IR1
8259 A
IR07 IR11
. . . . .
IR IR22
. .
8259 A
IR17 IR20
. . . .
. . . .
IR27
IR7
234
Essay questions
1) Explain about 8259? 2) Explain 8259 interfaces with 8085? 3) Cascade 2 priority resolver?
235
236
Day 30
DMA Controller (8257)
To transfer data microprocessor has to do following tasks i) To fetch the instruction ii) iii) To decode the instruction To execute the instruction
Address Latches
B Control bus B
HLD0
HOLD
DMA Controller HLD 0 IOR, IOW, MR, MW DREU DACK It has Channel each channel can be programmed individually TTL Clock
Peripheral Device
237
CH0
DRQ0 DACK0
R/W Logic
CH1
DRQ1 DACK1
CH2
DRQ2 DACK2
CH3
DRQ3 DACK3
Priority resolver
238
Interfacing 8257 to 8085 in I/O Mapped I/O: A0-A15 D0-D7 RD 8 WR 0 IO/M 8 5 Microprocessor Decoder IOR IOW MR MW
IOR IOW
Dev1
IOR IOW
Dev2
DRQ2 DACK2
IOR IOW
Dev3
DRQ3 DACK3
IOR IOW
A4 A5 A6 A7
CS
D0-D7 A0-A15
MASTER DMA
8085 Microprocessor
IOR IOW MR MW
SLAVE DMA
IOR IOW MR MW
240
QUESTION AND ANSWERS Essay Questions: I. II. III. IV. Explain 8257 with block diagram? Discuss in 8257 I/O Mapped I/O interfacing with 8085? Discuss in 8257 Memory Mapped I/O interfacing with 8085? Explain cascading of 8275?
241
MODULE V
242
Unit V
Architecture of 8051 Microcontroller Signals I/O Ports Memory Counters and timers Serial data I/O interrupts. Interfacing keyboard, LCD, ADC and DAC
243
It is single chip computer 4k ROM program area 128 x 8 RAM data area Event counters 2 x 16 bit 5 interrupts 8051 has Microprocessor + built in ROM, RAM + I/O devices + timers + counters Access time is less So 8051 contains i) ii) iii) iv) CPU Two kinds of memory (RAM and ROM) I/O ports Special function register and control logic
245
Architecture is
Register A
S.P
Latch 0 Buffer 0
Temp reg
Temp reg
. . .
PC Incrementer
. . .
ALU
PSW
Latch 3 Buffer 3
. . .
ALE
RSP
RAM
- - CPU
OSC
IR
SCON TH1 IE
TMJD TL0 TP
TCON TL1
246
Port 0
. .
Port 1
. .
I/O
Port 2
. .
I/O, A8-A15
Port 3
. .
e) Register set i) Accumulator ii) B register: GPR but not multiply (or) divide iii) PSW:
B7
B6
B5
B4
B3
B2
B1
B0
247
DPH
DL1
248
Day 32
II) Memory organization in 8051:
ROM/EPROM FFFF RAM
0000 RD WR
PSEN
Each memory is different addressing, control signals and function (Register B, SP, PSW, DPP, DPL)
P1
P0 8051
L A T C H
P3
PL
A8-A15
249
If freq = 1/12 freq If crystal frequency 12 MHz then clock frequency is 1 MHz. Serial port and their programming: 8051 Full duplex.
Mode 0:
8 bit transmitted
Mode 1:
10 bits transmitted Start + 8 bit + stop bits
Mode 2:
11 bits are transmitted Start + 8 data bit + programmable data bit + stop
Mode 3:
11 bits are transmitted Baudrade changes
ALE
WR
PORT 0
A0-A7
Data out
A0-A7
MOV X
250
VI Timers / Counters and their programming: 2 timer (Timer 0 & Timer 1) Timer is counting m/c cycles.
EA
ET2
ES
ET1
EX1
ET0
EX0
Reserved Enable serial port control bit Enable timer 1 Enable External interrupt Enable timer 0 Enable Internal interrupt 0 control bit
Prior 3:
I E0 TF0 IE1 TF1 RI+TI
Interrupt structure: 5 interrupt sources INTO and INT 1 level activated or transition activated.
251
0 IE0 INT0
TP0
IE1 INT1 1
Interrupt sources
TF1 T1 R1
252
RD WR
0803 Vcc
D0
8051 Port
Clk
D7
DAC:
V ref A1 A A A + 2 + 3 + ............... + 8 R ref 2 4 8 256
I0 =
A7
Rref
Vref
A8
V0
253
Interfacing kbd:
Return lines
8051
Scon lines
ADC:
MSD . . . .
Clk
Digital output
D0 . . . . . D7
ADC 0804
Analog output
V0
DAC 0808
254
D0
. .
V0 DAC 0808
8085
. .
D7
QUESTION AND ANSWERS Essay questions: 1) Explain the memory organization in 8051? 2) Explain I/O pins, ports and circuits in 8051? 3) Explain Timer / Counter in 8051? 4) Explain interrupt structure in 8051? 5) Explain interfacing kbd with 8051? 6) Explain interfacing DAC with 8051? 7) Explain interfacing ADC with 8051?
255
Day 33 in Microprocessor
8051 vibrates.
256
P 1.0 P 1.1 P 1.2 Port 1 P 1.3 P 1.4 P 1.5 P 1.6 P 1.7 RST P 3.0 P 3.1 P 3.2 Port 3 P 3.3 P 3.4 P 3.5 P 3.6 P 3.7 X1 X2 GND 8051
Vcc P 0.0 P 0.1 P 0.2 P 0.3 P 0.4 P 0.5 P 0.6 P 0.7 EA ALE PSEN P 2.7 P 2.6 P 2.5 P 2.4 P 2.3 P 2.2 P 2.1 P 2.0 Port 2 Port 0
a) CPU: ALU + A reg + B reg + PSW + SP + PC + DP + Special function register. On chip data memory and Register Bank: Internal RAM has: 1) Working register 2) Bit addressable 3) General purpose
257
7F
i) Working Register:
1F Bank 3 16 17 Bank 2 7F
0F Bank 1
08 07
R7 R6 R5
Bank 0
258
Essay questions:
I) Draw the architecture of 8051 and pin diagram?
Objective questions:
1) 8051 is program area _________ a) 2KROM a) 128 x 8 a) 4 b) 4kROM b) 256 x 8 b) 5 2) 8051s RAMs data area _________ 3) 8051 has __________ interrupts 4) Internal RAM i) working register ii) Data addressable memory 3) ______________ a) GPR a) 4 b) Instruction decoder b) 7 5) 8051 has ___________ ports
259