Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1: Performance Instruction Type Arithmetic Logical Loads Stores Conditio

ID: 3747527 • Letter: P

Question


Problem 1: Performance Instruction Type Arithmetic Logical Loads Stores Conditional branches3 Unconditional jumpsdles tomatO: Cycles sit $to, $al, $a2 sto, $zero, orange add $ti, $a0, $t1 6 s1l $t2, $a2, 2 add $t2, $a0, $t2 add $ts, $al, $zero andi $ts, $t5, 1 beq $ts, $zero, potato 1w $t3, 0($t1) add $t4, $t3 $t3 sw $t3, 0(St2) sw $St4, 0 ($t1) Table 1. Number of clock cycles for each type of instruction potato: addi Sai, sal, 1 addi $a2, $a2, -1 tomato $ra orange: jr Part (o) Above is the assembly code for the function declared as: tomato(int arrayl, int x, int y). Ass is an array of 500 integers, and the function is called as tomato(myarray, 4, 22). int array), int x, int y). Assume that "myarray ) How many times is the "slt" instruction executed? Justify your answer to rece () How many times is the "lw" instruction executed? Justify your answer to receive 4, 22). Show your work (20 points)? Part (b) Calculate the total number of cycles it takes to execute tomato(myarray,

Explanation / Answer

a)

i) SLT is an MIPS instruction which stands for 'Set If Less Than'.

Given, x = 4 and y = 22.

So, if we have slt $t0, $f1, $f2 this means the register t0 will fire-up and be set to 1 if $f1<$f2 else it will be zero.

Now, I'm not sure what the implication of the `myarray` is. It's either related to a previous question or something is missing above.

So, all in all if the above tomato function is called once and $f1=4 and $f2=22, the $t0 register won't be fired up.

ii) Similarly, to define the utility of the lw instruction it is used to load a word into a register. Again, the number of times that would execute would depend on the number of times tomato function is called which is unclear coz there's no information about myarray in the question.

b) To answer the second part of the problem I would need to know what myarray is, like I mentioned earlier.