Instructions for Second CPU Simulator Exercise

 


Bring up the Simple CPU Simulator referred to in these instructions in a separate, side-by-side browser window, if you haven't already.

Write your answers to the questions below in the provided Markdown template and submit it to Kit. Hint: you can reset the CPU Simulator back to its initial condition at any time by reloading the page.

The set of assembly language instructions that this CPU Simulator can execute appears at the bottom of this page.

Storing and Retrieving Data from Memory

  1. What instruction would store R0 to memory location 14?
  2. How many Fetch/Execute cycles do you think would be needed to add the contents of memory addresses 07 and 08 and put the results in memory address 15? Document your expected results. Write an assembly language to do this in the CPU Simulator and test your hypothesis. (Don\'t forget the HALT instruction.) Document the program you used and the actual number of cycles required, including the cycles needed to halt the program.
    Expected Results Actual Results
       
       
       
    Assembly Language Program:

     

  3. Write a program that takes a value in memory location 07 and doubles it, storing the result in memory location 08. Test your program using the CPU Simulator, then include it in your write-up document.

Understanding Machine and Assembly Language

From Reed, Chapter 14, Hands-On Exercises 14.7 - 14.13.

  1. What sequence of assembly-language instructions corresponds to the following machine-language program?
            100000000000
            101011000011
            111111111111 
  2. In English, what overall task does the previous machine-language program perform?
  3. What do you think would happen if you forgot to place a HALT instruction at the end of a machine-language program? How would the control unit react? Use the simulator to test your prediction, then report the results.

Exercises 15 - 19 ask for sequences of assembly-language instructions (in other words, small program snippets rather than whole programs), so there is no need to add a HALT instruction to these exercises.

  1. Write a sequence of assembly-language instructions to cause the contents of the four registers to be copied into memory locations 7, 8, 9, and 10, respectively.
  2. Write the sequence of machine-language instructions that corresponds to the assembly-language program you wrote for the previous question.
  3. Write a sequence of assembly-language instructions to add the contents of memory locations 10, 11, and 12 and then store the result in memory location 13.
  4. Write the sequence of machine-language instructions that corresponds to the assembly-language program you wrote for the previous question.
  5. Write a sequence of assembly-language instructions that multiplies the contents of memory location 07 by four. For example if the number 10 were stored in memory location 07, executing your instructions would cause the simulator to store 40 there. Note: Although the CPU Simulator instruction set does not include a multiplication operation, a number can be multiplied via repeated additions.