Homework 2

This homework is worth 40 points.

Please do the following problems:

  1. (2 points each) Give MIPS assembly code to implement
    1. for(i=0;i<20;i++) {
         cout << i << endl; 
      } 
          
    2. i = 0;
      do {
          A[i] = rand() % 500;
          i++;
      } while (i < 100);
          
  2. (2 points each) Describe how the following structure would be:
    1. Set up in memory
    2. Accessed (show for each field)
    3. Passed as a variable parameter to a routine.
    4. Passed as a value parameter to a routine.
    struct sType{
       int x,y;
    }
     
  3. (2 points each) Express the following instructions in MIPS binary format.
    1. ADD $t8, $t4, $a0
    2. LI $v0, 100
  4. (2 point each) Assume that each instruction is in MIPS binary format, express in assembly code.
    1. 00046902
    2. 1100FFFC
  5. On page 410 do part b for
    1. 4.1.4
    2. 4.1.5
    3. 4.1.6
    4. Argue that LW is the instruction that takes the most time to execute, even if memory access is at the given speed.
    5. Ho long must the clock cycle be to accommodate the LW instruction?
  6. On page 190 do part a for
    1. 2.12.1
    2. 2.12.2
    3. 2.12.3
  7. On page 216 do
    1. 2.38.1
    2. 2.38.2
    3. 2.38.3
  8. Do 2.39.1 (p 217)
  9. Do 2.39.2 (p 217)
Remember, your homework must be typed, and you must show your work.

Please turn in hard copy of your homework by the beginning of class on March 23. In addition, please email copies of your circuits, programs and other original source files to me.