Anda di halaman 1dari 3

8085 Programs

Program 27: Generation of Fibonacci series. Flowchart: Start

Initialize counter to display numbers in series.

Initialize register B to store the previous number.

Initialize register C to store the current number.

Add the two numbers.

Assign current number to previous number.

Save result as new current number.

Decrement counter.

Is counter = 0?

No

Yes Stop

Gursharan Singh Tatla

Page 1 of 3

8085 Programs

Program: Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 Explanation: This program generates the Fibonacci series. The Fibonacci series is: 0 1 1 2 3 5 8 13 21 34 HLT MOV INX MOV MOV ADD MOV MOV INX MOV DCR JNZ M, B H M, C A, B C B, C C, A H M, A D 200DH LXI H, 3000H MVI C, 01H MVI B, 00H Mnemonics MVI Operand D, 08H Opcode 16 08 06 00 0E 01 21 00 30 70 23 71 78 81 41 4F 23 77 15 C2 0D 20 76 Remarks Initialize counter to display numbers in series. Immediate value 07H. Initialize reg. B to store previous number. Immediate value 00H. Initialize reg. C to store current number. Immediate value 01H. Initialize H-L pair to point to memory. Lower-order of 3000H. Higher-order of 3000H. Move 00H from reg. B to memory. Increment H-L pair. Move 01H from reg. C to memory. Move previous number from reg. B to reg. A. Add the two numbers. Assign current number to previous number. Save result as new current number. Increment H-L pair. Move number from reg. A to memory. Decrement counter. Jump to address 200DH if counter is not zero. Lower-order of 200DH. Higher-order of 200DH. Halt.

In hexadecimal, it will be: 00 01 01 02 03 05 08 0D 15 22

The first two numbers of the series are 0 and 1. The third number is computed as 0 + 1 = 1, fourth number is 1 + 1 = 2, fifth number is 1 + 2 = 3 and so on. The count is initialized in register D to display the numbers in series. Initialize register B to first number 00H and register C to second number 01H. Initialize H-L pair to point to memory location 3000H.

Gursharan Singh Tatla

Page 2 of 3

8085 Programs

Move the first two numbers from registers B and C to memory locations 3000H and 3001H. Add the two numbers and store the result as first number. Increment H-L pair and move the result from accumulator to memory location. The next term is then computed by making the result equal to previous number. The process is repeated until all the numbers are calculated.

Output: After Execution: 3000H: 3001H: 3002H: 3003H: 3004H: 3005H: 3006H: 3007H: 3008H: 3009H: 00H 01H 01H 02H 03H 05H 08H 0DH 15H 22H

Gursharan Singh Tatla

Page 3 of 3

Anda mungkin juga menyukai