t1nman

Arch_fibXnum

May 21st, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global _start
  2. extern printf
  3. extern atoi
  4. extern exit
  5.  
  6. section .text
  7.  
  8. _start:
  9.         push dword [x]
  10.         call fibonacci
  11.  
  12.         push eax
  13.         push fmt
  14.         call printf
  15.  
  16.         call exit
  17.  
  18. fibonacci:  
  19.  
  20.         ;push ebp
  21.         mov ebp, esp
  22.         mov ecx, [ebp+4]
  23.  
  24.         xor eax, eax
  25.         inc eax
  26.         xor ebx, ebx
  27.         inc ebx
  28.  
  29. .cycle:
  30.         mov edx, eax
  31.         mov eax, ebx
  32.         add ebx, edx
  33.         dec ecx
  34.         jnz .cycle
  35.  
  36.         mov eax, edx
  37.  
  38.         mov esp, ebp
  39.         ;pop ebp
  40.  
  41.         ret 4
  42.  
  43. section .data
  44.     fmt db '%10d', 0xa, 0
  45.     x dd 5
Advertisement
Add Comment
Please, Sign In to add comment