3. 1) Introduction
Purpose of Processors & Controllers:
To perform the user defined task
How to communicate this tasks to microprocessor?????
Through program
What is program????
Sequence of instructions to perform the specified task.
Instructions:
An instruction is a binary pattern designed inside a
microprocessor to perform a specific function
A microprocessor executes instructions given by the user to
perform specified task.
Microprocessor understands the language of 0’s and 1’s only
This language is called Machine Language
4. 2) Types of Programming Language
00111110
00000010
00000110
00000100
10000000
Can we understand this????
Program to add two numbers
Very difficult to understand
Difficult to correct the errors
What is the solution ?????
1) Assembly Language
2) High Level language
5. Assembly Language
• Microprocessor cannot understand a program written in
Assembly language
• A program known as Assembler is used to convert a Assembly
language program to machine language
Assembly
Language
Program
Assembler
Program
Machine
Language
Code
6. High Level Language
• Machine language and Assembly language are both
– Microprocessor specific (Machine dependent)
• Machine independent languages are called
– High-level languages
– For e.g. BASIC, PASCAL,C++,C,JAVA, etc.
– A software called Compiler is required to convert a high-level
language program to machine code
7. With whom we have to communicate???
Accumulator (8-bit) Flag Register (8-bit)
B (8-bit) C (8-bit)
D (8-bit) E (8-bit)
H (8-bit) L (8-bit)
Stack Pointer (SP) (16-bit)
Program Counter (PC) (16-bit)
8- Lines
Bidirectional
16- Lines
Unidirectional
8. Registers of 8085
Six general-purpose registers:
- B, C, D, E, H, L
- Can be combined as register pairs to perform 16-bit
operations
Accumulator :
– identified by name A
– part of ALU
– Performs arithmetic and logical operations & is stored in it
Flag Register:
-Part of ALU
- 8085 has five flags named
1. Zero flag (Z)
2. Carry flag (CY)
3. Sign flag (S)
4. Parity flag (P)
5. Auxiliary Carry flag (AC)
Stack Pointer Register
-16-bit memory pointer register
-Points to a location in Stack memory
-Beginning address defined by user
9. What is an Instruction set???
• An instruction is a binary pattern designed inside
a microprocessor to perform a specific function
• The entire group of instructions that a microprocessor
supports is called Instruction Set.
• Consists of
– 246 Instructions, e.g. MOV A,B
• Each instruction is represented by an 8-bit binary
value.
• These 8-bits of binary value is called Op-Code
10. 3) Assembler Instruction Format
Format: 4 Fields
Label: Mnemonic operand1, operand2; comment
Example:
Label Mnemonic Operands Comment
START: MOV A, 54 ;Load A Register with 54H
Label: An identifier or a symbolic name
Mnemonic:
Used in conjunction with branch instruction
Aims to translate information into a form that
the human brain can retain better than its original form.
Definition:
Specifies operation to be executed in human
understandable format
Operand: On which operation is performed. It can have no or single or double operator
11. 4) Classification of Instruction Sets
• 8085 instructions can be classified as
1. Data Transfer (Copy)
2. Arithmetic
3. Logical and Bit manipulation
4. Branch
5. Machine Control
12. Data Transfer Instructions
• These instructions move data between
registers, or between memory and registers
• These instructions copy data from source to
destination
• While copying, the contents of source are not
modified.
18. Data Transfer Instructions
LHLD 16-Bit Address Load HL pair with content
of Direct address
•The contents of 16-bit address is stored to L register
•The contents of next memory location is stored to H register
•Example: LHLD 1500H
25. Summary of Data Transfer Instructions
1. Load a 8-bit number in a Register
2. Copy from Register to Register
3. Copy between Register and Memory
4. Copy between Input/output Port and
Accumulator
5. Load a 16-bit number in a Register pair
6. Copy between Register pair and Stack memory
26. Program
Write a program to exchange memory contents of 2000H with
4000H.
27. Programs
2000 AA
2001 BB
2002 CC
Memory Contents:
Find the contents of H & L register after executing following Instruction?
LXI H, 2001
LHLD 2001
Solution:
After first instruction H=20H & L=01
After second instruction H=CC & L=BB
28. PUSH & POP Testing Point
1) If the Initial content of SP is 2000H.
What is the value in SP if the number PUSH operation is equal to number of
POP operation.
2) If the content of SP is 2000H
If POP instruction is used before PUSH instruction what will happen
Answers:
1) SP value will be same
2) Garbage or unpredicted operation results
31. More Test on PUSH & POP operations
Find the contents of DE pair and PSW after executing following Instruction/
PUSH B
PUSH H
POP D
POP PSW
Initial Contents:
SP=A000H
BC=1050
HL=8090
90 E
80 D
50 Flag
10 A
9FFC
9FFD
9FFE
9FFF
A000SP
32. Program to understand I/O Operation
Write a program to display following letter E. Assume the address of the LED is
20H.Assume A is connected to AD0 and G is connected to AD7
Assume it is connected in Common Cathode.
Means all the cathode are connected through
a resistance and grounded
It is not an actual 7 Segment Display available in market. It is just for our example
33. Program to understand I/O Operation
8085
Decoder
LATCH
A
B
C
D
E
F
G
Address Bus
_ _
IO/M, WR
Enable Signal
Grounded
Data Bus
D0
D6
Solution:
MVI A,F9
OUT 20H
HLT
35. Arithmetic Instructions
1. Add an immediate data with
Accumulator
2. Add contents of
Registers(B,C,D,E ,H,L) or
memory to Accumulator
3. Add an immediate data with
carry to Accumulator
4. Add contents of or memory
to Accumulator with carry
5. Add 16 bit contents of
Register pair with content of
HL register
ADI 32H
ADD B
ACI 42H
ADC D
DAD D
36. Arithmetic Instructions
1. Subtract an immediate
data from Accumulator
2. Subtract contents of Rn
from Accumulator
3. Subtract an immediate
data from Accumulator
with borrow
4. Subtract contents of Rn
from Accumulator with
borrow
SUI 32H
SUB B
SIB 42H
SBB D
37. Arithmetic Instructions
1. Increment the contents
of Rn or memory by 1
2. Increment the contents
of Rp by 1
3. Decrement the
contents of Rn or
memory by 1
4. Decrement the
contents of Rp by 1
5. Decimal Adjust
accumulator
INR A
INX B
DCR C
DCX D
DAA
38. Flag Register Status on Arithmetic Instructions
Sl.NO Instruction CY AC S P Z
1 ADD
2 ADI
3 ADC
4 ACI
5 SUB
6 SUI
7 SBB
8 SBI
9 INR
10 INX
Not affected Affected
39. Flag Register Status on Arithmetic Instructions
Sl.NO Instruction CY AC S P Z
11 DCR
12 DCX
13 DAD
14 DAA
Not affected Affected
40. Example
Write a program/Instruction to Shift 16 bit data stored in HL
Register towards left by 1 bit.
CLUE: Use DAD instruction
To shift left by 5 bit. How many times we have to execute the above Instruction
What will happen if results exceed the FFFF. Will it work
What are the application of shifting operation?
1. Multiplication & Division
2. Serial communication
41. How to Clear Flag Register
One of the example:
LXI B, 00H
PUSH B
POP PSW
42. Test point for Flag Register operation
Find the content of Flag Register after
each operation. Identify what this
program is doing
1. LXI H, 2040
2. LHLD 2041
3. ADD M
4. INX H
5. MOV M,A
F0
20
42
02
A
2043
2042
2041
2040
Solution:
1. No change
2. No change
3. Affected
4. No change
5. No change
1) H=20 , L=40
2) H=20, L=42
3) A=F0+20= 10
4) H=20, L=43
5) 2043=10
Adding the content in 2042 and store
the sum in 2043
Flag Status:
0 0 X 0 X 0 X 1
43. Machine Control Instructions
1. NOP
2. HALT
3. DI
4. EI
No operation is performed
An interrupt or Reset is
required to come out from
Halt State
Disable all interrupt except
TRAP
To Enable all interrupt
except TRAP.
After Reset or interrupt
acknowledgement
interrupt flag is disabled
44. Steps to write Program
• Steps to write a program
–Analyze the problem
– Develop program Logic
– Write an Algorithm
–Make a Flowchart
– Write program Instructions using
Assembly language of 8085
Editor's Notes
Explanation:
Suppose HL pair has content of 00000000 00000001. After executing the DAD H the following operation happens 00 01+ 00 01=0002 which is nothing but 00000000 00000010.