CS641 hw2 Using Functions in MIPS Assembler and Understanding the GCC-compliant Stack Frames 1. Write the following program in C, compile it with mips-gcc, and convert that .s into SPIM code, maintaining the C calling conventions you find. The main for this program provides chars for its printbin function to display. In main, have an array of chars to display. The array is local to main, not externally defined, and contains 'A', 'B', and '0'. Use an array initializer to set this up. For each char in the array, have main call "printbin". The printbin function accepts its argument, a byte to display. The display should be in binary, like this for byte 3d: 0011 1101 Each 4-bit piece is called a nibble. Write a helper function "donibble", that prints out the 0/1-string for a nibble, and have the upper-level printbin function call donibble twice and print the space between the two nibbles, and the end-of-line. Donibble should use a loop with 4 passes, each printing one ASCII char, '0' or '1'. This will require logical instructions, Sec. 2.6. For printing a single char, use the function printchar, which just calls printf or uses the print string syscall. Thus we have 4 levels of calls here: main printbin called 3 times donibble called 6 times printchar called 30 times, 24 by donibble, 6 by printbin Call your C file printbinc.c. Create printbinc.s, the output of the mips-gcc. Then write printbin.s to mimic printbinc.s and be runnable on SPIM. In particular, you need to follow the register conventions very carefully, and set up the local copy of the array on the stack the way C does. At the end of a run, save printbin.log to show the output and final registers. 2a. Provide an analysis of the stack frames in printbinc.s in the format of the example in MIPScallconvention.html. b. Capture the stack while printchar is running by making a log at such a moment, and mark it up to show the stack frames. Put these answers in printbin_analysis.txt, along with the answers to 3. and 4. 3. Compile your C program printbinc.c using mips-gcc-O2 and report on how stack use has been replaced by register use, and count the instructions and memory references before and after for each function. Optionally, convert this tighter assembly code to SPIM and run it. 4. Write a small program testcall6.c that calls a function with 6 args. The function can just add up the 6 values and return the answer. The call can have constant argument values, say 0,1,2,3,4,5. Compile it with mips-gcc and mips-gcc-O2 and report on the stack frames and the effect of optimization.