The mark 5 system of automatic coding for TREAC

The mark 5 system of automatic coding for TREAC

The Mark 5 System of Automatic TREAC Coding T. PEARCEY, S. N. HIGGINS and for P. M. WOODWARD* SuhiMARY-The Mark 5 system is the fifth in a...

550KB Sizes 33 Downloads 85 Views

The Mark

5 System of

Automatic TREAC

Coding

T.

PEARCEY,

S. N.

HIGGINS

and

for

P. M.

WOODWARD*

SuhiMARY-The Mark 5 system is the fifth in a series of experimental tape codes devised for TREAC, the parallel computer at R.R.E. It is a complete algebraic autocode which is input under the control of a translation program some 8000 words long. The notation is almost entirely English words and algebraic expressions using numerical constants, sullixed variables, functions and nested brackets. Integer and floating-point arithmetic can be performed, the latter being interpreted by a wired-in interpreter. The compiled program can be up to 8000 words long, but the partitioning into blocks of up to 500 words must be decided by the user. The system is at present in the final stages of testing.

INTRODUCTION

VERY little information has been published about TREAC since an early and now obsolete description by B. V. Bowden (1953). Although it was always intended as an experimental machine, it has given continuous service since 1953 and, having many attractive features, is worthy of comment. A very brief description is given in the next section below of this paper, which will also help to show the magnitude of the tasks performed by the Mark 5 translation program. When a machine is used by a large number of people, it is difficult to withdraw facilities which have once been provided, even though improved ones are offered instead. Continual experimentation with coding schemes is thus apt to lead to an accumulation of different codes, all in use at once, * T. Pearcey is now at Melbourne University and S. N. Higgins is at the Royal Radar Establishment. P. M. Woodward, also of R.R.E., here summarizes the work of Pearcey and Higgins. 23

Pearcey, Higgins and Woodward

24

with resulting confusion between machine users. Restriction of experimental codes to an inner circle of experienced programmers is one solution of this problem, but unfortunately the experienced programmer is not the best judge of all new coding schemes. There seems, indeed, to be a need for two distinct approaches to the question of program compilation, one starting from the machine and the other from the mathematics. Experienced programmers generally prefer the former. They enjoy a sense of direct contact with the machine and use compilation merely to supplement, never to destroy, facilities available in the basic code of the machine. The current TREAC compiler of this type is known as the Mark 6 system and it is essentially a refined input routine with floating-address facilities, a few expanded orders and special arrangements for ‘debugging’. This compiler is some 2000 words in length, compared with 50 words for the standard input routine (Mark 0) which is regarded as a part of the machine itself. On the other hand, we may approach the coding problem from the point of view of the occasional user, regardless of destroying facilities available in basic code. Such a system is the TREAC Mark 5 code described in this paper. Whether the Mark 5 system will ever be used for problems other than the evaluation of algebraic and trigonometric expressions given in closed form remains to be seen, but it should certainly enable such problems to be quickly disposed of. The value of this elementary kind of computing is perhaps underestimated, since at present we tend to reserve our computers for major studies. The effort called for in programming trivial problems is often not worth while. We might as well use a desk machine. It is a curious thought that the largest compilers may be used for these simplest problems. In the TREAC Mark 5 system, no facilities are consciously provided for inserting sections of basic machine code. It is meant to be automatic throughout. We have therefore incorporated a facility for doing logical manipulations of Boolean type on machine words regarded merely as arrays of binary digits. It has been a TREAC tradition (founded by A. M. Uttley) to make liberal use of logical instructions, and this is reflected, we think, in the Mark 5 system. TREAC

FROM

THE

PROGRAMMERS’

ANGLE

TREAC is a one-address parallel machine with 24-bit words. An instruction occupies one word, and so does a fixed-point number or integer. Its current speed of operation is 60 microseconds for every operation, other than those which communicate with the auxiliary store (a drum of 8000 words). High-speed store holds 512 words on 24 cathode-

The bard

5 ~st~

of Automats

