CMU 15-190 Spring 2017: Topics in Intermediate Programming
Homework 3 (Due Wednesday 8-Feb, at 11:59pm)



  1. CountAndStore downwards
    Start by running the CountAndStore example in xComputer Lab 1 (remember to first set the speed to "Fastest Speed"!). Also, you can download tmcm_labs.zip from the piazza post we made (just search piazza for tmcm to find it). Once you have it working, modify the example so it starts with 255 in memory location 12, and subtracts rather than adds 1 each step, so that 254 is in memory location 13, and so on. Include your resulting code in your submission. Also, answer these questions:
    1. What happens after we store 0 in a memory location? Do we get negative values?
    2. What is the smallest value stored, and in what address?

  2. MultiplyByAdding
    First, run xComputer Lab 2, and then run the MultiplyByAdding example. Study this example extensively, discussing every detail about it. Then, answer these questions:
    1. This example uses labels -- such as Ans, Count, N2, and Done -- which look like variables. But they aren't really variables, since they are simply replaced with addresses when you translate the assembly code into machine code. So:
      1. What address is Ans replaced with in the machine code?
      2. Try editing the assembly code, replacing Ans with that address, and then try to translate and run the resulting code. Did that work?
    2. What is the difference between Lod and Lod-c?
    3. How is Jmz different from Jmp?
    4. What does Hlt do?
    5. What is "data" used for in the assembly language code?
    6. Slightly modify the code so that it computes 42 times 99. Take a screenshot of the simulator after you run that program so that it is displaying the result of 42*99 in memory location 15.

  3. DivideBySubtracting
    Write the assembly language program DivideBySubtracting that computes the integer division function, so if N1 holds 91 and N2 holds 13, after execution Ans would hold 7. Submit the assembly code, and also a screenshot of the simulator after you run the program so that it is displaying the result of 91/13.

  4. What to Submit
    Each member of the group should submit their own PDF file, 15-190-hw3.pdf, containing this information:
    1. Your name and andrew id
    2. The names and andrew id's of your groupmates
    3. The start/stop times you worked, and the total time you worked.
    4. Your thoughts about this exercise -- useful, interesting, etc? This will help us improve the 15-190 experience as we go.
    5. The solutions from above. Note: one way to create a PDF is to first make a Word file, then export that to PDF.
    You can submit your hw to the 15-190 autolab site here.

Have fun!