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 combineFour(int a,int b,int c,int d){int sum =a +b +c +d; if (sum %2==0){return sum; }else {return sum/2; }}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 a0,a1,and a2.
The method return value must be placed in register v0.
Each method must end with the instruction jr $ra.
Use the literal value 1for true and 0for 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(3,7,2), 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. (e.g. $s0 is 16, $s1 is 17, 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 ,0x7fffeffc, 0x7fffeff8,0x7fffeff4,0x7fffeff0,0x7fffefec, 0x7fffefe8,0x7fffefe4,0x7fffefe0,0x7fffefdc, 0x7fffefd8
find for each address Before `wackySum`,
Before 1st `combineFour`,
Before2nd `combineFour`,
and After `wackySum`
/ / Combine four ints and return their integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!