CSC 220

Program #1 - Fibber!

What’s the buzz:

  • Due: May 1, 2006 by 6:00 pm on that Monday night
  • Worth: 4 points, or 4% of your grade
  • Why: Introduction to Intel assembly code and the gcc compiler

Description

Fibber, our first program, is a small one, but Yow! There’s a lot of new stuff to learn!

Your mission is to implement an Intel assembly (IA-32) program that prints the n’th number in the Fibonacci sequence. In case you’ve forgotten your Fibonacci sequence (shame!), here’s a nice Wiki-page on it:

http://en.wikipedia.org/wiki/Fibonacci_sequence

Here’s some pseudo-code for an iterative solution to this problem:

int fib( int N)
   if N == 0 then FN = 0
   else if N == 1 then FN = 1
   else
      FN = 0
      FN-1 = 1
      Loop from 1 to N
         FN+1 = FN + FN-1
         FN-1 = FN
         FN = FN+1
   return FN

Please bundle that algorithm up into a function. Use scanf()/printf() functions to read/write from/to the user. Something like this:

printf to query user for an integer
scanf to read the value
answer = fib( value)
if overflow then printf an error message
else printf the answer

About that overflow check... once you get running (ha!), you’ll notice that large values entered by the user can break your Fibonacci program. If your Fibonacci answer is too large, an overflow will occur and the answer will appear to be a negative number (why is that?). Please check for this and tell the user that he has to input something smaller.

Grading

Please put your completed code on the k: drive. This should include:

  • Your assembly code file (fib.s)
  • Your executable (a.exe)
  • A README file describing the status of your program

You must comment your code; uncommented code will face a harsh brand of grading justice.

  • File header – a block comment at the top of the file: file name, author, creation date, description
  • Function header – a block comment at the top of each function (only main() in this program): function, parameters, return value, description
  • Inline comments – describe the purpose of each logical block of assembly code statements

Please use meaningful label names to make your program easier to understand.

Notes

We will have extensive lecture time on this and peek at all the tasty examples on the web site. Check back here every so often if you like.

thanks... yow, bill  

...

My site: william.krieger.faculty.noctrl.edu

My email: wtkrieger@noctrl.edu