Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TITLE Fibonacci Sequence (main.asm)
- ; Description: Fibonacci Backwards Generator
- ;
- ; Revision date:
- INCLUDE Irvine32.inc
- .data
- str1 BYTE "Enter an integer:",0
- intVal DWORD 1 DUP(?)
- fibArray DWORD 100 DUP(?)
- .code
- main PROC
- call Clrscr
- call PromptForInteger
- call Fib
- exit
- main ENDP
- ;------------------------------
- ;PROCEDURE TO ACCEPT AN INTEGER INPUT
- ;---------------------------------
- PromptForInteger PROC
- ;Display the message
- mov edx,offset str1
- call WriteString
- ;Read the input from the screen
- call ReadInt
- mov intVal,eax
- ;New Line
- call crlf
- ret
- PromptForInteger ENDP
- ;------------------------------
- ;PROCEDURE TO GET FIB NUMBERS
- ;---------------------------------
- Fib PROC
- cmp eax,0
- je L1
- cmp eax,1
- je L1
- jmp L2
- L1:
- mov ebx, eax
- jmp L3
- L2:
- dec eax
- push eax
- call Fib ;n-1
- pop eax
- mov ebx, eax
- dec eax
- push eax
- call Fib ;n-2
- pop eax
- add eax, ebx
- L3:
- Fib ENDP
- END main
Add Comment
Please, Sign In to add comment