Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .intel_syntax noprefix
- .global main
- .text
- main:
- mov eax, [esp+8]
- mov eax, [eax+4]
- push eax
- call atoi
- add esp, 4
- push eax
- call f
- add esp, 4
- push eax
- push offset msg
- call printf
- add esp, 8
- xor eax, eax
- ret
- f:
- cmp eax, 2
- je return1
- cmp eax, 1
- je return1
- dec eax
- push eax #; n-1
- call f
- add esp, 4
- push eax #; f(n-1)
- mov eax, [esp+8] #; get n
- sub eax, 2
- push eax #; n-2
- call f
- add esp, 4
- add eax, [esp]
- add esp, 4
- ret
- return1:
- mov eax, 1
- ret
- .data
- msg: .asciz "%d\n"
- #; if (n == 1 || n == 2) return 1;
- #; return f(n-2) + f(n-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement