Question: / / Combine four ints and return their integer sum if even, / / otherwise return the sum with integer division by two. public static
Combine four ints and return their integer sum if even, otherwise return the sum with integer division by two. public static int combineFourint aint bint cint dint sum a b c d; if sum return sum; else return sum; As with previous assignments, in order for your solution to be graded, it must work with my MUnit tests. Follow these rules:
Give your procedures the exact names indicated in this write up
Your procedures must be declared globl.
The method parameters will be placed in registers aaand a
The method return value must be placed in register v
Each method must end with the instruction jr $ra
Use the literal value for true and for false.
The Help menu in MARS has a list of instructions, or you may find it helpful to find a set on Google, such as this MIPS instruction reference. use of proper coding style on your assembly code? proper use of registers, the stack? wackySum.asm, Stack and Function Calls
Only attempt this part once you have full credit on the previous question.
For a call to wackySum show the contents of the stack at the specified points in the code. Hint: You can use MARS to see what the stack looks like during execution. However, the initial $s and $t values in MARS will differ from the initial values in the autograder.
Your answers will be checked against the actual values on the stack in your program. To do this, you will need to create a new file that contains only the code for your wackySum function, without the combineFour function. See the snippet below for details on what to upload and what goes into the table. Because combineFour will be called twice in this example, you will show the stack before combineFour twice, possibly with different values.
globl wackySum # START INCLUDE HERE wackySum: # before wackySum column of the table # your code # before combineFour column of the table jal combineFour jr $ra # after wackySum column of the table # STOP INCLUDE HERE combineFour:
Rules for input
The stack pointer should be written in hex.
Wherever $ra is stored, simply write $ra
Assume any $s or $t registers were initialized to their corresponding register number before your function was called. eg $s is $s is and so on
For any value in the table not used by your program, enter X A value that a is below the stack pointer, or b was added to the stack by a different function is considered unused by your program.
For all other values, enter the number in decimal. wackySumSnipped.asm? for each Address of this $sp xfffeffc, xfffeffxfffeffxfffeffxfffefec, xfffefexfffefexfffefexfffefdc, xfffefd
find for each address Before wackySum
Before st combineFour
Beforend combineFour
and After wackySum
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
