Sunteți pe pagina 1din 21

Unit-5

8085 Assembly Language Programs


Prof. Swati Sharma
swati.sharma@darshan.ac.in

Microprocessor
Unit-5
Unit-5 8085
8085 Assembly
Microprocessor && Interfacing
Assembly Programs
Interfacing
Programs 2150707 1
-- 2150707 Darshan
Darshan
DarshanInstitute
Darshan Institute
Instituteof
Institute of
ofEngineering
of Engineering
Engineering&
Engineering &
&Technology
& Technology
Technology
Technology
Subject Overview
Sr. No. Unit % Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 10%
4 Assembly Language Basics 10%
5 8085 Assembly Language Programs 10%
6 Stack & Subroutines 10%
7 I/O Interfacing 15%
8 Advanced Microprocessors 20%
9 SUN SPARC Microprocessor 5%
10 ARM Processor 5%

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 2 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to add two 8-bit number (consider carry bit)
Accumulator <- ABh

B <- ACh

ADD Accumulator and B

YES
Carry? Increment Result

NO
Display Result

End

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 3 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to add two 8-bit number with carry
1. MVI A, ABh

2. MVI B, ACh

3. ADD B ; A=A+B

4. JC L1 ; if CY=1

5. JNC L2 ; if CY=0

6. L1:INR A ;Increment result if CY=1

7. L2:HLT

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 4 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Exercise
Write a program to subtract two 8-bit number

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 5 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to exchange the data at 1501H & 1502H memory
location.
1. LDA 1501 ;load A <- M[1501]
2. MOV B,A ; B <- A

3. LDA 1502 ;load A <- M[1502]


4. STA 1501 ; M[1501] <- A

5. MOV A,B ; A <- B


6. STA 1502 ; M[1502] <- A

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 6 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program for reverse counter and display result in output
port1
Initialize counter
A <- 0Ah
C <- 00h

Display output-> Port 01

Decrement Counter
YES

Counter 0

No
Halt

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 7 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program for reverse counter and display result in output
port1
1. MVI A,0A
2. MVI C,00
3. L1: OUT 01 ; display content of accumulator
4. DCR A ; decrement accumulator
5. CMP C ; compare C with accumulator
6. JNZ L1 ; if Z 0
7. JZ L2 ; if Z = 0
8. L2: HLT

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 8 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to Set PSW (Accumulator & 5 Flags)
1. LXI H, FFFF

2. PUSH H

3. POP PSW;lower 8-bit to flags;higher 8-bit to Accumulator

Write a program to Reset PSW (Accumulator & 5 Flags)


4. LXI H, 0000

5. PUSH H

6. POP PSW

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 9 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Exercise
1. Memory Location 2050H holds databyte F7H. Write an
instruction to transfer data byte to Accumulator using 3
different Opcodes: MOV, LDAX, LDA

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 10 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Write a program to add the content of M[2040H] with A,
Subtract M[2041H] from add result.
Assume
A=30H
M[2040]=68H
M[2041]=7FH

PROGRAM:
1. LXI H,2040
2. ADD M ; A=A+M[2040]
3. INX H ; HL=HL+1
4. SUB M ; A=A-M[2041]
5. HLT

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 11 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
WAP to add 10 bytes starting from 3001h to 300Ah. Use register B to
save any carries generated, while adding data bytes. Display result to
output port 01h and store at M[300B].

Registers Memory

03 3001
A Result 04 3002
09 .
B Carry Counter C 06 .
D E D2
.
08
H L F7
A5
02
E3 300A
Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 12 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
1. MVI A,00
Start
2. MVI B,00
WAP to add 10 bytes starting from 3001h to 300Ah.

3. MVI C,0A
Clear Reg. to save Result 4. LXI H,3001
Clear Reg. to save Carry 5. L1:ADD M
Set Counter 6. JC C1
Set m/m Pointer 7. L2:INX H
8. DCR C
Sum = Sum + Pointer 9. JNZ L1
10. JZ END
NO Is there 11.C1: INR B
Carry? 12. JMP L2
YES 13.END:OUT 01
14.STA 300B
Carry= Carry + 1
15.HLT
Pointer=Pointer + 1
Counter = Counter -1 End

NO Is YES Display and Save


Counter=0 Result
13
8085 Assembly Program
WAP to find largest number among 10 bytes starting from 3001h to
300Ah. Display result to output port 01h and store at M[300B].

Registers Memory

03 3001
A Result 04 3002
09 .
B Counter C 06 .
D E D2
.
08
H L F7
A5
02
E3 300A
Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 14 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Start 1. MVI A,00
2. MVI C,0A
Clear Reg. to save Result 3. LXI H,3001
WAP to fnd largest number from 3001h to 300Ah.

Set Counter 4. MOV A,M


5. L3:INX H
Set m/m Pointer
6. CMP M
Data Transfer: 7. JC L1
A <- m/m pointer 8. JNC L2
9. L1:MOV A,M
Pointer=Pointer + 1 10. JMP L2
11.L2:DCR C
12. JZ END
Compare
13. JNZ L3
A m/m Pointer 14.END:OUT 01
15. STA 300B
Is there 16. HLT
Carry? End
NO YES
Data Transfer:
A <- m/m pointer Display and Save
NO
Result
Counter=Counter - 1
Is YES
Counter=0 15
8085 Assembly Program
Exercise
WAP to find Smallest number among 10 bytes starting from 3001h to
300Ah. Display result to output port 01h and store at M[300B].

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 16 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
WAP to find odd and even numbers in given array of 10 elements
starting from 2001H and perform addition of Odd and Even number
respectively.
Data=05h RRC
A:Accumulator
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 1 0 11
0 0 0 0 0 1 0

CY

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 17 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
Start 1. MVI B,00;StoreODD
2. MVI D,00;StoreEVEN
B <- 00h 3. MVI C,0A;Counter
D<- 00h 4. LXI H,0001;Pointer
C <- 0Ah 5. L1: MOV A,M
WAP to fnd sum of ODD and EVEN number.

Set m/m Pointer 6. RRC


Data Transfer: 7. JC ODD
A <- m/m pointer 8. JNC EVEN
9. ODD: ADD B ;RAL
Rotate all the bits 10. MOV B,A
to right and update 11. JMP CNT
Carry bit 12.EVEN: ADD D ;RAL
13. MOV D,A
Is there 14. JMP CNT
Carry? NO
15.CNT: INX H
YES 16. DCR C
Odd Sum:A=A+B Even Sum:A=A+D 17. JZ END
18. JNZ L1
NO 19.END: HLT
Pointer=Pointer + 1
Is YES
Counter=Counter - 1 End
Counter=0 18
8085 Assembly Program
Exercise
An array of Ten numbers is stored from memory location 2000H
onwards. Write an 8085 assembly language program to separate
out and store the EVEN and ODD numbers on new arrays from
2100H and 2200H, respectively.

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 19 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Exercise
WAP to find number of 1s and 0s of 8-bit number stored at
M[2010]

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 20 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology
8085 Assembly Program
Exercise
WAP to multiply two 8-bit numbers.
WAP to arrange an array of 10 numbers starting from 3001 to
300A in descending order.
WAP to eliminate duplicate entry from an array of 10 numbers.

Unit-5
Unit-5 8085
8085 Assembly
Assembly Programs
Programs 21 Darshan
Darshan Institute
Institute of
of Engineering
Engineering &
& Technology
Technology

S-ar putea să vă placă și