Hello World - Spring 2007

Homework 7

Attempt by: Monday, April 2
Due by: Thursday, April 5

Reading

Simulator

The assembly language simulator I showed you in class this week is available here. On a Mac, simply download this file to your Desktop, double-click it, and then choose "Assembler" in the pop-up window. On Windows, you'll need to have Java installed, which is available from Sun here (download the Java Runtime Environment/JRE 6u1). Using the simulator isn't required for this assignment, but it will help you gain a better intuitive understanding of assembly language and machine language.

Practice Problems (not to turn in)

The following problems will give you extra practice, and are strongly recommended, but you don't need to turn them in. Solutions are given on pages 695-699, but don't look at the answers until you have tried working through them on your own.

Problems To Hand In

  1. Do exercises 2, 3, and 5 on page 233 of the textbook.

  2. Do exercises 4, 5, 6, and 7 on page 285 of the textbook.

  3. Translate each of the following instructions into the machine language and assembly language specified in Figure 6.5 (page 248). Write the machine code both in binary and in hexadecimal. For example, "Decrease the contents of memory cell 24 by one" would be translated to:

    binary0110 0000 0001 1000
    hexadecimal6018
    assemblyDECREMENT 24

    If these instructions are executed in succession, after they are all completed, what (in decimal notation) is stored in memory cell 132? In memory cell 88? In the accumulator?

  4. Consider the following machine language program (the address column is presented in decimal):

    address  machine instruction    assembly instruction
    ----------------------------------------------------
     2       0010000000010001           CLEAR 17
     3       0010000000010000
     4       0000000000001111
     5       0111000000010000
     6       1010000000001100
     7       0000000000010001
     8       0011000000001110
     9       0001000000010001
    10       0100000000010000
    11       1000000000000100
    12       1110000000010001
    13       1111000000000000
    
    1. Indicate next to each machine instruction its assembly language equivalent. (The first instruction has been translated for you.)

    2. Assume immediately prior to the execution of this program, the value of memory cell 14 is 9 and the value of memory cell 15 is 3. Show the step-by-step execution of this program indicating the values (in decimal) of memory cells 16 and 17 after each step. What value is output (in decimal)?

    3. In a clear and concise sentence, explain what this algorithm does.

  5. Do exercises 9 and 12 on page 285 of the textbook.