CS 210 PROJECT #3 Due: Noon Friday 03/30/2007 This project offers the student some experience with mixed-language programming, and with using assembly language to implement a 'recursive' function. PROBLEM STATEMENT On the back of this page is the C++ source-code for a program which prints some of the upper rows in the famous PASCAL TRIANGLE of so-called 'binomial coefficients' that were studied in High School algebra. There is a formula for calculating these binomial coeffieients using values of the factorial function: bin( n, k ) = n! / k!(n-k)! But this formula is not very useful in practical computations, even with a computer, because of the large sizes of the numerator and denominator, even when the arguments n and k are fairly small. These values will quickly "overflow" the size of the CPU's general registers, so a program cannot make direct use of the built-in circuits for doing multiplication and division based on this formula. Fortunately there is another way to obtain the values for these binomial coefficients, based on 'recursion', as shown in the source-code for this 'triangle.cpp' application. Your task is to design an implementation of that function in assembly language, and then link your assembly language file (named 'binary.s') with a modfified version of 'triangle.cpp' where the body of the 'bin' function has been removed (or just commented out), and only the function's prototye is retained, like this: extern "C" int bin( int n, int k ); The commands for assembling your 'binary.s' file, and then compiling and linking your 'triangle.cpp' program, are these: $ as binary.s -o binary.o $ g++ triangle.cpp triangle.o -o triangle WHAT TO SUBMIT Copy all of your project files into your CS210 '/submit' directory where your Instructor can find them for testing purposes. Also turn in printouts of your source-files ('binary.s' and 'triangle.cpp') that you produce using the 'ljpages' printing-utility (from our course website). Finally turn in a printout of the screen-output your program generates, which you 'captured' in a file (by using i/o-redirection), like this: $ triangle > triangle.out (These printed submissions should be turned in at Room 222 in Harney.) ________________________________________________________________________ Allan B. Cruse University of San Francisco Spring 2007