Question: 1 a . Write a function combination which implements the combinatorial function n C r in MIPS assembler. A straightforward Java implementation without checks is
a Write a function combination which implements the combinatorial function in MIPS assembler.
A straightforward Java implementation without checks is given here:
int combinationsint int
int ;
forint ;;
;
forint ;;
;
return ;
b The assemble instructions for multiplication and division, respectively, are mul and div.
Use the nonrecursive factorial example with loops from the class as a starting point.
Write a main function which calls combinations twice with hardcoded and as follows:
aThe answer is
bThe answer is which takes more than bits to represent!
Exit your program with the proper syscall.
c Test and run your program. Provide a screenshot of test runs for the two cases.
I haven't learned mflo or mfhi.
text
main:
#Call combinations with
$
$
jal combinations
# Display result for
# Display result
ste, svil
$
move $
sae, ste
syscall
ji jal combinations
# Display result for
iw ste, sv li sve,
move $ mto
syscall
exit: $v exit with syscall
# subroutine FACTORIAL
# calculates IN: $
# OUT:
$ $ FACTORIAL
$$$
combinations:
#Function proglogue
sw swa, o $
$$ $$
$$
# Initialize result to
$ $
Error line column : lw: Too few or incorrectly formatted operands. Expected: lw $t$t
Error line column : lw: Too few or incorrectly formatted operands. Expected: lw $t$t
Error line column : sw: Too few or incorrectly formatted operands. Expected: sw $t$t
Error line column : lw: Too few or incorrectly formatted operands. Expected: lw $$
Error line column : sw: Too few or incorrectly formatted operands. Expected: sw $t$t
Error line column : lw: Too few or incorrectly formatted operands. Expected: lw $$
Error line column : sw: Too few or incorrectly formatted operands. Expected: sw $t$t
Assemble: operation completed with errors.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
