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.

14 comments:

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

    ReplyDelete
  2. cool yar ..logic samjha abhi//

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

    100 program related 8085

    ReplyDelete
  4. 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
  5. This comment has been removed by the author.

    ReplyDelete
  6. 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
  7. 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
  8. plzz help me with a program-
    to represent factorial of a number

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

    ReplyDelete