## CSS372

# Homework 1

### Chapter 1

Problem 1, page 37
Explain each of the following terms in your own words.

- Translator.
- Interpreter.
- Virtual machine.

**Answer:**

- 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.
- 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.
- 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?

**Answer:**

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
--------- --------- --------- ---------

**Answer:**

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:
- whether the sign bit of the result is 1
- whether the low-order 3 bits are 0
- 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
flags
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.
`42E48000H`
`3F880000H`
`00800000H`
`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 2^{6} 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.