[SOLVED] C algorithm MIPS Part A

$25

File Name: C_algorithm_MIPS_Part_A.zip
File Size: 216.66 KB

5/5 - (1 vote)

Part A
Cosc 2P12 Assignment 3
Write a MIPS program that asks for and gets a non-negative integer n. Use the read Int syscall. It then prints the number n followed by n asterisks. For example, if the user entered 5 it would print the following.
5 *****
Test your program with several values of n. Provide output for n=0,1,2. Part B
Modify your program from question 1 to ask for both a positive integer n greater then or equal to 3 and a character ch. Now have your program print an n-by-n hollow square of the character ch. For example, if the user entered 3 and X; 4 and U respectfully, it would print the following. Your program is to continue to ask for input and print the output until n=0, which will exit the program.
3 XXX XX XXX
4 UUUU UU UU UUUU
Part C
From a set of numbers size n we can select ordered subsets of size r. The number of subsets of size r in n is given by the formula P(n,r) = n!/(n-r)! For example, n=4, and r=2, then P(4,2) = 4!/(4-2)! = (4x3x2x1)/(21) = 12. So there are 12 possible permutations from a set of size 4 if we choose elements 2 at a time.

Write a MIPS program which will accept 1 positive integer, in effect n. Your program is to calculate P(n,r) for all possible combinations n and r from n down to 1. For example, the user enters 3, then your program should generate as output:
P(3,3) = 6 P(3,2) = 6 P(3,1) = 3 P(2,2) = 2 P(2,1) = 2 P(1,1) = 1
To make you program as modular as possible, be sure to implement the factorial function and P(n,r) as functions, passing and returning parameters as discussed in class. Your output should be a listing of all P(n,r) generated from n, in a form similar to the example above.
Part D
Using Lab 7 as a starting point, create the function aTof which will parse a buffer. A parse will find a floating point number. Your program is to print these floats out to the screen. Copy the following between the >< to a text file, and use this as input.>21.45 blah blah blah 43.0003 61 and 0.03<Floating point operations must be done with the coprocessor, which has its own set of registers, $f0 to $f31. An integer can be moved to a floating-point register, once there it must be converted to IEEE float standard. The code to the right demonstrates this:When parsing a float from the text input consider the following algorithm:For each digit shift left by multiplying by10, same as parsing an int. If there is adecimal then count N, how many digits we shift from the decimal. Then convert this integer to afloat and then divide by N*10.0.E.g. 101.22 is parsed to an integer of 10122, we count 2 digits after the radix this is N. After conversion to a float, 10122.0 we divide by 2*10 yielding 101.22.SubmissionThis submission will be physical and electronically submitted. Thus, it will be your responsibility to ensure that it is printed and submitted in due course prior to the due date as listed above. Marks will be awarded for completion, correctness, and neatness. Your code must be properly commented with your name and student number in a comment block at the top.To submit electronically your assignment 3 code folder will need to be stored on Sandcastle. From the assignment directory run the script submit2p12. It will prompt you for the requisite details and then electronically package the contents of the directory and submit your work.For the physical submission, print out the code for each part, and the output. It is your responsibility to ensure ample output is supplied Your submission should be contained in a large (8.5 inch x 11 inch) envelope. Cover Sheet completely filled out, available from: “http://www.cosc.brocku.ca/forms/cover” Note: your assignment will not be marked unless one is submitted with the assignment on the assignment due date. This should be stapled to the outside of the envelope. Printout of your source code, with proper identification on each printout. The End

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] C algorithm MIPS Part A
$25