Created
April 29, 2016 17:12
-
-
Save sivaramaaa/01f92044e763e4b0cc36a689febe8b02 to your computer and use it in GitHub Desktop.
Fibonacci Series of n number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern printf | |
extern scanf | |
section .data | |
prompt: db "Enter no of terms in fibbonoci series",10,0 | |
fmts: db "%d",0 | |
n : dd 0 | |
a: dd 0 | |
b: dd 1 | |
section .text | |
global main | |
main: | |
push ebp | |
mov ebp,esp | |
push prompt | |
call printf | |
add esp,4 | |
push n | |
push fmts | |
call scanf | |
add esp,8 | |
mov ecx,0 | |
l1: | |
cmp ecx,0 | |
je l2 | |
cmp ecx,1 | |
je l2 | |
mov eax,DWORD [a] | |
mov ebx,DWORD [b] | |
add eax,ebx | |
push ecx | |
push ebx | |
push eax | |
push fmts | |
call printf | |
add esp,4 | |
pop eax | |
pop ebx | |
pop ecx | |
mov DWORD [a],ebx | |
mov DWORD [b],eax | |
inc ecx | |
cmp ecx,DWORD[n] | |
jl l1 | |
jmp exit | |
l2: | |
push ecx | |
push fmts | |
call printf | |
add esp,4 | |
pop ecx | |
inc ecx | |
cmp ecx,DWORD[n] | |
je exit | |
jmp l1 | |
exit: | |
mov eax,0 | |
mov esp,ebp | |
pop ebp | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment