@V7 54 2 -5
@V9 0
@YCHAPTER 11 - MUSS USER MANUAL
@G@RCHAPTER 11 - PASCAL@G
@V10 1 9 211
@T% 10
@S211.1 INTRODUCTION
@T% 10
@BThe Standard Pascal referred to here is as specified by the working draft of I
SO.
ISO/TC 97/SC 5 N 595, January 1981.
In general the full standard language is implemented but some
implementation restrictions and extensions are listed below.
@S211.2 RESTRICTIONS
@
@
1.@ICharacter strings are restricted to a maximum length of 140 characters.@
@
2.@ISets are restricted to 128 elements.
Set types may be defined over any base type which is:-@
@
@I(a) an enumerated type (no element beyond the 128th. being
used), or@
@I(b) a type integer (or a subrange of) with a minimum element
>=0 and a maximum element <= 127, or@
@I(c) one of the types char or boolean.@
@
3.@IRun-time checking is restricted to detection of the following errors:@
@
@I(i) Subrange variable out of range.@
@I(ii) Non-existent CASE chosen.@
@I(iii) Illegal pointer access (only in simple cases).@
@S211.3 EXTENSIONS
@BWith the I+ option all deviations from the ISO standard are
monitored but code is still compiled for these extensions whenever
possible, with I- the following extensions are permitted.
@
@
1.@IFacilities are available to call any suitable MUSS
library procedure. To conform to the ISO standard any such
procedure used should be preceded by a procedure-declaration or
function-declaration with an external directive. The parameter
specification given will be checked for compatibility with the
MUSS specification. However the compiler allows such procedures
to be called without declaration
except when the procedure has a user-defined type
parameter, when an external declaration must be given.
Additionally the following
functions are provided@
@
@ISIGN(X1,X2)@
@IDIM(X1,X2)@
@ILOG10(X)@
@IARCSIN(X)@
@IARCCOS(X)@
@ISINH(X)@
@ICOSH(X)@
@ITANH(X)@
@ISIGN(X)@
@
@Iwhere Xs are either integer or real type.
These each correspond to one or more of the MUTL mathematical functions.@
@
2.@IAn OTHERWISE option is provided for case statements where the case constants
cannot all be listed.
If the CASE expression is of integer (i.e. not subrange)
type then an error will be registered rather than the
OTHERWISE alternative being chosen if the expression is
outside the range: LOW .. HIGH where LOW is the minimum of
-1000 and the lowest CASE constant listed and HIGH is the maximum
of +1000, and the highest CASE constant listed.  Thus a wider range
can be obtained by suitably choosing the CASE constants listed.@
@
3.@IHexadecimal constants are accepted. The hexadecimal digits must be
@X %\
preceded by % and be at most 32 bits.@
@X %%
@
4.@IAny line commencing ** is interpreted as a MUSS command to be obeyed
at compile time.@
@IThe main use of this feature is to include source
text from other files, or to direct the
action of the MUTL system when compiling a library (see 12.8) or
placing variables in a specific segment (see reference 12.9).@
@
5.@IRenaming of files is permitted in the program parameters.
(See 12.5)
@
6.@IA limited facility for compiling independent modules is
available.  (See 11.8 below).
@S211.4 CONFORMANCE TO @JPASCAL TEST SUITE
@BThe compiler has been validated against the Pascal processor
validation suite of B.A. Wickman and A.H.J. Sale. Details
of the results are in the PASCAL Implementation Manual Section 2.4.
@S211.5 INPUT AND OUTPUT
@BThe files INPUT and OUTPUT are predefined to be the current MUSS input
and output stream when the program run is started or the library opened.
Character input is implemented in a way suitable for on-line operation
on a line by line basis, (so called lazy input).
@BAll external files must be specified as parameters in the program
heading corresponding to the MUSS files of the same name.
An extension allows parameters of the form Pascal filename = MUSS
document where MUSS document is a sequence of characters terminated
by , or ) as described in Chapter 3.
@BThere is no limit as to the number of files a programmer may use but
the maximum number of "readable" files is 8 and that of "writable" too
is 8. All files must be initialized to "readable" and "writable" by
the procedures RESET and REWRITE. If a programmer wishes to read from
a file previously written on, he only has to call the procedure RESET
and vice versa. If  the number of
"readable"/"writable" files is insufficient then the procedure
CLOSE(f) may be called to reduce the number of files in that state.
@BThe correspondence between Pascal and MUSS files is
as follows:@
@Q 5
@
(i)@IMUSS sequence of characters is Pascal TEXT or FILE of CHAR.@
(ii)@IMUSS unstructured sequence of binary is Pascal file of basic type.@
(iii)@IMUSS sequence of units is Pascal file of records without variants.@
(iv)@IMUSS sequence of records is Pascal file of records with variants.@
@BThe Pascal input/output system imposes an additional level on the
basic MUSS system, so extreme caution is needed if basic MUSS
I/O commands are mixed with the Pascal facilities. At compile time
the compiler uses the basic MUSS facility.@
@
Note:@ITo avoid reading beyond the end of a file, all input files must be
terminated by a newline character.
@S211.6 COMPILE TIME PRAGMATS
@BThese are of the form (* $<letter> + *) to turn on feature <letter>
and (* $<letter> - *) to turn this feature off.
@BThe allowed letters are:@
@T% 30
@Q 16
@
D <integer>@IDirect variables declared beyond this point
into new code area.@
C@ICompile full run-time checking (default -).@
I@ICheck conformance to ISO standard (default +).@
E@ITurn on error listing (default +).@
L@IList source text (default -).@
P <integer>@ICall TL.PRINT (<integer>).@
S <integer>@IDirect compilation into new code area.@
T@ICompile run-time line number trace (default-).@
Y@IFollowing procedures are to be exported library procedures, when
compiling library (default-).@
R@IMake all real variables beyond this point double
precision (default-).@
N@IMake integer size 16-bit (default- i.e. 32-bit).
N.B. This may only be used at the start of compilation.@
@S211.7 COMPILE TIME ERRORS
@BError messages are printed below the faulty source line with
arrows indicating the symbol which was faulted. Arrows separated by
commas indicate more than one error on the same symbol.
@S211.8 PASCAL LIBRARIES
@BMUSS Pascal supports a limited module facility and it is also
possible to compile a set of Pascal procedures into a library.
@BA module is identical to a program except that the word "program"
is replaced by "module" and all outer level procedures are exported
for use by other modules.  Global variables are imported.  In a
"program" outer level variables are exported and procedures may be
imported.
@BA particular form of module is in MUSS library.
To compile a library the Pascal compiler is called with
third parameter = 4 (see 2.5.2). The user has control
over which procedures are in the external library interface.
The Y+ pragmat must precede the first such procedure heading.
If subsequent procedure are not required Y- is used to
inhibit addition to the library interface.
@BExample of a Pascal library consisting of two procedures
Q and S.@
@Q 21
@T` 28
@
@X%`
**TLSEG 0 0 %40000 -1 6`(Allocate Vax segment 4 as runtime address of library)@
MODULE P;@
(*$Y+*)`(Put Q in library interface)@
PROCEDURE Q(P1 : INTEGER);@
BEGIN@
WRITELN('PROC Q : P1 = ',P1)@
END;@
(*$Y-*)`(R not to be put in library interface)@
PROCEDURE R(C : CHAR);@
BEGIN@
WRITE(C)@
END;@
(*$Y+*)`(Put S in library interface)@
PROCEDURE S(VAR C : CHAR);@
BEGIN@
WRITE('PROC S : C = ');@
R(C);@
END;@
BEGIN@
END.@
@X%%
@S211.9 RUN TIME STORE USE
@BThe Pascal stack segment for local variables is the MUSS
stack segment. (This is one full segment on the VAX).
@BThe Pascal heap segment is currently segment
@X%|
%21, on the VAX.
@X%%
If more space is needed it is allocated dynamically. Heap space is
recovered by dispose and reused.
A procedure ATTACH (SEG.NO, PTR) is available in the
run-time library to set a pointer to the start of a given segment.
A warning message should be expected when this procedure is
called from a Pascal program because the type of the second
parameter will not correspond to the specification given for it.
In order to use this procedure the following declaration should be
made in the calling program:@
@U 3
@
PROCEDURE ATTACH (P1:INTEGER; VAR P2:<required pointer type>);
                                                  EXTERNAL;
@BThe present implementation creates full size records for
variant records without attempting to optimise the space
allocated. The layout of fields within records is controlled by
MUTL, presently to the byte level. Packed does not, at present,
attempt any further packing to the bit level.
@BPascal uses MUTL to create space for variables in the current
data area. Variable declarations can be directed into other
segments of store using **TL.SEG, **TLLOAD, and **TLDATAAREA
as described in 23.4.@
@Q 10
@T# 10 20
@
@X%#
#PROGRAM P;@
#e.g.#**TLSEG 2 0 %40000 -2 12@
##**TLLOAD 2 3@
##**TLDATAAREA 3@
##VAR X,Y,Z: INTEGER;@
##**TLDATAAREA 0@
##a,b,c: real;@
@X%%
@
@
puts the variables X, Y, Z in a segment 4 (on a VAX) and a, b, c on the stack. N
ote that
Pascal uses TLSEG 1 for the heap so this may not be reused.
When cross-compiling the pragmat (*$D<integer>*)
should be used instead of **TLDATAAREA to avoid calling
the wrong MUTL.
@F
