next up previous
Next: About this document

MASSACHVSETTS INSTITVTE OF TECHNOLOGY
Department of Electrical Engineering and Computer Science
6.001---Structure and Interpretation of Computer Programs
Spring Semester, 1999

Recitation -- Friday, April 23

1. Register Machines

A register machine consists of (1) a finite set of registers, (2) a fixed set of operators, (3) a controller (set of instructions) and (4) a stack. We can represent register machines using Data Path diagrams and Controller diagrams or in a language that can be simulated in scheme.

2. Register Machine Diagrams

Early in the semester, we saw some Scheme code to calculate square root using Newton's method:

Unfortunately, Radio Shack was out of square root chips, so we need to implement square root ourselves. Luckily they did have an improve chip and a good-enough? chip. Draw the data paths and control diagram for a square root machine.

When we connect it all up, we saw that the improve chip is broken, and Radio Shack doesn't have any others. However, they did have an average chip. Redraw the data paths and control diagram as necessary to replace the improve chip. Then, convert the diagrams into a register machine.

3. Hand-Crafted Register Machines

What does the following register machine compute if we assume its input is in register x and its output is in register y. In other words, . What's f?

Modify the above code so that it computes , where k is an additional input register.

Below is the code to compute the same as defined above. Given that code, write the code to compute , where a and b are two input registers. You may use a continue register and a stack. (Don't duplicate the code to compute )





next up previous
Next: About this document



Michael E. Leventon
Fri Apr 23 13:43:08 EDT 1999