CS33 -- Laboratory 4


Due 11:59pm Thursday, Sept 23

email to me at: cfk@cs.swarthmore.edu a message in text form (no word, html or any other format than plain text) that contains labeled solutions to the exercises below. Make the subject of the email: cs33lab4. Make sure it is posted to me before 11:59 pm on Thursday, 23 Sep. Some of the solutions will just be annotated programs in hex. Others may require prose explanations.

For lc3 machine language programs, please give me commented text like that below

;; before executing this program, put x3020 in R4 loc instruction comment x3004 x6700 ;; R3 <-- M[R4+0] x3005 x6501 ;; R2 <-- M[R4+1] x3006 x1083 ;; R0 <-- R2+R3 x3007 x7102 ;; M[R4+2] <-- R0 On the CS lab machines, you can copy and paste sections from the lc3 simulator to a file by dragging over the lc3 memory section using the left mouse button and pasting into an editor by using the middle mouse button.

For this lab assignment, feel free to work with a partner.

For the multiplication questions, assume the product will fit in 16 bits. Complete the following exercises from the textbook:

  1. 6.4 (you may assume both numbers are positive)
  2. 6.5
  3. 6.6 (should say use answers from 6.4 and 6.5;
    you may assume both numbers are >= 0)
  4. 6.7
  5. 6.11 (increment each of the numbers means add 1 to each)
  6. 6.13
  7. 6.18
  8. In class, I'll explain why binary multiplication can be realized by shifting and adding. This leads to a more efficient multiply than adding y to itself x times to realize the product xy. Your task is to write an lc3 machine language program to multiply the contents of R1 times the contents of R2 and put the product in R3 by using the 'shift&add' method. Using the idea of ex. 6.5 and the assumption that the product will fit in one word, you can do this with <= 8 shifts&adds once you decide which number is smaller.