A second integer representing the count of numbers to be selected from the




A second integer representing the count of numbers to be selected from the large pool. Note: Because the largest MIPS single precision integer value will not hold the value of more than 12!, you will need to use some algebra to simplify the calculations. With the simplifications, all the math can be done using the integer multiply. Additionally, it is expected that your program will handle correctly only a small subset of all the possible probability / odds calculations. You can use the fact that the number of balls selected will be less than 12, and that you can use the provided factorial subroutine. Use the System Calls on page A-44 for the input and output. The work products of this assignment are: 1) A copy of the source program. 2) Screen captures showing the output results. [ 150 points ]· An integer representing the large pool of possible numbers. ·The subroutine example on the following page, calculates the Factorial of an input integer. Starting with the code in the example, write a correct program in MIPS - SPIM assembly language that: 1) Calculates the odds of winning the Power Ball grand prize jackpot. 2) The calculated value is to be displayed on the SPIM screen with the appropriate commentary text. Such as “the odds are 1 in nnnn.” 3) Test your program by calculating the odds of choosing a set of 3 numbers from a set of 7 numbers. 4) The program is to accept as input: 

pfctrl:

sw $ra, 4($sp) # ***** the return address

sw $a0, 0($sp) # ***** the current value of n

addi $sp, $sp, -8 # ***** stack pointer

slti $t0, $a0, 2 # ***** 1 iteration, n=0 or =1;n!=1

beq $t0, $zero, L1 # ***** calculate n(n-1)!

addi $v0, $zero, 1 # *****=1; n!=1

jr $ra # ***** multiply

L1:

addi $a0, $a0, -1 # ***** := n-1

jal pfctrl # ***** (n-1)!

addi $sp, $sp, 8 # ***** the stack pointer

lw $a0, 0($sp) # ***** saved (n-1)

lw $ra, 4($sp) # ***** return address

mul $v0, $a0, $v0 # ***** (n)*(n-1)

jr $ra # ***** value n!