University of Wisconsin Computer Sciences Header Map (repeated with 
textual links if page includes departmental footer) Useful Resources Research at UW-Madison CS Dept UW-Madison CS Undergraduate Program UW-Madison CS Graduate Program UW-Madison CS People Useful Information Current Seminars in the CS Department Search Our Site UW-Madison CS Computer Systems Laboratory UW-Madison Computer Sciences Department Home Page UW-Madison Home Page

Homework 1

CS/ECE 354, Fall 2003


Send e-mail questions to Nitin Agrawal, nitina@cs.wisc.edu
Due Friday, September 19, before 5pm.


Homework (48 points total)


Notes:
A subscript indicates the base of a number. Subscripts are in base ten.
Partial credit may be given for incorrect answers only if work is shown.
  1. (4 points) A research group has discovered a long lost civilization that used writing. Their alphabet contained 142 characters. To record and preserve the content of written artifacts, a fixed-size, binary encoding of each of the characters of the alphabet will be used. How many bits are needed to represent a character? If a trinary encoding where to be used instead (of a binary encoding), how many trinary symbols would be needed to represent a character?

  2. (12 points) Fill in the following table, giving the same value in the different number systems across a row.
         Decimal       Binary      Octal     Hexadecimal
         -------      -------      -----     -----------
    	  31
    
                      1010111
    
                                   0573
    
                                                0x13c
    
    
  3. (2 points) Give a base 3 representation for the value 481.129

  4. (2 points) Give a base 9 representation for the value 20101.213

  5. (4 points) Give an octal representation for the value 25.36

  6. (4 points) Give a base 5 representation for the value 123.34

  7. (3 points) Give a single sentence that describes what an assembler does.

  8. (3 points) Write the SAL equivalent of the following C/C++/Java statement:

    dd = aa / ( -(bb) + cc );

    You may assume that dd, aa, bb, and cc have been declared as integers, and that any temporary variables (t1, t2, etc.) needed have also been declared.

  9. (5 points) Write the SAL equivalent of the following C/C++/Java statement:

    
    if  ( (i <= 400) && (j == 0) ) {
       x = i + y;
    } else {
       x = x - 1;
    }
    
    
  10. (5 points) The following SAL code fragment does not work. Identify the problem with the fragment, explain why the fragment does not work, and give a code fragment that works correctly. The code fragment contains a procedure call and the procedure.
    
      .data
    proc_rtn_addr:  .word
                a:  .word
                x:  .word
                y:  .word
    
      .text
            # the SAL code for the start of the program would be here
    
            la   proc_rtn_addr, rtn1
            b    proc
     rtn1:  done
    
    
    proc:   add  a, a, 1
            sub  x, y, a
    	b    proc_rtn_addr
    
    
  11. (2 points) Which instructions in the (corrected) procedure proc of problem 10 change the value of the program counter? Why?

  12. (2 points) Which steps within the instruction fetch and execute cycle require a memory access for a SAL arithmetic instruction?

Handing In the Homework

Turn in your file containing answers by running the script:


  handinHW1 hw1file

where hw1file is an example name of a file containing the homework answers. The handinHW script submits your homework for you. No printout will be turned in. (We assume that you have put /p/course/cs354-common/public/bin in your path by now.)