Write an assembly language program to generate Fibonacci series.
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to generate Fibonacci series. For example Fibonacci series is 0,1,1,2,3,5,8,13,21,34,55…..so on. The 2 is found by adding the two numbers before it (1+1), similarly, the 3 is found by adding the two numbers before it (1+2), and the 5 is (2+3), and so on!
Assumption: We have to write a program to generate Fibonacci series. For example Fibonacci series is 0,1,1,2,3,5,8,13,21,34,55…..so on. The 2 is found by adding the two numbers before it (1+1), similarly, the 3 is found by adding the two numbers before it (1+2), and the 5 is (2+3), and so on!
The Rule is x_{n} = x_{n1} + x_{n2 }where Xn is nth Term, Xn1 is previous term and Xn2 is Next term
Algorithm:
 Initialize counter
 Initialize variable for Previous number and current number
 Add previous number and current number
 Now make current number as previous number
 Result as previous number
 Check the counter, if the counter is not zero ,repeat process
 End the Program
Memory Address

Opcode

Operand

Comments

2000

MVI

D,05 H

Initialize counter

2002

MVI

B,00 H

Register for store previous number

2004

MVI

C,01 H

Store current number

2006

MOV

A,B

Store Previous number in A

2007

ADD

C

Add previous number and Current

2008

MOV

B,C

Current number is now previous no.

2009

MOV

C,A

Save result as new current no.

200A

DCR

D

Decrement counter

200B

JNZ

2006

If count is not zero then jump to 2006

200E

END

End the program

Used Instruction:
MVI: This instruction is used to store 8 bit data in specified register.
MOV: This instruction is used to copy the content from source register to destination register.
ADD: This instruction is used to add the content of specified register to the content of accumulator and store output in accumulator.
DCR: This instruction is used decrement the content of specified register by 1.
JNZ: Jump if counter is not zero at target address.
END: This instruction is used to execute the program.
Subscribe to:
Post Comments (Atom)
I need a ALP code in 8086 to find the Fibonacci series up to a number?
ReplyDeletePlease can u giv the program to find nth term in fibonnaci series... suppose ...generating the 10th term in the fibonacci series.... in 8085 programing !!! ?? pls ?
ReplyDelete