EE380 Assignment 2

Use this WWW form to submit your assignment. You may submit your assignment as many times as you wish; when the submission deadline is reached, your last recorded submission will be the one counted by the TA for grading. Note that each question is tagged with the course outcome(s) it addresses.


Your email address is .
Your password is .


  1. 100% IA32 is a CISC instruction set, but it does have some RISC-like attributes. Which of the following attributes of the IA32 instruction set is most RISC-like?
    A single instruction can copy an arbitrary size block of data from one place in memory to another
    Arithmetic instructions include sine, evaluated by a series expansion
    There are special instructions for managing stack frames
    Both operands for arithmetic operations can be registers
    Instruction encoding is variable length
  2. 100% Suppose that the variable x is kept in memory location 4000 and the content of that memory location is 42. What is the lval of x?
  3. 100% Which of the following segments of C code best describes what the following MIPS assembly code does?
    	la	$t0, x
    	lw	$t1, 0($t0)
    	la	$t2, y
    	lw	$t3, 0($t2)
    l1:	beq	$t1, $zero, l2
    	addu	$t1, $t1, $t3
    	beq	$t1, $t1, l1
    l2:	sw	$t1, 0($t0)
    

    while (x==0) { x=x+y; }
    while (x!=0) { x=x+y; }
    if (x==0) { x=x+y; }
    if (x!=0) { x=x+y; }
    x=x+y;
  4. 100% This MIPS/SPIM program includes a subroutine called myadd that performs x=(y+z);. In the space below, replace the myadd subroutine with one named mysub that will make x have the value it would get if C code like x=(y-z); were executed, i.e., the result of subtracting z from y. You should test your routine using SPIM before you submit it, which will require merging it with a test framework like the one used in this MIPS/SPIM program -- but only submit the mysub routine here. Remember that you can and should comment your code, especially if there are any known bugs. Half off for documented bugs. :-)
  5. 100% Write a complete MIPS assembly language program that will print your email address when executed using SPIM. Hint: you will want to use the syscall for printing a string... and yes, you can use mucky to create your answer.
  6. 100% What MIPS instruction is encoded by the value 0x3529002a? (Hint: take a look at the MIPS instruction set encoding in the textbook and in SPIM).
  7. 50% 50% This (now familiar) MIPS/SPIM program includes a subroutine called myadd that performs x=y+z;. In the space below, replace the myadd subroutine with one named mymul that will compute x=y*z;. (Hint: use addu because add detects overflow.) You should test your routine using SPIM before you submit it. Although there are many ways to do a multiply, here's C code for one of them that you might want to use:
    extern int x, y, z;
    
    void
    mymul(void)
    {
         /* do z = x * y the hard way... */
         int t0 = x;
         int t1 = y;
         int t2 = 0;
         int t3 = 1;
    
         while (t3 != 0) {
              if ((t0 & t3) != 0) {
                   t2 += t1;
              }
              t1 += t1;
              t3 += t3;
         }
    
         z = t2;
    }
    

  8. 100% Which of the following things is not normally found in a stack frame?
    A pointer to the previous frame
    Function argument values
    The return address
    Global variables
    Local variables
  9. 100% Which of the following statements about the MIPS assembly language and instruction set discussed in class is true?
    The li instruction can load an arbitrary 32-bit constant into a register
    The .code directive is used to identify a machine code segment
    The slt $t0,$t1,$t2 instruction makes $t0=($t1<<$t2)
    The jal instruction places the return address in register 31
    The blt instruction is a conditional branch-if-less-than
  10. 100% This MIPS/SPIM program includes a subroutine called myadd that performs x=(y+z);. In the space below, replace the myadd subroutine with one named mymax that will replace the value at location x with the maximum value of the three words starting at x. For example, the maximum of 4, 72, 61 is 72. The three words can be the ones called x, y, and z in the previous coding problems and in your support code, but your code should not reference them that way in your solution; x[k] is the kth word -- you should reference the words by varying k from 0 to 2. You should test your routine using SPIM before you submit it, which will require merging it with a test framework like the one used in this MIPS/SPIM program -- but only submit the mymax routine here. Remember that you can and should comment your code, especially if there are any known bugs. Half off for documented bugs. :-)
  11. 50% 50% A single-precsion floating-point value for the MIPS processor is encoded in the IEEE-compliant format illustrated below (the LSB is on the right). Given this encoding, using only MIPS integer instructions, write a function that will compute the absolute value of a floating-point number, i.e., x=abs(y);. Hints: use the fact that negative and positive float values differ only in the Sign bit, and test your routine using SPIM before you submit it.


  12. 100% We all know that floating point arithmetic is subject to roundoff errors. What about how floating point addition is implemented makes it inherently more subject to loss of accuracy than floating-point multiplication?



  13. 100% In the single-cycle design shown in the above (rather large and very familiar) figure, which of the following signals is a "don't care" when executing a MIPS beq instruction?
    Branch
    RegDst
    ALUSrc
    MemRead
    RegWrite
  14. 100% How would you build the "Sign Extend" function unit shown in the single-cycle design in the figure above? Answer in terms of the logic functions relating input bits I0-I15 to output bits O0-O31.
  15. 100% Which of the following techniques for implementing control logic for a single-cycle design (like that given in Chapter 5) is most likely to yield the circuit that operates with the smallest delay?
    Lookup Table (ROM)
    Random Logic
    Gate Array
  16. 100% In multiplying an integer, X, by 9 using the basic shift-and-add algorithms discussed in class and in the book, what is the minimum number of additions that must be performed? Show the values that are added (hint: use (X<<Y) to represent the value of X shifted by Y bit positions).


  17. 100% In the single-cycle design shown in the above (rather large and very familiar) figure, suppose that ALUSrc=0 and MemRead=1. Which of the following MIPS instructions might be executing?
    Sw $t0,4($t1)
    Lw $t0,4($t1)
    Or $t0,$t1,$t2
    Addi $t0,$t1,2
    None of the above instructions is consistent with the stated signal values


Although this is not a secure server, users are bound by the UK code of conduct not to abuse the system. Any abuses will be dealt with as serious offenses.


EE380 Computer Organization and Design.