Unit5 8085 Assembly Language Programs Prof Swati Sharma
Unit-5 8085 Assembly Language Programs Prof. Swati Sharma swati. sharma@darshan. ac. in Unit-5 8085 Assembly Microprocessor & Interfacing Programs - 2150707 Darshan. Instituteof of. Engineering&&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 8085 Assembly Programs 2 Darshan Institute of Engineering & 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 8085 Assembly Programs 3 Darshan Institute of Engineering & 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 L 1 ; if CY=1 5. JNC L 2 ; if CY=0 6. L 1: INR A ; Increment result if CY=1 7. L 2: HLT Unit-5 8085 Assembly Programs 4 Darshan Institute of Engineering & Technology
8085 Assembly Program Exercise Write a program to subtract two 8 -bit number Unit-5 8085 Assembly Programs 5 Darshan Institute of Engineering & Technology
8085 Assembly Program Write a program to exchange the data at 1501 H & 1502 H 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 8085 Assembly Programs 6 Darshan Institute of Engineering & Technology
8085 Assembly Program Write a program for reverse counter and display result in output port 1 Initialize counter A <- 0 Ah C <- 00 h Display output-> Port 01 Decrement Counter YES Counter ≠ 0 No Halt Unit-5 8085 Assembly Programs 7 Darshan Institute of Engineering & Technology
8085 Assembly Program Write a program for reverse counter and display result in output port 1 1. MVI A, 0 A 2. MVI C, 00 3. L 1: OUT 01 ; display content of accumulator 4. DCR A ; decrement accumulator 5. CMP C ; compare C with accumulator 6. JNZ L 1 ; if Z ≠ 0 7. JZ L 2 ; if Z = 0 8. L 2: HLT Unit-5 8085 Assembly Programs 8 Darshan Institute of Engineering & 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) 1. LXI H, 0000 2. PUSH H 3. POP PSW Unit-5 8085 Assembly Programs 9 Darshan Institute of Engineering & Technology
8085 Assembly Program Exercise 1. Memory Location 2050 H holds databyte F 7 H. Write an instruction to transfer data byte to Accumulator using 3 different Opcodes: MOV, LDAX, LDA Unit-5 8085 Assembly Programs 10 Darshan Institute of Engineering & Technology
8085 Assembly Program Write a program to add the content of M[2040 H] with A, Subtract M[2041 H] from add result. Assume A=30 H M[2040]=68 H M[2041]=7 FH PROGRAM: 1. 2. 3. 4. 5. LXI ADD INX SUB HLT H, 2040 M ; A=A+M[2040] H ; HL=HL+1 M ; A=A-M[2041] Unit-5 8085 Assembly Programs 11 Darshan Institute of Engineering & Technology
8085 Assembly Program WAP to add 10 bytes starting from 3001 h to 300 Ah. Use register B to save any carries generated, while adding data bytes. Display result to output port 01 h and store at M[300 B]. Registers A Result B Carry Counter Memory C D E H L Unit-5 8085 Assembly Programs 03 04 09 06 D 2 08 F 7 A 5 02 E 3 12 3001 3002. . . 300 A Darshan Institute of Engineering & Technology
1. MVI A, 00 2. MVI B, 00 3. MVI C, 0 A 4. LXI H, 3001 5. L 1: ADD M 6. JC C 1 7. L 2: INX H 8. DCR C 9. JNZ L 1 10. JZ END 11. C 1: INR B 12. JMP L 2 13. END: OUT 01 14. STA 300 B 15. HLT WAP to add 10 bytes starting from 3001 h to 300 Ah. Start Clear Reg. to save Result Clear Reg. to save Carry Set Counter Set m/m Pointer Sum = Sum + Pointer NO Is there Carry? YES Carry= Carry + 1 Pointer=Pointer + 1 Counter = Counter -1 NO Is Counter=0 End YES Display and Save Result 13
8085 Assembly Program WAP to find largest number among 10 bytes starting from 3001 h to 300 Ah. Display result to output port 01 h and store at M[300 B]. Registers A B Memory 03 04 09 06 D 2 08 F 7 A 5 02 E 3 Result Counter C D E H L Unit-5 8085 Assembly Programs 14 3001 3002. . . 300 A Darshan Institute of Engineering & Technology
1. MVI A, 00 2. MVI C, 0 A 3. LXI H, 3001 4. MOV A, M 5. L 3: INX H 6. CMP M 7. JC L 1 8. JNC L 2 9. L 1: MOV A, M 10. JMP L 2 11. L 2: DCR C 12. JZ END 13. JNZ L 3 14. END: OUT 01 15. STA 300 B 16. HLT WAP to find largest number from 3001 h to 300 Ah. Start Clear Reg. to save Result Set Counter Set m/m Pointer Data Transfer: A <- m/m pointer Pointer=Pointer + 1 Compare A − m/m Pointer NO Is there Carry? End YES Data Transfer: A <- m/m pointer Counter=Counter - 1 NO Is Counter=0 Display and Save Result YES 15
8085 Assembly Program Exercise WAP to find Smallest number among 10 bytes starting from 3001 h to 300 Ah. Display result to output port 01 h and store at M[300 B]. Unit-5 8085 Assembly Programs 16 Darshan Institute of Engineering & Technology
8085 Assembly Program WAP to find odd and even numbers in given array of 10 elements starting from 2001 H and perform addition of Odd and Even number respectively. Data=05 h RRC A: Accumulator D 4 D 3 D 7 D 6 D 5 0 0 0 0 D 2 D 1 D 0 0 1 0 CY Unit-5 8085 Assembly Programs 17 Darshan Institute of Engineering & Technology
WAP to find sum of ODD and EVEN number. Start B <- 00 h D<- 00 h C <- 0 Ah Set m/m Pointer Data Transfer: A <- m/m pointer Rotate all the bits to right and update Carry bit Is there Carry? NO YES Odd Sum: A=A+B Even Sum: A=A+D Pointer=Pointer + 1 Counter=Counter - 1 NO 1. MVI B, 00; Store. ODD 2. MVI D, 00; Store. EVEN 3. MVI C, 0 A; Counter 4. LXI H, 0001; Pointer 5. L 1: MOV A, M 6. RRC 7. JC ODD 8. JNC EVEN 9. ODD: ADD B ; RAL 10. MOV B, A 11. JMP CNT 12. EVEN: ADD D ; RAL 13. MOV D, A 14. JMP CNT 15. CNT: INX H 16. DCR C 17. JZ END 18. JNZ L 1 19. END: HLT Is Counter=0 YES End 18
8085 Assembly Program Exercise § An array of Ten numbers is stored from memory location 2000 H onwards. Write an 8085 assembly language program to separate out and store the EVEN and ODD numbers on new arrays from 2100 H and 2200 H, respectively. Unit-5 8085 Assembly Programs 19 Darshan Institute of Engineering & Technology
8085 Assembly Program Exercise § WAP to find number of 1’s and 0’s of 8 -bit number stored at M[2010] Unit-5 8085 Assembly Programs 20 Darshan Institute of Engineering & Technology
8085 Assembly Program Exercise § WAP to multiply two 8 -bit numbers. § WAP to arrange an array of 10 numbers starting from 3001 to 300 A in descending order. § WAP to eliminate duplicate entry from an array of 10 numbers. Unit-5 8085 Assembly Programs 21 Darshan Institute of Engineering & Technology
- Slides: 21