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

3. Consider the following C++ program segment: i=0; while (i!=j) { x[i]=y[i]; i+

ID: 3545327 • Letter: 3

Question

3. Consider the following C++ program segment:

i=0;
while (i!=j) {
                  x[i]=y[i];
                  i++;
}

1) Convert the C++ program into MIPS code use direct translation. (15 pts)

When write MIPS code, assume that variables are kept in registers as follows, and that all registers except those indicated as Free are used to keep various variables, so they cannot be used for anything else.

Variables

i

j

x

y

1 (constant)

Free

Registers

$1

$2

$3

$4

$5

$6, $7, $8, $9

2) If the loop exits after executing only two iterations, draw a pipeline diagram for your MIPS code executed on a 2-issue processor shown in Figure 4.69. Assume the processor has perfect branch prediction and can fetch any 2 instructions (not just consecutive instructions in the same cycle). Don

  

Variables

     

i

     

j

     

x

     

y

     

1 (constant)

     

Free

     

Registers

     

$1

     

$2

     

$3

     

$4

     

$5

     

$6, $7, $8, $9

  

Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote