previous | contents | next

is called. In this case the direction of the shift (i.e., x2 or /2) is controlled by the sign of N. Also this sign determines whether incrementing (+1) or decrementing (-1) is to occur. The absolute value of N may lie outside the range of 16, thereby causing shifts in V which leave 0 as the result.

If we apply the K(conditional execute), the control part for this problem is slightly simplified as in Figure SO-4.

ADDITIONAL PROBLEMS

1. The sign-magnitude representation for numbers was shown in Figure SO-1. Modify the design of the previous solution to perform x(2^N) and /(2^N) operations using this representation.

2. Further generalize the previous problem so that it has three control inputs for the logical, circular and arithmetic shift cases. N specifies the direction and number of shifts to be carried out.

3. Can you find a way to decrease the time for the parameter shift operation case given in Figure SO-3 and problem I above?

4. A related pair of operations to logical shifting permits the loading, and storing of a field of data within a single word. Design the RTM system for loading and storing a field of up to 16 bits, which takes parameters bit, b, field length I+1 (varying from 1 to 16 bits), and word, A, within a DMgpa. For loading, field A<b+l: b> is placed in data<l:0>. On storing, data<l:0> replaces A<b+l: b>, where 0 < b < 15 and b + 1<15.

5. Design RTM systems to test the various cases given in Problems 1 to 4.

FOR LOOP EXTENDED RTM

KEYWORDS: For loop, DO statement, ERTM, sharing DM modules, sum-of-integers

An important control operation encountered in almost every application is a set of operations which are iterated a variable number of times. This is called a loop, and in this example we shall build an ERTM to carry out loop control. First, however several programming language structures related to this problem will be discussed.

Fortran DO Statement

The following program uses Fortran to compute the sum-of-integers problem from Chapter 2:

This may not be correct for some Fortran implementations because the DO statement increment is -1. It is given because it corresponds to our implementation in Chapter 2. The DO loop also has the problem that statement 10 must be interpreted at least once, although that causes no difficulty for the example shown.

Algol For Statement

In Algol a more general form for loop control is allowed and, in addition, a loop can be executed zero times if desired. The general form of the Algol for statement is:

95

previous | contents | next