Machine Problem 2, due Oct 12
Part of
the homework for 22C:60, Fall 2008
|
Submit the source file mp2.a (or mp2.txt if you must)
for your solution using the submit command, documented at:
--
http://www.divms.uiowa.edu/help/msstart/submit.html
Note: The due date is the Monday following a Friday exam, but the exam will assume that you have made significant progress toward solving this assignment.
Write a program that prints as much of Pascal's triangle as will fit on the screen. Each entry in Pascal's triangle P(i,j) has a value defined as follows:
P(0,0) = 1 P(i,0) = 1 P(0,j) = 1 P(i,j) = P(i-1,j) + P(i,j-1)
The top level algorithm for putting the triangle on the screen should look something like this:
for i = 0 to height-1 do for j = 0 to i do dspat( width/2 - 2i + 5j, i ) dspdecu( P(i-j, j), 0 )
Simple transformations to the above code can make the assembly language much easier. Consider, for example, "factoring" constant computation out of the loop, so width/2 is computed just once.
Half credit will be given for cleanly formatted properly commented source code, regardless of whether it works correctly. Half credit will be given for the correct operation of your program, regardless of looks.