Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 ; nr; ; 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. Can someone help me edit my code so it can run and get the answer? When I ran the code I got the answer of I need the answers from b please and I also need help with EndLoop from my code below. result: word text Invert to and an for decrementing. You want to decrement a temporary register, not ae main: Call coubinations with $ $ jal conbinations combinations Store result in menory # Display result for ii $ Call combinations with $ $ li $a combinations $va result is store result in menory. Display result for Fisplay result Li $ lus $ab result & Load the result from aenory exit: $ve exit with syscall conbinations: i Prologue. addi $$ Allocate space for local variables su $$ $$ $$ $$ Save return address Save li $te Initialize Loop to calculate add $$$ Loop: mul $$$ addi $$ bne $$ loop jr $ ra # v # # and return
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 ; nr;
;
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.
Can someone help me edit my code so it can run and get the answer? When I ran the code I got the answer of I need the answers
from b please and I also need help with EndLoop from my code below.
result: word
text
Invert to and an for decrementing. You want to decrement a temporary register, not ae
main:
Call coubinations with
$
$
jal conbinations
combinations
Store result in menory
# Display result for
ii $
Call combinations with
$
$
li $a
combinations
$va result is store result in menory.
Display result for
Fisplay result Li $
lus $ab result & Load the result from aenory
exit:
$ve exit with syscall
conbinations:
i Prologue.
addi $$ Allocate space for local variables
su $$
$$ $$
$$
Save return address
Save
li $te Initialize
Loop to calculate
add $$$
Loop:
mul $$$
addi $$
bne $$ loop
jr
$ ra
# v
#
# and return
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started