Introduction To 8085
Introduction To 8085
T1 = 15 %
T2 = 15 %
Note :
1.
Syllabus
Module 1 (5 hours)
Syllabus
Module 3 (12 hours)
1. MICROPROCESSOR
A processor on a single microchip.
A 16-bit microprocessor can process data and
Year of release
8086
(16 bit)
8088
(16 bit, 8 bit external data bus)
80186
80286
80386
(32 bit)
80486
Pentium (64 bit)
Pentium Pro
Pentium -2
Pentium-3
Pentium-4
Pentium-D
Core-2
1978
1979
1982
1982
1985
1989
1993
1995
1997
1999
2004
2005
2006
Core-2 Quad
2007
9
PERSONAL COMPUTERS
IBM produced the first PC in August 1981 using the
8088.
It had 64 KB of RAM (expandable to 256 KB), a floppy
disk drive
In March 1983 ,the IBM PC XT was released-it had a
hard disk
In August 1984 ,the PC-AT using the 80286 was
released .
10
11
12
13
14
SYSTEM BUS
Bus collection of signal wires which connect between
Data bus
Address bus
Control bus
15
16
DATA BUS
Used to transfer data.
bi-directional
Data has to be sent from the CPU to memory and I/O.
Data has to be received by the CPU.
ADDRESS BUS
Address bus width determines
Maximum size of physical memory that the CPU can
access.
CONTROL BUS
Set of control signals for activities like writing /
reading to/ from memory / I/O devices or special
activities of the CPU like interrupts and DMA.
Signals travelling in either directions and some signals
may be bi-directional.
Memory read signal will be asserted for reading from
memory. It is sent to memory from the processor.
Interrupt is received by the processor from an I/O
devices.
19
PROCESSOR
Component responsible for controlling all the
20
21
SYSTEM CLOCK
All the activities of the processor and buses are
22
23
Memory
Primary or main memory
RAM ( random access memory)
ROM ( read only memory )
Secondary memory
Hard disk
Optical disk
Memory organized as bytes.
Memory capacity number of bytes it can store.
Eg: 1 KB, 1 MB
24
Memory
Two basic operations associated with memory
Read
Write
Access time
Time required for these operations
25
26
28
outside world.
It is difficult for a processor to deal directly with I/O
devices.
Processor does not have the necessary control signals
to deal with different peripherals.
Each peripheral have controller which acts as an
interface between the peripheral and the processor.
Eg: keyboard display interfacing chip, parallel port
30
3. COMPUTER LANGUAGES
High Level Language
Eg: c, c++, java
compiler
Assembly Language
assembler
Machine Language
31
spoken by us.
Easy to understand and write.
Not processor specific.
32
Assembly Language
Uses mnemonics for specifying the operation the
computer is to perform.
Mnemonics are direct translation of the machine code
to a symbol.
Eg: for addition
: ADD
for multiplication : MUL
Mnemonics depends on processor type , but related to
the operation.
Assembler converts assembly language to machine
language.
33
Machine Language
Consists of binary ones and zeros.
One binary code for addition , another one for
subtraction.
These operation codes are called opcodes.
Each processor has its own machine language and
assembly language.
Assembly language to machine language translation
and vice versa is a one to one process.
34
35
instructions.
Hardware budget is less.
Software is to written to realize complex instructions.
Only simple instructions implemented in a single clock.
Examples for RISC : ARM ,Suns Sparc processors
36
5.NUMBER SYSTEMS
Decimal
Binary
Hexa decimal
Binary Coded Decimal (BCD)-packed and unpacked
Conversions between them is possible
is possible.
37
1) 1001.011B = 9.375
2) 240FCH = 147708
3) 25.6H = ?
4) 31.3 H = ?
5) 1100.101B = ?
6) A32.3 H = ?
7) 100101B = ?
38
b) Decimal to binary
- Divide decimal number by 2 repeatedly and save
reminders.
- Write remainders from bottom to top.
- 13 = 1101
- 213 = ?
c) Decimal to hexadecimal
- Divide decimal number by 16 repeatedly and save
reminders.
- Write remainders from bottom to top.
- 225 = ?
39
d) Binary to hexadecimal
- Group binary number into groups of 4 bits.
- 0100 1100 = 4C
- 0101 0111 1111 = ?
e) Hexadecimal to binary
- Take each hexadecimal digit and write its equivalent
four bit binary number.
- 3AF24H = ?
40
f ) BCD numbers
- Binary coded decimal
- Unpacked BCD
- One decimal digit as a byte.
- 9 = 00001001
- 98 = 00001001
00001000
8
- Packed BCD
- One decimal digit is packed into 4 binary bits.
- 98 = 1001 1000
9
8
41
1001.
BCD in hex form
- 1)write the binary equivalent of each decimal number
as a nibble.
- 2) write the hex equivalent of each nibble.
- BCD of decimal number 675 is
-
0110
6
0111
0101
126
245
43
6. ASCII CODE
( American Standard Code for Information Interchange )
It is a 7 bit code, written as a byte.
Used when entering data through the keyboard &
0= 30H
Z=54H,
9= 39H
a= 61H
z= 7AH
44
processing.
45
Negative numbers
-8
-7
-6
-5
-4
-3
-2
-1
-0
+0
+1
binary
1000
1001
1010
1011
1100
1101
1110
1111
0000
0000
0001
hex
8
9
A
B
C
D
E
F
0
0
1
47
48
49
=1,048,576 bytes
210 x220 = 230 = one Giga Byte (1 GB) = 1024 x1024 x 1024
= 1,073,741,824 bytes
1024 =1,099,511,627,776
50
51
time
It can have access to memory of 64 KB (maximum)
It has a number of control pins as well.
52
53
associated blocks
The whole system is controlled by the timing and control
circuit which synchronizes the activities of the processor
with a central clock
All arithmetic and logic computations take place in ALU
Instructions from memory are brought to an instruction
register and decoded by the instruction decoder
54
55
56
59
ADDRESS REGISTERS
They are 16 bit long
i) Program counter always points to the address of the
next location
ii) Stack pointer always point to the top of the stack
61
instruction
;comment
62
ADDRESSING MODES
The way an operand is presented for execution by the
instruction.
Addressing modes are
Register addressing
Direct addressing
Indirect addressing
Immediate addressing
63
ADDRESSING MODES
REGISTER ADDRESSING
In this mode, only registers are involved .Both the
65
DIRECT ADDRESSING
In this ,one of the operands is directly addressed i.e,
INDIRECT ADDRESSING
Here ,one of the operands is indirectly specified . It is
STAX B
IMMEDIATE ADDRESSING
Here , the source data is written in the instruction
itself
MOV A,78H
ADD A,67
68
between
i) registers ii)register and memory iii) I/O and
accumulator .
These also include instructions for loading an 8 bit or
16 bit number into a register of the same size. For
certain instruction ,the accumulator ( A register) is
implied.
69
ARITHMETIC INSTRUCTIONS
For all arithmetic operations, A is implied to contain
ADD R
in A
SBB R ; subtract from A, the content of R and carryresult in A
73
INR R
DCR R
INR M
DCR M
INX Rp
DCX Rp
DAA
74
Example 0.22
Bring data from the memory location 4567H ,add
56H to it and store the sum in location 0567H.
75
solution
LDA 4567H
ADI A,56H
STA 0567H
76
Example 0.23
Write a program to add an immediate data to a data in
77
solution
MVI B, 3CH
LXI H, 0987H
MOV A, M
ADD A, B
INX H
MOV M,A
78
Example 0.24
There is a byte of data in location 6756H ,which is to
79
SOLUTION
LXI B,6756H
LDAX B
SUI 05
STAX B
80
BRANCH INSTRUCTIONS
JMP address16 ; jump unconditionally to the given
address
JZ
address16 ; jump on zero- jump to the given
address if Z=1
JNZ address16 ; jump on non-zero-jump to the given
address if Z=0
JC address16 ; jump on carry-jump to the given
address if C=1
JNC address16 ; jump on carry-jump to the given
address if C=0
CALL address16 ; call a subprogram written in the
address given
81
Example 0.25
Write a program for multiplying 24 by 10. Since there
82
SOLUTION
MOV A,0
83
Example 0.26
Two numbers are stored in memory .Verify if their
sum is greater than 255 .If yes, send the ASCII value of
Y to an output port with address 78H .Other wise send
N.
84
SOLUTON
LXI H, 0897H
in A
ANI data8 ; logically AND the contents of A and data
given-result in A
ANA M ; logically AND the contents of A and
memory-result in A
ORA R ; logically OR the contents of A and R- result
in A
ORI data8 ; logically OR the contents of A and data
given-result in A
86
LOGICAL AND BIT MANIPULATION INSTRUCTIONS ORA M ; logically OR the contents of A and
memory-result in A
XRA R ; logically XOR the contents of A and R- result
in A
XRI data8 ; logically XOR the contents of A and data
given-result in A
XRA M ; logically XOR the contents of A and
memory-result in A
CMP R ;compare the contents of A and R-only flags
affected
87
flags affected
CPI data8 ; compare the contents of A and given dataonly flags affected
RLC ; rotate the bits in A once, to the left
RAL ;rotate the bits in A and the carry bit, to the
left,once
RRC ;rotate the bits in A once, to the right
RAR ; rotate the bits in A and the carry bit, to the
right,once
88
C flag
Z flag
destination =source
89
Example 0.27
Compare the number in the memory location 4566H
90
SOLUTION
LDA 4566H
91
92
94
95
96
97
clock of 4MHz.
Maximum frequency of operation for 8085 is 5MHz.
(crystal of 10 MHz is to be connected)
CLK OUT : from this pin , clock of the processor can
be extracted and used for timing any unit in the s/m.
Vcc = +5v & Vss is ground reference.
98
99
Interrupt
Processor is performing a particular task
If another more important task is to be done, current
101
Interrupt pins
Interrupt vector
TRAP
0024H
RST 7.5
003CH
RST 6.5
0034H
RST5 .5
002CH
102
103
104
105
end
106
numbers
-8
-7
-6
-5
-4
-3
-2
-1
-0
+0
+1
binary
1000
1001
1010
1011
1100
1101
1110
1111
0000
0000
0001
hex
8
9
A
B
C
D
E
F
0
0
1
107
2s complement
Find 8 bit 2s complement number corresponding to
6?
6 in 8 bit representation : 0000 0 1 1 0
Complement each bit
Add 1 to it
108
1111 1001 +
1
1111 1010
F
A
; complement
; add 1
; in hex
AH (4 bit )
FFFAH ( 16 bit)
109
Conversion from 2s
complement form
Find the decimal number whose 2s compliment
representation is FAH?
Complement each bit
Add 1
110
A
1 1 1 1 1 0 1 0 ; (number)
0000 0 1 0 1 ; complement
0000 0 1 1 0 ; 2s complement
=6
take ve value = -6
FA is the 2s complement representation of -6
111
representation?
1) FFF2H
2) F9H
Answer :
1) -14
2) -7
112
COMPUTER ARITHMETIC -
Addition
Hexadecimal
59H
69H
C2H
Case 2
0111 1000 +
1001 1001
1 0001 0001
120 +
153
273
78H +
99 H
111 H
Decimal
45 +
22
67
Case 2
Packed BCD
Packed BCD in hex
0100 0101 +
45H +
0010 0111
27H
0110 1100
6CH
The lower nibble of sum is greater than 9
No BCD digit can have a value > 9
correction
add 6 (0110) to the lower nibble alone
0110 1100 +
6CH +
0000 0 1 1 0
0 6H
0111 0010
72H
Decimal
45 +
27
72
116
Case 3
Packed BCD
Packed BCD in hex
0111 0110 +
76H +
0110 0010
62H
1101 1000
D8H
Upper nibble of sum > 9
Correction
Add 6 to upper nibble alone
1101 1000 +
D8H +
0110 0000
60H
1 0011 1000
138H
117
Case 4
upper and lower nibbles of sum > 9
add 6 to both nibbles
Packed BCD
1000 1001 +
0111 0010
1111 1011
0110 0110
1 0110 0001
119
Examples
1) Add +90 and -26
2) Add -120 and +45
Answer
1) 1 0100 0000
2) 1011 0101
120
subtraction
Subtract 56 from 230 ?
decimal
230 56
174
binary
1110 0110 0011 1000
1010 1110
hex
E6H 38H
AEH
decimal
53 18
35
packed BCD
0101 0011
0001 1000
0011 0101
0101 0011
0001 1000
0100 1101
0001 1000
0100 1101 -
0001 1000
0011 0101
result is 35
123
56
= 174
DECIMAL
ANSWER:
0010 0011 0000
packed BCD
125
ANS : 42
-94
79
33
126
Answer :
1) +26 from +68
68 + (-26)
Decimal
68
is
-26
is
binary
0100 0100 +
1110 0110 ( 2s compliment)
1 0010 1010
Ignore the extra bit
MSB is 0 , the result is +ve [0010 1010 =42]
If MSB is 1 , the result is ve ( take the ve of its 2s
compliment)
127
1001 1100 +
(-100)
1100 1001
(-55)
1 0110 0101
( ignore extra bit )
MSB is 0 : indicating +ve number
There was an overflow into sign bit
128
processor.
To add / subtract data of different widths.
Processor do not allow addition / subtraction of data
of different widths.
129
bit.
35H > 0035H
FFH > FFFFH
130
0035H +
7890H
= 78C5H
131
Solution :
1) A8C1H
2) 1 0FEDH (ignore extra bit)
3) 1 B451H (ignore extra bit)
132
8086 PROCESSOR
The 8086 Processor is a 16 bit processor internally as
well as externally
Its ALU, internal registers and most of its instructions
are designed to work with 16 bit binary words
It has 16 bit data bus, so it can read data from or write
data to memory and ports either 16 bits or 8 bits at a
time
8086 has 20 bit address bus . So 1MB memory
locations
133
EXECUTION UNIT
It contains the arithmetic and logic unit, control unit,
137