Page 3 - October_Newsletter_2017
P. 3
cmp edx, 0
ja @f
mov eax, 0
ret
@@:
cmp edx, 2
ja @f
mov eax, 1
ret
@@:
push ebx
mov ebx, 1
mov ecx, 1
@@:
lea eax, [ebx+ecx]
cmp edx, 3
jbe @f
mov ebx, ecx
mov ecx, eax
dec edx
jmp @b
@@:
pop ebx
ret
All fairly easy, as you can see.
Now compare this with the same function in C: a more modern struc-
tured language.
unsigned int fib(unsigned int n) {
if (n <= 0)
return 0;

