Question: Question text: Translate function foo into MIPS assembly language. You must follow MIPS register usage conventions for function calls/returns as discussed in class. Check the

 Question text: Translate function foo into MIPS assembly language. You must

Question text: Translate function foo into MIPS assembly language. You must follow MIPS register usage conventions for function calls/returns as discussed in class. Check the Appendix of this document for a quick reference. Assume the function declaration of bar is int bar(int x); and a label bar marks the starting point of its function body. You can assume that function bar follows the same MIPS conventions but do NOT need to implement it. You need to comment your code to get full credit for this question.

void foo(int *vals) { while (bar(*vals) != 0) { vals++; } }

Conventions given:

follow MIPS register usage conventions for function calls/returns as discussed in class.

4. (14 points) Translate function foo into MIPS assembly language. You must follow MIPS register usage conventions for function calls/returns as discussed in class. Check the Appendix of this document for a quick reference. Assume the function declaration of bar is "int bar(int x);" and a label bar marks the starting point of its function body. You can assume that function bar follows the same MPS conventions but do NOT need to implement it. You need to comment you code to get full credit for this question. void foo(int *vals) f while (bar(*vals) !- 0) { vals++; Appendix: MIPS ISA There are MIPS conventions you need to follow and a subset of MIPS instructions that you need to support in order to implement the coding part of this assignment. It is assumed that you acquire this knowledge from our textbook/lecture slides, but this section serves as a quick reference for you. MIPS instructions that vou must support: You are required to support only a subset of MIPS instructions. Use the table below as your quick reference. For all other inputs, your program should output "invalid" for the required checkings MIPS add sub funct 0x20 0x22 MIPS addi funct opcode 0x00 0x00 0x23 0x04 opcode 0x08 0x00 0x2b 0x02 0x2a SW be MIPS conventions vou must follow: You are required to follow MIPS conventions for register usages and function calls/returns Check the textbook and lecture slides for details. Here is a quick summary Function calls/returns must use jal and jr. Arguments and return values must use Sa and Sv registers in order. That is, the first argument must use Sa0, the second argument must use Sal, etc. If there is only one 32- bit return value, Sv0 must be used Use stack and Ssp for local data and register spilling Divide the maintenance of shared registers between the caller and callee following the table below: . . . * Reg Name Reg Number Usage Whose Responsibilitv? Caller Callee 2-3 4-7 Sa0-Sa3 St0-St7, St8-$t98-15,24-2.5 Ss0-Ss7 Ss Sra Return value Argument Temporaries Saved Stack pointer Return address 16-23 29 * The value of Sra will not be changed by the callee but will be changed by jal. 4. (14 points) Translate function foo into MIPS assembly language. You must follow MIPS register usage conventions for function calls/returns as discussed in class. Check the Appendix of this document for a quick reference. Assume the function declaration of bar is "int bar(int x);" and a label bar marks the starting point of its function body. You can assume that function bar follows the same MPS conventions but do NOT need to implement it. You need to comment you code to get full credit for this question. void foo(int *vals) f while (bar(*vals) !- 0) { vals++; Appendix: MIPS ISA There are MIPS conventions you need to follow and a subset of MIPS instructions that you need to support in order to implement the coding part of this assignment. It is assumed that you acquire this knowledge from our textbook/lecture slides, but this section serves as a quick reference for you. MIPS instructions that vou must support: You are required to support only a subset of MIPS instructions. Use the table below as your quick reference. For all other inputs, your program should output "invalid" for the required checkings MIPS add sub funct 0x20 0x22 MIPS addi funct opcode 0x00 0x00 0x23 0x04 opcode 0x08 0x00 0x2b 0x02 0x2a SW be MIPS conventions vou must follow: You are required to follow MIPS conventions for register usages and function calls/returns Check the textbook and lecture slides for details. Here is a quick summary Function calls/returns must use jal and jr. Arguments and return values must use Sa and Sv registers in order. That is, the first argument must use Sa0, the second argument must use Sal, etc. If there is only one 32- bit return value, Sv0 must be used Use stack and Ssp for local data and register spilling Divide the maintenance of shared registers between the caller and callee following the table below: . . . * Reg Name Reg Number Usage Whose Responsibilitv? Caller Callee 2-3 4-7 Sa0-Sa3 St0-St7, St8-$t98-15,24-2.5 Ss0-Ss7 Ss Sra Return value Argument Temporaries Saved Stack pointer Return address 16-23 29 * The value of Sra will not be changed by the callee but will be changed by jal

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 Databases Questions!