Homework 1

Chapter 1

Problem 1, page 37

Explain each of the following terms in your own words.

  1. Translator.
  2. Interpreter.
  3. Virtual machine.


  1. A translator converts programs in one language into programs in another, usually lower level language. Example, a Java compiler converts Java source code into Java Byte code.
  2. An interpreter carries out a program, instruction by instruction. It first converts an instruction in one languge into a set of lower-level instructions and executes those.
  3. A virtual machine is a conceptual machine. It does not exist except as a program in some (usually) higher level language. The SimpComp simulation program is an example of a virtual machine. That there can be virtual computers demonstrates the fundamental equivalence of hardware and software.

Problem 8, page 38

In what sense are hardware and software equivalent? Not equivalent?


Hardware and software are functionally equivalent. Any function done by one can, in principle, be done by the other. They are not equivalent in the sense that to make a computer run the lowest level must be hardware. There must be some embodied (physical) machine executing logic operations as a basis for software. There is also a difference in performance. Hardware will always execute operations faster than equivalent software.

Appendix A - Binary Numbers

Problem 7. Perform the following calculations on 8-bit, two's complement numbers.

    00101101        11111111        00000000        11110111
   +01101111       +11111111       -11111111       -11110111
   ---------       ---------       ---------       ---------


    10011100        11111110        00000001        00000000
The first calculation results in an overflow. The subtractions are done by forming the two's complement of the subtrahend and then adding it to the minuend.
Problem 9. Consider the following addition problems for 3-bit binary numbers in two's complement. For each sum, state:
  1. whether the sign bit of the result is 1
  2. whether the low-order 3 bits are 0
  3. whether an overflow occurred.
    000        000        111        100        100
   +001       +111       +110       +111       +100
   ----       ----       ----       ----       ----
A: The first row below gives the answer with a carry out from the three bit register indicated by CO below that bit. Consider a flags register with N (negative), Z (zero) and V (overflow) flags. Then the second row of numbers (under "flags") represents the state of the flags NZV after the operation.
    001        111     1  101     1  011     1  000
                      CO         CO         CO
    NZV        NZV        NZV        NZV        NZV
    000        100        100        001        011

Appendix B - Floating Point Numbers

Problem 2. Convert the following IEEE single-precision floating-point numbers from hex to decimal.
  1. 42E48000H
  2. 3F880000H
  3. 00800000H
  4. C7F00000H

A: Writing 42E48000H in binary we get:
0 10000101 11001001000000000000000

(a) The unbiased exponent is 133 - 127 = 6 so we have 1.11001001 x 26 which is 114.25. Similarly we get:
(b) 1.0625
(c) 2-126
(d) -122,880

Close this window to return to the course site.