Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Convert the following C code into MIPS assmble code, the code is about drawing triangles using asterisk. Check the output of the c code first.
Convert the following C code into MIPS assmble code, the code is about drawing triangles using asterisk. Check the output of the c code first. : #include
void printlayerint n int l
for int j ; j nl; j
printf;
for int j nl; j nl; j
printf;
printf
;
int main
int op;
printfPlease enter option : triangle, : inverted triangle: ;
scanfd &op;
int n;
printfPlease input a triangle size: ;
scanfd &n;
for int i ; i n; i
if op
printlayern i;
else
printlayern ni;
return ;
check the code output using the following test.h script, run it on ubuntu. Add your own test cases.
#binbash
TESTCASEROOTtestcase
TESTCASEANSWERROOTtestcaseanswer"
STUDENTANSWERROOTstudentanswer"
problems
"factorial"
"prime"
"calculator"
"triangle"
"fibonacci"
testproblem
local prolbem$
local sourcecfile$problemc
local sourceasmfile$problems
local executablefile$problem"
echo "Testing Problem: $problem"
if f $sourcecfile" ; then
echo "Source c file not found: $sourcecfile"
return
fi
if f $sourceasmfile" ; then
echo "Source asm file not found: $sourceasmfile"
return
fi
gcc $sourcecfile" o $executablefile"
testcasefiles$ls $TESTCASEROOT grep $problem
for file in $testcasefiles@; do
local testcasepath$TESTCASEROOT$file"
local testcaseanswerpath$TESTCASEANSWERROOT$file"
local studentanswerpath$STUDENTANSWERROOT$file"
$executablefile" $testcasepath" $testcaseanswerpath"
spim file $sourceasmfile" $testcasepath" tail n $awk 'END print NR $testcaseanswerpath$studentanswerpath"
diffoutput$diff $testcaseanswerpath $studentanswerpath
if z $diffoutput" ; then
echo $file PASS"
else
echo $file FAIL"
echo $diffoutput"
fi
done
rm $executablefile"
mkdir p $TESTCASEANSWERROOT"
mkdir p $STUDENTANSWERROOT"
for problem in $problems@; do
testproblem $problem"
echo
done
screenshot the output, make sure the code works.
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