Coding for

TREAC

25

ray tubes. There are about as many basic orders as there are letters of the alphabet and apart from shifts and transfers (including reversal of sign), the only arithmetic operations are add and subtract. Multiplication and division are therefore programmed, the former taking a time of 8 msec, which clearly dominates the speed of the machine. However, the very high speed (for 1953) of all other operations makes TREAC an admirable machine for logical, musical and translation-type programs. A mnemonic code is used, of which the following are examples P A S T X

Pick from store Add to accumulator Subtract from accumulator Transfer to store Exchange with store

J B 0 D E

Jump to Branch to Logicaf Or Logical Differ Logical Extract

There are no modifiers, no overflow indicators, and the only arithmetic register accessible to the programmer is the accumulator. The character of TREAC was revolutionized in 1957 by the addition of a ferrite ring store with a magnetic capacity of 32 words, each of instruction length only (15 bits). The rings in this store are threaded by 64 wires to give permanent storage of 2048 instructions. Thus TREAC now has a wired-in subroutine library which includes the floating-point This interpreter is about IO50 words in length and provides interpreter. many facilities not available in basic fixed-point language. They include B-line operations and single instructions for forming commonly occurring functions of the number in the accumulator, such as modulus, square root, inverse tangent. That there is little more to say about the: machine from the programmers’ angle emphasizes its extreme simplicity. MARK

5 AUTOCODE-GRAMMAR

A program in Mark 5 language is divided into blocks small enough to be contained in high-speed store. The partitioning has to be specified by the programmer. Blocks are made up of sentences each containing a word or phrase in English which we call the verb. The verb governs a number of clauses. Each clause contains up to three phrases, an object phrase, an adverbial phrase, and an optional parenthesis. To give an immediate example, PRINT: x(J), J = 0[1]3, (STARTING VALUES):. is a sentence. The verb is PRINT, and the remainder is all one clause to the end of the sentence. Within this clause, X(J) is the object phrase, the

26

Peaq,

Higgins and Woodward

range of values of J is the adverbial phrase (adverbial phrases are generally of this type) and the remark in round brackets is the parenthesis. The latter is for annotation purposes only, and is ignored by the machine. One of the first decisions the composer of an autocode has to make concerns punctuation. It is tempting to permit layout characters (space, fresh line, etc.) to act as the punctuation marks, but it was decided early in the planning of Mark 5 to allow the programmer complete freedom to use his own layout. In fact, layout could be omitted altogether. Punctuation is therefore by commas, colons and full stops. Verbs and clauses always end with colons and a completed sentence has a full stop in addition. Phrases end with commas unless at the end of a clause, when the colon serves for both. The peculiar colon and full stop at the end of the sentence is due to the limited number of characters available with 5-hole tape. Another decision concerns English. Experienced programmers do not take kindly to typing unnecessarily long-winded code. We do not think the amount of English in Mark 5 too burdensome. Most of it is in the verbs, unless the programmer chooses to put it also in parentheses. Abbreviations have been avoided throughout, because we believe it is easier to memorize complete and correctly spelt words. For reference, it must be possible to label sentences. Labels are really floating addresses (in programming language) and their counterpart in ordinary mathematics is equation numbering. In the Mark 5 system we label clauses rather than sentences. If two consecutive sentences each have one clause following the same verb, we simply omit the verb the second time and treat the pair as a single sentence with one verb and two clauses. For example, consider the sentence 4)

PRINT:

x:

Y: z:.

5)

This has three clauses, the first two bearing clause labels. The only other form of label is the block label, preceding a sentence. Thus 71

PRINT:

.Y:

Y:. defines the start of a new block, and the first clause is understood to be clause 0 of this block. Apart from this convention, one is free to label how one likes, not necessarily in numerical sequence. If wished, one can start a new block with a clause label other than zero by writing (say) T/4)

PRINT:

x:.

The Mark 5 System of Automatic Coding for TREAC When referring to any clause, the notation label and n the clause label.

27

