CSE 410 Assignment 2 & Programming Assignment 3

Spring 2007

Due: At the beginning of class, Wednesday, 4/25/2007

HOMEWORK ASSIGNMENT

P&H 3rd edition, read Chapter 6 through the end of 6.6. In P&H 2nd edition, read Chapter 6 through 6.7.

  1. Convert the following decimal numbers to 2's complement, 16-bit binary numbers. Show your answers in both binary and hexidecimal
    1. -410
    2. -2,301
  2. Convert the following 16-bit 2's complement hexadecimal numbers to decimal.
    1. 0xCAFE
    2. 0x8000
  3. What is the difference between latency and throughput? What is the effect of pipelining on these two metrics?
  4. Describe the different kinds of dependencies and their causes.
  5. Identify all of the data dependencies in the following code. Which dependencies can be resolved via forwarding, and which will cause a stall?

        add  $3, $4, $2
        sub  $5, $3, $1
        lw   $6, 200($3)
        add  $7, $3, $6
    

PROGRAMMING ASSIGNMENT

Implement a MIPS function quad(a,b,c,x) that computes the integer value ax2 + bx + c for integer arguments a, b, c, and x.

 

You should use the standard MIPS function calling- and register usage-conventions discussed in class and described in the book.

 

Then write a main program that calls your quad function several times and prints out the result of each function call on a separate line. Optionally, you can add labels and identifying text to the output, but this is not required. See the example programs linked to the course calendar web page for some examples of how to use the syscall instruction to produce output. Appendix A of the book has more information.

 

Your main program should call the quad function three times with the following parameter values, and print out the value returned.

a=3, b=5, c=2, x=5

a=1, b=-7, c=23, x=-6

a=7, b=9, c=-1, x=15

Challenge: The value ax2 + bx + c can be calculated using 3 multiplications and 2 additions. Can you reduce this and save an instruction or two in your code?

 

Hand in a printout of your code and the console output along with your answers to the written questions. You should also submit a copy of your program (only) online using this link to the online turnin page.