Professional Documents
Culture Documents
Architecture
and
Microprocessor
1
Computer Architecture
& Microprocessor
Session I
Number System
Conversions
Binary Operations
Code
Logic Gates
Boolean Algebra
Registers & Counters
Computer Languages
2
Computer Architecture
& Microprocessor
Number System
3
Computer Architecture
& Microprocessor
Has a base of 10
number X (base)position-1
Example :
49510 , 8410
4
Computer Architecture
& Microprocessor
Byte (8 - bits)
Example:
10102 , 11102
5
Computer Architecture
& Microprocessor
Has a base of 8
Example:
1238 , 4358
6
Computer Architecture
& Microprocessor
Has a base of 16
Example:
B3A116 , 98C16
7
Computer Architecture
Number System Table & Microprocessor
Example
16 540
16 33 -12
2-1
9
Computer Architecture
& Microprocessor
Example
To convert 21C
16 to its decimal equivalent
2 1 C
C X160 = 12 X 1 = 12
1 X161 = 1 X 16 = 16
2 X162 = 2 X 256= 512
540
10
Computer Architecture
& Microprocessor
Example
11
Computer Architecture
& Microprocessor
Example:
To find the decimal equivalent of 10112 :
12
Computer Architecture
& Microprocessor
Example
To convert 215 to its decimal equivalent
8
2 1 5
5 X 80 = 5 X 1 = 5
1 X 81 = 1 X 8 = 8
2 X 82 = 2 X 64= 128
141
13
Computer Architecture
& Microprocessor
9’s Complement
Example:
9 9
5 4
4 5
14
Computer Architecture
& Microprocessor
10’s Complement
Example:
15
Computer Architecture
& Microprocessor
Example
1 1 1
1 0 1
0 1 0
16
Computer Architecture
& Microprocessor
Example
17
Computer Architecture
& Microprocessor
Binary Subtraction
18
Computer Architecture
& Microprocessor
BCD
19
Computer Architecture
& Microprocessor
Gray Code
ASCII Codes
7 bit code
21
Computer Architecture
& Microprocessor
ASCII Codes
ASCII Code Character ASCII Code Character
00 NUL 11 DC1 (X-on)
01 SOH 12 DC2 (Tape)
02 STX 13 DC3 (X-off)
03 ETX 14 DC4
04 EOT 15 NAK
05 ENQ 16 SYN
06 ACK 17 ETB
07 BEL 18 CAN
08 BS 19 EM
09 HT 1A SUB
0A LF 1B ESC
0B VT 1C FS
0C FF 1D GS
0D CR 1E RS
0E S1 1F US
0F S0 20 SP
22
10 DLE 21 !
Computer Architecture
& Microprocessor
ASCII Code
ASCII Code Character ASCII Code Character
22 “ 32 2
23 # 33 3
24 $ 34 4
25 % 35 5
26 & 36 6
27 ‘ 37 7
28 ( 38 8
29 ) 39 9
2A * 3A :
2B + 3B ;
2C , 3C <
2D - 3D =
2E . 3E >
2F / 3F ?
30 0 40 @
31 1 41 A 23
Computer Architecture
& Microprocessor
ASCII Code Character ASCII Characters
42 B 56 V
43 C 57 W
44 D 58 X
45 E 59 Y
46 F 5A Z
47 G 5B [
48 H 5C \
49 I 5D ]
4A J 5E ^()
4B K 5F -()
4C L 61 a
4D M 62 b
4E N 63 c
4F O 64 d
50 P 65 e
51 Q 66 f
52 R 67 g
53 S 69 h
54 T 6A i
24
55 U 6B j
Computer Architecture
& Microprocessor
ASCII Code Character
6B k
6C l
6D m
6E n
6F o
70 p
71 q
72 r
73 s
74 t
75 u
76 v
77 w
78 x
79 y
7A z
7B {
7C |
7D }
7E ~
25
7F DEL
Computer Architecture
& Microprocessor
ASCII -8 Code
26
Computer Architecture
& Microprocessor
Logic Gates
I/P O/P
Truth Table
I/P 0/P
0 1
1 0
27
Computer Architecture
& Microprocessor
AND Gate
I/P1
O/P
I/P2
Truth Table
I/P1 I/P2 O/P
0 0 0
0 1 0
1 0 0
1 1 1
28
Computer Architecture
& Microprocessor
NAND Gate
I/P1
O/P
I/P2
Truth Table
I/P1 I/P2 O/P
0 0 1
0 1 1
1 0 1
1 1 0
29
Computer Architecture
& Microprocessor
OR Gate
I/P1
O/P
I/P2
Truth Table
30
Computer Architecture
& Microprocessor
NOR Gate
I/P1
O/P
I/P2
Truth Table
31
Computer Architecture
& Microprocessor
XOR Gate
I/P1
O/P
I/P2
Truth Table
32
Computer Architecture
& Microprocessor
XNOR Gate
I/P1
O/P
I/P2
Truth Table
33
Computer Architecture
& Microprocessor
Boolean Algebra
Types of operations
OR (+)
AND ( . )
NOT (- or ‘ )
34
Computer Architecture
& Microprocessor
Algebraic Theorems
OR Laws
• A+0=A
• A + 1 =1
• A+A=A
• A+A=1
AND Laws
• A.0=0
• A.1=A
• A.A=A
• A.A=0
35
Computer Architecture
& Microprocessor
Laws of Complementation
A=A
1=0
0=1
If A=0, then A =1
If A=1, then A=0
Commutative Laws
A+B=B+A
A .B = B .A
Associative Laws
(A + B) + C = A + (B + C) = A + B + C
(A.B).C = A.(B.C) = A.B.C
36
Computer Architecture
Distributive Laws
& Microprocessor
A . (B+C) = A .B + A .C
A + B.C = (A + B) . (A + C)
Other Expressions
A + AB = A
A . (A + B) = A
A + AB = A + B
A . (A + B) = AB
AB + AB = A
(A + B)(A + B) = A
AB + AC = (A + C) . (A + B)
(A + B) ( A + C) = AC + AB
AB + AC + BC = AB + AC
(A + B)(A + C)(B + C) = (A + B)(A + C)
37
Computer Architecture
& Microprocessor
Half Adder
AB CD
00 00
01 10
10 10
11 01
38
Computer Architecture
an bn cn sn
cn+1
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
39
Computer Architecture
& Microprocessor
7 Segment LED Display
40
Computer Architecture
& Microprocessor
41
Computer Architecture
INPUTS OUTPUT
X Y Z W A B C D E F G
L
E
0 0 0 0 0 1 1 1 1 1 1 0
G
1 0 0 0 1 0 1 1 0 0 0 0
A
2 0 0 1 0 1 1 0 1 1 0 1
L
3 0 0 1 1 1 1 1 1 0 0 1
4 0 1 0 0 0 1 1 0 0 1 1
D
5 0 1 0 1 1 0 1 1 0 1 1
I
6 0 1 1 0 1 0 1 1 1 1 1
G
7 0 1 1 1 1 1 1 0 0 0 0
I
8 1 0 0 0 1 1 1 1 1 1 1
T
9 1 0 0 1 1 1 1 1 0 1 1
S
1 0 1 0 1 0 0 1 1 1 1
E
1 0 1 1 1 0 0 1 1 1 1
R
1 1 0 0 1 0 0 1 1 1 1
R
1 1 0 1 1 0 0 1 1 1 1
O
1 1 1 0 1 0 0 1 1 1 1
R
1 1 1 1 1 0 0 1 1 1 1
42
Computer Architecture
& Microprocessor
TTL Circuit
43
Computer Architecture
& Microprocessor
Flip Flop
44
Computer Architecture
& Microprocessor
Registers
Group of flip-flops
Connected in parallel
Shift Register
Temporary storage
Types:
Serial-in, serial-out
Serial-in, parallel-out
Parallel in, serial-out
Parallel in, parallel out
45
Computer Architecture
& Microprocessor
Counters
Modulus of Counter
• Binary Counter
• Decade Counter
• Pre settable Counter
Binary Counter
CLK
Q J Q J Q J Q J
Q k Q k Q k Q k
3 2 1 0
46
Computer Architecture
& Microprocessor
Asynchronous
Types of Counters
Synchronous
Up Counter
Down Counter
Up-Down Counter
Controlled Counter
Ring Counter
47
Computer Architecture
& Microprocessor
Computer Languages
Machine Language
– 0 and 1
Assembly Language
– mnemonics
– assembler
48
Computer Architecture
& Microprocessor
Loader
Assembler Floppy Disk
Object Program
49
Computer Architecture
& Microprocessor
Source Code
Translator
50
Computer Architecture
& Microprocessor
- Slower
- faster
51
Session II
Microprocessor – an Introduction
General Architecture of Microprocessor
Memory
I/O
Architecture of 8085 Microprocessor
52
Computer Architecture
Microprocessor – An
& Microprocessor
Introduction
Programmable Logical device
Functionality
• manipulates data
• Controls timing of various operations
• communicates with peripherals
Applications
53
Computer Architecture
MPU
Architecture
- Logical design of microprocessor
Types of Operations
54
Microprocessor initiated
Computer Architecture
& Microprocessor
operations
Communications Operations
• Memory Read
• Memory Write
• I/O Read
• I/O Write
Steps involved
• Location Identification
• Transfer of data
• Providing Timing or synchronization signals
55
Computer Architecture
& Microprocessor
Requirement
Address Bus
• Unidirectional
• Arbitrary number – (commonly used 16)
• Capable of Addressing 2 n
Data Bus
• Bidirectional
• Decides the range of data being handled
• Determines the word length and the register size
56
Computer Architecture
& Microprocessor
Control Bus
Communication Process
To Read an instruction
57
Computer Architecture
Requirement
• Accumulator
• Flag Register
• General purpose Registers
• Program Counter
• Stack
58
Computer Architecture
& Microprocessor
(8085 Microprocessor)
Accumulator
Flag Register
59
Computer Architecture
& Microprocessor
Registers
60
Computer Architecture
& Microprocessor
Reset
• Program Counter is cleared
Interrupt
• Normal Execution interrupted to execute Service Routine
Ready
• Synchronizes MPU operations with Peripherals
Hold
• Peripherals takes Control of Buses
61
Computer Architecture
& Microprocessor
Memory
Stores Binary Values
Types
62
Computer Architecture
& Microprocessor
• Flip-flops
• Stored as Voltage
• MOS Transistor
• Stored as charges
• Faster
• Refreshing Circuit
63
Computer Architecture
& Microprocessor
ROM Memory
• Non Volatile
• Types: -
Masked ROM
PROM (Programmable Read Only Memory)
64
Computer Architecture
& Microprocessor
Memory Organization
A memory requires:
Memory Map
65
Computer Architecture
& Microprocessor
Size of Memory
• Number of Register
• R/W
Number of I/O lines
CS
Control Logic
A
D 110
D
110
A2 R
E
S 101
S
A1 100
D
E 011
A0 C
O 010
D
E 001
R
000
D7 D6 D5 D4 D3 D2 D1 D0
66
Computer Architecture
& Microprocessor
Input / Output
Methods of Communication
• Memory-Mapped I/O
67
Computer Architecture
& Microprocessor
• Memory-Mapped I/O
16 Address Lines
Memory Map is shared
68
Computer Architecture
& Microprocessor
Interfacing Devices
Tri-State Device
• 3 stages – logic 1, logic 0 and high impedance
Buffer
• Logic circuit which amplifies the current
Latch D Q D PR Q
• a D flip-flop
G Q CK
CLR
Q
• Types :-
Transparent Latch Positive Edge Triggered
69
Computer Architecture
& Microprocessor
Decoder
• Displays an output based on the combination
of input 2 to 4
Input Output
Decoder
2 to 4
Input Output
Encoder
Encoder
• Outputs a code based on the input
70
Computer Architecture
& Microprocessor
8085 Microprocessor
Features
• 8 bit
• Has 40 pins
• Multiplexed Address/ Data Bus
71
Computer Architecture
8085 & Microprocessor
X1 1 40 Vcc
PINOUT 2 39 HOLD
X2
RESET OUT 3 38 HLDA
SOD 4 37 CLK(OUT)
SID 5 36 RESET IN
TRAP 6 35 READY
RST 6.5 8 33 S1
RST 5.5 9 32 RD
INTR 10 31 WR
INTA 11 30 ALE
AD0 12 29 S0
14 28 A15
AD1
14 27 A14
AD2
15 26 A13
AD3
16 25
AD4 A12
17 24
AD5 A11
18 23
AD6 A10
19 22
AD7 A9
20 21 72
A8
Computer Architecture
+5V GND
8085 Signals & Microprocessor
TRAP A8
RST 7.5
Interrupts RST 6.5 AD7
& RST 5.5 Multiplexed
Address/Dat
Externally INTR
a Bus
Initiated AD0
Signals READY
ALE
HOLD
S0
RESET IN Control
S1
And
IO/M
External Signal INTA
RD Status Signals
Acknowledgement HLDA
WR
Address Bus
• UniDirectional
• 8 Higher Order Address Bus
• BiDirectional
• Bus Multiplexing
• Latching of Low - order Address Bus – ALE
74
Computer Architecture
& Microprocessor
RD (Read)
• Active low Control Signal
• Reads from Memory / IO
WR (Write)
• Active low Control Signal
• Writes to selected Memory / IO
75
Computer Architecture
A15 A15 & Microprocessor
A8 A8
ALE
AD7 EN A7
AD0 LATCH A0
D7
Data Bus
8085 D0
IO/M
MEMR
RD
WR MEMW
Control
Signals
IOR
IOW 76
Computer Architecture
& Microprocessor
IO/M
• High – IO Operation
• Low – Memory Operation
S1 and S0
• Status Signal – rarely used
• Identifies various operations
S1 So Desc.
0 0 HALT
0 1 WRITE
1 0 READ
1 1 FETCH
77
Computer Architecture
& Microprocessor
Power Supply and Clock Frequency
78
Computer Architecture
& Microprocessor
TRAP (Input)
• A non-maskable restart interrupt.
• highest priority of any interrupt.
79
Computer Architecture
& Microprocessor
HOLD
• Indicates a peripheral’s request to use address and data buses.
READY
• Delays microprocessor’s operation to work in pace with the
slow peripherals connected to it.
RESET IN
• Sets program counter to zero
• The buses are tri-stated and MPU is reset.
RESET OUT
• Indicates MPU is being reset
• Can be used to reset other devices.
80
Computer Architecture
& Microprocessor
Serial I/O Ports
SID (Input)
SOD (output)
81
RST 6.5 Computer Architecture
INTA TRAP SID SOD
INTR RST 5.5 RST 7.5
& Microprocessor
Interrupt Control Serial I/O Control
Temp Instruction
Accumulator Multiplexer
Reg. (8) Register (8)
(8)
W Temp. Reg. Z Temp. Reg.
R
Flag (5)
e
Flip-flops B Reg. C Reg. g
i
Reg. Select
D Reg. E Reg. s
Instruction t
Decoder e
Arithmetic and H Reg. L Reg.
Logic Unit r
Machine
Cycle Stack
(ALU) A
Encoding r
(8) Program Counter
r
a
y
Address Latch (16)
Timing and Control
X1 CLK Reset
GEN Control Status DMA Address Buffer Data Address
x2
Buffer (8)
RD WR ALE S0 S1 IO/M HLDA RESET OUT A15 – A8
Ready HOLD RESET IN
Address Bus AD7 – AD0
82
Address/Data Bus
Computer Architecture
& Microprocessor
Registers
A Arithmetic Operations
(Accumulato Logical Operations
r)
8 Bits
B C B & C combined to form 16
8 8 Bits Bits
Bits
D E D & E combined to form 16
8 8 Bits Bits
Bits
H L H & L combined to form 16
83
Computer Architecture
& Microprocessor
Flags
S Z AC P CY
D7 D6 D5 D4 D3 D2 D1 D0
Bus Timings
Example:
• To fetch a data 10101010 from a location
2005H
85
Computer Architecture
& Microprocessor
T1 T2 T3
CLK
High –Order
A15 – A8
Memory Address
Low -Order Memory
AD7 –AD0
Memory Address
Contents
ALE
IO/M
M
RD
86
Computer Architecture
& Microprocessor
Data Bus
Memory
B C
Instruction
ALU D E
Decoder
H L
Stack
Program Counter
Control
Logic
Address Bus
87
Computer Architecture
& Microprocessor
Instruction Set
• Entire group of instructions that determines what functions
the microprocessor can perform.
Parts of Instruction:
• Task to be performed – operation code (opcode)
• Data to be operated on – operand.
88
Computer Architecture
& Microprocessor
Classification
• Instruction Word Size
One-word or 1-byte instructions
Two-word or 2-byte instructions
• Functionality
Data transfer (copy) operations
Arithmetic operations
Logical operations
Branching operations
Machine-control operations.
89
Computer Architecture
& Microprocessor
ONE-BYTE INSTRUCTIONS
Example:
• MOV C,A
Both operand registers are specified.
• ADD B
The operand B is specified and the accumulator is
assumed.
• CMA
Accumulator is assumed to be the implicit operand
90
Computer Architecture
& Microprocessor
TWO-BYTE INSTRUCTIONS
• Uses two-bytes
First byte specifies the operation code
Second byte specifies the operand.
• Example
MVI A, 32H
THREE-BYTE INSTRUCTION
• Example
JMP 2085H, LXI H, 2050H
91
Computer Architecture
& Microprocessor
Between Registers.
Specific data byte to a register or a memory location.
92
Computer Architecture
& Microprocessor
MOV
• Copies data from one register to another
• Syntax:
MOV Rd, Rs
• Example:
MOV A, B
MVI
• Copies 8 Bit data to a specific register
• Syntax:
MVI Rd, D
• Example:
MVI C, 5
93
Computer Architecture
& Microprocessor
OUT
• Copies the Contents of Accumulator to Port
• Syntax:
OUT PortNo.
• Example:
OUT 56
IN
• Copies the Contents of the Port to Accumulator
• Syntax:
IN PortNo.
• Example:
IN 57
94
Computer Architecture
& Microprocessor
Between Registers
OP Oper Byt Description
Code and es
MOV Rd, 1 Copies data From
Rs Source Register Rs to
Between Registers and Memory
Destination Register
OP Oper BytesRd Description
Code and
MOV M, Rs 1 Copies data From
Source Register Rs
to Memory M
MOV Rd, 1 Copies data From 95
Computer Architecture
OP Oper Byt
or I/O Port
Description
Code and es
IN 8 Bit 2 Copies data From
Port Specified port Address
Addr to Accumulator A
ess
OUT 8 Bit 2 Copies data From
Port Accumulator A to
Addr Specified port Address
ess
MVI R, 2 Loads the Data to the
Data Specified Register 96
Data to/from Register, Computer Architecture
& Microprocessor
Memory
OP Oper Byt
or I/O Port
Description
Code and es
LDA 16 3 Copies the content of
Bit Memory location
Addr specified by 16 bit
ess address to Accumulator
A
LDAX RP 1 Copies the content of
B/D Memory Location
Specified in Register Pair
B or D to Accumulator A
STA 16 3 Copies the content of
Bit Accumulator A to 97
Computer Architecture
& Microprocessor
ARITHMETIC OPERATIONS
Addition
• Adds an 8-bit data to the accumulator
• Carry Flag is set if the sum exceeds 8-bits
ADD
• Adds a register’s content to the accumulator
• Syntax:
ADD R
ADI
• Adds an 8-bit data to the accumulator
• Syntax:
ADI 8-bit Data
98
Computer Architecture
& Microprocessor
Subtraction
SUB
• Subtracts a register’s content from the accumulator
• Syntax:
SUB R
SUI
• Subtracts an 8-bit data from the accumulator
• Syntax:
SBI 8-bit Data
99
Computer Architecture
& Microprocessor
Increment/Decrement
INR
• Increments the content of a register
• Syntax:
INR B
DCR
• Decrements the content of a register
• Syntax:
DCR B
100
Computer Architecture
& Microprocessor
Arithmetic Operations
OP Ope Byt Description
Code rand es
ADD R/M 1 Content of the Register
or Memory is added to
the content of
Accumulator and the
result is stored in
Accumulator
SUB R/M 1 Content of the Register
or Memory is subtracted
from the content of
Accumulator and the 101
Computer Architecture
& Microprocessor
LOGICAL OPERATIONS
AND
• Logically AND the Register Content with Accumulator
Content
• Syntax:
AND R
ANI
• Logically ANd Immediately 8-Bit Data with Accumulator
Content
• Syntax:
ANI 14
102
Computer Architecture
& Microprocessor
ORA
• Syntax:
ORA C
ORI
• Syntax:
ORI D
103
Computer Architecture
& Microprocessor
XRA
• Syntax:
XRA C
XRI
• Syntax:
XRI 6
104
Computer Architecture
& Microprocessor
CMA
Rotate
Compare
• Compares an 8-bit data with accumulator content
105
Computer Architecture
& Microprocessor
BRANCHING OPERATIONS
• Alters program execution sequence either conditionally
or unconditionally.
Jump
• Conditional jump
Alters program sequence when condition test is true
• Unconditional jump
Alters program sequence without condition checking
Call
• Changes sequence of a program by calling a subroutine
Return
• Changes sequence of a program by returning from a
subroutine
106
Computer Architecture
& Microprocessor
Unconditional jump
JMP
• Syntax:
JMP Address
• Example:
JMP F200
107
Computer Architecture
& Microprocessor
Conditional Jump
• Based on Condition of the flags
• All Instructions are followed by a 16-Bit address
JC
• Transfers program control to a particular address if Carry Flag
is Set
JNC
• Transfers program control to a particular address if Carry Flag
is not Set
JZ
• Transfers program control if Zero Flag is Set
JNZ
• Transfers program control if Zero Flag is not Set 108
Computer Architecture
& Microprocessor
JP
• Transfers program control if Sign Flag is not Set
JM
• Transfers program control if Sign Flag is Set
JPE
• Transfers program control if Parity Flag is Set
JPO
• Transfers program control if Parity Flag is not Set
109
Computer Architecture
& Microprocessor
Halt
• Processor Stops Executing
• Syntax:
HLT
No Operation
• No Operation is performed
• Syntax:
NOP
110
Computer Architecture
& Microprocessor
Types:
• Immediate addressing.
• Register addressing.
• Direct addressing.
• Indirect addressing.
111
Computer Architecture
& Microprocessor
Immediate Addressing
Register addressing
112
Computer Architecture
& Microprocessor
Direct addressing
• Example:
IN 00H or OUT 01H
Indirect Addressing
113
Computer Architecture
Programming
Memory Address
• 16 bit address of System Memory
Machine Code
• Hexadecimal entered in System Memory
Opcode
• Abbreviated Symbols specified by manufacturer
Operand
• Item to be processed
Comments
• Documentation explaining purpose of instructions used
114
Computer Architecture
& Microprocessor
Task Mnemonics
115
Computer Architecture
& Microprocessor
Programming Format
OP Opera Description
Code nd
MVI B, Loads 37H to Register B
37H
MOV A, B Copies Content of Register B
to Accumulator
OUT Port1 Sends 37H to Port ‘Port1’
HLT None End of the Program
116
Computer Architecture
& Microprocessor
Arithmetic Operations
OP Oper Byt Description
Code and es
ADD R/M 1 Content of the Regis
or Memory is added
the content
Accumulator and
result is stored
Accumulator
SUB R/M 1 Content of the Regis
or Memory is subtrac
from the content
Accumulator and
result is stored
117
Computer Architecture
& Microprocessor
Loops
Continuous Loop
• Uses unconditional jump
Conditional Loop
• Uses Conditional Jump
118
Computer Architecture
& Microprocessor
Counter
• Executes certain set of instructions a
specified number of times
• Uses the concept of conditional loop
• Can be incremented or decremented
119
Computer Architecture
& Microprocessor
First Program
Load a number to Register B and
display the output in Port1
Steps:
1. Load registerStartB with a Number
2. Send to Output
In Register to Port1
Input Number
AlgorithmOutput Number
Stop
120
CA & µP
Unit IV
121
Computer Architecture
& Microprocessor
Setting up a Counter
Executes certain set of instructions a specified number of times
122
Computer Architecture
& Microprocessor
Flowchart
Start
Initialize
Update
No Is the
Final
Count
Yes
End
123
Computer Architecture
& Microprocessor
Time Delay
124
Computer Architecture
& Microprocessor
Time Period = 1
Frequency
T - States
One Subdivision of the operation performed in one clock period
125
Computer Architecture
& Microprocessor
Time Delay
Uses the concept of counter
No. of Counts depends on T-States.
126
Computer Architecture
& Microprocessor
HLT - 5 T-States
127
Computer Architecture
& Microprocessor
Time Delay
Time Delay in executing the Loop
128
Computer Architecture
& Microprocessor
129
Computer Architecture
& Microprocessor
Total Time
T
LA = 1.785 mSec. - (10-7) x 0.5 µSec.
130
Computer Architecture
& Microprocessor
TD = TO + TLA
131
Computer Architecture
& Microprocessor
TO = .006 mSec.
TD = TO + TLA
TD = 1.7895 mSec.
TD ≈ 1.8 mSec.
132
Computer Architecture
& Microprocessor
Note:
Time Delay can be Varied by
changing the Count number FFH.
133
Computer Architecture
& Microprocessor
MOV A, C - 4 T-States
ORA B - 4 T-States
HLT - 5 T-States
134
Computer Architecture
& Microprocessor
Time Delay
T-States Inside the Loop Count
Let us Assume DCX
the B - 6 FFFFH = 6553510
Frequency of theMOV A,C - 4
Processor is 2MHz
ORA B - 4
JNZ LOOP - 10
f = 2 MHz
Total = 24
T-States Outside the
T = 1/f
Loop
LXI B, FFFFH - 10
T = 1/2 MHz
HLT - 5
Total = 15
T = 0.5 µSec.
135
Computer Architecture
& Microprocessor
Total Time
T
LA = 786.42 mSec. - (10-7) x 0.5 µSec.
136
Computer Architecture
& Microprocessor
TO = .0075 mSec.
TD = TO + TLA
TD = 786.426 mSec.
TD ≈ 786.4 mSec.
137
Computer Architecture
Flowchart
Initialize Loop2
Initialize Loop1
Update
No
Is the Final
Count
Yes
Update
No
Is the Final
Count
Yes
End
138
Computer Architecture
Loop
Program
DCR B - 6 T-States
JNZ Loop2 - 10/7 T-States
HLT - 5 T-States
139
Computer Architecture
& Microprocessor
Time Delay
T-States Inside the Loop1 T-States Outside the Loops
140
Computer Architecture
& Microprocessor
Total Time
T
LA1 = 1.785 mSec. - (10-7) x 0.5 µSec.
141
Computer Architecture
& Microprocessor
Total Time
TLA2 = 457.47 mSec. - (10-7) x 0.5 µSec.
TLA1 = 457.47 mSec. - 0.0015 mSec.
TLA1 = 457.4685 mSec.
142
Computer Architecture
& Microprocessor
TO = .0095 mSec.
TD = TO + TLA2
TD = 457.478 mSec.
TD ≈ 457.5 mSec.
143
Computer Architecture
& Microprocessor
Sample Program
Write a program to count continuously in hexadecimal
from FFH to 00H in a system with a clock period of 0.5
µSec. Use Register D to setup one millisecond delay
between each count and display the count in one of the
Output Ports
Note:
144
Computer Architecture
& Microprocessor
Program
MVI E, 00H - 7 T-states
Count: DCR E - 4 T-states
MVI D, Count No. - 7 T-states
Delay: DCR D - 4 T-states
JNZ Delay - 10/7 T-states
MOV A, B - 4 T-states
OUT Port - 10 T-states
JMP Count - 10 T-states
145
Computer Architecture
No.
T = 0.5 µSec.
TL = (T-States x T) x Count No.
TL = (14 x 0.5 µSec.) x Count No.
TL = 0.007 mSec. x Count No.
TLA = (0.007 mSec. x Count) - 0.0015 mSec.
TO = 35 x 0.5 µSec. = 0.0175 mSec.
TD = (0.007 mSec. x Count) - 0.0015 mSec. + 0.0175 mSec.
1 mSec. = (0.007 mSec. x Count) + 0.016 mSec.
1 mSec. – 0.016 mSec.
Count No. = = 140.571 ≈ 14110 ≈ 8CH
0.007 mSec.
146
Computer Architecture
& Microprocessor
Stack
Set of Memory Locations in R/W memory
The Storage & Retrieval on stack follows LIFO (Last in First Out)
147
Computer Architecture
Stack
Using Inst. PUSH the contents of a Register Pair can be copied to stack
Using Inst. POP the contents from the stack is copied to Register Pair
Stack Instructions
PUSH B - From Rp. BC to Stack
PUSH D - From Rp. DE to Stack
PUSH H - From Rp. HL to Stack
PUSH PSW - From Accumulator & Flags to Stack
POP B - From Stack to Rp. BC
POP D - From Stack to Rp. DE
POP H - From Stack to Rp. HL
POP PSW - From Stack to Accumulator & Flags
149
Computer Architecture
& Microprocessor
Example:
Program:
150
Computer Architecture
executing
A
first 2 Instructions
B X X
D
H 42 53
SP 2000
Register Contents after
A
executing PUSH Instructions
B X X Memory
D 53 1FFE
H 42 53 42 1FFF
SP 2000 X 2000
151
Computer Architecture
152
Computer Architecture
& Microprocessor
MOV A, L
Display Flags
OUT Port1
PUSH PSW
Getting Flag content to Reg. L
POP H
MOV A, L
OUT Port1
Subroutine
It is group of Instructions written separately from the main program to perform a
function no. of times in the main program.
If a Time Delay is required for no. of times in a main program, to avoid repetition of
same delay instruction, Subroutine is used
Instruction
RET inst.
• Copies the content in the top two location of the
stack
• Unconditional Return from Subroutine (Note:
Conditional Return Statements are also there)
156
Computer Architecture
& Microprocessor
Example
Mem. Instruc Description
Add. tion
2000 LXI SP, Initialize the stack pointer
H 4000H with 2400H
2004 CALL Calling the subroutine at
H 3000H 3000H
2007 Inst. Other Instructions
H
2008 HLT End of Main Program
H
157
Computer Architecture
& Microprocessor
Flow of Subroutine
Main Program
2000H Subroutine
…
2004H 3000H Start
2005H 3001H
2006H 3002H End
… …
… …
…
158
Data Transfer During CALL
Computer Architecture
& Microprocessor
159
Computer Architecture
Program
Counter
Inst. Stack Pointer
Register
CALL
20 40
04 00
20 3F
05 STACK FF
20 3F
0 3FFE
06 FE
7 3FFF
20 2 4000
07 0
X
X 160
Computer Architecture
Instruction
Machi Stack Addr Progr Data Inter
ne Point ess am Bus nal
Cycle er Bus Count (DB) Regis
s 3FFE (AB) er ters
(W)
(Z)
M1 3FFE 3002 3003 C9 -
Opcod Opcod
e e
Fetch
M2 3FFF 3FFE 07 161
Computer Architecture
& Microprocessor
The traffic and pedestrian flow are in the same direction; the
pedestrian should cross the road when the Green light is on.
162
Computer Architecture
& Microprocessor
The on/off times for the traffic signals and pedestrian signs are as
follows:
163
Computer Architecture
& Microprocessor
164
Computer Architecture
Main Program & Microprocessor
167
Computer Architecture
& Microprocessor
Example
Convert (86)BCD into its binary equivalent
0111 0010
• 00000110 Unpacked BCD1
• 00001000 Unpacked BCD2
168
2 Digit BCD to Binary Computer Architecture
Conversion
& Microprocessor
Main Program
defined as the Output Buffer.
Cont.
171
Binary to BCD
Computer Architecture
& Microprocessor
Main Program
START:LXI SP, STACK - Initialize stack pointer
172
Subroutine PWRTEN
Computer Architecture
& Microprocessor
173
Subroutine BINBCD
Computer Architecture
& Microprocessor
174
BCD to 7 Segment Display
Computer Architecture
& Microprocessor
Main Program
175
Subroutine UNPACK
Computer Architecture
& Microprocessor
176
Subroutine UNPACK
Computer Architecture
& Microprocessor
178
Binary to ASCII
Computer Architecture
& Microprocessor
Main Program
LXI SP, STACK - Initialize stack pointer
LXI H, XX50H - Point index where binary number is stored
LXI D, XX60H - Point index where ASCII code is to be
stored
MOV A, M - Transfer byte
MOV B, A - Save byte
RRC Shift high-order nibble to the position of low-
RRC order nibble
RRC
RRC
179
Binary to ASCII
Computer Architecture
& Microprocessor
Subroutine – ASCII
Subroutine
Main Program
Subroutine - MLTPLY
Interfacing Peripherals
185
Computer Architecture
& Microprocessor
Classification of Interfacing
Communication
• Synchronous – Both transmitter & Receiver aer
synchronized by same clock pulse
• Asynchronous – Both of Irregular Intervals
Transfer of Data
• Parallel – Entire word is transmitted at a time
• Serial – One bit at a time over single line
I/O Types
• Peripheral I/O – Identified with 8 bit address
• Memory mapped I/O – Identified with 16 bit address
186
Computer Architecture
& Microprocessor
Interrupt
A computer input that temporarily suspends the normal
sequence of operations and transfer control to a special
routine.
187
Computer Architecture
& Microprocessor
Vectored Interrupt
Maskable
• RST 7.5 - 003CH
• RST 6.5 - 0034H
• RST 5.5 - 002CH
Non-maskable
• TRAP - 0024H
188
Interrupt Instruction Computer Architecture
& Microprocessor
OP Oper Byt Description
Code and es
EI None 1 The Interrupt Enable flip-
flop is set and all the
RSTMneInstruction
interrupts
Hex Call are enabled
DI Nonemoni CodInterrupt
1 The Locati Enable flip-
cs flope is reset
on and all the
RST interrupts
C7 0000except TRAP
0 are disabled
H
RST CF 0008
1 H
RST D7 0010
2 H 189
Real Time Example to Interrupt
Computer Architecture
& Microprocessor
Interrupt Process is to compare it to a telephone line with a
blinking light instead of ring when you are reading a book.
193
Computer Architecture
Locations
194
Instruction to Read & Write Computer Architecture
& Microprocessor
Interrupts
OP Oper Byt
OP Oper Byt Description Description
Code and es
SIM None 1 Multipurpose Instruction
and used to implement
SIM Data Bytes the 8085 interrupts and
D7 D6 D5 DSerial 4 D3 DataD2 Output
D1 D0
RIM SO None SD X1 R7 M M M Instruction
Multipurpose M
D E X .5 andSEused 7. to 6. read 5. the
Serial Output data X 8085 5 5 5
interrupts
Mask Set Enable
and
Serial Data Enable Don’t D
3=1
1 = Enable Care
Serial Data Input
Mask Interrupts
If bits = 1
0 = Disable
Reset RST 7.5
If D4 = 1
195
Computer Architecture
RIM Data Bytes & Microprocessor
D7 D6 D5 D4 D3 D2 D1 D0
SI I 7 I I 5 IE 7. 6. 5.
D 6 5 5 5
Interrupt Enable
Serial Input Data 1 = Enable
Pending Interrupts Interrupt Masks
1 = Pending 1 = Masked
EI ;Enable Interrupts
MVI A, 08H ;Load bit pattern to enable RST 7.5, 6.5 and 5.5
SIM ;Enable RST 7.5, 6.5 and 5.5
196
Computer Architecture
& Microprocessor
Assuming the microprocessor is completing an RST 7.5
interrupt request, check to see if RST 6.5 is pending. If
it is pending, enable RST 6.5 without affecting any other
interrupts; otherwise, return to the main program.
197
Computer Architecture
Serial I/O & Microprocessor
I/O requirements
• I/O Mapped & Memory Mapped
Transmission
• Synchronous Vs. Asynchronous
• Simplex & Duplex (Half or Full)
• Parity Check (Odd or Even) with bit D7 = 1: Even
BAUD
• No. of Signals / Second
Modem
• FSK (Send bits according to frequency)
198
8155/8156 Programmable I/O & Computer Architecture
& Microprocessor
Timer
Features
40 Pins
199
Pin Configuration Computer Architecture
& Microprocessor
PC3 1 40 Vcc
PC4 2 39 PC1
TIMER IN 3 38 PC2
RESET 4 37 PC0
PC5 5 36
PB7
6 35
TIMER OUT PB6
7 34
IO/M PB5
8 33
CE
PB4
9 32
RD
PB3
10 31
WR
8155 / 8156 PB2
11 30
ALE
12 29 PB1
AD0
14 28 PB0
AD1
14 27 PA7
AD2
15 26 PA6
AD3
16 25 PA5
AD4
17 24
PA4
AD5 23
18
PA3
AD6 19 22
PA2
AD7 20 21 200
PA1
Block Diagram Computer Architecture
& Microprocessor
IO/M
Port A
AD0-7 A 8 PA0-7
256 X 8
Static
CE RAM
Port B
ALE
B 8 PB0-7
RD 8155
WR
Port C
RESET C 6 PC0-5
Timer
201
Expanded Block Diagram Computer Architecture
& Microprocessor
CE
Port
A7 A
Internal
Latch 5 Timer MSB
A1
Port
4 Timer MSB
B
A2
A3
Internal 3 Port C
Decoder2 Port B
Register
Control
1 Port A Port
0 C
Control Register
AD7
Data Bus Timer
AD0
LSB
Timer
MSB
202
Computer Architecture
& Microprocessor
Port Address A15 – A8 is duplicated by A7 – A0
A A A Control
2 1 0
0 0 0 Control Register
0 0 1 Port A
0 1 0 Port B
0 1 1 Port C
1 0 0 Timer LSB
A15
1 0 1 Timer MSB
& A are Active Low Enable
14
A , A
13 12 & A11 are give as input to 8205 decoder
O is give to the chip enable of 8155
4
203
Computer Architecture
& Microprocessor
204
Computer Architecture
& Microprocessor
To enable o4 of 8205 A13=1, A12=0,
A11=0
The
A Following
A A A A table
A HEXgiveControl
the address
of 13
Ports of 28155
12 11 1 0 Code
1 0 0 0 0 0 20 H Control
Register
1 0 0 0 0 1 21 H Port A
1 0 0 0 1 0 22H Port B
1 0 0 0 1 1 23H Port C
1 0 0 1 0 0 24H Timer
LSB
1 0 0 1 0 1 25H Timer 205
Control Register Computer Architecture
& Microprocessor
D7 D6 D5 D4 D3 D2 D1 D0
Port A Port B
0 – Input ; 1 - Output
00 NOP
01 STOP/NOP
D D P P PC P P PC
2 C5 C4 C2 C1 0
IEA IEB
10 STOP after TC 3 3
11 START
0 0 I I I I I I
1 – Enable
0 – Disable
1 1 O O O O O O
ST BF INT
0 1 O O O BA RA
A
ST BF INT ST BF INT206
Computer Architecture
Display
Design 2 7-segment LED displays using Ports A & B of
8155 to display the data bytes.
Solution
207
Computer Architecture
& Microprocessor
208
Computer Architecture
Control Word & Microprocessor
D7 D6 D5 D4 D3 D2 D1 D0
= 03H
0 0 0 0 0 0 1 1
209
Computer Architecture
& Microprocessor
Timer in 8155
Two 8bit Registers
210
Computer Architecture
& Microprocessor
Timer
M M T1 T1 T1 T1 T T T T T T T T T T
2 1 3 2 1 0 9 8 7 6 5 4 3 2 1 0
M M Description
2 1
0 0 One Square
Wave
0 1 Continuous
Square Wave
1 0 Single Pulse 211
Example for using Timer
Computer Architecture
& Microprocessor
The System Clock is connected to Timer IN of 8155. The clock has 3MHz
Frequency. Write a program to produce continuous square wave with a frequency
of 1KHz. Includes a start timer command, disable the port interrupts, make Port
B&C as O/P ports and make Port A as I/P port.
1 0 1 1 1 0 0 0 LSB Timer
0 1 0 0 1 0 1 1 MSB Timer
1 1 0 0 1 1 1 0 Control Word
• Timer
• 300010 = 0BB8H
• Timer M2, M1 = 0,1 (Continuous Square Wave)
• Control Word
• D0, D1, D2 & D3 = 0,1,1&1 respectively (Port A is I/P & Port B&C are O/P
• D6, D7 = 1, 1 (Start the Timer)
212
Computer Architecture
& Microprocessor
Program
MVI A, B8H - Setting LSB of Timer
213
Computer Architecture
& Microprocessor
8355 / 8755
2K memory of EPROM
214
Pin Configuration Computer Architecture
& Microprocessor
CE1 1 40 Vcc
CE2 2 39 PB7
CLK 3 38 PB6
RESET 4 37 PB5
N.C. 5 36
PB4
READY 6 35
PB3
IO/M 7 34
PB2
IOR 8 33
PB1
RD 9 32
PB0
IOW 10 31
8355 / 8755 PA7
ALE 11 30
12 29 PA6
AD0
14 28 PA5
AD1
14 27 PA4
AD2
15 26 PA3
AD3
16 25 PA2
AD4
17 24
PA1
AD5
18 23
PA0
AD6 22
19
A10
AD7 20 21 215
A9
CLK
Block Diagram Computer Architecture
& Microprocessor
READY
AD0-7 Port A
A 8 PA0-7
A8-10 2K X 8
EPROM
CE2
IO/M
ALE
8355/8755
RD
Port B
IOW B 8 PB0-7
RESET
IOR
Prog/CE1 VCC
VDD VSS
216
Computer Architecture
& Microprocessor
217
Computer Architecture
& Microprocessor
Address Bits
A1 A1 A1 A1
A1
5/ 3/ 2/ 1/ A A A
4/ Selected
A A A A D D D
D
A
D D D 2 1 0 Register
D6
7 5 4 3
0 0 0 0 0 X 0 0 Port A
0 0 0 0 0 X 0 1 Port B
0 0 0 0 0 X 1 0 DDR A
0 0 0 0 0 X 1 1 DDR B
218
Computer Architecture
& Microprocessor
219
Computer Architecture
& Microprocessor
Example
Write initialization instructions to configure port A and
port B as output ports, and display 32H at port A
Program:
MVI A, FFH ; Control word to set up all bits as output
bits
OUT 02H ; Initialize port A as output
OUT 03H ; Initialize port B as output
MVI A, 32H
OUT 00H ; Display 32H at port A
HLT
220
8279 Programmable Keyboard / Computer Architecture
& Microprocessor
Display Interface
Simultaneous Keyboard Display Operation
Major Segments
Keyboard
• Connected to 64 contact key matrix
• Entries are stored in FIFO
• Interrupt sent for every entry
Display
• Has 16 characters scanned display
• 16 character memory
222
Pin Configuration Computer Architecture
& Microprocessor
RL2 1 40 Vcc
RL3 2 39 RL1
CLK 3 38 RL2
IRQ 4 37 CTRL/STB
RL4 5 36 SHIFT
RL5 6 35 SL3
RL6 7 34
SL2
RL7 8 33
SL1
RESET 9 32
SL0
RD 10 31
8279 OUT B0
WR 11 30
OUT B1
DB0 12 29
14 28 OUT B2
DB1
14 27 OUT B3
DB2
15 26 OUT A0
DB3
16 25 OUT A1
DB4
17 24 OUT A2
DB5
18 23 OUT A3
DB6 22
19
BD
DB7 20 21 223
CS
Logical SymbolVcc Computer Architecture
& Microprocessor
IRQ RL0-7 8
8 Data
Bus Key Data
SHIFT
RD
CNTL/STB
CPU WR
Interface CS
SL0-3 4 Scan
A0
4
OUT A0-3
Display
RESET
Data
4
OUT B0-3
CLK
BD 224
Vss
Computer Architecture
Pin Names & Microprocessor
226
Computer Architecture
& Microprocessor
Different Sections
Keyboard Section
Scan Section
Display Section
227
Computer Architecture
& Microprocessor
Programming 8279
left or right entry and key rollover.
blanking format.
228
Computer Architecture
& Microprocessor
229
Computer Architecture
& Microprocessor
Circuit
The 8279 Programmable Keyboard / Display Interface
230
Computer Architecture
& Microprocessor
Port Address
Keyboard/Display Mode
MVI A, 00H Control word to set mode: Left 0 0 0 D D K
K K
entry, 8-character, 2-key lockout
encoded scan keyboard
STA 1900H Initialize 8279
231
Computer Architecture
232
Computer Architecture
Timer
40 Pin
3 independent Counters
5 Modes of Operations
233
Computer Architecture
& Microprocessor
Signals of 8254
234
Computer Architecture
& Microprocessor
Modes of Operations
Mode 0
Interrupt on Terminal Count
• Count Begins one clock pulse after the count
has been written in to counter
• GATE 0 = 1, then counter 0 counts down
• CLK 0 pulse then the counter decrements by 1
• GATE 0 = 0. then counts inhibited
The operation is same for all the 3
counters
235
Computer Architecture
& Microprocessor
Read/Write Operations
236
Computer Architecture
& Microprocessor
Control Word
237
Computer Architecture
& Microprocessor
238
Computer Architecture
& Microprocessor
239
Computer Architecture
& Microprocessor
240
Computer Architecture
& Microprocessor
241
Computer Architecture
& Microprocessor
Program
MVI A, CWR1 ;Get 8255A #1command word
OUT CR1
MVI A, CWR2 ;Get 8255A #2 command word
OUT CR2
MVI A, BLMSET ;Get byte to blank the LIMIT SET
lamp.
OUT PORTC2 ;Send to port C of 8255 #2
CALL RALARM ;Reset alarms.
CALL STCNTR0 ;Start counter 0.
EI ;Enable interrupts
RET ;End of subroutine.
242
Computer Architecture
& Microprocessor
Accuracy of 1º C
243
Computer Architecture
& Microprocessor
Hardware Design
A transducer is used to convert temperature into an equivalent
analog electrical quantity
244
Block Diagram of Hardware Computer Architecture
& Microprocessor
Design MPU
SOD
SID
8 Bit
Relay 8 Bit
EPROM 8 bit
I/O Port Driver & I/O Port
I/O Port
Relay
Temp.
A/D 7-segment
Transducer Switches
& Buffer Converter Displays
245
Detailed Block Diagram
Computer Architecture
& Microprocessor
246
Computer Architecture
& Microprocessor
247
Computer Architecture
& Microprocessor
Memory
• No RAM is necessary
• EPROM 2716 is used to used (2KB of Memory)
I/O Port
• System requires 26 I/O lines (17 O/P & 9 I/P)
• 8255 (24 Ports) with SID & SOD
A/D Converter
• ADC chips are quite costlier when compared to
DAC. As fast conversion is not necessary
• ADC can be implemented by using an external
DAC and a comparator with MPU as Controller
248
Computer Architecture
& Microprocessor
LED Display
• 2 7-segment display is used
Switches
• One Thumb wheel Switch is used(4 toggle switches)
249
Computer Architecture
& Microprocessor
250
Flowchart
Computer Architecture
A/D Converter
NO
Is MT = DT
Yes
Make Relay Make Relay
OFF ON