m/n is used, m being the block

ALGEBRA

To avoid lengthy description, examples of algebraic expressions are given under PUT in the list of verbs. Let it suffice here to say that a basic expression consists of a sum (including + and -) of products, each of which may be terminated by a single term divisor. A product is indicated by mere juxtaposition, and / is used for division. By enclosing a basic expression in square brackets, it assumes the status of a single term. Letters or numbers may be used as suffixes in round brackets, and the most general form of suffix is J + 2 or K - 3, i.e. an integer variable plus or minus an integer. Double suffixes are not allowed for. VERBS

The grammar of a sentence is largely governed by the verb. For example, the verb PRINT is transitive, while LOGIC is an intransitive verb! In other words, some verbs take object phrases, some both objects and adverbs, some form sentences in themselves and have no subordinate clauses. Wherever a parenthesis is likely to be useful, it is generally permissible to include one as the last phrase in a clause. The following is a complete list of the verbs in Mark 5 autocode. The explanations are given in narrative form and are intended to be read in sequence. They do not include all the detail necessary in a manual for actual use, but even there one or two paragraphs per verb have been found sufficient. TITLE

is the first verb in all programs and is followed by a heading to identify the program and the tapes.

CLASSIFY

will seldom be used. The letters IJKLMNOPQRST normally denote integers, and the remainder floating-point variables. This verb enables a different partition to be made.

ALLOT

Storage space for constants and unsuffixed is allocated by the compiler automatically. range of values taken by a suffix-and storage space required by the variable as may not be evident from a look at the Thus, it is necessary to estimate upper the values of suffixes and quote them

variables But the hence the a wholeprogram. limits for for each

Pearcy, Higgins and Woodward

28

suffixed variable. 6 TO Y:.

For example,

ALLOT:

3

TO

X:

INPUT

This verb causes input of a sequence of numbers from tape. It is followed by a clause which identifies the sequence as the values of a stated variable.

PUT

is the main computing verb, and its object phrase is an equation with a variable on the left and algebra on the right. For example, we could have PUT:

