Fibbing Around

April 24, 2008 on 10:45 pm | In Personal, Programming | By QBasicer |

My officemate Alexei and I were wondering a bit on how fast Fibonacci in assembly would be, so I wrote a quick little linear fib application in Linux.

08048074 <_start>:
 8048074:       31 c0                   xor    %eax,%eax
 8048076:       bb 01 00 00 00          mov    $0x1,%ebx
 804807b:       ba 01 00 00 00          mov    $0x1,%edx

08048080 <_calc>:
 8048080:       31 c9                   xor    %ecx,%ecx
 8048082:       01 c1                   add    %eax,%ecx
 8048084:       01 d9                   add    %ebx,%ecx
 8048086:       89 d8                   mov    %ebx,%eax
 8048088:       89 cb                   mov    %ecx,%ebx
 804808a:       42                      inc    %edx
 804808b:       83 fa 2e                cmp    $0x2e,%edx
 804808e:       75 f0                   jne    8048080 <_calc>
 8048090:       89 cb                   mov    %ecx,%ebx
 8048092:       b8 01 00 00 00          mov    $0x1,%eax
 8048097:       cd 80                   int    $0x80

Runs pretty quick, but I’m not sure how good it would be, as it’s only using 32 bits, so it can only calculate fib(46) and lower, and doesn’t even output (that’s a bit trickier).

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress with Pool theme design by Borja Fernandez. I rewrote the CSS because I'm cool like that.
Entries and comments feeds. Valid XHTML and CSS. ^Top^