Sunday, September 13, 2009

Program to generate fibonacci number(8085)

Statement:Write an assembly language program to generate fibonacci number

Source Program:
MVI D, COUNT : Initialize counter
MVI B, 00 : Initialize variable to store previous number
MVI C, 01 : Initialize variable to store current number
MOV A, B :[Add two numbers]
BACK: ADD C :[Add two numbers]
MOV B, C : Current number is now previous number
MOV C, A : Save result as a new current number
DCR D : Decrement count
JNZ BACK : if count 0 go to BACK
HLT : Stop.

21 comments:

  1. hey thanks for the programs......
    but how bout storing in memory?
    also u r not doing DAA...

    ReplyDelete
  2. For more programming at 8085
    www.pradipyadav.com

    100 program related 8085

    ReplyDelete
  3. can anyone post sample input and output for this program pls....

    ReplyDelete
    Replies
    1. LXI H,3000H
      MVI D,05H
      MVI B,00H
      MOV M,B
      INX H
      MVI C,01H
      MOV M,C
      INX H
      BACK: MOV A,B
      ADD C
      DAA
      MOV M,A
      INX H
      MOV B,C
      MOV C,A
      DCR D
      JNZ BACK
      HLT

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
  5. plzzz help any one for this program
    to stored generated series number in memory...plzzz help

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. LXI H,2600 // Count, no of terms
      MOV C,M
      DCR C // Dec Count by 2
      DCR C //As First 2 values are stored

      LXI H,2400 //2400=0,2401=1
      LXI D,2402

      L1: MOV A,M
      INX H
      ADD M
      DAA
      STAX D

      INX D
      DEC C

      JNZ L1
      HLT

      Delete
  6. SOLVED PROGRAM FRNDS

    LXI H,3000H
    MVI D,05H
    MVI B,00H
    MOV M,B
    INX H
    MVI C,01H
    MOV M,C
    INX H
    BACK: MOV A,B
    ADD C
    DAA
    MOV M,A
    INX H
    MOV B,C
    MOV C,A
    DCR D
    JNZ BACK
    HLT

    ReplyDelete
  7. plzz help me with a program-
    to represent factorial of a number

    ReplyDelete
  8. it shows errors in d first 4 lines...plzzz help..

    ReplyDelete
  9. Here is my program code for generation of fibonacci series from 1 to 100:-

    MVI C,01H
    LXI H,2100H
    MOV M,C
    MOV B,C
    MOV A,C
    LOOP: ADD B
    CPI 01H
    JC L1
    CPI 64H
    JNC L2
    INX H
    MOV M,A
    L1: MOV B,C
    MOV C,A
    JMP LOOP
    L2: HLT

    OUTPUT:

    2100->01
    2101->01
    2102->02
    2103->03
    2104->05
    2105->08
    2106->0D
    2107->15
    2108->22
    2109->37
    210A->59

    ReplyDelete
  10. Dum ni hai program mei...
    remove it.....

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete