27.04.2015 Views

Computability and Logic

Computability and Logic

Computability and Logic

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.1. ABACUS MACHINES 49<br />

Figure 5-4. Addition.<br />

In case no assumption is made about the contents of register p at the beginning, the<br />

operation accomplished by this program is the following:<br />

[m] + [n] → n<br />

[m] + [p] → m<br />

0 → p.<br />

Here, as always, the vertical order represents a sequence of moves, from top to bottom.<br />

Thus, p is emptied after the other two moves are made. (The order of the first two moves<br />

is arbitrary: The effect would be the same if their order were reversed.)<br />

5.4 Example (Multiplication). The numbers to be multiplied are in distinct boxes m 1 <strong>and</strong><br />

m 2 ; two other boxes, n <strong>and</strong> p, are empty to begin with. The product appears in box n. The<br />

program is indicated in Figure 5-5.<br />

Figure 5-5. Multiplication.<br />

Instead of constructing a flow chart de novo, we use the block diagram of the preceding<br />

example a shorth<strong>and</strong> for the flow chart of that example. It is then straightforward to draw<br />

the full flow chart, as in Figure 5-5(b), where the m of the preceding example is changed to<br />

m 2 . The procedure is to dump [m 2 ] stones repeatedly into box n, using box m 1 as a counter:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!