UNIVERSITY OF MANCHESTER...UNIVERSITY OF MANCHESTER ATLAS AUTOCODE REFERENCE MANUAL A. BROOKER J.S....
Transcript of UNIVERSITY OF MANCHESTER...UNIVERSITY OF MANCHESTER ATLAS AUTOCODE REFERENCE MANUAL A. BROOKER J.S....
-
UNIVERSITY OF MANCHESTER
ATLAS AUTOCODEREFERENCE MANUAL
A. BROOKERJ.S. ROHL
1st MARCH 1965
Scanned by The Centre for Computing Historywww.ComputingHistory.org.uk
-
PREFACE
Tills manual is a reference manual which describes the Atlas
Autocode Compiler currently available (I/3/65) at Manchester
University. It is not a teaching manual though we have tried to
make it fairly readable. Further compilers may in the future
become available both on Atlas and other machines and it is
expected that they will be described with reference to this manual,
Vi'e v.ould like to thank Mr, G. Ri
-
OJKTF.NTS
1 • IKTm.lDUCTI(jN ,
Example of an Atlas Avitocode Program 1.1
Blocks and Ron Lines
phrase Structure Notation
THE BASIC LANGUAGE
Symbols of the Language ^2. 1
2.2
2.2
2.3
Names
Constants
Delimiters
Typos
Declaration of Variables 2.3
ruuctional D'-poncJonce 2.5
Standard Functions ^'5
Aritliniotic Expressions ' 2.5
Integer Txpre^^yions
Arith)ne tic Ass iemnents
Simple Labels
Vector Labels
Conditional Labels
Co nd i t i o n a1 Ope r a t or s
Cycle Instructions2 11
Miscellaneous Notes
2. 6
2.7
2.8
2.8
2.9
2.9
2.10
3. SitjRAGE AT.LGCATIUH AND Biy)CK STRUCi'URE OF PROGRAMSq 1
The Stack "
Storage Allocation Declarations 3'^Block Structure of Programs
4. noUTIKES
Basic Concepts
Formal Parameters and Actual Parameters 4*3Function Routines 4o
Scope of names
Permanent Routines
3.2
4.1
4.6
4.6
Fmictions find Routines as Parameters 4-7Recursive Use of Routines 4-^own Variables 4*9
-
5. INPUT AND OUTPUT OF DATA
selection of Data Channels 5*^
Basic Input Routines 5*^
Basic output Routines 5*4
Captions 5'^
Binary Input and output 5*^
6. M-HNITOR PRINTING AND FAULT DlAGNOSIS
Compiler Time Moniioiing 6.1
Run Time Monitoi ing
Fault Trapping
Fault Diagnosis 6*5
Queiy Printing 6.0
Routine Tracing 6.7
Jump Tracing
Array Bound Check 6.7
Other Checking Facilities ^.7
7. PRESENTATION OF gjMPLETE PROGRAMS
Program and Data 011 Same Tape • 7*^
Program and Data Tapes Separate 7*3
Program on Several Tapes 7*4
S. COMPLEX ARITHMHTIC
Declarations 8.1
Standard Functions 8.1
Arithmetic Expressions 8.2
Arithmetic Instructions 8.2
Conditions ^*4
Routines and Functions 8.4
Input and Output of Complex Numbers 8.5
9. STORE MAPPING
The Addi^ess Recovery Function 9*^
Array Functions 9*^
The Renaming of Variables within a Block 9« 3
Store Mapping Routines 9*4
-
1^• THE USE OF MACHINK INST]
-
1 INTRODUCTIQN
All ATJJ\S AU'A;a:)DE PROGRAM Consists of a series of STATEMENTS
v.hich describe in algebraic notation the calculation to fee executed.
The statements are of two kinds, declpjrative statements giving the
nature of the quantities involved, and imperative statements which
describe the actual oper.ations to be performed on them, and the sequence
in wliich thoy are to V.e carried out, 'ihe statements are not immediately
recofjnisal: le hy the ccmpvrler .••.ad must first he converted into an
oquivalont :iOqucnce of l a.sic MACHINE INSTRUCTIONS. This is done by
a special translation pro^rairt called a COMPILER which is held
per!!v;.)icntly j.vailalle in the in^chinG. Not until tJe program has l-een
'cc^piltd' t '.n it !.e executed,
Tfte folJov.'irig example i,x\fes a ij;eneral idea of the principles
i iwolvcd in v-ritiiig a proj^ram, Vt'e v/ish to fit a straight line
y •= rx + h to sets of data of the form Xl. ,Y1; X?,,Y2; ; Xn, Yn
wlilch are to le pujiched and presented on a data tt-'pe in this order.
E;iC}i such set is to be terininated by the number 999999 and the final
set Ky two such numbers. For each set the quantities
^ - "f^XiYi - {'XifYi
nfxi^ - (i-Xi)^
1.1
^ = gYi -- afXl
n
c = iYi^ - 2(aiXiYi + bf:Yi) + a^ ixi^ + 2ab^Xi + nls^
are calculated, the last being the sum of the squares of the deviations
HYi - aXi - b)2.
The following is the formal proi^-rs-ra for this calculation. The
statements are to be interpreted in the v/ritten order unless a statement
is encountered which transfers control to another specifically labelled
stateinent. In general each statement is written as a new line, otherwise
it must be separated from the previous statement by a semi-colon.
-
1.2
begin
real a, b, c, Sx, Sy, Sxx, Sxy, Syy, nextx, nrxty
intc[;er n
read (nextx)
Z: Sx = o; Sy = o; sxx = (3; Sxy = o; Syy - O
n = o
1: repd (nexty) ; n = n -
-
2.1
the basic L.A.NGUAGli]
SYMBOLS OF THE LANGUAGE
A program is presented to the computer as a length of perforated
pspcr tape, prepp.red on a Flexowrlter keyboard machine, the keys of which
are engraved with the following symbols:-.
A ^ C})K i"G HIJ K LMWn R STU VvV XYZ
: b c d e rgb i j k 1n;nopq r s t u vv/x.y z.
a 0 rf
o'231567'"59
-=>< 1 M )[] ?
A back-spr.cii)g facility allows underlining and also the forniation of
Compound characters. For exarriple : -
c^c^ ^ > < ; ^
The 1 ;3t of these consists of an asterisk superimposed on a vertical bar .
It is usually referred to as a vertical arrow (and would be written
?s such in a manuscript) *nd is used to denote exponentiation,
thus af(n-l) means 'a raised to the power (n-1)'. Such a notation is
necessary because we have no iiieans of effecting superscripts and subscripts
with a Flexowriter; the format is essentially one dimensional. There is
one exception, the superscript ^ for which there is a special symbol:
it is equivalent to [2,
Since the handbook itself is prepared on a Flexowriter the same
conventions for exponents will also be used in the text,
NOTE All SPACES and UNDPJRLINED SPACES in a program are ignored when the
program is read into the machine. Thus they may be used freely to assist
legibility in the written form of the program,
NAMES
These are used to identify the various operands, functions and
routines which appear in the program, A name consists of one or
more Roman letters, possibly followed by one or more decimal digits,
and poh;.;ibly terminated by one or more primes(*). For example:-
X I Alpha alo TEMPI y'* b3'
-
UndGx"lined names and mixed nj'.uios su«.'h rs IUWST -'re HuT J'llov/ed, C
Tliore are cert3.in nr.mes, e.g. log, sin, exp, print, ror.d, etc.
which have a stajidard meaning (the PERMANENT routines) but s.11 other
n?inos must fee declared before any reference is m€?.de to them (see fcelow),
m future a general name will be denoted by [haMIO.
QJNSTAKTS
Nuir.ericy.l (positive) constants are written in a straight for\v;^rd
notation. For exi^mple:-
2.538 1 .25 J7.28a--1 iay
The last tv.o ex amp lea mean I.728 and 10000000.
The numerical pai t can be written in any number of ways. For example:-
15 015 15. I5.OVOO
are all equivalent. The exponent, where prei-ont, consists of a
follov.ed by an optional sign and decimal dibits.
The symbol ^ is equivalent to the tv;o symbols .5. Thus 2.5
mi?.y be punched as 2^. (
There is a further specialised type of constant consisting
of a symbol (either basic or composite) enclosed in quotes. Its value
is that of the intt'.rnal equivalent of the symbol, a list of which is
given in Appendix 5. Thus
z 33
= 2063
Though this form of constant may be used whenever a constant is relevant
it Is most often used when reading symbols off a data tape (see Section 5),
DELIMITERS
These are a preassigned set of symbols and underlined words. For example:-
+ -*/(» )>>->;sr
cycle repeat integer real then cayjtion comment
Note that -> consists of two symbols, - followed by >
Unlike names whose meaning ca.n be defined by the user, delimiters
have fixed absolute meanings in the language, I
-
2.3
TYPES
Calculations are performed on tv/o principal types of opersnd,
rep.l fi.Dd integer (later on we sha.ll introduce coiuplex). I^oth are
represented Tsy floating point nur.-.i jrs (in the form where a
is held to a precision of 40 binary digits and fe is an S-l^it integer);
I lit those of integer type are kept in P.n unstnn.d»rdised form
(so that the losist significant 24 bits can be used directly for
B-modification; the precise method of storr.£;e is described in the
section on machine instructions).
The lo
-
OUO dlmonsion^l arrays of elements may be docar.rcd by statcn.aiits such as(•
array a,b(0:99), cClOllg)
which reserves space for three arrays of real variables a(i), U>(i), c
-
2.5
FUNCTIUKAL DEPENDENCE
FuiicLlonal dependfince is indicated by writing the n-me of the
function follov/ed by the list of arguii'euts in parentheses (in a sirsilp.r
fashion to array elcineuts). For example:-
sir.(27rx/a) arctan(x,y) TE!.;P(i) a(Jo,lo)
E&.ch ; rgurjicnt can be an arithmetical c-.rprGssion (stie below).
Witliin a block all n?.Hies rn-jyt bo tiistiiiCt, and it is not
possible to liave a function v/ith Lhe srnse nr'Ae as a scalp.r. Thus
a and i-ii) or f and f(x) would JJCJT be nllcwed to rv.ppear in the
same block,
S TAN DARD FUH CF I(.)NS
Certain standard functions s-.x-e p-v'p.il:?ble and may be used
directly in arithivictic expressions (see next section) without formal
declaration:
sin(x) cos(x) tan(x) 1og(x) exp(x) sqrt(x)
arcsin(x) {-n/Z ^ result < 7r/2)
iirccos(x) (O < result < vr)
arctan(x,y) (- o.rctan (y/x), -?r < result < tt)
radius(x,y) (= sqrt (x^fy^) )
niod(x) (- 1x1)
fracpt(x) (= fractional pajrt of x)
intpt(x) (= integral part of x)
int(x) (:= nearest integer to x. i.e. it-' ot(x+.5) )
parity(n) (= (-l){n)
The last three functions are of type integer (see later), the rest of type real.
The arguraents of all these functions infs.y be general expressions, except
that the argument of the last must be of type integer,
A complete list of standai-d functions is given in Appendix 2,
AR ITID.'iET IC EXPR ESS IONS
A general arithmetical expression is denoted by Cexpr] and consists
of an alternating sequence of operands and operr-.tors possibly prece>ied by a
sign symbol, thus *
[ + • ] [operand] Toperator] Cqperand] [operator] .... [.OPERAKD]
An [operand] is a [VARIABLE], [ CONSTAl\"r], ([EXPR]), KexI'R]!., or [FUNCTION],
and an [OPERATOR] is one of + - / ^ (the asterisk denoting multiplication).
*=H3r, more strictly, (See Appendix 1)
[eXPR] = [+'][EXPR']
[EXPR'] = [operand][op][EXPR'],[operand]
[operand] = [NA?rIE][APP], [const], ([EXPR]), I [EXPR] I
[ + ♦] = +,-,NIL
-
Ml explicit multiplication sign is not required when ambiguity could not
nri.se from its omission. For example:-
2.5alb means 2.5''al=*b
h'i;TE: When the compiler looks for a name, it finds the longest possible
ns.me. Thus ab is i.iilten as a name rather than a'̂ 'b even if only a and b and not
.-^.b Y>ere declared. In this case a fault (NAME ab NoT SET) would be indici-'.ted.
E>:;v!:.p.les of expressions are:-
A(i~3,j) + A(i+3,j) + A(1,J~1) + A(i,j +1) - 4A(i,j)
Z + logd + cos(27r(x/a + y/b + z/c)))
LENGTH + BREADTH + HKIGHT
1 + sqrt(x(i)^ + y(i)^ + '/-(i)^)
a * b/c + d/e
(x + y + xO/Ca + bH-c)
2.5x1b * (c + d)e
e = Ix-yl + .00001
(l4.x)K(n-3) * (1-^)^3
NOTES
1, MultipliC5».tion and division take proccdence over addition ?.nd
subtraction and division tjikes precedence over multiplication, fhus
the fifth example iner'.ns a ♦ (b/c) * (d/e),
2, i'^'^XPR]! is interpreted as the positive magnitude of the
LkXI.:]. Thus it is equivalent to niod([eXPR] ),
3, An expoaent is denoted by | [oPERAKD] and exponentiation tj'kcsprecedence over the other operations. Thus the last exaiople me«ns
((1 + x) to the (n - 3))*((1 - x) to the 3). In the formation of
a I n, n must be an Integer or integer CfjxPR] (see next section);
then if
(i) n > 0, result = a*a»a (n tiwes)
(ii) n = o, result = 1 '
(iii) n < O, result = l/(a+a^a ^a)
4, To form a ^ b, where b is real we must write it in the formexp(b*log(a)),where a must be positive,
INTEGER EXPRESSinNS
An [EXPR] is an integer [EXPR] if all the [OPERAND]-s ai-e
scalars, array elements etc. declared to be of type integer, or are
integer constants or integer functions (e.g. int, intpt, or parity).
-
2.7
Thus if we assuiue th^t x is a. CVAHIAnJ.E] ^nd 1, n, j, k(l),k(2)
integer LvaRIAKLE]'s the follov/ing ^-ro intcf;fcr [exPR]'s,
»*(n-l)/2
i + J + k(2) + int(x)
j ^ k
intpt(n (n-l)/3)
The definition given P.bovG docs not ^n.?a"^ntee tlK'.t an inte£;er Cf^XPR]
will ?lw;\ys give j-vn integral result, e.g-. , I0/3 jK-O -Te riot
inlojii'al, Thore is no gu^irp.ntee either thiit expressions like
n-(n-l )/2(v;hich is integral) will always yield the exact finswer (in this
pp.rticul?..r case it does), V.'hen the result of such an operation is in doubt
it is preXc-rr-ble to use 'int' e.g., int(ri +(n-.l)/2) to give r.n ex?.ct integer
result.
Except in certain speciiil eases integer [exPRI's are ev-luated by floating
point P.rithrnetic in exactly the spjne way s.s general (real) expressions, tut
rre dostnndardised on assigm.ient (explicit or in^plicit) to their integer
uGstination. The definition of an integer [EXPR] is a basis for checking
tl:?-t such assignments ai-e sensible. The special cases rncntioned al*'Ove refer to
the subscript expressions in array elcjr.cnts. Such expressions, which i:hould
8.: :\ys be integer [exPR]*s are usually simple linear forms which are de^lt
v.'lth "ore ;;ppropriately by E-JTiodificp.tion, It is mainly to facilitate
siich operations (and the .-associated operation of counting) that integer's
sre used, Being destandardised quantities they can be transferred directly
to B-registers without using the floating point accumulator.
ARITHMETIC,ASSIGNMENTS
The general arithioetic ivvstmctioa is
CVARIABLE] = CEXPR]
Exsjnples are:-
X(p,q) = lH2Cos(2«'(x+y))
a = (b4c)/(d+e)+F
i = i+1
The action of the general arithmetic assignuient is to place
the computed value of the [exPR3 in the location allocated to the l.h.s,
tVARIABLE]. If the l.h.s. is a [VARIABLE], the r.h.s. CeXPR]
may be of type real or integer, but if the l.h.s. is integer then
the r.h.s. must be an integer [exPR]. For exsjuple, if y had been declared
i-eal and i integer then we could vrite y = i feut not i = y even if we knew •
that y had an integral value.
-
LABELS, JUMPS AKD OJNDITIJJiAI• ' ''̂ ATORS
Normally instructions are obeyed sequentially, but.frequently it
is required to transfer control to some instruction other than the nextin the sequence, or to obey an instruction only if certain conditions aresatisfied. The following facilities are provided:
SIML^LE LABELS Any instruction can be labelled
;y writing an integer Tn] before it, separated
'.y a colon. Irtore than one label is porinltted.
Unconditional juwp instructions are written as
tK]
VECTOR T^^BKLS
These are used to provide for a
multi-4vay switch. With reference to the
accompanying diagram the instruction
-> A(i) will jump to A(l), A(2) or A(3)
according as i = 1, 2 or 3.
A fault is signalled if the value of i
Corresponds in any way to a label not set.
The general form of the label is [nA^ME] ( Cn] ) J
The range must be ' clared a,t the head of
the routine by a statement of the form
svi_tch 1!nAME]([ +']Cn]:[ +'][n]) wh^^re
the C+'] indicates that the intej^e;. s
may be preceded by a sign if necessary.
For example
^itch SEGMFNT (-4-.+4)
A list of switches can be given. For exainple:-
switch A,B,C(1:3),D(o:2)
The [nAK^eI's must not conflict with those
of other operands in the same block.
->10
lo: —
4:5;
-^4
switch A(1 : 3)
A(l):
A(3):
->A(i)
A(2):
-
QINDITIUNAL LABELS
Another kind of multi-v;a.y switch is test 4, 5, 6
illustrated by the accompanying diagram,
Kere the conditions at the places indicated
are tested in turn and control passes tg the 4 case x
-
2. 10
Alternatively, conditional operators may appear AFTER unconditional
instructions, in which case they are written
ijf [OJND] or unless [Q^ND]
for example x - u ^ Ixj < ,0000001
-> 1 unless z > R or z = O
CYCLING INSTRUCriONS
These are pairs of statements which allow a ^roup of
instructions to fee obeyed a fixed numfeer of times. For exp-jviplo;-
eyele i = o, 1, n-1
repeat
In the above example the instructions between cycle ».nd repeat are
traversed n times, with i successively taking the values 0,1,
After the final cycle, control goes to the statement following repeat.
The l.h.s. must fee an intei^er name, but the r.h.s. qu?,ntities m?.y he
£;onoral integer [exPR]'s which axe initially evaluated and stored. Thus
within the imiermost cycle of the example kelow, the values of p,q and r
may be altered without affecting the number of times the cycle is traversed.
Tl^e initial value, increment, and final value must la such that
final value - initial value
increment
must be a positive integer or zero otherwise a fault is indicated.
For example
cycle i = 1,1,p
cycle k = 1,1,r
c(i,k) = 0
repeat
cycle j = 1,1,q
cycle k = 1,1,r
c(i,k) = c(i,k) + a(l,j)*b(j,k)
repeat
repeat
repeat
NOTE Statements such as cycle x = .2,. 1,1 are NOT allowed,a.nd
should fee replaced by an equivalent permissible form. For example:-
cycle 1 - 2,1,lO
X . 11
where i has been declared Integer and x real.
-
2. 11
MISCELLANEOUS NOTES
"snd of program is the formal end of tlie program aud P-ppes-rs after the
Iff.st written instruction; its action is to terminate the reading of the
program and to start obeying it from the first instruction.
2. The instruction stop can appear anywhere in the program s.nd signifies
the dynamic end of the program; its action is to terminate the c^^ lcu3 a.tion,
3. The delimiter comrrient allows written coniyieuts to he inserted in a
program to assist other users in understi;.nding it. The information
f "ilo'ivlng co)"v-ient (which may inclu le coJnposite characters) up to tJ^e
li-.xt newline or serai-colon is igno •'-d by the cotjputer. The delimiters pg.ge
f'u.d I are synonyms for comisent, th gh the first has an obvious special use
in the pagin^ition of programs,
/j.. It has been noted earlier that all spaces and underlined spaces in a
program are ignored and that Autocode statements are terminated by a semi
colon or a newline. If a line is terminated by the delimiter £ then the
following newline character is ignored by the computer. Thus a single
statement may extend over several lines of the printed page, , It is not
anticipated that this facility will be frequently used, excei>t vl.en
writing conmients and possibly long algebraic expressions,
5. If a program)r4er is prepared to exclude upper case letters from names
and captions, then he can effect a saving both in the size of the tape
and the speed of compilation, by using the special instruction
upper case delimiters
f.i)d then writing all following delimiters in upper c?..se without the
underlining. Thus the example of P2.10 could then hs written: -
CYCLE i = 1,1,p
CYCLE k = 1,1,r
c(i,k) = 0
REPEAT
CYCLE j = 1,1,q
CYCLE k = 1,1,r
c(i,k) = c(i,k) + a(i,J)*b(j,k)
REPEAT
REPEAT
REPEAT-
The delimiter causes the con.piler to replace each upper case letter by
the equivalent underlined lower case letter, so that a mixture of
normal and upper case delimiters can be used. If this is required only for
certain parts of a program then the instruction
normal delimiters
can be used to return the compiler to its normal operation.
-
3«i
3 STORAGE ALIOCATION AKD TOE PTOCK STtiUCfURE OF I'RjGR.-UtS
TKE STACK
In order to illustrate the priiiciiJlas of £tor?g;e allocation, we
assume the following simplified .>icture of the data store (the stack),
fuller description being givej; in the section on tJie use of macliine instructions,
CELI^ IN 1st AVAILABIJS CELLS
USE I
I t i I III
E^^ch cell or acntion repieseut.-j a 1-it -word In tlie co5Tiyuter store
r-.nd can 1-3 used to hold eitlxer a re^.l or jui integer vp.rli'.ble. At Eiiy
•'.mo duriiig the running of a the stack pointer, St, points to the
xt avfilahle location i.e, it contains the c.ddres3 of the next free word.
In the examples that follow, shaded arer-s represent 3oCf.tions
• •lich hold inforrny.tion essentiiil to the pruii;rrin, such rs ai-ray diraensions
..s)d origins, and are not of impoi'tsince in the context of tl.is section. Each
area may in fact consist of several locations. Cells which pxe allocated
to variables are indicated by the presence of the nar.ie given to the v^-rialfle,
'"'"OHAGE ALLOCATION DECL.ARATICDNS
The declarations which allocate storage space f.re
real integer p.rra.y integer array
and to illustrate the stack mechanism we consider the follcv/ing exi-Jiiple:
begin
x-eal a, b, c; integer i, max
array A(l:2,l:2), x(l;3)
After the above declarations the stack picture would be as k-elow
Stl St2
IM\\\\\yi a I b I c I 1 |maxlA\\\\\\\\MA(l.l)IA(l,2)lA(2,l)lA(2,?,)JMMVL^)l^JaIM3Ll
Stl is the position of St teefore feegin and St2 its position after the
dt;clarations. Any further declaration advances St by an appropriate pjnount,
likewise any activity initiated by the instructions in the body of the block
causes St to be advanced(either explicity or iiaplicity) still further,
Finally when end or end of program is reached, then St reverts to Stl,
Variables declared by real and integer are called FIXED VARIAJiLES,
'acause the amount of storage space required can be determined at conpiler time.
Array declarations, however, may have general integer expressions as the parameters
and hence have dynamic significance. For example one wight have a declaration
;-iich as . .
array A,B(l:m, l:n),x(l:n)
In this case the space allocated will depend on the cortiputed values
of m and n and cannot be determined at compiler time. The stack pointer
St is thus advanced in several stages i'ollowing the initial step which
reserves space for all the fixed variables.
-
. (
BLOCK STRUCrURE OF PHOGRA-MS
This is illustrated by the following exsjiiple:-
boj^.n
re^ a,b,c
a = 1; h 'Z
c - ?-+b
begin
real i?,h,d
a -- 2; d --- 1
h -- c
c - 4
end
a - :b-(-c
end
The .stack picture associated with the above block is given V.-elow:
Stl St2 St3
I imvw a12 3 456
Before the first begin St is at Stl, and moves to St2 on entering the
outer block. After the second begin St is at St3 and reverts to St2
when end is reached. At the second end, corresponding to the first
begin, St assumes its origin^.l position, Stl,
In the diagrajn, positions 1, 2, 3 cox'respond to the declarations
of the outer block, and 4, 5, 6 to those of the inner block. After the
instruction c =: a+b, the value 3 is left in position 3; while the instructions
of the inner block leave the values 2, 1, 3, 4 in the positions 4, 6, 5, 3
respectively. The last instruction of the outer block leaves the value
7 in position 1,
-
3.3
Tlius the vjiiiables a, fe of tJie I.lock
-
4.1
4
BASIC CONCEPTS
A large progrfun Is usually inade up of scvc-r?.l rovitines
• ach of \vhlch represents some characteristic part of the calculation.
Such routines may be called in at several different points in the progra-in,
and their design and use is a fundamental feature of the If.nj/uage,
The inti oductory exai^ple consisted of a in^^in block only (delimited by
begin and end of pro;^rr..)n) although it ri.'i'ko;, reference to the routines 'rerd',
'print*, 'newline*, which : o)
where the coefficients >vre selected from sGtrie vector a,
routine pol^'^Creal nairie y, eg-ray n-me a, real x, intec,er m,n)
integer i
y = R(r.Hn) ; return if n = 0
cycle i = m+n -1,-l,m
y =: x*y+a(i)
repeat
return
end
Given the values of x,iii,n and the addresses of y and the s-rray
elements a(i), it evaluates the polynomial and sets y to this value.
The'statement ei^ is the formal or written end of the
routine while return is the dynamic end, i,e. it is the instruction
which returns control to the main routine. Where the formal end is also a
dynamic end as in the present example the return instruction preceding end
can be omitted; in this case ervd serves for both purposes.
NOTES
1: There can be any number of alternp'ive exit points in a routine - i.e.
return can occur more than once,
2; return is a member of the FORMAT CLASStui] - i.e. it can be made conditional,
as above.
-
4.2
T)^is routine can be EK'.; EDDED and used in a )r.?in routine as illustrated
below,
V^egin
real U, V, z, x ; integer m
array bCo:!^), 0(0:50)
routine spec poly (realname y, prray name a, real x, integer m,n)
poly(U,b,z,o,m)
roly(V,c,x2,20,l0)
stop
routine poly(realn^xie y, .-Array nr-Uie a, real x, integer in,n)
^r^e^r^ i
y = a(r!H-n); return if n = O
cycle i = ni+n-1, -1,m
y = x^yi:r(i)
repeat
return
end
end of program
The routine is called in by the i-aln routine whenever the
name 'poly' appeai-g. The first reference to *poly* would cause the poly
routine to evaluate
U = b(o) + b(l)z + + b(ra)z^m
and the second would cause it to evaluate
V = c(20) + c(21)x2 + . .. + c(30)xj«20
The parr.ineterM in the routine specification and routine
heading are the FOR>«^AL PARA.METERS and the ps^xsmeters in the call statements
axe the ACTUAL PARAMETERS (see next section).
The body of the r0^1 tine may be considered as a felock
.delimited by routine and end, and the concepts of storage allocation, local
and non—local names
-
4-3
Any nuHiber of routines may be ovibcdded in a mp.in routine
in the above farJiion and they are referred to s.s SUE'l^UTINES of the main
routine. If the body of R subroutine occurs before any reference to it
in the msin routine, the routine spGCific;ation )iiay be omitted, but by
convention it is usual to place all the subroutine specifications among
the declarations at the head of the main routine and the bodies at the end.
l^RMAL PARAMETERS AND ACTUAL PAR^METER^
The p?^r?)iictei^s of the ro-'tine are the iteins of information which
.specj.ry Ihe of the routine V'/henever it is usvid. The foriT'.al paranicters
are t>:e names by wJiich this infoxrnation is ref. raineter, as shown in the following table:-
Forrnal p?n:ametcr type
intGr(5T name
real '?? me
3. 1 •: f.'''-1"
i oal
integer array name
array name
integer array
array
rcuti)i.3 type i.e.
routine
ieaX fa
integer fn
I Corresponding actual parameter
1 name of an integer vpjriable
1 name of a real variable
an integer CexPR]
(similar to an integer assiguioent)
a li -nera1(i. e, real or integei') CEX.PR]
(siinilar to a real assignment)
name of an int cer array
name of a (real) array
name of an integer array
name of a (real) array
(the difference between these and the
previous pair of parameters is
explained l?elow)
SoiiiotiioQs it is required to pass on the
najne of a routine as a parameter.
In this case the actual pejrameter is the
name of a routine which must correspond in
type and specification with the formal
pi^jraraeter, the specification of which will be
found in the routine body
-
In the expjT.ple of a routJiie to evaluate a polynomial described e^irlior,
the forip.al parameter y is the iiatr.e of the vn.riable to which the result is fissijined,
and the corre.'jpoiiding actual pra'ansuter must be a najiie, in this case the name of (
a real variable. The formal parant:. "er then is of type real naine^
A reference to y inside the routine is essentially a reference to the non-local
variable ny.med by the actual paraineter. The sariie applies to the .t^rra^n-^ne
parameter a, a reference to a inside the routine being a reference to the
non-local am?.y v.-hoso luuns is Kukstituted for a in the calling statement.
The formal para^^ieter rcr.l x on l^he othcu' hand can be replaced' l:y a
^tiuersl aritJur^etic expre^^slon, -..hich is evaluated and y.ssip'nod to the local
variable x which is specially cn^ated in addition to r.ny local real
v.-riables declared in the routine. The same applies to tJ)e fornial parameters
iitteger ni,n. These are essentially local quantities, and expressions are subiitituted
In place of tJicm ai*e evaluated and the resultant values assij/ned to the local
vr'.riablos m and n, v/hich are lost on exit from tlie routine. Consequently
the routine hhould place the information it produces in variables vrhich are
Cf lied by KA?nC (such as x and a),"
The foi'inal parameters x, m, n are said to be called by VALUE in so far
n.s it is only the values of the corresponding actual parameters which are of
ir; Lcrest, This is the essential difference between the formal parameter types
ai^^a^ 1ad f:rray name (or integer array and integer array name). In the former
case the array naiued by the actual parameter is copied into a specially created
local array, and a reference to the nPiae in the routine is taken as referring to {
this local array. As the copying process can be time-^ons\iuiing and space-consuming,
array's should be called by NAMJE if at all possible, especially if they r.re large.
Another example of a routine is the following
routine matmu It ( arrayname A, B, C iutci^-er p, q, r )
integer i,j,k ; real c
cycle i - 1,l,p
cycle j = 1,1,r
c = 0
cycle k = 1,1,q
c = c+A(i,k)=i=E(k, j)
repeat
C(l,j) = c
repeat
repeat
end
This forms the product of a p x q matrix A and a q x r matrix B, The
result, a p X r matrix, is accumulated in C, The routine assu! js that the first
element of each matrix has the suffix (1,1), A typical call sequejice might be !
mat mult(M, x, y, 20, 30, 1)
where H, x, y had been declared by
array H(1;20,1:20), x,y(l:20,1:1)
-
4o
FUNCTION ROUTINES
When a routine has a single output value it may he writi n as a
function routine and then used in an arithmetic expression in the same way as
the permanent functions (cos, sin etc.). For example, the polynomial routine
described earlier may be recast as a function routine as follows;-
real fn poly (arrayname a, x-eal x, integer m,n)
integer i ; real y
y = a(mHn) ; if n = 0 then result = y
cycle i =
y = y*x+a(i)
repeat
result = y
end
NOTES
1: In general, the e it from a routine is of the form : result - LexPR]
and this causes the EXi SESSION on the right hand side to be evaluated as
the value of the function,
result = CexFR] acts as the dynamic end of a function (i.e. it corresponds
to return in a routine), and may appear any number of times within the function,
3^ result = [EXPR] is a number of the FORJ^iAT CLASSCui] - i.e. it maybe mp.de conditional.
The specification of the above routine would be written
real fn spec poly(arrayn3jne a, real x, integer ',n)
and the routine can be called in an arithmetic statement, for example
y = a-b + 2h*poly(c,l/x,0,l6)
An example of an integer function is given next. It selects the index of the
maximum element x(k) in a set of array elements x(m), x(m+l),.,,.,x(n) (n> m)
integer fn max(arraynaine x, integer in,n)
integer i,k
k = m
->1 ^ n = m
cycle i = m+l,l,n
k = i ^ x(i) > x(k)
repeat
1: result = k
end
A call sequence for this function routine might be
y = 1 + x(max(x,1,100))
-
(•
SCOPE OF NAMES
In general all names are declared at the head of a routine
ither in the routine heading or l^y the declarations integer, r
-
4.7
FUNCiaoNS AND RiJUTINKS AS PAJiAHETERS
This Is illiiatrated by the following e>raiBpl0 involving an
integration routine
routine spec integr; : e(real name y, real a, b. intes-^r n, real fn f )
v.'hich integrates a function i'(x) over tJie ronrje (a, b) by ev?.lu.vting
y =
-
b :-gi_n
routine integrate (real name y.real a,b,^lciger n,real_fn f)real £n sj)ec mix (r^t^al y)
real z, b
coinment Simpson rule integration
1;read (b)
b = lOUO then stop
integrate (z, O, 1, int(lOb), aux)
new l ine
print (b, 1, 2);spaces(2);print (z, 1, 4)1
real fn auy)
result - expC -y) cos(b-y)
.jfid
I routine integrs-te 1
end of progr
NiiTRS
1: That the nain^s given to the auxiliary I'outine and its
parameters need not be the same in the integration routine as in themain program, but they must c-orrospond in type.
2; Since 1he result of the intergration is a single quantity, the routinecould be rec st as a real fn : -
2al fn spec integrate (real a,b, integer n, real fn. f)re
nnd called by, for example:-
print (integrate (0,1nt (lob), 8.ux) ,1,6)
RECURSIVE USE OF RtjUTINES
The name of a routine is local to the routine or block in which
its specification appears, and so the body of the routine is within thescope of its own name. Hence it may call itself. It may also call itselfindirectly by invoking other routines which make use of it. on each activationof the routine a fresh copy of the local working space is set up in the stack,so that there will be no confusion between variables on successive calls.(This does not apply however to own variables. See next section.) Some criterionwithin the body of the routine must eventually inhibit the calling statementand allow the process to unwind. Functions defined recursively, for exaiiiple;-
n: = n(n-l): , n > 1
- 1 , n = 1
can be implejnenled in this way, but it is always more efficient to userecurrence rather than recursive techniques.
-
4-9
OV/N VARIABLES
Wlien a routine is left s.ny infojrroatton stored in vai'iables coi'reypoGoJ
to local declarations in th:?t routine is lost, and no furthur reference rc-y
be ruade to it. In some cases it may be desirable to retHin soivjo of this
iuforination and be able, to refer to it on a sub
-
5.1
5. INPUT AMD OUTPUT OF DATAThe input and ou1;pu1; of data v^ill generally ho accomplished by
means of permanent routines. In this suction these permanent routines aredescribed and the precise form of data is given.
SELKCT ION GF DATA CHAJ'iHELS
The selection of an input channel is performed by the routine:-
• routine spec select input (intetor i)
This selects the input chajHiel corroyponding to the value of i, andthis channel, tceether with the particular input device assigned to itin the Job Description
-
It should be noted that a siJiijle Hinice is sufficient to terminate a
number, and that no spaces are allowed within .lie u'antissa or within tne numericalpart of the exponent (unlike constants appearing in a program where all spaces
arc irrelevant and the number is terminated by the following name or delimiter).Further since 'tabs' are converted to a number of spaces, numbers may
be scparnted by 'tabs'. Several numbers in a sequence way be read by the routine:-
routine ^>pGjC read([VARIABLE LIST])
For exarnpTo, read(a, i , x(i ) )
This is treated if it wore a series of instructions
read (a) ; > iad(i) ; read(x(i))
htnce the subscript of X(i) takes the value just assigned to 1.
The read routine is an exception to the general form of a routine, as
it )T)ay have an indefinite number of real n^ie and int'::ger name p&rarneters.
Successive numbers on a data tape may be read so ss to fill
an array by means of the routine
routine spec read array(arrayname A)
For example:- A(1:20, 1:20) ^read array (A)
would cause the next 4OO numbers on the data tape to be read so to fill
the array A, row by row. It is thus equivalent to
array A^(l:20, 1:20)
integer i,j
cycle i - 1,1,20
cycle j = 1,1,20
read (A(i,J))
repeat
repeat
Thi"ee permanent routines ai-e provided for manipulating alpba-nuvaeric
data. The first:-
routine spec read symbol (integername i)
reads the next symbol (simple or compound) from the selected channel,
converts it into a numerical equivalent and places the result in the ^specified integer location.
For example, if the next character on the data tape were an
asterisk (numerical equivalent I4) the instruction 'read symbol (p)'would set the value of the integer variable p to I4 and move to the next
character on t^pe.
-
5.3
T^e second allows the next symbol on the data tape to be inspected without
mc .'ing on to the following one. It is
integer fn spec next .sysiibol
Tie third:-
routine spec skip
pj^-.'-ses over the next syiribol without reading it.
A table of numerical equivalaixts and a description of the formation
of compound symbols is given in Appendix 5,
It is in testing syj.ibols that the alternative form of a constant
is useful. For exa/r.ple, we coxild test if the not symbol on a t?.pe were rvi
asterisk by
->1 jl^f next symbol = I4
or ->1 i^ next symbol =
Since spaces and underlined spaces are ignored in a program, and nov.-line
pnd :;emirolou are used as terwdnaters, special symbols sxe provided to
r present thera. Thus a space can be tested for by
~>1 ^ next symbol ~ ^
The symbols ave:-
^ i representing a space
^ ^ '' an underlined space
;1 ' * a nev;line
/I '* a seiai-colon
If the data itself contains these special symbols, then they can be tested only
by using the internal equivalent.
Finally there is a permanent input routine which permits the reading
of an indefinite number of decimal nun'bers into successive storage locations,
stopping v.'hen a particular s^'inbol on the data tape is reached. This routine is
routine spec read sequence (addr s, integer p, integer name n)
The formal parameter type addr is explained in Section 9; for the
present purpose it is sufficient to say that the actual parameter will be the
n?.me of a variable, representing the first location into which the numbers are
to go, p is the numerical equivalent of the terminating character, and on
exit from the routine, n contains the number of numbers that have been read.
-
As an example of the use of the nbuve rout e, suppose a data tape
contains an unknown number of juiinbers, but less than lOOO, and tliat the
last number is follov.'ed by an asterisk. Then the instructions
array X (.l:loOu)
in t :gor n
road sequf,Mice (X(l), 34, n) [or : read sequoncc(x(l) , * , n) ]
v.ould cause the successive numbers to be read into X(l), X(2), etc.
If there were 800 numbers in the sequence, then n would be.set to 800
when the routine was left,
NOTE
on input, each line of data is reconstructed to give an image of the
print-out produced by the Flexowriter. Thus 'backspacetab','upper case'
rnd 'lower case* do not appear as characters in the reconstructed line,
since they do not appear on the print-out. 'Tab* produces an equiv.;lent
-^ubei* of spaces, 'backspace' helps form a composite r-iiaractor, asid
non-significant cases are iii'jjored. Those positions containing an erase
are then deleted from this line. The line image is normally 16
-
5-5
It sliould be noted that nc termintiting characters are included
by the above routines. They may be .included by the user by means
of the routines;-
£.^1' ^ ® spe c ncw1 i ne
routine spo*; pa.ce
routine spec newlines(iiUerer n)
routine spec sp^ices (inte^-er n)
routine spec tab
routine spec print syinbol (intc£,er i)
The first of these resets the carri?-.ge of the approprii^te printer
(or pu)\ches the ncwline cliuracter), and the .'-econd causes the print r to
::];ttings are at positioris 8, 16, 24, 32, 48, 84, 80,
96, 112, 128, l44» ^59* 1'̂ ® sixth" prints the syjiiboi corresponling to the
value i.
The routiu^^:-
He? 1' .•.'pago
causes the lineprlnter to comncnce a new page, if the output
device is a line printer, or punches 30 newline characters if it is a puisch.
The routine:-
routine spec runout (integer n)
punches n runout characters (used to seperate sets of results, for example)
on the punch. It has no effect if the output is on a line printer.
Arrays of numbers may be output by means of the routines
routine spec print array fl (array name A, integer m)
routine spec print array (array name A, integer m,n)
For a one-dimensional array, the elements of the array ai-e printed
across tJie page, each number being terminated by two spaces, or a newline
if the right hand edge of the page has been reached. The successive rows of
a two dimensional array are printed as above, successive planes of a three
dimensional array are printed as two dimensional arrays, and so on. Each
array is started on a newline and the printing style for the Individual
numbers is the same as that of the *print fl' and 'print* routines.
-
CAPTIONS
Tli'TG is a special facility for lu-liMng captions. For exi^'inple
caption TAJ31.E ^ UF TKMP AGAINST fi VOL
This prints the information after cr^-ption up (o, but not including, the ^terminating symbol 'newlina' or ' semi-colon *. Since spr.c 3 and underlined spaces
are Ignored and *new line* f!.nd 'semi-colon' nre used as terir.inators, we also use
the special characters:-
^ or
;l " A
A " ^
Thus
newline
~ r pj-'int (y,l,3); ncv.lJno
caption B p -- ; print (2,1,3);
v/Quld be printed as
A = 1.7.12
B = -2,380
In general c_ can be used (in its usual S'-i;;-. ) in a Cf.ption if the inforr^iation
is too long to fit on one line across the pi"-.2e. In view of this if i-.a
underlined word ending in _c is used at the end of a caption, it mvist 'oe
terminated by 'semi-colon' not 'newline',
BINARY INPUT AND OUTPUT
Binary tape may be read and punched by means of the routines
routine spec read b':iajL-y (integername i)
routine spec punch b-inp.ry (integer i)
The first reads the next row of holes on the tp.pe as a binary mmber
(in the rauge 0~127, with the tape so oriented that the sprocket hole comes
:2tv.'eeu the digits of value 4 and 8), and places it in the nayned Vtf
-
6.1
6 MONIT ,R PRINTING AND FAULT DIAGNOSIS
F/>ULT NtlNITtMUNG
Thei^e are two types of fault which can be detected by the compiler,
those which can be found during compiling and tho:je which become evident during
the running of the cojupiled program. To J-id the programrtier in correcting
Ihetje faults information is .?.utor. • tically printed out where a fault occurs,
QDMPILER TIME MUNI^njRING
During compiling an outline of the program is produced as an aid to the
finding of faulty instructions. It also associates each block and routine with
its serial number, for use in tracing faults found at run time (see later).
/ .11 faults during compiling are monitored. Those to which a line
•rabor can be attached, such as NAME NUT SET, are preceded by it, while
• o;.e whicli can only be found at the end of a routine such as TuO TEW
. KATS are monitored after the END. In calcu'^ating the li-io ninr.ber, blank
liniis are ignored, .-ind lines joined >,\y the continuation symbol c count as one.
FiT)ally at the end of each routine all the non-local variables except the
permatient routines and functions are printed out. Although these do not
necessarily indicate a fault, they may indicate a name which should have been
c-clared locally. A typi-cal program monitor might be
O BKGIN BUICK ; SERIAL NO = 89, M/C ADDRESS = >^721
26* NAME TEMP NOT SET
55+ LABEL 7 SET TWICE
70 BEGIN R(3UTINE POLY: SERIAL NO = 9O, M/C ADDRESS = 32IO115* NAME TEMP NDT SET
115* REAL NAME X IN EXPRESS KJN
120 END R0UTINT3 Pf)LY ; OCCUPIES 256 M/C INSTRUCTIONS
* Li\BEL 18 NOT SET
NON-LOCAL VARIABLES A TEMPI Si
182 END OF PRi:}aRAM: OCCUPIES 800 M/C INSTRUCTIONS
The above should be self-explanatory. It indicates that the program
started at line o and finished on line 182. These are physical lines
and exclude all blank lines on the print-out. The cuter block is given
the serial number 8g. The routine PoLY started on line 70 and was given
the serial number 90, There were mistakes in lines 26 and 55 line115. Finally label 18 was not set in the routine POLY,
-
6.2
since there jnay be jriore than one statement on a line, it is not possible
to tell specifically which statement is involved but the faults are printed
in the order in which they are discovered, A full list of faults is given
in Appendix 4 tosether with a brie>: description of th#iir nature,
RUN TIME MnNI'miUKG
During the running of a program certain faults may bo detected
Ijoth by the coiripiler r-ad by the machine and its supervisor progr^jn.
For exaniple, the supervisor program detects the case where the square
root of a i ogative argur.5(-,ut is being requested and the compiler detects
faults connet:ted with s'.'itch and tost instructions,
TJie standard procedure is to print out 2 lines of information
specifying the frailt and the line on which it occurs folluwed by a list
of useful informntion found in the FIXED part of the sta«.'k. For exejiiple: -
LINE 117 ROUTINE 90
EXP QVERFIJJW
R{)UTINE 90
arrayCi;10,1:5)
ARRAY(1:10,1:5)
10 5
333333334^0 ^ • J^^'49999997« o.ooooooooooa-99
64
CYCLICCURRENT VALUE = 6, FINAL VALUE = 10, INCREMENT ==1)
CYCLE(CURRENT VALUE = 4, FINAL VALUE = 5, INCREMENT = 1)
BLOCK 89
0.0000000000a-99 3.7152463802a 3
10 5 3 6
ARRAYd: 10,1:5)
ARRAYd; 10, 1:5)
-
NOTES
1: This fault print out must be interpreted with care. V.hen the ffiult occurs,
the fault print out routine looks in the STACK to find the fixed variables ?.nd
interpret them (see Section 10). Now every location in the store initially looks
as if it contains a real qua)itity. Thu.s:-
(i) until an integer is a.ssigned a value, it will appear as (and be printed
as) a floating point quantity (probably zero),
(ii) until an array declaration is obeyed, it will appear as 2 floating
point quantities.
(iii) until a cycle has been entered, it will appear as 3 floating-point
quantities.
Conversely, since all sub-routines of a program share the same spac-,
ll\en on entry to the sccond and subsequent routines, the stack will contain
the valur*s l(>ft by t! ; previous routine and these will be interpreted accordingly,
if the current routine does not alter them.
2: The 'CURRENT VALUK' attributed to a cycle is the value o" the inj^eg^
n.*?.rne used on the left hand side of the instruction at the tih.e of the fault.
Thus if a program consisted of a number of cycles one after other, controlled
by i, and the fault were inside tl\e last cycle, then all cycles would have the
same 'CURRliKT VALUE* - the current value of i.
3: only cycles, arrays, integers and reals are distinguished.
(i) for integer name's and real name's the address of the actual paramter
is printed (as an integer) .
(ii) for array fn's (see Section 9) its parameters are printed (as integers).
(iii) for routines and function's used as parameters, six real quantities
are printed,
(iv) for complex quantities, the real and imaginery parts are printed in
floating point style.
-
6.5
t\^UT;r TRAPPING
The above stpjulard monitoring procedure involving the termination of
the program, is not always convenient. For exrinple if a program is dealing
with a series of data sets, it may be preferable to restart on the next
'case' in the event of (say) EXP OVFm;^IX)W rather than terminate the entire job.
An instruct;", n is provided which enables the usex* to trap certain
faults and ti'ajisfer control to some preassigncd point in the program. It
takes the form:-
fault [fault list]
where I FAULT LIST] = LK-LIST]-> [n] [H)5ST OF FAULT LIST]
Foi' example:-
fault 1,2,5 3,4 ->10
mor.ns 'if a fault of type l.,2 or 5 subsequently occurs then jump to label 18 ; aadif a faulL of type 3 or 4 occurs then jump to label 10,
The effe^.-t is to preserve all the necessary control data to enable control
to revert to this point in the program (and then jump to label 18 or lo) should
ona of the specified types of faults occur at some lower (or the same) level.
Tlie l:'bel must be in the same block as the trapping statement, whi
-
6.6
The first pair of statements are DECLAilATIVKS V:))ich di.Oimlt the -rePs 'f
the program in which provision is to bo in?~de for the pp.rticulp.r checking facility.
The second pair are INSTRUCTION'S v.Iiich turn the facility oji or off (initially they
sjt-e on). They do this by setting a cert».in switch V:hich is oxf^mined whenever
the facility is about to be executed. If tlie relevant sv/itch is on then tKe
facility is executed, if off it is skipped. If the facility hr.s not been
co'-piled in the first place then the instructions have no effect. This sv.-itch
;:ui. ( irjg is oxtrytnely f?.st so that there is nothing to be !;r,i;.£.-d from recorv.ing
tlie current sts>.te of the switch (in some integer, say), p.nd testing this before
each settijig order. For example, the following sequence causes queries to be
printed every tenth time round the cycle,
cycle i = 1,1
queries off
if fr2cpt(i/lo) = 0 then queries o^
repeat
The switch sensing on the other h«nd is a tir.ie consuming opor?.tjon and it
is for this reason that the declaratives are provided to delimit the areas of the
progTam in v-hich tliis takes place. In most cases, however, the check is compiled
over the entire program.
The checking facilities in question ^re described by the phrase:-
[check] = queries, routine trace, jump trace, array bou?\d check
They will be described in turn.
QUERY .vUNTING
Any arithmetic instruction (including complex) can be followed by a ?,
for example:-
a =: b(i) + c?
When the facility is operative the new value oji the l.h.s. is printed every
time the instruction is obeyed. The style of printing will be fixed, floating,
or complex floating according as the l.h.s. is of integer, real, or complex
type.
[Unlike the other facilities, ?'s are normally compiled so that a
compile queries at the head of a program is redundant. Also ignore queries
is equivalent to stop queries.]
(
-
6.7
ROUTINB TRACING
Vi'hen the routine trace is op«;rntive It • r.u^oa the routine Jiuir.bca- to
be printed each time a routine or block is e)(t« ..-d p.nd left. The corref?poj;de)ice
between the routine number and the nr/Uio cyn he ound from the pro^rj^un out 1.1 -e
produced during compilation, TJie printout of m. i'outiue trr.c© hiight appear
R95 Rgy RF96 EKO96 KMD97 R90
]i3 Ti ->4 ->6 S3 ">7 '>S ->9
Hera T and S refer to test and switrh rc:;pectively. If the labol and
routine trace are both oper;--tive the print out i>iiiht aijpepr:-
F^95 -^3 Ti -^4 ">'3 R97 S3,
ARRAY BOUND CHECK
If this facility is operative the values of the subscript
expressions in all array eleir.ents are checked to see if they lie in the
range s*/ecifiod by the bound pairs in the array (declarations. If not, the
progrfiju is terminated with the approt>riate monitoring.
OTHER CHECKING FACIIJTXES
Certain checks are luilt into the object program e.g., whether
a cycle instruction calls for an integx*al nuwber of cycles and whether a
switch index is out of re-rAf^e or corresponds to a label not set. All
are time and space consuming operations. They can be removed from an
object program v/hich is otherwise ready for production by means of the
declaration
production run
-
7 r-Hi^SKKrATIUN t.;F QjMPLETE rR(;GH/VMS
J(';B DKS CHI FT IONS
The running of programs on the computer is controlled by a
supervisor proijram Jield permanently in the • nchine. The supervisor
accepts coir-plete programs as a series of t; ..es (program and data) and
a J{j!5 i)ESCJUPTIi3N which may be on a separate tape or included with the
pi-o^i ; !ii or data. A full description of the system is given elsewhere
fj], ;!nd in tliis section we give examples to illustiate the general
principles of job descriptj.ons.
PH.OGHAM AND DATA (3N SA?>1K TAPK
The simplest form of job consists of job decription, program and
dat;a on the one tape. For example;-
J(jB
UMA, J(jNES.5/2
OUTPUT
O LlNKPRIiNTER 100 LINES
STORK 32 BTXlCKS
COMPUTING JOOOO INSTRUCTIONS
OjMPILER AA
begin
I PRGGR/\M 1
1 1I I
end of program
I II DATA I
I II I
NOTES
1. The title f'^nd line) identifies the job. The first few characters
will be a ». ode lo idcntily the particular organisation and the rest wj,H
be information of an arbitrary form to identify the progranimer and the
program within the organisation.
Reference
Cl] 'Documents and Job Description* I,C,T. Ltd., October 191)3.
This gives a full description of the possible arrangements of program
and data tapes and the utilisation of the multi-channel input/output
facilities on Atlas.
7.1
-
2, The 13UTPUT inXoi tiiation aays that reference to channel o in the
pio2r?-m moans the iinepriiiLcx* (if no c iput channel is selected in the
proj^x 1 channel 0 is used), Tlie ninriber of LINES gives an upper limit
to i:he amount of output that is to be permit Led.
2, STORK gives an uppex* limit on the number of 5^^ word main store
blocks used by the program and data.
3. ajMPUTING gives a limit on the running time of the program. An'INSTRUCTION' is equivalent to 2048 machine instructions.
The (HJTPUT, .'-mRE, and mMPUTING sections are optional, both
individually and collectively. If they are omitted the allowances given
in the above example are r.,; sumed, i.e., 100 LINES, 3^ BIj(JCKS, 10000
INSTRUCTIONS, These should in fact be adequate for most small probl
-
;.3
PROGRAM AND DATA TAPES SEPARATE
OXten \ • en a lirogram is being used for productioa runs, it is
convenient to keep the program on a separate tape which is never changed.
For each run the job description and data form a separate tape. For example
ajMPILER AA
(title 1)
begin
PR(3(iRy^J4
of program
The data tape including the job description, would be
JOB
(title 2)
INPUT
O (title 1)
SELF ^ 1
DATA
I
IDATA I
+ *Z
The input section gives the relevant program as being channel 0 (the programci'nnnel) and SELF = 1 indicates that the data tape is to be read as channel 1.
Tlius an instruction 'select input (1)' is required in the program. Thiscould, if necessary, include any OUTPUT, STORE, and COMPUTING information
since this is the part of the job description.
Possible titles for the above exajiiple might be
(title 1) MA, PIO
(title 2) UMA, PIO/RUN 26
-
7-4
PROGR/Ul ON SEVERAL TAPES
It is often convenient to Jiave the program itseli on tv;o or more distinct
tapes, where,, for example, the program may be so long t))iiL it would be pliysically
uiunanageable to keep it on one tape.
Alternatively the program may contain a large section (declarations and
routines perhaps) which is common to many programs and which can conveniently
be kci:)t on a separate tape.
The instruction
i^w coiTipile from inputLn3
is n^ed to switch the compiler from one input stream to anot)ier. For example: -
Jt3B
(t i 11 e 1)
INP-.T
1 (title 2)
2 (title 3)
QDMPILER AA
begin
I FIRST PART I
I OF II PROGRAM !
now compile from input 1
+ - z
QJMPILEK .VA
(title 2)
1 SECXDND PART
1 OF1 PROGRAM
I
end of program
* v»Z
DATA
(title 3)
I DATA 1
I iI
***Z
-
8.1
S CX)MPLEX ARITH}.€STIC
As indicated previously, facilities c-xist for the wAnipultitloa
of coinpl&x as well as r&Pl and ' qur.atities, co^nplgx quantities
iire stored as a pair of res-l m
-
AKIT.' :';ETIC EXPRESS IONS
The arithmetic expression [EXPR] is still of the form
[ +' ] iOPERAND] CciPERATQR] l OPERANP] IlOPERATfjR] [OPERAND]
but UjPKRAKD] is now expanded to be
LVAR lAliLE] , [ ajNS'IVvNT] , ( LEXPR] ) , 1LEXPR] I , IFUNCTION] or x
Ilcie ^ is a delimiter denoting the i (or j) of complex algebra notation.
Kxai.iples of tliis r ore general expression are: -
(V'Conj(l) - I
-
KIJTES
1, Just as real quantities may not appear on the r.h.s. of an integer
assignment (except as arguments ox integer Xunctions), so complex
quantities may r jt appear in real or integer expressions.
Hov/evur, the functions
re(z), i!ii(x.), magCz), arg(z)
convert from complex to ri^al quant it •:< s and may therefore appear on
the r.h.s, of a reai assignment. In fact any function wJiose
value is real regardless of its arguments may be used in a real
expression (just as any ini eger function, regardless of its argument,
may appear in an integer expression). Thus if K and B are real and Y
complex then:-
X = B + im(Y)
is valid,
2. re(^) and im(z) are actual locations in the store and can therefore
be used on the l.h,s. of an instruction (whose mode is then real).
For example:-
re(z) = sqrt(2)
ira
-
8.4qiNDITIOKS
in conditional operators, [EXPR]*s must be real (in the sense
of. note 1 of the previous section ). Hence the following arc legitimate:-
if^ arg (z) > TT/Z Ihcn -> 3
3 case mag 1 s
PJ)l.iTIKES AND FUNCTIONS
Since routines and functions f^re allowed to operate on
Liui.ntitieg, the par; meter types have been expanded to include
Formal paranieter type
c nair.e
nnlox
coniplex array name
c Ginp lex _ai- :• y
1 rorresponding aclual parameter
name of a complex variable
any expression (which will be
evaluated as if for a complex
ossigment)
name of a complex arr^
name of a complex array
The rout'ne types Crt] have also been expanded to include complex fn.
As an example we will rewrite the function routine for the polynomial
a(m) + a(mH-l)x+ + a(in-i-n)xfn
assuming x and the coefficients a(i) to be co)nplex.
complexf^ poly (complex arrayname a, complex x, integer m,n)integer i.; complex y
y = a(m-j-n) ; result - y ^ n. = O
cycle i = m+n-1, -1, ra
y = y*x + a(i)
repeat
result = y
end
-
8.5
IKPUT-OUTPUT OF COI.iPl.,liX liUMBERS
Data Is punched In the .foi'm
[real PAJiT] + i [IMAGINARY PART]
but the j,miivicJup.l parts can l>e ijun.cJied 3.n r.viy j^cccpt??bl
-
9.1
9 STORE MAPPING
THE ADDRKSS RECOVERY FUHCTIOK
The absolute p.ddress of Any varj.?.ble is not generally knov/n ia
:?.n Autocode progrfUiiine, but it way l e obt?.inod by rr:c?.ns of a stund-'-rd
function. For pie;-
s = rddr(A(0,0))
TJiis pl>'.< it
ii'itvy bs F.uy vRrir'blo, rsff.l, iivtr, or co:";.>lox ;i.n.d tk@ rt/suj-t is v.h intcgiving the ;'.!;-j:oluto ; ddreps of the storr.re loCi^.tioR ?.llocst6d to thatvrriable.
Absolute addresses used in conJu;-.ctioii vith y^ci'iiy iTuK.ctiois
(i2te below) :^^.a with tho 'storage' functions
i j:at Q;t; r ( ir.t'^ c:'̂ ^ n )
reftl (i}'.tc£;ca- n)
coiijplex (integer n)
Those give the contents of the nddr«s»3 in questiou ixs ar. iKtci:,j;r,
rej?l, or complex nui^ber. Xm the last c-.se the real ?rid iu^s:inPTy pax-tsof the . awbor are ^^ssuFicd to be in n r--.ud n-fl. The P.ctuAl
may of course be an integer expression e.g., s-j-k-1, functionsptpy be employed on the left hfnd side of p.tx sssi£;?x>:-3nt statcv.eat asw-ll PS in an expression. Thus the p-ir of instructions
s = addr(a.)
real(s) = b
are equivalent to
a = b
ARRAY FUNCTION'S
T^e declsxrations of Section 2 defiiie variables and allocate
storage space for tkc;m. In this section we introduce a declarsitioa\ -ich defines variables as the mmbers coiitained ia storage locations
that have already be« t allocated. This is of ir.-.portaRce in coKinuaicatingbetween routines with the addr type of formal par^jr^eter and in reixaiaiEg
variables (see below).
An example is
array fn X(s,p)
which defines X(i) as the real number in the storage location whose
address is given by s+i*p. Thus it defines a vector X(i) interms of an origin s and a dimension parameter p.
-
Array functions Ji;ay define rectangular J.rrays with any nuniber
of subscripts. For exaruple;-
prra-y fn Yis r^s a.
vector x(i), one could wx'ite
Array fa x(sl,i)
x(0) would theJA corrv^-spoi'd to tbe ia address si, x(l) to that
ia sl+1 etc. If it is degfirod that tke first location sLould
corrctspoi'-d to x(l), tKe declarMtion v/ould k-a written
g.rx'g.y fn x(sl~l,l)
If T/e had wy.K'ted to define a lo x lO Matrix, stored row by row
rstkcx- thr.a a vectco.', wo could kr^'e writ tea
array fa A(si,10,1)
piid a(0,0) v,'ould co-rrdspo>id to Rf.ldress si,
array fK A(sl-11,lo,1)
would defiio a E.atrix ia the avAilal^le space wJr.ose first elcKcat
Y/a.s A(l,l).
NOTES
1, If tlio suffices of arrays &r© to start fro» (1,1, 1) rather tkaa
(0,0, o), approprisvto adjustMent ssust fee mad® to the expressioa giving
tke origia ia tke array fuECtioa declsuratioa,
Z SpriCe redefiucd fey array fH*s may still ¥© referred to by its origiaal
. laaKOo
-
of VAK:ABLES WITIiIN a BIX)CK
v;e illustrate this with p.a ex^s.^ple. Suppose we wpitt to define arid
allocate storage for pairs of variables x(i), y(i) so that they
Rre ia succesive loca.tions, T-o irr^vy dcClar?tioia will only define
a vector or matrix arrn.y stoiod in the conveutioE.?^! i-'r,iu'er, so "s/e
."ucpt lJlC followinjij d(,vice
b e ;:,i>l
avrg-y (1:2(J00)
s = fiddr(p.(l))
p.rray fa x(s-2,2), y(s-l,2>
9^^
Tl\e first pair of jair;.l>crs could thca lo referred to either sls
x(l), y 1: lo)
:r: d we wisk to dofir.e ti e first colu"n of A :-s a vector, thea v.-e could
write
p-rray fa y(r.cidr(A(l, 1) ) - 10,10)
which defiuc-s y(i) = real (adar(A(l,l)) - 10 + lO+i)
i.e. as the first coluir.n of A. Tlus y(l) is equivaleHt to A(1,1), y(2)to A(2,l), ,y(10) to A(10,1).
la the cs.se of cotxplex pxray fuMCtioRS the user Kust t?Jie i&to account
tl^.r.t a complex Kuv-ber occupies 2 consecutive locations. TKus if si is
tke ?-ddress of Q(1,1) of a coKtplex array Q(1:10,1:10 ) , then
.Complex t^rray R(si-20,20)
defiuos a vector R(i) whose ele)' \ts are tke first colunn of Q, i.e.,
R(l) - y(i» 1)
-
9-4
STORE MAPPING ROUTINES
Stoi^age JfuEictioK.3 of arbitrary cor.plexity c?.n ofets>.iked T.y l eai s of store ^p.-appiifig: routines, Tfe.ese sore esscRtially rvjAcl^on routiK.es v.hick
cov-pute aa address. For expxiple: -
real x-ap X (t)?.teter i, j)
rci.su^;^ = s+^i*(i-1 i+j-1
« Kd
o";putoa tl.o i'.e'.tbrcss of tLe (i,J)tfe eleK3eKt of a real love-r trira:.£;ulsa' r.r.c'irAg actual p atcr
1
ac.c-r I the of mc.y iKtc^;er, real or cor, piex
I variable (includir.g aa aaray eleueut), Tlie
I a^.dres'- of tl:e vpjri?.ble is Jiauded oki as tke
I ps.raLiCler proper. It is equivs."" ut to rta
1 integer paryj-seter ia tke >:ody of tk©
I routine, la fact aa ac^.f^r parPAJoter
1 replaced by x is equivalent to
I aa iatcrer parRSieter replf'-Ced
1 Ity addr (x)
real n:a.p | tko actual pjiraip.eter is the iti^usa
ii>te£;fcr y.:tip 1 of a niapiviiag routiRs of tl&e
coiaplox t.p>p \ specified type
I
-
10:THEUSEOFMACHINEINSTHUCriGNS
STACKvSTRUCriJRE
MachineinstructionsCf.nbeusedinroutineseitherto)inp.kep.n
inn^rloopnoie.efficientortoeffectsomeopc-rp.tioav.'hichcannot
easilybedoneotherwise.Itisassuniedthattherordc-risreason?.bly
f;uriiliarwithtJieloi^icalstructureofthemp.chine,t.hj>tiswithth.e
l>asicorderrede.ItpJsoessentialtoknowl^owdatp.isstorediuthe
stack.Vi'eilJustraLethiswithreferencetotliefolliytvinrjroutine.
&
routi^matrixfn(arraynan-eA,Bintogorni,nrj^al_fn_F)
re?aa,b,c;intcaeri^J
arrr:^C(1:m,1:n),E(1:m)
r£aifnspe£F
cyclei=1,1,m
cyclej=1,1,n
repeat
rej^ef^
end
NUTES
1,Thefirstwordofthelocalstacksectioncontainsthecontrolnuieber
forreturningtothecalli;routine(thefirsthalfword)andtheprevious
contentsofI5d,thecurrentlevelE-line(thesecondhalfword).The1st
halfwordofthesecondwordcontainsthetestlink(whichrecordstheposition
withinthelabellistofatestinstruction),andthe2ndhalfwordcontains
iiiforination(thenumberandtypeoftheroutineandthenumberoffixed
vrriablos)requiredbytherun-tirnefaultmonitorroutine.HereBdrefers
totheB-lineassociatedwiththeroutine,andcorrespondstothetextual
(Jeithoftheroutineintheprograminwhichitisembedded.If(say)
tillsisathenEd=B2.TherelativelocationsofthefixedvariablesA,
B,m,netc.,areassignedatcompiletime.ImmediatelyonentrytotheroutinethecurrentvalueofB90,whichalwayspointstothenextavailablelocationinthestack,isrecordedinBdandthepreviouscontentsofBdrecordedin
thestack(asalreadynoted).B90isthenadvancedtotheendofthefixedstorageallocation.WhenthedeclarationsforCandDare'obeyed'itis
advancedagaintothefinalvalueshown.
-
^YOUTOFTH5STACKFORTH2DSCLAHA^l'IOXS27V,atr:.xfn'
Everythingexcer'treala,"b,candthe(real)arra;>'-sthemselvesaredestandardisedandheldin'lon^ord'units.InsonecasestheIsu(orm.s.)halfv.'ordofthedestandardisedquantityis'flagged'toidentifyitsfunctionfortheT)'cirposeof'stack-orint'(seetheshadedh.w's.)TheolarJcsectionsindicateanindefinitenurcberofwords.
«•fixedvsz'ia.'blep,llocation'
i3,(initialvalueof3^^)i
idestandardisedI
isimilartonaT.oers
iC,3butrefer"backstandardisedtonon-local{fl.ptarrrys!n^omoers
i
dynajnicallocation-
;st:"(finalvalue'o"^3i^90'
cvclecycle-•
Ipoints
-
30.3
2, Dcstsiiidiirdlsed quantities are foDned by adciing 0 3K-12) to tlie sti iiJj.rdlsed
form. This const:;Mit will be found in loc^^1;ioa *1000001. This octal form
of tlio address can ba used in rru-'-chine iustruction fori--ats(see lct«r).
Thero rre no integer r-nme or real nrjne purarrieters in this e>:a;nple; if
piv.f^cnt they v/ould ke represented (s.t tba appropriate place nrnong the fixed
v.-.rir ' les) hy si.nt^lQ v/ords, nau.ely he5\- addresses, in a dest^iad-^rdiscd form.
vhey i\e at present in distir.£;aisl)f.fele from inte^'^r' s, sii-il-rly for
coviiplcx narrie pra'TJiietcrs, A complex cnjr?.utily requires tv.'o consecutive
words, representing the real .-rrid irnRi^iAf-.ry pi-rts,
3» arrays. The primary reference to ? • arr?.y c< nsists of a pjiir of vords. Thesecond half of the 1st word points lo the (1st v;ord of the) 'dope vector^
that of the second word to the 'Iliffe vector'. The dope vector cont?d.ns
the vn.lr.cs of the bound--pp.ir list to^^thor v/ith the nu'Jiher of p?.irs, i.e.
the dimensionality of the array. If th
-
4- the P/vB-AMETRIC function F. six words of information are kept here,lu F.ddition to the control number for entering the routine it is
nc-cesi2>'.ry to keep a record of the display of the relevant E-lines
when the routine is first substituted p.s an actual parameter. For
fvirthor details see the Compiler,
5' in the text the initial and final values j?.udii^creinent iu a cycle ?-re evpluo.ted and checked for compatibility before
the cycle is cc,.U:.onced. The increment ford final vjilues, together with
the ;.ddre:^s of the controlled in ^.-ger variable are recorded for use in
the execution of the cycle. The dis,2;ra)n illustrates how they are stored,
stack: IfTSTRaCTlOKS
The following autocode for/rats i nvolvinj^ t.he stack pointer (EQO)
;- .i e available ^
.'iL == si ±
St = Cexi^r]
Ckaiae] = £t
st represents the contents of rgo. In the last instruction the [NAiuE]
innst 1:3 local to the routine -xwitaining the instruction, otherwise a
fKult is indicated,
MAaiIKE CODE FORMATS
Scviie 'machine code' formats are now described,
1, Where there is no h^wbolic address involved ;.n instruction is written in
the form
Cra],[n],Cn],[address part]
(a.nd terminated ag usual by ; or nevline). Here Cfd] refers to the
function digits, Cn] to the Ea and Bm -Jigits, and [ADDRESS PART] to the
address part, which may take a nuKber of forms. It may be v/ritten as a
Constant in the usual v.-ay (preceded possibly by a sign) bearing in mind
that the binary point is located 3 places from th . right hand und. Thus
0121, 80, O, 2,5 is equivalent to
05064000 00000024
-
10.5
It iiiJiy aliso consist of an octal numbei which consists of an * follov>ed
by up to 8 octal digits, including any significant aeros. Thus
0101, 91, 0, 'lOOl is equivalent to
04066600 100]0000
in oc?;:.l notation,
i'inr"'/ .it may consist of a label or a (possibly signed) const tint plus
a 1: 1. The label is replaced by the control nuvibcr corresponding to it. We
iiK^y X for to lab^illed constaxits (see next section) in tJiis v/ay. For exaraple
0334, O, o, 14:
0101, 99, o, ^ + 14;
14; ^i'O 3, 00000 \2.
pu:,;s"an r.^standardised 10 in the accuinulator, and a halfword lO in ^399
NOTE : The formal definition of [ADDRESS FART] is
[ADDRESS PART] = [+']faDNSTl+TN]:,[n3:,[+'3[CONST],CoW]
2. The format
[+'][const]
is used to plant a standivrdised 48-bit floating point number in the current
location of i'e program,
3. pairs of 24-bit words may be planted in the object pr.'.a'rgjn by means of the format
[ADDRESS PART]C,][ADDRESS PART]
Thus v..: may plant tables of integers or labels, for example:-
3.4
7:.8:
/», We now have an instruction format which uses a symbolic address,
Efd] , Cn], [ka}:^h;] [j^odhst* ]
where C+CONST']=[+]C QDNST], NIL
Here the [NAIIE] can refer to anything which is represented in the fixed storage
sections of the stack. The resulting instruction is
[FD3,[n3, d, p [+ CONST']
-
whei'e (Bd, p) is the 'address* of the npjne, Ed beiug the B-iine pointing
to the appropriate section of the stack, and p being the Rddress relative ^
to the origin of that section. Thus an instruction
032^, O, a
appearing in the routine under discussion would be translated as
0324, O, 2, 14
assuming yld ~ V:-2t that F occupies 6 v»'ords.
The effect would be to put a in the accumulator.
If the [r ;E3 refers to an unstaiidardised floating point intej, r then we
T;iRy v.ish to select the intet^iral half for use in a.E-line, For exair.ple
OlOl, 80,
is equivalent to
0101, 80, 2, 6.5
If a and rn h^d been real and integer name' s then 2 instructions would f
be n'vcessary in each case, thus
oiol, 99, a + ^
0324, 0, 99, o
and
0101, 99, m + ^
OlOl, 80, 99, i
If a is complex then
0324, O, a
\vcv»ld put the real part into the accur-.jlator, and
0324, O, a+1
v/ould load the imaginary part,
in the case of arrays vie can select by similar sieans the tv.'o priiaiary
reference v.'ords, and with their aid obtain access to the dope vector and/or (
the array itself.
-
.10.7
•EXvU^PLE ON THE USE OF MACiilh'E ORDERS
The following ex; :ple forms tJo sum of t;;rcG routir.c.s B, C of
; •••-ilar divricnsions. (It ihi in f».ct tie p«.-?rTn.:-!:e vector of A;cor^n&iit ^364 " no of clciv^cnts in r e.trix
;co:ni.>cnt set /56l = address of Ist oleinnit of A
;co;riraen^ S';;t ,662 - c-ddress of 1st ele;.icut oi B
;cojpj'ieut set ^563 =? fddrcss of 1st elerneiit of C
; coinv.ic-iit perform addition
; Coir.;r:ent DIHENSION FAULT
-
11.1
11. THK PKHM/Ux'ENT HOUTINKS
Id Soci-ion 5/ deci'ibcd the j.nput and output routines,
•The permanent matei-ial also inc.!udes routines Xoi* the solution of linearequations, the solution of systems of ordinary differential equations andoperations on iiiaurices. Further rovitin' s may be addud from tj.nie to
time.
I-
routine spec eqn so1ve(ax'rayname
'L'.'iis /'outii'.e solves the equations
A(l,l)x(l) -}• A(3,Z)x(2) + + A(l,n)x(n) = b(l)y\(2,l)x(l) + A(2,2)x(2) + + A(2,n)x(n) = b(2)
A(n,l)x(l) + A(n,2)x(2) + + A(n,i50x(n) = b(n)
(i.e. A.X = b), where the coefficients A(i,j) are stored in thematrix A, and b(i) in the vector b. v is destr yed and the solutionis placed in b. If during the el imiiiat ion process, ilie equations arefoi-nd to be linearly dependant, then 'det' is set to iiero and theroutine is left, with both A and b upset, otherwise 'det' is set to
th- determinant of A. Consequently 'det' should be tested after each
Ccill of the routine.
MATRIX RX3UT ' :«S
The h-.atrix routines operate on tv/q dimensional arrays(i.e. i.iatrices
not vectors). The dimensions of the arrays are not required as parametersas the routines automatically find these from the declarations, and checkthem for compatibility. The programmer may insert similar testsin his own routines by means of the functions
integer fn spec dim (arrayns-me A)
3nteger fn spec bound (arrayname A, integei n)
The first gives the dimensionality of the array(1 for a vector, 2 for amatrix etc.), and the second the nth bound (upper or lower) of the arraycounting from left to right. For example, if A were declared by:-
array A(-5: j-5, l:p) wliere p = lo then
dim(A) would have the value 2
bound(A,l) ' * ' ' ~5
bound(A,2) * ' * ' +5
bouud(A,3) ' ' * * 1
bound(A,4) ' * * '10
-
n
Tilt-' routines
routine sp^^c unit (5££f^;j' ;lpe_o matrix add (arrayname A,B,C)
rjoui:ine_ spoc matrix sub (arrayname; A,B,C)
routine spec matrix copy (arrayname A,B>
set A to Bi-C, B-C and B respectively. Although the parajiiotcrs are oI .
type arrayna-nio, the operation of r.)ie routines is sucn taat tne san,e array
can be substituted for more tlian one of the para)notc;rs. For example:-
matrix add(A,A,A)
doubles A. The same is not true of the follo\vj.ng routiney:-
1- ou t i ne spec ma t r i x )nu11 ( array name A, B, C)
routine spec matrix mult'(arrayname A,B,C)
routine sp
-
11.3
Tlie routines
jroutine spec matrix div(arrayr.aKie A,B, roalnaine del)
routino pec invert (arrayname A,B, rc-alname dec)
sec A Co inv(lO A and inv(B) re.spoctively. In the process B is destroyed
and tlie value of iis determinant placed In det. Should the matrix be
fecund to be singular, ' d< i; ' is set i:o zei-o. Consequently 'det* should be
tested aXti^r every call Tor these routines, IjC B is required at the end
oi tjje routine, then the tei-Iiniquos desoj'ibed above sliould be used. The
Xunc tion
real J^n det (urraynai.)e B)
sets 'det' to the determinanc ox B and destroys B,
^L!:^yi:ION ::f diffkiihntial fx^uations
There are two routines available lor advancing the solution ol
a system oX Xirst order oidi- :u-y diXXerential equations
dy(i)/dx - X(i)(x,y(l),y(^), ,. . . ,y(n)) i=U,2,...,n
froin x to x-j-h, using the Kutta-I.'erson Xourth-order integration inethodl.2j.
The system is defined by means of an auxiliary routine, which must bu
s^ipplied by the user, ox the form : -
3
-
11.4
The parameters are : -
y name of a (real) array. On input y(1) , y . . . y (n) .-jhould
contain the solution at x. on output they will
contain the solution at x+h.
X the initial value of the independent variQ.ble
h the increment of the independent variable.
n the number of equations in the system,
e the name of a real variable, which on c'.M.put will contain
an estiniate of the maxiinum truncation ori'or over the step,
aux the name of the routine which evaluates the derivatives at a
general point (see above).
The second routine
rcucine spec kutta nierson(njt-raynj^me y,£e^l xO,xl, roaJ name e £
inJLegor n,k, yux)
advances the solution, by means of a series of calls for 'intstep*, from
xo to xl, keeping, if possible the estimate of tlie m«xiinum truncation
error less than e. An initial step length of (xl-xo)/2{'m wliere 2l(nMi)
>k > 2fm, is taken. If over a step the local truncation error (given
by 'int step') is greater than e, then the step length is halved; if
the error is loss than .ole thon the step length is doubled.
If three successive reductions in st(ip length give no improvement in the
estimated truncation error, then e is replaced by tv/ice iht: smallest error
achieved, and the iritegration process continued. The parameters are : -
y tiie name of a (real)array, on input y (1), y (2), . .. y (n)
should contain the solution ac xo. ijn output tliey will
contain the solution at xl,
xO the inital value of the independent variable.
xl the final value of the independent variable,
e the name of a real variable, on input tJiis should com ain
the accuracy criterion, on output it will be unchanged if this
accuracy has been acJiieved ; if not, it will be replaced by a
more- realistic value(see above).
n the number of equations in the system
k an estimate of the niuiiber of steps required to cover the
iange(see above)
aux the name of the routine which evaluates the derivatives
at a general point(see above).
-
Al. 1
APPh'KDIX 1. PHRASE STRUCTUHE NOTATION
In describing Atlas Autocode we uso square brackets round an
entity to denote that it represents a class of entities and may be replaced
by any member of the class. Wo call an entity in square brackets a PilRASE.
For example we could define a decimal digit by
PHRASELDIGIT] ^ 0,1,2,3,4,5,6,7,8,9
where the coiimas r-re interpreted as meaiiiiig 'or'. Thus there are ten
dilforont iJiivigs wliich can be cf.lled I.D1(tIT3, f=-nd wlien we refer to f.niGIT]
elsowliere we menn that any of the ten will bo .lejjitiifate.
We can then buila up from this basis and di.-scribe, for example,
a sij^ned digit as
PJiRASEI SIGNED DIGIT] -- -i-CDIGlT], -LdIGIT]
There are also pl:5ces where a phrr-.se Hiay or may not appear and to
sigi»ify this a special pha ase 'MIL* )nay be written as the last alternative
in a phrase definition. For example Llio swiLt;li .limits in a sv.'itch
declaration can be preceedod by a + or - .sign if desired, (Absence of
a sign corresponds to +,) The relevant definition is
iNAME list] ( [+' 3[N] : [ + ' J r.N] )
whore P}iRASE[ + '] = +,-,NIL
Thus "I *+4
-4: 4
3
are exarriples of switch lini s.
Alternatively we c a use the special ? qualifier as follows,
PHRASEL +3 +, ~
PHRASE [+?] = {.±1yiah
The last is implicit and we can use Lj;. ] (e.g., in place of 1- +']) without
expilicity giving the latter definition.
In the interest of efficiency however, it is preferable to
keep the depth of analysis as snail as possible and fox* this reason we
use the former scltsr.ie.
The phrase structure notation can be used I'ecui-sively, i,e., phrase
definitioiis may,directly or indi.-^ctly, use themselves. For example we
ri;ay define a 'list of names separated by conuiias' by
PKRASElNAh^E LIST] = CNAi^5E] LREST OF NAME LIST]
PERASE[REST of HA.ME LIST] = [, ] LnAME] LrEST OF NAME LIST], NIL
-
fil.i
i
[since a is used to separate the altcDi;"lives of a phrase definition ^
it cannot stand for itself like the other basic syinbols. Instead v/e
mij.-vt write [,]. similarly Ceol] and CSP] are used to denote 'end of line'
and 'space' in the source language.]
The qua]iXior * also indicates recursiveness and a CkaNIE LIST]
ronld bo tJefined as
Pi-:nASErNAh'.E list] " CNAME]r. ,MAHE^?]
P}IRASE[,NA-ME] = [,][NAAiE]
the definitions
PimASEC,KAJ/.E *? ] = [ , KAJ.l E 0 , KIL
PiiRASE [ , Ky^J.IE ^] = C, NAME 3[ , NAJME *] , C, NAME ]
being ii:iplicit. Again, however, for reasons of efficiency we use tl.e forner definii ion.
Given the phrases of the language it is tJicu possible to describe all t])e .formats
allowed in a program. For example, if we introduce the phraseCTYPE] as
PIIRASECtyPE] " integer, real, corriplex
. . ("we ca) define the format for the scalar declarations as
FORMATfSS] = [TYPS]INA}/.E LIST-Jts]
The tss] iiidicates that it is a source statement, -.vhich means it appears on
its own in an Autocode program.
In Atlas Autocode there is a furtlier type or CLASS of format,
the unconditional instructions [Ul], which have the special property that
they niay be preceded by the conditional operators LcoND]
unless CaJND] then.
A list of the phrases and formats of A.tlas Autocode follows.
Note that some phrases (Cs],tcONST],LNAME] and CtEXT]) are not formally defined.
These are defiued by special built-in routines which we will not consider here,
but those interested may refer to the references given below.
c
-
At, 3
Finally we should point out that jjonie of the definitions oxe not
completely rigid. For example, the aritbrrietic assignment statement is
defiiied as
FuRMA-TEui] = [NAJIWlfAPP] [EXPR]
In the routine which deals uith titis format, tests ai-e «iade to ensure that
the fNA.ME3[APP] does in fact describe a variable, snd is not, for example,
a function, •
References
[3]. Brooker,R,A., Morris,D. and Rohl,J.S. ''Trees and Routines'',
Computer Journal, Vol. 5, No, 1.
[/jJo Brooker,R. A. , ?viacCsll\nn, I.H. , Morris,D, and Rohl, J, S.
''The Coinpilei' Conipiler'' 3i*d Axinual Review of Automatic Programming
(ed, Goodman), porgamon Press,
-
[expr]
[+1
lEXPR'] .
[operand]
Eapp]
rexpr-list]
= L+'][expr']
= +, -
== +, NIL
= [operand] l.OP] [}• .-IPR ' ] , [oPKliAND]
= [NAME]LAPP],LCuNST],(CEXPR]),1L}';XPR]!, BUT NOT il
([ EXPR-LIST] ), NIL
= [expr][rest of EXPR-JJST]
Ai.4PHRASE
PHRASE
PHRASE
PHRASE
PHRASE
PHRASE
PHRASE
PHHASE
PHRASE
PjiRASE
PHRASE
PHRASE
PjiRASE,
PHRASE
PHRASE
• PHRASE
[REST f)F KXPR-LIST]=[,][EXPR][REST OF EXPR-LIST], NIL
i"op]
Cc:0
[AO]
[qUEIiY' ]
(CR) [pr^£ii|£]
t,']
Ci V1_]
Cacc']
- +, , I, . I NIL
c5;ia, aco, ca, sac
~ ncc +, acc-, acc /, '!££[ »
= ?, NIL
" ill
i.J, NIL
- if,
- acc, i:a, fiuc
PiiHASE [type] = integer, renl, £o3)\ex
PH SE LTYPE'] -
PHRASE [NAME LIST] = [NAME] [REST OF NAME 1,1ST]
PHRASE [REST OF NAME LIST]=4 , ] INAME] LREST OF NAJrlE LIST], NIL
PHRASE [ARRAY LIST] = [N;U/.E LIST]([B0UND PAIR TJ.ST J)[ REST OF ARRAY 1,1ST]
PHilA.SE [REST OF AJ^RAY LAST]--[,][NAME LIST] ( [B-OUND PAIR LIST] )[jr^ST OF ARRAY LIST], NIL
PHRASE lBDUND pair JJST] •- [}^:.]UKD PAIR] [REST OF )30UND PAIR LIST]
PHRASE [REST OF BOUND PAIR LIST]=[,][B'jUND PAIR][REST OF BOUND PAIR LIST], NIL
PHRASE (.BOUND PAIR] -= [EXPR] ; LKXPR]
PiiHASE [ARRAY FN LIST] = [NAME] ( [EXPR-LI