# 汇编代写| MIPs代做 – Cosc 2P MIPS

Assignment代做|Lab代写|汇编代写| MIPs代做 – 这是一个比较小型的mips程序代写任务

### Cosc 2P MIPS assignment 3

Part A

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

#### X X

#### XXX

#### 4

#### UUUU

#### U U

#### U U

#### 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)/(2×1) = 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 by 10, same as parsing an int. If there is a decimal then count N, how many digits we shift from the decimal. Then convert this integer to a float 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.

```
The End
```