Professional Documents
Culture Documents
AAEC PASCAL 9000 Reference Version 1.2 Jan 2 1978
AAEC PASCAL 9000 Reference Version 1.2 Jan 2 1978
VERSION 1.2
REFERENCE MANUAL
1.2.78
l'
r-----------------
I I
i I
I
I
•I
I I
I PASCAL 8000 I
J I
I I
I I
I I
j J
I I
I I
I I
J I
I I
J I
I REFERENCE MANUAL I
I I
I VERSION 1.2 I
I I
I I
I I
I I
I I
' .. 1 I
I I
•
I I
J J
I I
I I
I I
I I
I J
J J
,,
I
I
t
I
I I
I t
I t
J I
J
I
IGordon Cox
Rewritten for IBM 360/370 Operation
Australian Atomic
,
1
-. IJeffrey Tobias
I
Energy Commission
Australia
I
I I
J I
j t
I I
L .J
Pascal 8000 Reference Manual IBM 360/370 version
TABLE OF CONTENTS
INTRODUCTION 5
2. Variable initialisations 7
3. Forall statements 7
4. Loop statements 7
5. Procedure skeletons 8
7. Exponentiation 9
bA!':H~ya§.LDEfI.t!1 TID!!! 12
·., 1. VOCABULARY 12
2.1 Numbers 13
2.2 Strings 13
2.3 Identifiers 13
3. CONSTANT DEfINITIONS 14
4. TYPE DEfINITIONS 15
6. VARIABLE INITIALIZATIONS 21
7. EXPRESSIONS 22
7.1 Operators 23
8. STATEMENTS 25
8.2.2.1 If statements 27
9. PROCEDURE DECLARATIONS 31
10.1.1 Predicates 35
:3
Pascal 8000 Reference Manual IBM 360/370 version
12. PROGRAMS 42
ACKNOWLEDGEMENTS 43
1. Listing format 44
2. Listing control 45
3. Compiler options 46
5. Execution summarv 47
6· Post-mortem dump 47
7. Miscellaneous 49
REFERENCES 62
2. Variable Initialisations
The ability to initialise varIables is introduced in Pascal 8000.
Values of variables declared in the outermost block, namely the main
program, may be initialised at compile time. The variables that can be
initialised are of types simple, string, array, record (without
variants) and set. No type specification is necessary. The syntax is
m:= (# 0 , 0 , 0 , 0 #);
<forall statement) ::= fora 11 <cont 1'01 vari abl e> in <expression>
~,2-<siatement>
The express ion fo 11 owi ng t he symbol in must be 0 f type set, and the
control variable following the symbol .t:2.!:all must have the base type of
the set. for example the following statement
I := i+1:
if table(.i.) =
x th~ found;
i1 i =
tablesize !~n nofound
This definition, however~ causes some difficulties at run time with the
possible confliets of type and number of the parameters of the procedure
or funetion parameter. It is difficult for the compiler to detect this
kind of mismatch in the source program.
<forma 1 parame ter secti on> :: = <parameter group> J }!~ <paramet er group>
I 1U:ocedure <procedure skeleton> {,<procedure skeleton>} I
i!!oetjflI! <procedure skeleton> [,<procedure skeleton> : <type>
<procedure skeleton> ::= <identifier> J <identifier> {<type> (,<type>})
9
Pascal 8000 Reference Manual IBM 360/370 version
call is made.
..
(i.e. strinQsl may be read
The standard procedures read and write may now apply to any file,
text or non-text. Operating on a non-text ftle, the definitions are
raad(f,vll is equivalent to
and
A
tft!lPe-change" function has been introduced (courtesy Kludgeamus
(1976». The mechanism provided by the standard functions nord" and
nchr" has been extended, and now any type-identifier can be used to
change the type of an expression, with the expression result remaIning
constant. The type function has one argument, of any type. For example
10
.b~l!!
name:='Cred';
ebcdic:=integer(name)
, .
11. ~!~~ase Statement
<ccnstant> •• <constant>
Thus,
~!~~:<statement>
The standard type alta is defined to mean ,eack,gg .5ITI~~ (.1 •• 8.1 Qf
char •
.;
11
o I p I q I r I sit I u I v I w I x I y I z I $ ,
<di g it > :: = 0 I 1 I 2 J 3 I 4 I 5 I 6 I 7 J 8 I 9
<special symbol> ::= + I - I *
I I I = J <> I < I > <= I >= I ( I ) i
(. I .) J (* I *) I := I • ' , l r l ] I & I ; 1
: I • I (i) I •• I ( t I #) I 1 { I I I ., I .... = I * *
t <reserved word>
<reserved word> :: = d i v I mog I Ai I I in I .Q.I I 1!.D.!! t ..Dot I 11 I lhen
else I ~~~ I Qf I rep~! I .!IDti! I 1!hilg I QQ
1..2I. I .!.Q I i!.Q1!.!}!Q I 1.2.U!! I !QQ.p t J2os!!.!!g~
.l2~li.n I ~.!}~ I ~11h I .ruU2 Icon~j I ~~.r. I ll.Qg
YA~ I 1!.r.r.ll I ~~o 1: d I .!~.! I fi!~ liJ!~1iQ.!}
.RroC.i.dur~ I !~be! I .Qack~.!! I RJ:.2g1:~.m
The construct
or
Note also that the symbols r a n d 1 can be used (or array and set
operat ions if these characters are available. If they cannot be easily
utilised, then the substitute character pairs are (. and . , . The same
applies to the comment braces rand }, which may be interchanged with (*
and *).
12
There are two kinds of constant numbers, namel~ integers and reals.
I t the string is to contain a quote mark, then this quote mark must be
written twice.
13
Examples: pi = 3.14159
minuspi = -pi
title = 'this is a title'
oddnumbers = (.1,3,5.7,9 .)
vector = (t 0.0,0.0 #) : A1:1:.5Ul (.1 •• 2.) of real
14
"
<scalar type) ::= ( <identifier> f#<identifier>l )
Examples: (club#diamond,heart,spade)
(sunday,monday,tuesday,wednesday,thursday,friday,saturday)
15
values of the subrange. The lower bound must be less than the upper.
16
---------------------
Examples: ~£.£.Q.r.9
day: 1 •• 31;
mo nth : 1 •• 12 ;
year : integer
£l!i!
.r~.£.QJ:g
name: alta;
~.! sex : boolean g!
true: (age: Integer);
false: (height: real}
A set type defines the range of values which becomes the powerset of
its so-called base type. A base type must be a simple type (except for
real), and its associated integer values must be between 0 and 63. (for
this reason, a set of characters is not allowed due to the
. , representation by the EBCDIC code) •
17
18
<referenced variable)
'. Component variables are the components of the data of array, record
or fil e type.
<component variable> ..
... -- <indexed variable> I <field designator> I
<file buffer>
(. <expression> {,<expression>} .)
Exampl e: mat r i x f. I + 1, 2* j + 1 .)
19
5.2.3. I i l~Y1!~.u
Example: Cilelii
Example: pli
".
20
Exampl es: k := 0
m := (I 1.0,1.0,,1.0 #)
21
7. EXPRESSIONS
<simple expression>
( <express ion> )
Examples:
(a+b+c) 3**x**2.0
(simple
22
The operator n2! implies the logical negation of its boolean operand.
Note that the symbol ~ may also be used.
---,
I a I b I real I i n t e ge r ( )= 0 ) I integer(O) j
I
linteger
Ireal
+-
I
I
real
real
,
...
I
integer
real
-l
I
I
undefined
real
I
L- .J
:,
r-- ,
foperator foperation loperands 'result J
I------+___ + +-- -I
• * Imultiplication ,real, integer 'real, integerl t
I ,set intersection Iset type T Iset type T t
I I f -f-.- I
I / .division lreal, integer Ireal J
I +- -f_'" I
I------f_ + .. I
I i +-- f I
I... • f I
L ~
23
•loperator ,
I
I +
,
loperatlon
laddition
,
toperands
Ireal, integer
Iresult
"+Ireal,integer'
J
I
I
I +- f t I
I +- f t I
I}. As long as at least one of the operands is of real type, the result
is rea 1.
•loperatorloperation ,
loperands • result 1
I I
lequality,
f
,simple, strl ng, set
+"
,boolean
I
1= <> I
I f f -4 I
I
I
Iset inclusion
-+
I set types
f
,boolean
,
I
I
1<
'-----f
) ,order lsi mp Ie or string types
+-
I set membershiplbase type and set type
'boolean
,
I boolean
I
I
I .l!! I
L J
f ,<actual parameter>l )
24
Pascal 8000 Reference Manual IBM 360/370 version
8. STATEMENTS
Both sides of the statement must be of the same type (file types are
not allowed). The exceptions are when
11 The type of a variable is real and the type of an expression is
integer. In this case the integer value of the expression is
ccnverted to real value.
21 One of them is a subrange type of the other.
25
Examples: f( 2.0,xl,funl)
cos( pi )
26
8.2.2.2. ~~state.!!!~..n!J!
27
The control variable, the initial value, and the final value must be
of the same simple type. They may not be of type real. The value of
the control variable must not be altered in the repeated statement. The
initial and final values are evaluated only once. If, in the case of 12
(QQ.!!!!!g), the initial value is greater (less) than the final value, the
controlled statement is not executed. The final value of the control
variable is left undefined on normal termination of the for statement.
28
29
30
31
In this case a parameter list (and result type for the case of
functions) is unnecessary at the actual procedure declaration.
32
fOI j : =u12 v do
z( • i.) : = a(. j - u + i • )
unpack(z,a,il means
33
Pascal 8000 Reference Manual IBM 360/370 version
2) date (s) gives the current date in the form dd/mm/yy, where yy
denotes the last two digits of the year, mm the month
and dd the day of the month.
·1
34
Pascal 8000 Reference Manual IBM 360/370 version
5) 1 n( x ) Natural logarithm of x.
35
Pascal 8000 Reference Manual IBM 360/370 version
1) trunc (xl x is of type real. and the result is the truncated value
of x.
.' 3} ord (x) x is of any simple type. except real, and the result is
the integer value associated with x.
1) succ (x) x is of any simple type, except real, and the result is
the successor to x. It Is undefined it one does not
exist.
2) pred (x) x is of any Simple type, except real, and the result is
the predecessor of x. It is undefined if one does not
exist.
name := I fred' ;
ebcdic:= integer(namel
~nd:
NOTE: The type change function can create havoc in a program if used
incorrectly. It is recommended for use by advanced programmers only •
..
~
37
read ( r r,] v ( :m ] )
38
Pascal 8000 Reference Manual IBM 360/370 version
where f is a file of any type, and pl,p2 ••• pn are the parameters ot
the form defined below. The above is equivalent to
e e:m e:m:n
char
39
r ,
Itype 'default m t
I f- I
f
•I boo I ean 14 or 5 •I
I f
I integer 112 •
I
I I I
'real 124
I I •J
Ichar I1 I
I I I
,string Ilength of string I,
L
. ,"
write (r,p)
i s equ i val en t to
40
~
,-- -,
,character I act ion I
J + I
I I I
I I
1
I I 1
I I I
I I I
L
-I
41
42
• .1 "We are grateful to the many people who assisted us In various ways
during the work. Our compiler is based on Dr. H. H. Naegeli's "trunk"
compi Jer, which Professor T. L. Kunil arranged to be sent to us. Our
special gratitude goes to Professor H. Ishida of the Computer Centre
for his supervision and support ot the project, to Professor E. Goto
for his supervision, and to Mr. M. Yasumura, our previous coworker (now
at UCLA), for his contribution to the work. The implementation is done
as a cooperational research project with the Computer Centre."
43
1. Listin~ format
Headi ng: Each page is headed by one line, indicating the version of
Pascal that is currently executing, the date and time ot compilation,
as well as a page number. A title is also printed, i t one has been
defi ned.
44
$title <title) replaces the title currently printed (if at all) with
<title> and then skips to a new page. The title is
printed at the top of each page, until a new Stitle
record is encountered, or an $untitle record is found.
Only the first 40 characters ot the supplied title are
relevant.
..
45
Pascal 8000 Reference Manual IBM 360/370 version
where x, y. ••• are the compiler options described below, and the
symbol ' . ' means the activation of the option, and the symbol 1_' means
the suppression of the option. The specification of options may be
inserted anywhere in the program, so that users can control the code
qeneration selectively over specific parts of a program.
Compiler cptions.
46
Pascal 8000 Reference Manual IBM 360/310 version
47
.
.
(except alta), sets and other user-defined structures are not
in the local variable dump •
Included
At the start of a step, the CPU time remaining for the job is
determined, and a trap is set for about 10 seconds before this time
expires. When this trap is sprung, an error message, followed by the
post-mortem dump is printed. At this time, any local flIes which were
open are closed and scratched. (At the time ot writing, this does not
work on SVS and MVS systems, and CPU time expiry results in a S322
abend on these systems.)
48
Pascal 8000 Reference Manual IBM 360/310 version
7. Miscellane~~
1) The external file name floutput" does not have to appear in the
"program" parameter list, unless operations on the file "output"
are to be performed.
Thus, the maximum of code that may be generated for the main
program is 24k bytes. The mechanism of iaplementation of this
extended addressing feature involves the use of spare 'display
registers'. Some of the registers are also used for optimisation
of the 'with' construct, as they can be used to store the base
address of records currently being referenced.
Pascal 8000 Reference Manual IBM 360/310 version
" ," 2) Both external and local files may be declared in a procedure at any
level. System control blocks are allocated tor a file on the stack
when the procedure containing the tile declaration is invoked.
Buffers are allocated on the stack when the first reset or rewrite
to the file is issued. These areas are not however accessed
directly from the procedure's display register.
I/LOCAL DD UNIT=SYSDA,DISP=SHR,VOL=SER=volser
"
Current implementation restrictions for local files are that no
secondary extents may be taken, and all local files have an equal
primar~ space allocation quantity. The primary space allocation is
taken from the SPACE parameter on the LOCAL DD statement if it
exists, otherwise a default value of 5 tracks is used. If DCB
parameters are specified on the LOCAL DD statement, these must be
suitable for all local files used. DSNAME must not be specified on
the LOCAL DD statement.
50
SYSvVddd.Thhmmss.xxnnn.jobname.Rnnnnnnn
where yvddd and hhmmss are the date and time of job initiation, xx
is variable depending on the environment, nnn is a serial number,
jobname is the name of the job, and nnnnnnn Is a serial number.
Through its use of variable fields, this name is different trom all
others in the operating system. Each local file is given a unique
name built from this name by replacing the jobname field with
Poonnnnn where nnnnnnn is a local Cile serial number. These
dsnameg still appear as temporary datasets to the operating sygem,
and thus if any are inadvertently left allocated on the disk by
premature termination of a job, they should in due course be
scratched by whatever means is used by an installation to remove
old temporary datasets.
51
12) for output to a text file with RECFM=A, the carriage control
character position is accessible to the user, and should normally
be filled with a blank. The "page" function will cause the
character written in the control position to be overwritten at the
time the record is written. If a text field beinq written overruns
the end of the record, the excess is placed on the following
record.
13) For input Crom a text file with RECFM=A t the carriage control
character will be read by the user as the first character of each
record.
52
Examples:
Rrgc~du~ plotxy(~ x,y:real); 12~jr~n;
function rand(x:integer) : real; 1.2..!:.!r.an;
53
Example.
( *$E+*)
..Q~9.in
~ng;
54
Note that once the (*$E+*) option has been set, it may not be
reset, and such attempts will be trapped by the compiler. Further,
procedures and functions cannot be passed as arguments to
externally compiled routines.
55
r----' ------"1
Jtype I bytes Icomment I
1--
lin t eg € r
+--------f-'----------------------------------------
J 4 f
-----,------1
I
Iboolean I 4 ,l=true,O=false (same as IBM FORTRAN) I
'char I 4 IEBCDIC code in low order byte 1
I real I 8 IIBM floating point representation I
Iset I 8 ,bits representing elements, starting from lett I
Jscalar
L _ __
I 4 lordinal value of occurrence, starting at 0 I
--'
Examples.
x : integer;
a : Rack~d ~I~~(.1 •• 4.)
of char (* 4 bytes *)
b : arr~~( .1 •• 4.) 21 char (* 16 byt es *)
c : real (* 8 bytes *)
...
~
56
The load module PASCAL, from file 2 of the tape, works as the
Pascal s~stem driver. It has no specific knowledge of the Pascal
compiler; it merely provides a running environment for programs
compiled by the compiler - the compiler itself being one such
program. This program requires a SYSPRINT dataset for its standard
output. This dataset should have a usable print width of 133
characters, including carriage control, and it may have a a RECfM
of UA. VA, VBA, fA, or fBA. If no DCB parameters are specified,
the default of RECfM=VA, BLKSIZE=141, LRECL=137 is used. If local
files are to be used a LOCAL dd statement is also required. This
should have the form:
//LOCAL DD UNIT=3330,DISP=SHR,VOL:SER=volser
//$LOCAL DD UNIT:SYSDA,SPACE;(TRK,O)
//LOCAL DD VOL=REf=*.$LOCAL,DISP=SHR
57
The optional parameters sl, s2 etc after each stepname are used to
control the main storage usaqe for each step. Each must be a decimal
integer, and describes the amount of storage (in multiples of 2K bytes)
which is to be left free during the running of the step. This storage
is required for system functions such as OPEN, CLOSE, ABEND etc. The
remainder of the storage available within the user's region is
allocated for the compiled code, the stack and the heap. If this
parameter is not specified, it defaults to a value of 4 (implying 8K),
and this has been found to be adequate for most purposes at the
authors' installation. It may need to be increased if more temporary
storaqe is needed for anyone system function, or if heavy demands on
permanent storaqe are made by the Pascal program - e.g. by opening a
large number of local or external files (although file buffers are
constructed on the stack, control bloc-ks and channel programs
associated with each buffer are constructed from the free storage).
The control of main storage in this way means that for most
applications the combined stack and heap size is specified by a single
parameter - the REGION parameter on the EXEC statement.
If any of the defaults for the parameters nl, n2, or for the free
storage parameter s is required to be changed, the change may be
effected by chanqing their values in the member PASDATA in the runtime
system source library, reassembling the module PASCAL in this library,
Pascal 8000 Reference Manual IBM 360/370 version
The load module PASCALe, from file 2 of the tape, contains both the
runtime system and the compiled code of the compiler. This compiler
and runtime system is functionally the same as the compile-and-go
version. except that the load module is structured differently, and the
format of compiled code follows the IBM object-module conventions
rather than appearing as the two datasets produced by the compile-and
go versi on.
SYSGO describes the dataset which will contain the object module
produced by the compiler. This should have DCB attributes of
.
~
RECFM=F or fB, and have LRECL=80. with any suitable blocksize •
$PASMSGS the text file on which error message texts are provided and
I used by the compiler in the same manner as for the compile
and-go version.
LOCAL defines a device which may be used for local file allocation,
as for the compile-and-go version.
Any external files declared and used by the program will require
matching ddnames.
59
Pascal 8000 Reference Manual IBM 360/370 version
When the runtime system initialises itself, a trap is set for about
10 seconds before job-step CPU time expiry. When a Pascal program
(e.g. in a loop) springs this trap, a traceback with local variable
dump is provided. Currently this time-limit feature does not work
under SVS or MVS, and the job proceeds to a 5322 abend. This will be
fixed when the method of accessing the time remaining in the current
job step in these systems is learnt. IBM Australia cannot help here
can anyone on the distribution list?
.'
61
Dahl, O.-J., Di .ikst ra, E.W. and Hoare, C.A.R. (1912) Structured
. ~-
Programming. Academic Press •
Habermann, A.N. (1913) - Critical comments on the programming language
Pascal. Acta Informatica, 3, 41-57.
Hikita, T and Ishihata, K (1916) An Extended PASCAL and its
Implementation Using a Trunk. Report of the Computer Centre
University of Tokyo, Vol 5, 23-51.
Hoare, C.A.R. and Wirth, N. (19731 - An axiomatic definition of the
programming langua~e Pascal. Acta Informatica, 2, 335-355
Ishihata, K. and Hikita, T. (1976) Bootstrapping Pascal using a
trunk. Department of Information Science, faculty of
Science, University of Tokyo.
Jensen, K. and Wirth, N. (1974; Second Edition, 1975) - Pascal: User
Manual and Report. Springer.
Kludgeamus, S. (1976) - Sydney University, private communication.
Lecarme, O. and Desjardins, P. (1975) More comments on the
programming language Pascal. Acta Informatica, 4. 231-243.
Wi rth, N. (1971) - The programming language Pascal. Acta Informatica,
1, 35-6.3.
I Wirth, N. (1911)- The design of a Pascal compiler. Software
-' Practice and Experience, I, 309-333.
Wi rth, N. (1975) An ass essllent of the programmi n9 1 anguage Pasca 1.
,
-\
SIGPLAN Notices, 10, 6, 23-30.
62
-, 4
\
. ,
t.<
- .