James Madison University, Fall 2022 Semester
Lab03: CPU and RAM simulator
Background
A "computer" is essentially a complex set of digital circuits that are activated as needed. The machine cycle (fetch, decode, and execute) controls the flow of both code and data through a CPU, main memory, and other devices. Today you will gain experience with machine-level instructions, which are the abstract tools that all software systems are based on. Software applications written in high-level languages (like C++, Java, and Python) must be "compiled" into machine instructions before they can run. Operating systems use special purpose machine instructions to control the hardware directly.
Objectives
- Explain how data are represented, stored, and manipulated by computer hardware.
 - Apply computing tools and techniques to solve problems at multiple levels of abstraction.
 
Part 1: Calculator Tool
| 
Download Lab03-Worksheet.txt
 (right-click and Save Link As...)  | 
- 
    
During this lab, you may use a calculator to convert decimal numbers to their hexadecimal representation. (Make sure you understand how to do this on paper!) The calculator program on a Mac can be set to "programmer" view. The calculator on Windows can also be set to convert decimal to hexidecimal (binary, etc.). Or you can install the following: Calculator
 - 
    
When you first run Calculator, it will be in Basic mode. Change the mode to Programming. This is an example of how that could appear:

 - 
    
Now enter a number (e.g.,
Here is an example of how this might look. Experiment with the calculator you are using.92) and see how its hexadecimal and binary representations (5Cand01011100) are shown automatically:
 - 
    
You can also change the input to hexadecimal or binary as shown above. The calculator will do arithmetic in whatever base you have selected:
     
    
 - 
    
Complete the calculator exercises (question 1) in the lab worksheet.
 
Part 2: Brookshear Machine
    Interactive simulator of the Brookshear machine
    
  | 
- 
    
Use the simulator to complete the following Chapter Review Problems on pages 120--121 of the textbook. Pay careful attention to the address of each bit pattern and the initial value of the program counter. Write your answers to questions 2--5 in the worksheet.
- #15
 - #16
 - #18 -- explain also in 1-2 sentences what this program does
 
 - 
    
Convert the following program into machine language. (Note: this is what a "compiler" does for you.) The numbers 74 and 20 are integers in decimal notation. Don't forget to rewrite them as hexadecimal in your instructions!
x = 74 y = 20 z = x + yTo receive full credit, you must store all variables in main memory. The address of x is0x20, y is0x21, and z is0x22. (Note: "0x" indicates that a nubmer is in hexadecimal.) Use the simulator to test your program. 
Submission Instructions
Submit your completed worksheet via
 canvas.jmu.edu by Friday at 5 PM.