Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .data
- .section .text
- .globl _start
- _start:
- pushl $5
- call fibonacci
- addl $4, %ebp
- movl %eax, %ebx
- movl $1, %eax
- int $0x80
- # Computes n-th fibonacci number
- # eax - result
- # ebx - current
- # ecx - last
- # edi - index
- .type fibonacci, @function
- fibonacci:
- pushl %ebp
- movl %esp, %ebp
- movl $1, %ecx
- movl $1, %ebx
- movl $3, %edi
- loop_start:
- cmpl 8(%ebp), %edi
- jge end
- movl %ebx, %eax
- addl %ecx, %eax
- movl %ebx, %ecx
- movl %eax, %ebx
- incl %edi
- jmp loop_start
- end:
- movl %ebp, %esp
- popl %ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment