Lab 04
Lab 04
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
MEMORY CONTENT
9050H 00H
9051H 01H
9052H 01H
9053H 02H
9054H 03H
9055H 05H
9056H 08H
9057H 0DH
9058H 15H
9059H 22H
`
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
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.
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
Program Table:
LABEL MEMORY OPCODE OPERAND HEX CODE
`
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).