Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Name:RAHUL VATSA

Roll: 001610701027
ETCE UG
3rd Year 1st Semester
LAB: Microprocessor Lab
LAB 04

`
LAB 03: Fibonacci number generation using 8085
AIM: To write an 8085 ALP to generate the first Fibonacci numbers. .
Algorithm:
1. Store 9050H in (HL).
2. Initialize register B with 00H, register C with 08H and register D with 01H.
Here (B) and (D) are the first two fibonacci numbers while (C) is the loop
counter.
3. Move (B) to (M).
4. Increment ( HL )by 1 .
5. Move (D) to (M).
6. Move (B) to (A).
7. Add (D) to (A) and store the result in (A).
8. Move (D) to (B).
9. Move (A) to (D).
10. Increment (HL) by 1.
11. Move (A) to (M).
12. Decrement (C) by 1.
13. Jump to step 7 IF (C) !=0
14. END

`
`
Program Table:
LABEL MEMORY OPCODE OPERAND HEX CODE

9000H LXI H , 9050H 21,50,90


9003H MVI C , 08H 0E,08
9005H MVI B , 00H 06,00
9007H MVI D , 01H 16 ,01
9009H MOV M,B 70
900AH INX H 23
900BH MOV M,D 72
900CH MOV A,B 78
HERE : 900DH ADD D 82
900EH MOV B, D 42
900FH MOV D , A 57
9010H INX H 23
9011H MOV M, A 77
9012H DCR C 0D
9013H JNZ HERE C2 ,0D,90
9016H HLT 76

Result: After execution of the ALP in 8085 we get

MEMORY CONTENT
9050H 00H
9051H 01H
9052H 01H
9053H 02H
9054H 03H
9055H 05H
9056H 08H
9057H 0DH
9058H 15H
9059H 22H

Which is indeed the sequence of first 10 Fibonacci numbers.

`
Experiment 06 a: Finding square of a hexadecimal number
using 8085.
Aim: To write an 8085 ALP to find the square of the number and store it in
memory.
Algorithm: We store the number we wish to square (3F) in (9050H)
1. Store 9050H in (HL) to set it up as memory pointer
2. Clear (A)
3. Clear (C) to set it up as carry register.
4. Store (M) in (B)
5. Add (M) to (A) and store it in (A)
6. If (CY) =0 goto step 8
7. Increment (C) by 1
8. Decrement (B) by 1
9. If (B) !=0 goto 5
10.Store (A) in (9051H)
11.Move (C) to (A)
12.Store (A) in 9052
13. END

`
`
Program Table:
LABEL MEMORY OPCODE OPERAND HEX CODE

9000H MVI A ,00H 3E , 00


9001H MVI C , 00H 0E , 06
9002H LXI H 9050H 21 , 50 ,90
9005H MOV B,M 46
NEXT: 9006H ADD M 86
9007H JNC HERE D2 , 0F ,90
900AH INR C 23
900BH DCR B 05
900CH JNZ NEXT C2 ,06,90
HERE : 900FH STA 9051H 32 ,51 ,90
9012H MOV A,C 79
9013H STA 9052H 32 , 52 ,90
9016H HLT 76

Result: After execution of the ALP in 8085 we get the result equal to
Which is in agreement with the result obtained by arithmetic operation.

`
Experiment 06 b: Finding square of a hexadecimal number
using 8085.

Algorithm: We store the number (09H) we want to cube in 9050H memory


1. (A)<- FFH.
2. Store 06H to (B) to set it up as loop counter.
3. Store 9A00H to (HL) to set it up as memory pointer
4. Compare ((HL)) to (A) .
5. If (A) > ((HL)): Move ((HL)) to (A).
6. Increment (HL) by 1
7. Decrement (B) by 1.
8. If (B) !=0 : goto 4
9. Store (A) in (9E00H).
10. END.

Flow Chart:

START

(A)<-FFH
(B)<-06H
(HL)<-9A00H

(A)> (M)
YES
NO
NO
(A)<-(M)

(HL)<-(HL) +1

(B)<-(B)-1
`
(B)=0

YES

(9E00H)<-(A)

END

Experiment 06 b: Finding cube of a hexadecimal number


using 8085.

Program Table:
LABEL MEMORY OPCODE OPERAND HEX CODE

9000H MVI A , FFH 3E , 00


9002H MVI B , 06H 06 , 06
9004H LXI H 9A00H 0E , 00
NEXT 9007H CMP M BE
9008H JC NEGATIVE DA ,0C ,90
900BH MOV A,M 7E
NEGATIVE 900CH INX H 23
900DH DCR B 05
900EH JNZ NEXT C2 , 07,90
9011H STA 9E00H 32 , 00 ,9E

`
9014H HLT 76

Result: After execution of the ALP in 8085 we get (9E00H) = 01H which is
indeed the smallest number in the given array (at memory 9A04H).

You might also like