0.0123 *SW [,X1/X:.

Y =

This sentence illustrates the use of function-letters, always preceded by an asterisk and followed by square brackets. The symbol n is automatically given its appropriate numerical value. As a further example, WC could have PUT:

Y(J) = X(J + 2) + 42/[Z

- 31, .I = 0[2]K:.

This illustrates algebraic brackets (square), suffix brackets (round), and an adverbial phrase giving a range of values. The three quantities in the adverb can be letters or numbers in any arrangement. The effect of the whole sentence would be to generate and store a table of Y from a given table of X. Notice that numerical constants can be mixed, in the algebra, with variables. In this example, the variables are floating point and the constants are all integers. In any mixed equation (not counting suffixes, which arc always integers), the integers will automatically be converted to floating point. As a final example, we could have PUT:

A

=

[[X

+

3.251X + 1.871X - 0.71 3.6:.

which illustrates nested brackets numerical constants.

and a product

of

PRINT

may be followed by an algebraic expression and a stepping adverb. In extremely simple problems, all the computing could be done in the PRINT sentence.

LAYOUT

This verb is used 7 LINES: 5 SPACES:.

as in the sentence

LAYOUT:

The Mark 5 System ofAutomatic Coding for TREAC INTEGER

LAYOUT

FLOATING LAYOUT

These two verbs are used for altering the program parameters which control the automatic layout in a PRINT sentence. This is an unconditional transfer of control, thus DO: 3/2: causes execution of the program from block 3, clause 2.

DO

SWITCH

29

is another form of DO, but its object phrase is arranged so that control can be transferred to a directory of DO clauses elsewhere in the program, the particular clause being selected by the value of a stated integer variable.

TO

A typical n-sentence

IF

with three clauses would be

0.0, DO 3/2: x < 0.0, DO 4/6: x > 0.0, DO 5/l:.

IF: X=

The left-hand sides of the inequalities may be any signed and suEixed variables or constants, and the right-hand sides can be complete algebraic expressions. Seven inequality symbols may be used, equals, not equals, greater, less, and in floating-point work, much greater, much less and comparable with. INITIAL VALUES

enables numerical values to be substituted variables at the start of a program.

START AT

This verb signals the end of the program, followed by a block and clause label.

for

and is

Before completing the list of verbs, we may now give a trivial example of a complete program. This prints out the sum of two numbers read from a number tape. TITLE: TRIVIAL EXAMPLE* 1-jSTOP: INPUT: PRINT:

(TO PUT NITMBER TAPE

IN READER):.

Y:. X -+-Y, (ANS~.~~ER):.

x:

STOP:. START AT:

l/O:.

The following verbs will be less frequently form an important part of the system. SUBROU~NE

Marks start of subroutine.

RETURN

Marks end of subroutine.

used in simple problems,

yet

Peamy, Higgins and WoadwaTd

30 INSERT

Entry to subroutine.

NEW

Enables a new block to be started numerical label.

BLOCK

without

putting

a

RECORD

Causes output,

READ

Causes input, base 32.

PLACE

Identifies auxiliary variables (stored on drum) with working variables. The former are distinguished by an asterisk.

LOGIC

Causes +, -, ‘times’ and f, to be given logical interpretations until further notice.

ALGEBRA

Cancels Loom.

A COMPLETE

base 32.

EXAMPLE

In the following complete example, several features occur which have not been explained in this condensed account, Chief among them are : Clause 2 0’ means do clause 0 of the current allowed to put ‘DO l/O’. ‘DO

block.

In full, we should be

Clause 4 In the following PUT sentence, power, i.e. square root.

*1/2PR

is a function

meaning

half-

Clause 5 *2 is a function combination which means ‘twice’. This function uses a shift instruction and is more economical than multiplication by two. The less economical form of the denominator would be written [2A (2)], or better [2.OA(2)]. In the former case, the 2 would be stored as an integer and converted to floating point in the program, whereas in the latter case 2.0 would be stored as a floating-point constant in the first instance. The program reads in and prints out sets of coefficients of a quadratic equation, followed in each case by the real or complex roots. Computation stops when a leading coefficient of zero is encountered. TITLE: EVALUATION ALLOT:

11

STOP:

OF THE

ROOTS

OF

~(2)~~+~(1)~+

.f: 2 TO A:.

1, (INSERT COEFF. TAPE):.

1) INPUT: A,

(3 VALUES):.

ii = O*

The Mark 5 @stem of Automatic Codingfor TREAC 2)

3)

IF:

A(2) = 0.0,

LAYOUT:

1 LINE:.

FLOATING

LAYOUT:

PRINT:

PUT:

110, (C~EFFS.):.

A(

- 4*OAA(2):.

4) IF: Y < 0.0, DO 9, (COMPLEX PUT:

5)

2

*1/2PR[Y]

=

PRINT:

PUT:

7)

IF:

(REAL

u=

-

<

0, ~0

U

LAYOUT:

IF:

5,

9) PUT:

10)

1, (INPUT

Z

10, (PRINT

SECOND

REAL

=

*1/2Z’R[-

-

A( 1)/*2[A(2)] : UZ,

C~EFFS.):.

VALUE:

(COMPLEX

AT:

u =

SECOND ROOT):.

Y]/,tr2[A(2)]:. ROOT):.

6:.

INITIAL START

NEXT

SPACES:.

(PRINT

PRINT:

DO:

ROOT):.

u:.

Y < O-0, DO

DO:

:.

1 LINE:

42 8)

ROOTS):.

A(1) + UZ]/*2[A(2)]:

[-

0.0, 6)

PROBLEM):.

351:.

LAYOUT:

Y =

OF

341:.

J = 2 [-

A(J),

FLOATING

0, (END

DO

-

1.0:.

0:.

REFERENCE BOWDEN, B. V., Faster than Thought, Pitman,

1953.

COMPLEX

ROOT):.

31