Content deleted Content added
Line 48:
<syntaxhighlight lang="asm">
fib:
mov rax, rdi ; put the argument into
test rdi, rdi ; is it zero?
je .return_from_fib ; yes - return 0, which is already in
cmp rdi, 2 ; is 2 greater than or equal to it?
jbe .return_1_from_fib ; yes (i.e., it's 1 or 2) - return 1
Line 57:
mov rsi, 1 ; the number before that, which also starts out as 1
.fib_loop:
lea rax, [rsi + rdx] ; put the sum of the previous two numbers into
cmp rcx, 2 ; is the counter 2?
je .return_from_fib ; yes - rax contains the result
|