Calculate Fibonacci Numbers
This function calculates the Nth Fibonacci number.
The Fibonacci numbers are a well-known mathematical sequence. The first and second numbers are both 1. From then on, the Nth number is the sum of numbers (N-1) and (N-2), so the sequence begins:
1, 1, 2, 3, 5, 8, 13, 21 . . .
Because the numbers can become large, the program calculates a 64-bit result. It assumes on entry that ecx contains the number in the Fibonacci sequence to calculate. It returns the result in edx:eax, which means edx stores the high 32 bits and eax stores the low 32 bits.
If the result would overflow 64 bits, 0 is returned.
This is a code fragment, ...
Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.