CS 210 PROJECT 2 Due Date: Noon Thursday 03/12/2009 This project acquaints students with some numeric formatting issues that arise when presenting a mathematical table and with design steps in implementing an algorithm based on formulas from elementary algebra. PROJECT STATEMENT Enhance the 'squares.s' example-program which we discussed in class so that, in addition to showing the squares of the first twenty positive integers, computed without using any x86 multiplication instructions, it also shows the cubes of these integers, but once again without using any multiplication instructions. Your revised program source-file should be named 'powers.s', and it should display its numerical output arranged in columns whose fields are right-justified, so it looks like this: Table of Squares and Cubes number square cube ------------------------------ 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 . . . . . . . . . 20 400 8000 ------------------------------ You can redirect your program's output to a file (so it can be printed). For example, if your executable file is named 'powers', you can use the command-syntax: $ ./powers > powers.out $ ./ljpages powers.out To avoid using multiplication operations in 'squares.s', we applied ideas from elementary algebra, described by these two formulas: twice( x ) = x + x square( n+1 ) = square( n ) + twice( n ) + 1 In a similar manner, you can calculate the cubes of positive integers by using this additional pair of formulas from algebra: thrice( x ) = x + x + x cube( n+1 ) = cube( n ) + thrice( square( n ) ) + thrice( n ) + 1 Copy your (four) project-files to your '/submit' directory, and hand in printouts of your 'powers.s' and 'powers.out' files to your Instructor. _______________________________________________________________________ Allan B. Cruse University of San Francisco Spring 2009