Reading Assignment and Discussion Topics
Computer Science 111

for class on Tuesday March 7, 2000

Please read Chapter 5, up to about the middle of section 5.2.4, of the Schneider and Gersting text (pp. 169-200). Section 5.2.2 is good for you, but optional. Be prepared to discuss the following:

Section 5.2.4 introduces machine language instructions. Instructions like these are the way that algorithms are ultimately executed by any computer. But programmers (and pseudo-programmers like us) use higher-level expressions of algorithmic intent--things like assignment statements, while loops, and so on. These high-level programs are converted by compilers into machine-language programs before being executed by a computer.

How do you think the compiler should convert a while loop into machine language instructions? Remember that the while structure usually includes some initialization, a test, some statements in the body of the loop, and often an increment or decrement of the loop index. You can assume that all the variables you need, as well as handy constants like 1, have pre-assigned memory locations. Set up a simple while loop (like any we've used in class) and convert it into machine language. Never mind about the body of the loop: just plug in a few dummy instructions. Use any instructions from pages 197-198.

This machine language happens not to include multiply and divide instructions. How would you multiply or divide positive integers using only the given instructions? Your divide program should generate a remainder as well as a quotient.