Skip to content

Instantly share code, notes, and snippets.

@seisvelas
Created December 5, 2018 01:52
Show Gist options
  • Save seisvelas/a860e4569f0a8e5d1c917d5ec4042e62 to your computer and use it in GitHub Desktop.
Save seisvelas/a860e4569f0a8e5d1c917d5ec4042e62 to your computer and use it in GitHub Desktop.
Attempted recursive fibonacci finder
.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