CSE 30: Homework 3

    (Deadline: Wednesday, 21st April, 1999, 11:59pm)
    (Extended Deadline: Wednesday, 28th April, 1999, 11:59pm)

    1.  Exercise 3.3

      This program is used to teach about bits and bit manipulation.  The program selects a certain field from a register and places it into a selected register. Students should run their program on the following data:
         
        source data (in %l0) = fff
        least significant bit (specified in %l2) = 2
        width of field = number of bits in field (specified in %l3) = 3


      To run their programs on this data, students should put mov instructions at the beginning of the program.  They should run the program under gdb in order to generate output.  The gdb output should be generated by putting in the label fin: at the end of the program, and then examining the
      contents of registers %l0-%l3.

      Note: in this exercise you will be using the logic instructions from Chapter 3.  You may need to use instructions introduced in chapter 4, namely the shift instructions on page 107.

    2.  Exercise 4.1
      In this exercise, the students should use simpler input than is used in the book exercise.  Note also that we are only doing the addition part of the exercise.
      Students should use m4 to define
        a1 to be the input 007 (i.e. 07 octal) and
        a2 to be the input 001 (i.e. 01 in octal).


      Also define the following to stand for the registers that you use:

        a_r = l0  (register for holding a1)
        b_r = l1 (register for holding b1)
        s_r = l2 (register for the sum)
        c_r = l3 (register for the carry)


      This exercise gives more practice with SPARC instructions and shows how
      xor and and instructions can be used to implement addition.  The program
      should be run with gdb in order to generate output.  Students should put a
      break in the loop and print out the partial results in the sum and carry
      registers, i.e. s_r = l2, and c_r = l3.