Docsity

Problem Set 3 - Computer Organization and Systems Programming | CSE 30, Assignments of Computer Science

Toggle sidebar
bg1
University of California, San Diego
Dept. of Computer Science and Engineering
CSE 30 โ€“ Computer Organization and Systems Programming
Problem Set #3 โ€“ Due 2pm October 20, 2009
MARS (30 points)
The following questions are based on FIR_Filter.txt file
(http://www.cse.ucsd.edu/~kastner/cse30/FIR_Filter.s). Start by loading this file then answer the
following questions:
1. What's the address of the first instruction in your code (addi $sp, $sp, -4)?
2. What's the content of $a0, $a1, $a2 after the instruction "jal FIR" is executed? (For extra
credit, explain why)
3. What is the beginning address of in_array? csnt_array? (Hint: the instruction la takes two
arguments; the first is the destination register for the address from the second argument.)
4. What's the value of $ra AFTER the jal FIR instruction is executed? (For extra credit,
explain why)
Set a breakpoint at instruction 0x00400088 and run the program until you hit that breakpoint:
5. To which instruction does this breakpoint correspond (note: this instruction should appear
in the FIR_Filter.s file?
6. What is the value of $t0?
7. What is the value of $t4?
8. Why is $t3 significantly larger than $t0?
9. What's the content of the address that $t3 points to?
Set another breakpoint at instruction 0x004000b0 and run the program until you hit this
breakpoint:
10. What's the value of $t3? $t5?
11. What's the value that $t3 is pointing to?
pf3

Partial preview of the text

Download Problem Set 3 - Computer Organization and Systems Programming | CSE 30 and more Assignments Computer Science in PDF only on Docsity!

University of California, San Diego Dept. of Computer Science and Engineering CSE 30 โ€“ Computer Organization and Systems Programming Problem Set #3 โ€“ Due 2pm October 20, 2009 MARS (30 points) The following questions are based on FIR_Filter.txt file (http://www.cse.ucsd.edu/~kastner/cse30/FIR_Filter.s). Start by loading this file then answer the following questions:

  1. What's the address of the first instruction in your code (addi $sp, $sp, - 4)?
  2. What's the content of $a0, $a1, $a2 after the instruction "jal FIR" is executed? (For extra credit, explain why)
  3. What is the beginning address of in_array? csnt_array? (Hint: the instruction la takes two arguments; the first is the destination register for the address from the second argument.)
  4. What's the value of $ra AFTER the jal FIR instruction is executed? (For extra credit, explain why) Set a breakpoint at instruction 0x00400088 and run the program until you hit that breakpoint:
  5. To which instruction does this breakpoint correspond (note: this instruction should appear in the FIR_Filter.s file?
  6. What is the value of $t0?
  7. What is the value of $t4?
  8. Why is $t3 significantly larger than $t0?
  9. What's the content of the address that $t3 points to? Set another breakpoint at instruction 0x004000b0 and run the program until you hit this breakpoint:
  10. What's the value of $t3? $t5?
  11. What's the value that $t3 is pointing to?

Simple MIPS Assembly

  1. (10 points) Translate the following code into MIPS assembly: A[i] = B[i-1] + B[i] + B[i+1] Assume that A and B are byte arrays. Both arrays are stored in memory. Register $s contains the initial address for array A ; register $s2 contains the initial address for array B ; and register $s3 contains the value of i. Assume that load (lw) and store (sw) take 3 cycles each. How many cycles does your code take? How many additional registers does your code require?
  2. (10 points) Pseudoinstructions are not actually part of the MIPS instruction set, but are often used to when writing MIPS assembly programs. The assembly translates these pseudoinstructions into a sequence of โ€œtrueโ€ MIPS assembly instructions. For each pseudoinstruction below, produce the shortest possible sequence of true MIPS instructions. You can only use one additional register $at to store temporary values. a. Swap $s0, $s1 - description: $s0 = $s1, $s1 = $s b. Branch greater than: bgt $1, $2, label c. Branch greater than or equal: bge $1, $2, label d. Branch less than: blt $1, $2, label e. Branch less than or equal: ble $1, $2, label f. Add large immediate: addiL $1, $2, 0x
  3. (5 points) Replace the C code for if (x < y) x = y + 2; else y = x 4; by a set of equivalent MIPS instructions. Use as few instructions and additional as possible. Assume x and y are in registers $s0 and $s1, respectively. Comment your code.
  4. (10 points) Implement the following C code in MIPS: for (int i=0; i != 10; i++) { a[2i] = b[i] + i; } Assume that the base address at a[] is stored in $a0, and the base address of b[] is stored in $a1. Comment your code.