Skip to content

Instantly share code, notes, and snippets.

@eira-fransham
Last active January 16, 2019 11:02
Show Gist options
  • Save eira-fransham/57fcb0dbb4c6688403735e704c846a19 to your computer and use it in GitHub Desktop.
Save eira-fransham/57fcb0dbb4c6688403735e704c846a19 to your computer and use it in GitHub Desktop.
fib:
push rbp
mov rbp, rsp
sub rsp, 0x10
xor eax, eax
cmp rsi, 0
sete al
test eax, eax
; If `rsi` is _not_ zero, then jump to .fib-then
je .fib_then
mov eax, 1
jmp .fib_ret
.fib_then:
mov rax, rsi
sub rax, 1
mov r10d, 1
mov qword ptr [rsp], rsi
mov rsi, rax
lea rax, qword ptr [rip + fib@GOTPCREL]
test r10d, 1
je 0xc2
lea rax, qword ptr [rip + fac@GOTPCREL]
test r10d, 2
je 0xc2
ud2
call rax
imul rax, qword ptr [rsp]
mov rsi, qword ptr [rsp]
.fib_ret:
mov rsp, rbp
pop rbp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment