Unit-4 - Assembly Language Programming Basics (Part-2)
Unit-4 - Assembly Language Programming Basics (Part-2)
(MPI)
GTU # 3160712
Unit-4:
Assembly Language
Programming Basics
PART-II: 8085 Assembly Program Basics
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Subject Overview
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. No. Unit % Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 12%
4 Assembly Language Programming Basics 13%
5 8085 Assembly Language Programs 12%
6 Stack & Subroutines 13%
7 I/O Interfacing 20%
8 Advanced Microprocessors 15%
For example:
MVI B,20H
LXI D,1034H
ADI 45H
SUI 30H
CPI 68H
For example:
LDA 1035H ; here 1035 is 16-bit memory address
IN 02H ; 02 is 8-bit I/O port address
OUT 03H ; 03 is 8-bit I/O port address
For example:
MOV A,B ; A B
ADD B ; A A+B
DAD H ; HL HL+RP
For example:
XTHL
SPHL
PCHL
The comment should explain what is intended; they should not explain mnemonics.
Comment is optional.
Example:
MOV A,B ; Move data from B to A
MOV A,B ; send data to accumulator for processing
If the code doesn’t work, it is essential to search carefully for errors in programming logic,
machine codes and execution.
How to Debug machine code:
Translating assembly to machine code is similar to building a circuit.
Following errors are common:
1. Writing a wrong code.
2. Specifying the wrong jump location.
3. Writing memory address in decimal, thus specifying wrong jump location.
4. Writing lower order and higher order bits in wrong sequence.
memory location.
Start
Store result
[1007] <- A
End
Operation T-States
Opcode Fetch 4-6T
Memory Read 3T
Memory Write 3T
I/O Read 3T
I/O Write 3T
Operation M/C
Fetch (F) 1
Memory Read (MEMR) 1
Memory Write (MEMW) 1
I/O Read (IOR) 1
I/O Write (IOW) 1
Read Immediate Data (R) 1
Machine Cycle:
1(F) = 1 Machine Cycle
Timing Cycle:
= 4T (Fetch)
02 0001
A
04 0002
B C 0A 0003
06 0004
D E
0F 0005
H L 0D 0006
05 0007
03 0008
LHLD 0006H
2. SHLD 2470
3. SPHL
4. DAA
5. INR R/M
6. JMP
7. PCHL
8. CMP R/M
9. RRC
10. RIM
11. SIM
12. ORA R/M
13. XCHG
14. DI
15. EI
Timing Diagram
Opcode Fetch
T1 T2 T3 T4
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CLK
A15
High order memory address Unspecified
A8
AD7 Low order
Opcode
AD0 M/m addr.
ALE
IO/M
RD
Memory read cycle
T1 T2 T3 T4
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CLK
A15
High order memory address
A8
AD7 Low order
Data from memory
AD0 M/m addr. S1 S0 Mode
0 0 HLT
0 1 WRITE
1 0 READ
ALE
IO/M
S0 IO/M=0, S1=1 , S0=0
S1
RD
Memory write cycle
T1 T2 T3 T4
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CLK
A15
High order memory address
A8
AD7 Low order Data from
AD0 M/m addr. Microprocessor S1 S0 Mode
0 0 HLT
0 1 WRITE
1 0 READ
ALE
IO/M
S1 IO/M=0, S1=0 , S0=1
S0
WR
I/O read cycle
T1 T2 T3 T4
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CLK
A15
High order I/O address
A8
AD7 Low order
I/O data
AD0 I/O addr. S1 S0 Mode
0 0 HLT
0 1 WRITE
1 0 READ
ALE
S0
A15
High order I/O address
A8
AD7 Low order Data from
AD0 I/O addr. Microprocessor S1 S0 Mode
0 0 HLT
0 1 WRITE
1 0 READ
ALE
S1
CLK
AD7
Low order Low order Data from
M/m addr. Opcode M/m addr.
AD0 memory
ALE
IO/M
RD
Timing Diagram : MVI A, 32H
Opcode Fetch Memory Read
T1 T2 T3 T4 T5 T6 T7
Positive Vibes:MPI is the interesting, easiest and scoring subject.
CLK
AD7
Low order Low order Read
M/m addr. Opcode M/m addr.
AD0 Immediate
ALE
IO/M
RD
Calculate Execution time of MVI A,32H
Given: Clock Frequency (f) = 2 MHz Positive Vibes:MPI is the interesting, easiest and scoring subject.
Calculation:
1 1
Step-1: T-state = clock period = = = 0.5 sec
𝑓 2
Step-2: Execution time for Opcode Fetch
= 4T x 0.5 = 2sec
Step-3: Execution time for Memory Read
= 3T x 0.5 = 1.5sec
Step-4: Execution time for Instruction
= (4T + 3T) x 0.5
= 7T x 0.5
= 3.5sec
CLK
A15
High order Unspecifi High order memory
Port address 02H
A8 memory address ed address
ALE
IO/M
RD
IOW
Timing Diagram : IN 02H
CLK
A15
High order memory Unspecifi High order memory
Port address 02H
A8 address ed address
ALE
IO/M
RD
IOR
GTU Exam Questions
Sr. Questions Marks
Positive Vibes:MPI is the interesting, easiest and scoring subject. Year
1. Draw the timing diagram of following instruction of the 8085 microprocessor. 7 W’17
i. OUT 50h W’18
ii. MOV A, B S’18
iii. MVI A, 8bit S’19
2. How many machine cycles are executed by 8085 microprocessor? List down it. 1 S’18
3. Explain various addressing modes of 8085 microprocessor. 7 S’18
W’18
W’19
4. Identify the machine cycles in the following instructions 7 W’18
1. SUB B
2. ADI 47H
3. STA 2050H
4. PUSH B
Mobile 8085 and 8086 Microprocessor Opcodes app from Play Store:
Application http://tiny.cc/aopcodes
Thank You