Created
December 5, 2018 01:52
-
-
Save seisvelas/a860e4569f0a8e5d1c917d5ec4042e62 to your computer and use it in GitHub Desktop.
Attempted recursive fibonacci finder
This file contains 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
.section .data | |
.section .text | |
.globl _start | |
_start: | |
# adjust stack frame and push fib args to stack | |
pushl $5 | |
pushl $1 | |
pushl $0 | |
call fibr | |
movl %eax, %ebx | |
movl $1, %eax | |
int $0x80 | |
## FUN LIB ## | |
fibr: | |
# load func args | |
popl %eax # 0 | |
popl %ecx # 1 | |
popl %ebx # nth fib | |
decl %ebx | |
# tmp reg %esi | |
movl %ecx, %esi | |
addl %ecx, %eax | |
movl %esi, %eax | |
movl %esp, %ebp | |
cmp $0, %ebx | |
je done | |
pushl %ebx | |
pushl %ecx | |
pushl %eax | |
# recurse | |
call fibr | |
# leave function | |
done: | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment