View the step-by-step solution to:

Question

Hello Tutor,

 Can you

please help me with this question.


Step 1: Create a program

 • reserve space in memory for an array of words of size 10. Use the '.space' directive. The array is called my_array. 

 • the program will implement the piece of C code described below. The value of initial_valueis the first digit of your CWID. iand j will be in one of the registers $t0 to $t9.


j = initial_value;

for (i=0;i< 10; i++) {

  my_array[i] = j; 

  j++;

}

This is an example given in the question to understand.


Implementing a for loop.


Ex 2: for (i=begin; i < limit; i++) {

  .... /* for body */ 

         }

Assuming that the initial value (begin) for the loop index is in register $a0, the limit is in $a1, and that the loop index iis in register $t0, then the for loop could be implemented as:

move $t0, $a0   # iis in $t0 

Loop:  ble$a1, $t0, Exit   # exit if limit <= i

  ....   # body of the for loop 

  addi$t0, $t0, 1   # i= i+1 

  j Loop 

Exit:  ....   # this is outside the loop.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes