New Perspectives Classic Labs

CPU SIMULATOR

In a computer central processing unit (CPU), the arithmetic logic unit (ALU) performs instructions orchestrated by the control unit. Processing proceeds at a lightning pace, but each instruction accomplishes only a small step in the entire process. In this Lab you work with an animated CPU simulation to learn how computers execute assembly language programs. In the Explore section of the Lab, you have an opportunity to interpret programs, find program errors, and write your own short assembly language programs.  

1.  Click the Steps button to learn how to work the simulated CPU. As you proceed through the Steps, answer all of the Quick Check questions that appear. After you complete the Steps, you will see a Quick Check Summary Report. Follow the instructions on the screen to print this report.  

2.  Click the Explore button. Use the File menu to open a program called Add.cpu. Use the Fetch Instruction and Execute Instruction buttons to step through the program. Then answer the following questions:

 a. How many instructions does this program contain?

 b. Where is the instruction pointer after the program is loaded but before it executes?

 c. What does the INP 3 M1 instruction accomplish?

 d. What does the MMR M1 REG1 instruction accomplish?

 e. Which memory location holds the instruction that adds the two numbers in REG1 and REG2?

  f. What is in the accumulator when the program execution is complete?

 g. Which memory address holds the sum of the two numbers when program execution is completed?

3.  In Explore, use the File menu to open a program called count5.cpu. Use the Fetch Instruction and Execute Instruction buttons to step through the program. Then answer the following questions:

 a. What are the two input values for this program?

 b. What happens to the value in REG1 as the program executes?

 c. What happens when the program executes the JPZ P5 instruction?

 d. What are the final values in the accumulator and registers when program execution is complete?

4.  In Explore, click File, then click New to make sure the CPU is empty. Write a

program that follows these steps to add 8 and 6:

 a. Input 8 into memory address M3.  

 b. Input 6 into memory address M5.  

 c. Move the number in M3 to Register 1.  

 d. Move the number in M5 to Register 2.  

 e. Add the numbers in the registers.  

  f. Move the value in the accumulator to memory address M1.  

 g. Tell the program to halt.  

Test your program to make sure it produces the answer 14 in address M1. When you are sure your program works, use the File menu to print your program.  

5.  In Explore, use the File menu to open a program called Bad1.cpu. This program is supposed to multiply two numbers together and put the result in memory location M3. However, the program contains an error.  

 a. Which memory location holds the incorrect instruction?

 b. What instruction will make this program produce the correct result?

6.  In Explore, use the CPU simulator to write a program to calculate the volume, in cubic feet, of the inside of a refrigerator. The answer should appear in the accumulator at the end of the program. The inside dimensions of the refrigerator are 5 feet, by 3 feet, by 2 feet. Make sure you test your program, then print it. 

 

  
Use your browser's Back button to return to the list of InfoWebs for the chapter. Click any one of the links below to access the home page for your textbook.
 

 

 
  New Perspectives on Computer Concepts 9th Edition New Perspectives on
Computer Concepts
8th Edition
New Perspectives on
Computer Concepts
7th Edition
Computer Concepts Illustrated 6th Edition Computer Concepts
Illustrated
5th Edition
Copyright 2004 by MediaTechnics Corporation