t1nman

Arch_fib

May 21st, 2012
81
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.         mov ecx, [esp+8]
  10.         push ecx
  11.         call atoi
  12.         add esp, 4
  13.         mov ecx, eax
  14.  
  15. ; start of fibonacci calc
  16.  
  17.         xor eax, eax ; first number
  18.         inc eax
  19.         xor ebx, ebx ; second number
  20.         inc ebx
  21.  
  22. print:
  23.         push eax
  24.         push ecx
  25.  
  26.         push eax
  27.         push fmt
  28.         call printf
  29.         add esp, 8
  30.  
  31.         pop ecx
  32.         pop eax
  33.  
  34.         mov edx, eax
  35.         mov eax, ebx
  36.         add ebx, edx
  37.         dec ecx
  38.         jnz print
  39.  
  40.         call exit
  41.  
  42. section .data
  43.     fmt db '%10d', 0xa, 0
Advertisement
Add Comment
Please, Sign In to add comment