

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
                  DECUS PASCAL FOR PDP-11
                  =======================



                        USER MANUAL
                        =========== 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
                          Contents
                          --------

    1       Usage of the Pascal compiler
      1.1     How to compile
      1.2     How to link
      1.3     Adjusting program workspace
    2       Extensions
      2.1     Character set and special symbols
      2.2     Identifiers
      2.3     Standard constants
      2.4     Standard types
      2.5     Standard files
      2.6     The extended CASE statement
      2.7     The LOOP statement
      2.8     Standard procedures
      2.9     Standard functions
      2.10    Procedures and functions as parameters
      2.11    Separate compilation
      2.12    String parameters
      2.13    Structured function results
      2.14    Boundless array parameters
      2.15    Examples
    3       Restrictions
    4       Compiler options
    5       Representation
    6       The Runtime Environment
    7       Comparison with Standard Pascal
      7.1     Conformance
      7.2     Deviation
      7.3     Error Handling

    Appendices

    A       Character set
    B       Special symbols
    C       Reserved words
    D       Standard procedures
    E       Standard functions
    F       Error codes
    G       Options and switches
    H       Additional procedures and functions
 
 
 
 
 
 
 
 
6-NOV-1985                 - i -               PDP-11 Pascal


 
 
1 RUNNING A PASCAL PROGRAM

In  this section, it is assumed that the Pascal compiler has
been installed on the system in such a way that  it  can  be
invoked  with  the  command  PAS.  (See  release  notes  for
installation procedure.)
 
 
 
 
1.1 How to compile

The command with its arguments can be given with any of  the
following formats:
 
   PAS                          = <source>,<source>,...
   PAS                 ,, <cxp> = <source>,<source>,...
   PAS       , <listing>        = <source>,<source>,...
   PAS       , <listing>, <cxp> = <source>,<source>,...
   PAS  <obj>                   = <source>,<source>,...
   PAS  <obj>,,           <cxp> = <source>,<source>,...
   PAS  <obj>, <listing>        = <source>,<source>,...
   PAS  <obj>, <listing>, <cxp> = <source>,<source>,...

   PAS  <source_obj>
   PAS  <source_obj>,,           <cxp>
   PAS  <source_obj>, <listing>
   PAS  <source_obj>, <listing>, <cxp>
 
Where <obj>, <listing>, <cxp>, <source> and <source_obj> are
normal file specifications:
 
    <obj>       is the program object file (output)
    <listing>   is the compilation listing (output)
    <cxp>       is the symbolic object code (output)
    <source>    is the program source (input)
    <source_obj> is the name for both source and object files.
 
When  several source files are specified, the compiler reads
each one in the order given.
 
The  <obj>,  <source_obj>  and  <listing>  file  specs   can
optionally have switches appended to them. (See chapter 4.)
 
If the compiler is not installed, it can be invoked with the
run  command (RUN PAS), in which case it will prompt for the
command line arguments.
 
 
 
6-NOV-1985                 - 1 -               PDP-11 Pascal


 
 
The  file   specifications   follow   RSX   standard,   i.e.
dev:[uic]file.typ. Default values are
 
        dev: = SY0:
        [uic] = default terminal UIC
        .typ = .OBJ, .LST, .CXP or .PAS respectively

        The default dev: and [uic] for the LST and CXP
        files are implied from the specifications on the
        preceding file specifications.
 
Switches corresponding to most compiler options (see chapter
4)  can  be given. Only one letter is significant, eg. /E is
equivalent to /EIS. Switches can be negated through - or  NO
(eg. /-R or /NORR).
 
Most  switches apply to the object file, only /U (spool) /LW
(line width), /PW (page width)  and  /W  (warnings)  can  be
placed on the listing file specification.
 
Default  switch settings are chosen at compiler installation
time.
 
Four switches not corresponding to options exist. /U on  the
listing  file  indicates that the file should be spooled for
printing after compilation; default: /-U (no  spool).  /PW:n
and  /LW:n  on  the list file can redefine the page and line
widths. Defaults are selected at compiler  generation  time.
/AA:n  defines  which level of predefined identifiers to use
(See ch. 4.).
 
        Eg.     PAS  EX
                PAS  EX, EX/U
                PAS  EX, EX, EX = EX1, EX2, EX3
                PAS  T.OBJ, L = DK1:[200,200]EX2.PAS
                PAS  EX3/AA:1, L
 
Four error signals can be generated at this point. All cause
immediate exit from the compiler:
 
    -  FILE NOT FOUND
          if there is no source file with the given name
 
    -  FILE SPECIFICATION ERROR
          if no source filename is given
 
 
 
 
 
6-NOV-1985                 - 2 -               PDP-11 Pascal


 
 
    -  SWITCH ERROR
          if an illegal switch is given
 
    -  ERROR OPENING OUTPUT FILE
          if an I/O error is encountered in creating any
          of the output files
 
 
When the compiler is invoked from a command file  or  batch,
the  success  of  the compilation can be sensed by examining
the compiler's exit status. If errors were  detected  during
compilation, the exit status will be 2 (EX$ERR).
 
 
 
 
1.1.1 Displaying generated code
 
To  obtain  the symbolic listing of the generated code it is
necessary to have a <cxp> file specification in the  command
line  and  to  have  the  C option selected either as the /C
switch on the command line <obj> file  specification  or  as
the  $C+  option in the source code (see section 4.2). The C
option has two effects: it  causes  the  printing  of  octal
addresses  in  the  listing and it enables the output of the
symbolic object code to the <cxp> file if any. For  example,
to  obtain  the  symbolic  object  code  for program EX, the
following command line could be used:
 
        >PAS /C, EX, EX = EX
 
Both a <listing> and a <cxp>  file  will  be  produced.  The
octal  addresses  in  the listing file can be referred to in
finding the <cxp> code for a particular statement.
 
Obtaining the symbolic  generated  code  only  for  selected
portions  of  the  compiled  program  can  be achieved under
control of $C+ and $C- options in the source code.
 
The facility for outputing symbolic generated code  is  made
optionally available at compiler generation time.
 
 
 
 
 
 
 
 
 
6-NOV-1985                 - 3 -               PDP-11 Pascal


 
 
1.2 How to link Pascal programs

Pascal  programs  are  linked  by the normal linker: TKB (or
FTB). For example:
 
        >TKB <task>, <map> = <object>
 
The file names are given  as  above,  and  only  the  object
file(s) are mandatory. On your system it may be necessary to
specify the Pascal support library also.
 
        >TKB <task>, <map> = <object>, [x,y]PASLIB/LB
 
where  [x,y]  is  the  directory where the Pascal library is
stored.
 
The  program's  workspace  (stack  and  heap)  is   reserved
according  to  the compilation report of the main program at
the end of the listing. If more space is required, it can be
obtained by extending the task when the task built.  On  RSX
the  task can also be extended at install time or on the RUN
command.
 
  Eg.   >TKB
        TKB>EX4,EX4=EX4
        TKB>/
        ENTER OPTIONS:
        TKB>EXTTSK=4000         ; Add 4000 words (decimal)
        TKB>UNITS=10            ; 9 files + TTY (see ch 6)
        TKB>ACTFIL=9            ; 9 files will be opened
        TKB>//
 
TKB option TSKV=$P.VEC:8 can be specified. In that  case,  a
fatal  error  will  also  give an octal dump of the heap and
stacks of the task. The dump is  done  with  the  PMD  (Post
Mortem Dump) facility if installed.
 
 
 
 
1.2.1 Overlayed Tasks
 
It is also possible to build overlaid tasks. To do this, the
program  should  be  compiled  with  option  Y+  to  produce
separate object modules for each procedure and then LBR must
be used to create an object library so  that  these  modules
can  be  individually  specified  in an overlay description.
Separately compiled procedures may also be  introduced  into
 
 
6-NOV-1985                 - 4 -               PDP-11 Pascal


 
 
the   task.   Example:   program  P  has  three  independent
procedures which can be overlayed:
 
        {$Y+  Split object modules }
        program P;
           procedure A ...
           procedure B ...
           procedure C ...
        begin {P}
         A;  B;  C
        end.
 
 
   - Compile:   >PAS P

   - Create object library:   >LBR P/CR = P

   - Create overlay description file, P.ODL:

        For memory resident overlay:
            .ROOT  P/LB:P-*!(P/LB:A,P/LB:B,P/LB:C)
            .END

        For disk resident overlay:

            .PSECT  $99999  RO,D,GBL,OVR
            .ROOT  P/LB:P-*(P/LB:A,P/LB:B,P/LB:C),$99999
            .END

   - Link using this ODL:  >TKB P = P/MP
 
   See also the build files for the compiler itself.
 
 
For the disk resident overlay description, the placement  of
P-section  $99999  must be done to force it to be at the end
of the task. This P-section is the workspace for the runtime
stack and heap (see ch 5). It must be at the end of the task
because the Pascal runtime initialization allocates all  the
space  between the beginning of the heap section and the end
of the task partition for the Pascal stack and heap. For the
memory  resident  overlay  situation,   the   task   builder
automatically positions the section properly.
 
 
 
 
 
 
 
6-NOV-1985                 - 5 -               PDP-11 Pascal


 
 
1.2.2 Overlaying with debugger
 
When  the symbolic debugger is selected, a very large amount
of additional runtime routines get linked into  the  program
to  support  the  debugging  functions.  As  a result, large
programs  cannot  use  the  debugger  without  resorting  to
overlays.  There  is  no direct coupling between the program
and the debugger so it is therefore  possible  for  them  to
completely  overlay  each  other; only the program structure
data table and other data sections have  to  be  permanently
resident.
 
If the PASLIB object library has been merged into the system
object library, SYSLIB, then an overlay description based on
the following can be used:
 
          .PSECT  $DDTDF  RW,D,GBL
          .PSECT  $99999  RO, D, GBL, REL, OVR
          .NAME   PAS$LD
          .NAME   DBG$LD
          .NAME   HP$LD

          .ROOT   R-(PAS$LD-USER,DBG$LD-DEBUG),HP$LD-$99999-HEAP

  R:      .FCTR   $DDTDF-LB:[1,1]SYSLIB/LB:PASDDT:FCSFSR

  DEBUG:  .FCTR   LB:[1,1]SYSLIB/LB:INIT$$

  HEAP:   .FCTR   LB:[1,1]SYSLIB/LB:P11HEA

  USER:   .FCTR   { List of user object modules goes here }

          .END
 
 
If, on the other hand, the PASLIB object library has been kept as
a separate object library, then an overlay description based on
the following can be used:
 
          .PSECT  $DDTDF  RW,D,GBL
          .PSECT  $99999  RO, D, GBL, REL, OVR
          .NAME   PAS$LD
          .NAME   DBG$LD
          .NAME   HP$LD

          .ROOT   R-(PAS$LD-USER,DBG$LD-DEBUG),HP$LD-$99999-HEAP

  R:      .FCTR   $DDTDF-R1-R2
 
 
6-NOV-1985                 - 6 -               PDP-11 Pascal


 
 
  R1:     .FCTR   LB:[1,1]PASLIB/LB:PASDDT
  R2:     .FCTR   LB:[1,1]SYSLIB/LB:FCSFSR

  DEBUG:  .FCTR   LB:[1,1]PASLIB/LB:INIT$$-LB:[1,1]PASLIB/LB

  HEAP:   .FCTR   LB:[1,1]PASLIB/LB:P11HEA

  USER:   .FCTR   { List of user object modules }-LB:[1,1]PASLIB/LB

          .END
 
 
With  both  of  the  above  overlay  descriptions,  the task
builder  will  issue  several  diagnostic   messages   about
multiple definitions. These can be ignored.
 
 
 
 
1.3 Adjusting Program Workspace
 
The size of the workspace section for runtime stack and heap
is  initially  set  when  the  main program is compiled. The
compiler  provides  enough  space  to  accomodate  all   the
variables  and  parameters  of  the  main  program  and  all
procedures compiled with it in the same source  file.  Since
the  compiler can only see the static nature of the program,
the space it  allocates  may  be  inadequate.  This  may  be
because  the  program  performs  recursive  calls, allocates
dynamic variables, or calls separately compiled  procedures.
In  these  cases  the  workspace  can  be  increased  in the
following ways:
 
  1. When building:
 
         for non-overlayed and disk overlayed tasks use  the
         EXTTSK task builder option:
 
                 eg. EXTTSK = 800 (decimal words)
 
         for  memory resident overlayed tasks use the EXTSCT
         task builder option:
 
                 eg. EXTSCT = $99999:500 (octal bytes)
 
  2. When installing the task (on RSX) use the /INC switch:
 
             eg. INS EX4/INC=800. (octal or decimal words)
 
 
6-NOV-1985                 - 7 -               PDP-11 Pascal


 
 
  3. When running the task (on RSX) use the /INC switch:
 
             eg. RUN EX5/INC=1000 (octal or decimal words)
 
 
Methods 2 and 3 cannot be used for  tasks  that  use  memory
resident  overlays  because  the  heap section is not at the
physical end of the task partition.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                 - 8 -               PDP-11 Pascal


 
 
2 EXTENSIONS
 
There is a special switch (/A) which can be used to  control
which  extensions  are  to  be included. A default value for
this switch is selected at compiler generation time. It  can
be  redefined  using  the  /A  switch  on  the  object  file
specification in the command line. See paragraph 4.1 below.
 
 
 
 
2.1 Character set and special symbols

Many installations have  character  sets  with  the  bracket
symbols  replaced with national characters. In order to make
it easy to write readable programs it was necessary to allow
a special symbol combination as well.  New  special  symbols
are:
 
        (. left bracket
        .) right bracket
        (* start of comment
        *) end of comment
        # not equal
        & and
        ! or
 
 
 
 
2.2 Identifiers
 
Identifiers  of up to 10 characters in length are recognized
distinctively. This can be sensed in a program as the  value
of  the  standard  constant  ALFALENG  (see  2.3 below). Any
characters beyond 10 are ignored. Lower case characters  are
treated as upper case. The underscore character (_) can also
be used in identifiers.
 
 
 
 
2.3 Pre-defined constants

For   deflevel   (/A)  >=  2  some  standard  constants  are
predeclared. The integer constants are defined as
 
        CONST   MAXINT = 077777B {  32767 };
 
 
6-NOV-1985                 - 9 -               PDP-11 Pascal


 
 
                MININT = 100000B { -32768 };
                ALFALENG = 10;
 
The real constants are defined as:
 
        CONST   MAXREAL   = 1.7014117E+38;
                MINREAL   = 1.5224277E-39;
                SMALLREAL = 1.1983428E-7;
 
They represent the absolutely greatest and  smallest  reals,
and SMALLREAL is the smallest value that makes 1.0+SMALLREAL
<> 1.0 .
 
The  definition  of these constants is effectively done in a
block which surrounds the main program  and  thus  will  not
interfere with any redefinitions of these identifiers in the
program.
 
 
 
 
2.4 Pre-defined types

For deflevel (/A) >= 2 the standard type TEXT is predeclared
as
 
        TYPE  TEXT = FILE OF CHAR;
 
To  allow  characters  of full ASCII or eightbit code, ASCII
and BYTE can be thought to be defined as
 
        TYPE ASCII = CHR(0) .. CHR(177B) ;
        TYPE BYTE  = CHR(0) .. CHR(377B) ;
 
For deflevel >= 3 a standard type for RSX/IAS file  handling
for use with reset and rewrite is predeclared as
 
        TYPE IOSPEC = (RANDOM,UPDATE,APPEND,TEMPORARY,INSERT,
                       SHARED,SPOOL,BLOCK,NOCR,FDFTN);
 
The definition of these types is effectively done in a block
which surrounds the main program and thus will not interfere
with any redefinitions of these identifiers in the program.
 
 
 
 
 
 
 
6-NOV-1985                - 10 -               PDP-11 Pascal


 
 
2.5 Pre-defined files

In  addition to the standard text files INPUT and OUTPUT the
standard text file TTY is available. This file  is  used  to
communicate  with the user's terminal (TI: of RSX/IAS). This
file can be opened only through the program statement.
 
The specification of TTY in the program  statement  actually
causes  the  declaration of two text file variables, TTY and
TTYIN, for terminal output and input respectively.  However,
for  I/O  procedures and functions related to input, the use
of  TTY  as  the  file  variable   will   be   automatically
interpreted   as   a   reference   to  TTYIN.  For  example,
READ(TTY,X) is the same as READ(TTYIN,X).
 
When the file variable is omitted from the parameter list of
standard I/O procedures such as READ and WRITE, the standard
files will be assumed  in  the  following  way.  For  output
procedures,  OUTPUT  is  assumed  if  present in the program
statement, otherwise TTY if present; for  input  procedures,
INPUT  is  assumed  if  present  in  the  program statement,
otherwise TTY if present.
 
In separately compiled  procedures,  standard  file  TTY  is
available as the default file. Note that external procedures
that  use TTY for I/O should only be used with main programs
that have TTY specified in the program statement.
 
 
 
 
2.6 The extended CASE statement

There are two forms of extension for default  case  handling
in the case statement.
 
The CASE statement may be extended with the case OTHERS. The
statement  associated  with  OTHERS  will be executed if the
expression of the CASE statement does not evaluate to one of
the explicitly given case labels.
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 11 -               PDP-11 Pascal


 
 
    Syntax:
        <case statement> ::= CASE <expression> OF
             <case element>  { ;<case element> }  END
        <case element> ::= <case label list> : <statement> !
                           <empty>
        <case label list> ::= <case label>  { ,<case label> }  !
                              OTHERS

    Example:
                var x: char;
                  ...
                case x of
                  'a':  p(x);
                  'b':  q(x);
                  ...
                  OTHERS: begin
                          s2; s2; z(x)
                          end
                  end;
 
 
The second form of the extension is the one adopted by  ANSI
as a candidate extension to the Pascal Standard.
 
    Syntax:
        <case statement> ::= CASE <expression> OF
             <case element>  { ;<case element> }
             { ;<otherwise-case> }                END
        <case element> ::= <case label list> : <statement> !
                           <empty>
        <case label list> ::= <case label>  { ,<case label> }
        <otherwise-case> ::= OTHERWISE
                                <statement> { ; <statement> }

    Example:
                var x: char;
                  ...
                case x of
                  'a':  p(x);
                  'b':  q(x);
                  ...
                  OTHERWISE
                        s1;  s2;  z(x)
                  end;
 
 
It  is  worth  noting  that  the  case  statement  is always
translated to a so called "jump table", which is wasteful if
 
 
6-NOV-1985                - 12 -               PDP-11 Pascal


 
 
the table is sparse. In such cases it is more economical  to
use successive if-then-else statements.
 
 
 
 
2.7 The LOOP statement

The  LOOP statement is an additional control statement which
combines the effects of WHILE and REPEAT statements.
 
    Syntax:
        <loop statement> ::= LOOP
                              <statement part>
                             EXIT IF <expression>;
                              <statement part>
                               END
        <statement part> ::= <statement>  { ;<statement>  }

The expression must result in a Boolean value.
 
 
 
 
2.8 Pre-defined procedures

2.8.1 DATE and TIME

The procedure DATE( <alfa variable> )  assigns  the  current
date  in the format '19yy-mm-dd' to the parameter which must
be of type PACKED ARRAY [1..10] OF CHAR.
 
The procedure TIME( <alfa variable> ) assigns the daytime in
the format 'hh:mm:ss.t' to the parameter which  must  be  of
type PACKED ARRAY [1..10] OF CHAR.
 
 
 
 
2.8.2 MARK and RELEASE

There  is no procedure DISPOSE but the pair MARK and RELEASE
takes care of deallocation when a nested structure is  used.
MARK  puts  a  mark  in  the  heap  and RELEASE releases all
storage above the topmost mark in the  heap.  They  have  no
parameters,  but  for compatibility with the PASREL compiler
on DEC10 they may be called with one (unused) parameter.
 
 
 
6-NOV-1985                - 13 -               PDP-11 Pascal


 
 
2.8.3 HALT

The  procedure  HALT  can  be  used  to  help  debug  Pascal
programs.  A  call  of HALT gives an octal dump of the stack
and heap, and exit  from  the  program.  The  dump  is  done
through the PMD (Post Mortem Dump) facility if installed. In
programs  compiled  with option D+, symbolic debugging, HALT
will instead invoke the debugger.
 
 
 
 
2.8.4 RESET and REWRITE

The standard procedures RESET(f) and  REWRITE(f)  have  been
extended with up to 5 new parameters. These make it possible
to  use  almost  all  of  the  RSX/IAS  file system, but two
properties are fixed:
   - all files are  accessed  in  locate  mode,  except  for
     random files which are accessed in move mode;
   - text  files  (files of char, ascii or byte) use records
     of variable length with one line per record, all  other
     files use records of fixed length.
 
The new call format is:
 
        RESET (f,filename,dir,dev,ioselect) and
        REWRITE (f,filename,dir,dev,ioselect)
 
Only  as  many  parameters  as necessary need be present and
trailing parameters may be omitted. They  must  be  declared
as:
 
   f:      FILE OF <type>;

   filename: PACKED ARRAY OF CHAR, string constant or substring
           to give an external file name.  Examples:
           'SOURCE.PAS', 'TEXT;3', CMDLINE[I..J] or  a string
           variable containing 'FILE2.EX     '.
           The length is insignificant.  If the name is
           shorter than the string, the string must be
           filled with trailing blanks.
 
   dir:    PACKED ARRAY OF CHAR, string constant or substring
           to give a file directory.  Example:
           '(40,13)', '[200,200]'.  The parentheses are
           automatically translated to brackets.  The length
           is insignificant.  If the directory name is
 
 
6-NOV-1985                - 14 -               PDP-11 Pascal


 
 
           shorter than the string, the string must be
           filled with trailing blanks.

   dev:    PACKED ARRAY OF CHAR, string constant or substring
           to give device name.  Example:  'SY:','LP0:'. The
           length is insignificant.  If the device name is
           shorter than the string, the string must be
           filled with trailing blanks.

   ioselect: SET OF IOSPEC;
                   IOSPEC is predeclared if DEFLEVEL >= 3.
                   Otherwise it can be declared as
                   TYPE IOSPEC = (RANDOM,UPDATE,APPEND,TEMPORARY,
                   INSERT,SHARED,SPOOL,BLOCK,NOCR,FDFTN);
 
                   The keywords mean (cf RSX/IAS):
 
       RANDOM      the records of the file may be fetched/updated
                   in random order.
       UPDATE      an existing file will be changed.
       APPEND      an existing file will be appended to.
       TEMPORARY   a temporary file will be used.
                   The temporary file is created at the first
                   execution of a REWRITE statement where
                   TEMPORARY is specified.  Later RESETs or
                   REWRITEs of the same file use the same
                   temporary file regardless of parameters.
       INSERT      together with UPDATE this element states that
                   the file will not be truncated if written into.
       SHARED      the file is opened  in such a way that
                   other tasks may open it too.
       SPOOL       this text file shall, when closed,
                   be handed over to the print spooler
                   for printing on the line printer.
       BLOCK       enables blockwise get and put.  Only
                   one file element is read or written,
                   even if more than one can be contained
                   in one block.  QIO is used directly, so
                   this is not exactly as READ and WRITE
                   of RSX/IAS.  Two parameter form of GET
                   and PUT must be used (see 2.8.6).
       NOCR        prevents the inclusion of the carriage return
                   file attribute when creating a text file.
       FDFTN       causes the inclusion of the FD.FTN file
                   attribute when creating a text file which
                   specifies that the first character of each
                   line is a Fortran carriage control byte.
 
 
 
6-NOV-1985                - 15 -               PDP-11 Pascal


 
 
For  both  RESET  and  REWRITE,  f  is  the  only  mandatory
parameter. The other parameters have default values if  left
out in a call:
 
       filename: the internal name of the file variable or the
                 name of formal parameter if used.
       dir:    default uic of task
       dev:    'SY0:'  (Selectable at compiler generation)
       ioselect:  []   the empty set
 
       Example: RESET (F) is equivalent to
                RESET (F, 'F',, 'SY0:', [])
 
If  the reset/rewrite statement is applied to a file that is
already open and the filename, dir, and dev  parameters  are
all omitted then the same file is re-opened.
 
 
 
 
2.8.5 BREAK and PAGE

The  procedure  PAGE (<textfile>) inserts a form feed in the
given file. It may be called without parameter in which case
it is assumed to be the standard file OUTPUT if  present  in
the PROGRAM statement, otherwise TTY if present.
 
The  procedure  BREAK  can  be called without a parameter or
with one text file parameter. If no parameter  is  specified
and  TTY is present in the program statement, or if the file
parameter is TTY then the current  line  buffer  is  written
without  carriage  return added. Thereby, a later input from
TTY can be given on the same line. If the file is  not  TTY,
break is equivalent to writeln.
 
 
 
 
2.8.6 GET and PUT

The  standard  procedures  GET  and  PUT  can  take a second
parameter of type integer. This parameter has effect only if
RANDOM or BLOCK was specified when opening the file. In case
of RANDOM, it is the number of the record to be  input  from
the file (GET) or written to the file (PUT). If the file was
opened  with  BLOCK  in  ioselect,  the  second parameter is
mandatory and one file element is transferred to or from the
block with the given number.
 
 
6-NOV-1985                - 16 -               PDP-11 Pascal


 
 
2.8.7 READ and WRITE
 
See also Jensen & Wirth for  detailed  explanations  of  the
standard features.
 
READ can read characters from a text file, one at a time. It
can also read characters representing integers and reals and
convert them to binary.
 
Text  files opened for reading (by RESET) have an input line
buffer. If EOLN is TRUE when a read is issued, a new line is
requested. READ then takes characters from the buffer  to  a
CHAR  variable  or  an array of char, or part of an array of
char as detailed by a substring specification,  or  converts
them to integer or real before storing the result.
 
READLN  without  parameters  or with only a file variable as
parameter requests a new line  to  be  read  into  the  line
buffer.  Any  remaining characters in the old line are lost.
If READLN has other parameters (variables to get values) the
new line is requested after the variables are read.
 
READ is extended to allow  direct  read  into  an  array  of
characters.  The  array  is  filled  from  the  current line
buffer. If not  enough  characters  remain  in  the  buffer,
trailing  spaces  are inserted. Reading into only part of an
array  of  characters  is  possible  using   the   substring
specification (see 2.12).
 
When  reading integers or reals, spaces preceding the number
are skipped. Trailing spaces can also be skipped (see option
H below, 4.7) until eof or not space, but for TTY only until
eoln or not space.
 
When a file is opened with RESET, its  first  line  is  read
into  the internal buffer. EOLN and EOF are set according to
the result of this READLN operation, i.e. normally they  are
both  FALSE.  In  order  to  allow  more natural interactive
program execution, TTY is treated differently. The TTY input
buffer is initially empty and no automatic read  is  issued.
Thus a program gets the opportunity to present itself before
any  data  has  to  be entered from the terminal. Here is an
example of how a terminal dialogue would be programmed:
 
 
 
 
 
 
 
6-NOV-1985                - 17 -               PDP-11 Pascal


 
 
          :
        writeln (TTY, 'Line 1');
        writeln (TTY, 'Line 2');
        write   (TTY, 'Prompt: ');   break (TTY);
        readln  (TTY);
        read    (TTY, hisentry);
        write   (TTY, 'Question ...? ');  break (TTY);
        readln  (TTY);
        read    (TTY, answer);
          :
 
WRITE can write items of type boolean, char, integer,  real,
string constant, (packed) array of char and part of an array
of  char  (substring). After each of these a field width may
be given as ":w" where w is an integer expression. For reals
a second value can be specified that  gives  the  number  of
decimals.
 
WRITE  is  extended  to  allow printing of integers in octal
form. This is achieved by adding :O after the  field  width,
e.g. WRITE(I:4:O); .
 
The characters resulting from WRITE operations are stored in
an  internal  buffer. The line is written on the file when a
WRITELN is issued. To  file  TTY  the  line  is  written  as
<lf><buffer><cr> . To avoid the <cr> the procedure BREAK can
be used, see 2.8.5 above.
 
The  standard  procedures  READ and WRITE are generalized to
allow all types of files. For non-text  files  no  automatic
conversion  is  done,  but  the  file  component  is  stored
directly from memory in its  internal  representation.  This
means  that  pointers  in  a  record are invalid when such a
record is read back from a file. Example:
 
        type 
            rec = record ... end;
        var
            person:  rec;
            infile, outfile:  file of rec;

        ...
        read (infile, person);
 
 
 
 
 
 
 
6-NOV-1985                - 18 -               PDP-11 Pascal


 
 
2.8.8 NEW (on variant records)

When a NEW is  performed  to  allocate  a  record  that  has
variants  and  if one or more variant selectors are supplied
as parameters to NEW then the corresponding tag field(s), if
any, will be assigned the given selector value(s). Also, the
amount of storage allocated will be just enough to hold  the
selected variant of the record.
 
 
  Eg.
    type
        Ttyp = (V1,V2,V3);
        smallrectyp = record
            i: integer;
            case b: boolean of
                FALSE: ( j: ... );
                TRUE:  ( k: ... )
            end;
        bigrectyp = record
            a: sometype;
            case t: Ttyp of
                V1: ( ... );
                V2: ( ... );
                V3: ( a3: integer;
                      b3: smallrectyp );
            end;

    var
        p: ^bigrectyp;

    begin
      :
    new ( p );          { Allocates space for largest
                          variant of bigrectyp        }
      :
    new ( p, V2 );      { Allocates just enough space for
                          V2 variant.  p^.t = V2         }
      :
    new ( p, V3, TRUE ); { p^.t = V3  and  p^.b3.b = TRUE }
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 19 -               PDP-11 Pascal


 
 
2.8.9 NEW (on arrays)
 
When  a  NEW  is  performed  to  allocate an array, space is
normally  provided  to  accomodate  the  entire   array   as
declared.  An  optional parameter can, however, be specified
in the NEW to allocate only a portion of the array.
 
    Eg.
        type
            atyp = array [0..10] of anytype;

        var
            a: ^atyp;

        begin

        new ( a: i );
 
 
In this example, only enough space for i+1 elements will  be
allocated.  The  expression  i  must be of a type compatible
with the index type of the array and represents the  maximum
index useable in the allocated array.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 20 -               PDP-11 Pascal


 
 
2.9 Pre-defined functions

2.9.1 RUNTIME

The  function  RUNTIME returns an integer giving the daytime
in seconds modulo  8  hours  (RSX/IAS  doesn't  measure  CPU
time).
 
 
 
 
2.9.2 TWOPOW and SPLITREAL

The  function  TWOPOW(<integer  expression>):REAL  gives  as
result the real 2**<integer expression>.

The   function   SPLITREAL(<real    expression>,    <integer
variable>):REAL  returns  the  binary  exponent  of the real
expression in the integer variable and  gives  as  result  a
real  with binary exponent zero but the same mantissa as the
expression.
 
 
 
 
2.9.3 IORESULT

The function  IORESULT(<file>):INTEGER  returns  an  integer
value  indicating  the  result  of the last operation on the
given file. Result = +1 if OK and <0  if  error.  The  error
codes  are  those returned from RSX/IAS. For further details
see RSX/IAS manuals. A few error codes have been added,  see
appendix F.
 
 
 
 
2.9.4 ORD
 
The  ORD  function  can  also take a pointer or a set (of 16
elements or less) as an argument. The integer result will be
the 16 bit representation of the argument.
 
 
 
 
 
 
 
 
6-NOV-1985                - 21 -               PDP-11 Pascal


 
 
2.10 Procedures and functions as parameters

This implementation of Pascal has been  updated  to  conform
with  the  proposed  Pascal  standard  with  regard  to  the
declaration of formal procedures and functions.  (See  First
ISO  Draft Proposal for Pascal, ACM SIGPLAN notices, vol 15,
No. 4, April 1980). At the declaration of a formal procedure
or function, identifiers and types of its formal  parameters
must be specified.
 
   Example:
 
   program INTEGRATION (tty);

   function INTEGRATE ( function F (x: real): real;
                   lowbound, highbound, delta: real ): real;
           { Body } ...

   { Since standard functions cannot be actual parameters .. }
   function SINUS ( arg: real ): real;
       begin
       SINUS := sin(arg)
       end;

   begin
   writeln ( INTEGRATE (SINUS, 0.0, 3.14, 0.01)
   end.
 

Note  that  Fortran  procedures  and  functions and standard
procedures  and  functions  cannot   be   used   as   actual
parameters.
 
 
 
 
2.11 Separate compilation

It  is  possible to compile one or more procedures without a
main program. In that case, no program statement is  allowed
and  the  source  file  must  begin  with  an option comment
stating M-. For further details see paragraph 4.11 below.
 
Separately compiled procedures and functions can be accessed
if they are declared with the  procedure  body  replaced  by
EXTERN.  Fortran  and assembler-written routines can also be
accessed  if  their  parameter  transport   follows   Pascal
standard  or  Fortran. In the latter case the procedure body
 
 
6-NOV-1985                - 22 -               PDP-11 Pascal


 
 
should be replaced by EXTERN( FORTRAN ). (This gives  access
to  RSX executive directives through their FORTRAN interface
routines.) If the external name contains '$' or '.'  it  can
be given as a string constant.
 
    Eg.
        EXTERN( FORTRAN, '$TEST' )
 
 
Global  variables can be shared between the main program and
separately compiled procedure/functions. This is done in the
procedure by  declaring  the  shared  variables  before  the
procedure  heading.  Because there can be no checking across
separate compilations, it is the programmer's responsibility
for ensuring that these variables are  declared  in  exactly
the  same  way  in  both the main program and the procedure.
Good use can be made here of the compiler's include facility
or of a separate include preprocessor.
 
   Example:
        Main program                    Separate Procedure
        ------------                    ------------------

   program main;                        {$m-}

   type                                 type
       atyp = ...                           atyp = ...
       ctyp = ...
                                        var { global }
   var                                      a: atyp;
       a: atyp;                             b: integer;
       b: integer;
       c: ctyp;
                                        procedure proc;
   procedure proc; extern;
                                        var { local }
   begin { main }                           x: ...
     :                                      y: ...
     :
                                        begin { proc }
                                          :
                                          :
 
 
 
 
 
 
 
 
6-NOV-1985                - 23 -               PDP-11 Pascal


 
 
2.12    String parameters
 
Arbitrary  length  character  strings  can  be   passed   as
parameters   to  procedures  and  functions.  These  "string
paramaters" are declared using the word STRING.
 
    Eg.  PROCEDURE PA (...; STRING A,B,...; ...);
 
Both character arrays and string constants of any length can
be supplied as arguments for string parameters  and  can  be
modified  by  the  procedure.  Use  caution  here  because a
constant can be modified.
 
Within a procedure that is using  string  parameters,  these
will  always  be  treated  as  arrays of characters with the
first character at subscript 0. The standard  function  SIZE
can  be  used  to  obtain  the  actual  length of the passed
string.
 
    Eg.
        const
            C = 'named constant';

        var
            v:  packed array [1..8] of char;

        procedure  p ( string s );
            begin
            if size(s) >= 5 then ch := s[4]
            end;

        begin
        p (C);
        p ('string');
        v := 'variable';
        p (v);
        p (v[2..6]);
        p (C[0..4])
        end.
 
 
Note that there are only two ways in which string parameters
can be used:
 
   - as actual parameter to a procedure/function, or
   - to access a single character in the string.
 
Currently, the compiler will not give error  notice  when  a
 
 
6-NOV-1985                - 24 -               PDP-11 Pascal


 
 
string  parameter is used in other ways but the program will
fail at runtime.
 
A substring specification can be used as an actual parameter
for  a  parameter  that  has  been  declared  as  a   string
parameter. A substring specification has the form:
 
        A [ n..m ]
 
where  A  is  an  array  of  characters  or  a formal string
parameter and n and m are expressions  of  a  type  that  is
compatible with the subscript type of A. The values of n and
m  define  the bounds of the substring of A. If m equals n-1
then the substring has zero length (null string).
 
If runtime checks are in effect  then  for  each  use  of  a
substring specification, the following checks will be made:
 
      For  A [ n..m ] :

         1.  check that m >= n-1

         2.  if m >= n (ie. non-zero length) then check
             that both n and m are within the bounds of
             the array A.
 
 
Substrings  can  also  be used as parameters to the standard
procedures WRITE, WRITELN, READ, REWRITE and RESET.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 25 -               PDP-11 Pascal


 
 
Example:

     var
         line:  packed array [1..80] of char;
         i, j, k, s:  integer;

     begin

     { Parse a file specification in line }

     i := 1;
     while (i<80) and (line[i]=' ') do i := i + 1;
     s := i - 1 ;
     j := s ;
     k := s ;
     while (i<80) and (line[i]<>' ') do
         begin
         if (line[i]=':') and (k=s) then
             begin  j := i ;  k := i  end;
         if line[i] = ']' then  k := i ;
         i := i + 1
         end;


     { Create file f with given file spec }

     rewrite (f,                     { file }
              line [k+1..i-1],       { file name }
              line [j+1..k],         { directory }
              line [s+1..j]);        { device }
     if ioresult(f) < 0 then error;
 
 
 
 
2.13 Structured function results
 
The result of a function is not limited to scalar,  subrange
or  pointer  types; the result can be of any structured type
also.
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 26 -               PDP-11 Pascal


 
 
2.14 Boundless array parameters
 
The parameter mechanism  in  Pascal  is  extended  to  allow
procedures  that  can  take  differently  declared arrays as
parameters. (Also known as "conformant  array  parameters".)
This is achieved by declaring the parameter as VAR <params>:
ARRAY[<type>,...] OF type, e.g.
 
PROCEDURE MATADD(VAR A,B,C: ARRAY[INTEGER,INTEGER] OF REAL);.
 
Such  procedures can be called with any array with the right
number of dimensions as actual parameter. The  same  element
is  selected if the same indexvalue is applied to the formal
and to the actual array.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 27 -               PDP-11 Pascal


 
 
2.15 Examples


2.15.1 Updating a Sequential File

{ Example program - updating a sequential file.
  This program applies modifications to records in an existing
  sequential file (Staff).  No records are added or deleted.
  The modifications are obtained from file 'Updates' which must
  be sorted in order of employee number. }

program modify (tty);


type
    Emp_no_type = 0..9999;
    Name_type = packed array [1..30] of char;
    Person_type = record
        Name:    Name_type;
        Emp_no:  Emp_no_type;
        Salary:  1..MAXINT;
        end;


var
    Emp_no:      Emp_no_type;
    New_salary:  integer;
    Staff:       file of Person_type;
    Updates:     text;



procedure error ( x: integer );
begin
writeln ('ERROR ', x:1);
halt
end;  { error }



begin  { main program }

rewrite (Staff,,,, [UPDATE, INSERT]);
if ioresult(Staff) < 0 then  error (1);

reset (Updates);
if ioresult(Updates) < 0 then error (2);

 
 
6-NOV-1985                - 28 -               PDP-11 Pascal


 
 
while not eof(Updates) do
    begin
    readln (Updates, Emp_no, New_salary);
    while (Staff^.Emp_no <> Emp_no)
    and not eof(Staff) do  { locate given employee }
        get (Staff);
    if eof(Staff) then error (3);  { Employee not found }
    Staff^.Salary := New_salary;
    put (Staff);  { Update this record }
    if ioresult(Staff) < 0 then error (4);
    end;  { while }

end.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 29 -               PDP-11 Pascal


 
 
2.15.2  Updating a Random Access file

{ Example program - updating a random access file.
  This program applies modifications to records in an existing
  random file (Staff).  No records are added or deleted.  The
  modifications are obtained from file 'Updates' which can
  contain updates in any order of employee number. }


program modify (tty);


type
    Emp_no_type = 0..9999;
    Name_type = packed array [1..30] of char;
    Person_type = record
        Name:    Name_type;
        Emp_no:  Emp_no_type;
        Salary:  1..MAXINT;
        end;


var
    Emp_no:      Emp_no_type;
    New_salary:  integer;
    Staff:       file of Person_type;
    Updates:     text;



procedure error ( x: integer );
begin
writeln ('ERROR ', x:1);
halt
end;  { error }



begin  { main program }

rewrite (Staff,,,, [RANDOM, UPDATE]);
if ioresult(Staff) < 0 then  error (1);

reset (Updates);
if ioresult(Updates) < 0 then error (2);

 
 
 
 
6-NOV-1985                - 30 -               PDP-11 Pascal


 
 
while not eof(Updates) do
    begin
    readln (Updates, Emp_no, New_salary);
    get (Staff, Emp_no);  { Position to required record }
    if eof(Staff) then error (3);  { Employee not found }
    Staff^.Salary := New_salary;
    put (Staff);  { Update this record }
    if ioresult(Staff) < 0 then error (4);
    end;  { while }

end.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 31 -               PDP-11 Pascal


 
 
3 RESTRICTIONS

3.1 Reserved words

The following words are also reserved:
 
        LOOP EXIT OTHERS EXTERN FORWARD OTHERWISE
 
 
 
 
3.2 Packed structures

Packed data structures are only  implemented  for  character
arrays  (always packed, two char's per word) and for Boolean
arrays (packing optional,  one  Boolean  per  bit).  Use  of
procedures  PACK  and  UNPACK  is  allowed  but no action is
taken.
 
 
 
 
3.3 GOTO statement

The GOTO statement is restricted to allow only local  GOTO's
(within the same procedure/function).
 
 
 
 
3.4 SET size

The  representation of sets is chosen so that a set may have
at most 64 members.
 
 
 
 
3.5 File declarations

A file that is declared in a procedure  must  be  explicitly
closed  (if  it  is opened) before exit from that procedure.
See procedure CLOSEF in appendix H.
 
 
 
 
 
 
 
6-NOV-1985                - 32 -               PDP-11 Pascal


 
 
3.6 Parameter transmission

Pre-defined procedures  or  functions  or  external  Fortran
routines may not be passed as actual parameters.
 
 
 
 
3.7 Definition level 0 and 1

The compiler can be generated with a predeclaration level of
0,  1,  2 or 3. The level can also be chosen at compile time
through the switch /A:n on the  object  file  specification,
see  point  4.1  below.  Level 1 is exactly standard Pascal,
level 0 is restricted to give the  compiler  more  workspace
(no predeclared arithmetic functions).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 33 -               PDP-11 Pascal


 
 
4 COMPILER OPTIONS AND SWITCHES

When  compiling  a  Pascal  program it is possible to select
some special features called options.  All  option  switches
have  default  values.  Some  can be changed dynamically and
some may be set only  before  the  first  statement.  Option
switches  are  turned  on and off through comments beginning
with '$'  (  =chr(44B))  followed  by  one  or  more  option
selectors,   separated   by  commas.  Each  option  selector
consists of one letter followed  by  '+'  or  '-'.  Example:
(*$L+,C-,M+*).  The  default  values  listed  below  may  be
changed at compiler generation time.

Most option switches can  also  be  set  with  command  line
switches. These override all selecting of the same option in
the  source  code.  The switches follow RSX/IAS standard but
only one character is significant.
 
        Eg. /EI/-CC/MM .
 
 
 
 
4.1 Predeclaration level: A

The  compiler  always  has  some  names  predeclared,   i.e.
INTEGER,  TRUE  etc.  All  names  occupy data space when the
compiler is run. For large programs, and  for  compatibility
reasons  it  can  be  of  interest  to  reduce the number of
predeclared  types,  functions  etc.  to  a  minimum  or  to
standard  Pascal.  The  predeclaration  level is selected at
compiler generation time, but can  be  reset  for  a  single
compilation  through  the command line switch /A followed by
an unsigned integer. Examples: /AA:1, /A0 .
 
Level   Restriction (-) or extension (+)
  0     - arithmetic functions ( sin, cos etc. )
  1     standard Pascal
  2     + maxint,minint,maxreal,minreal,smallreal
        + text,ascii,byte,alfaleng
  3     + ( 2 ),   + iospec
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 34 -               PDP-11 Pascal


 
 
4.2 Listing of generated code: C

This switch can  be  changed  dynamically.  When  C+  is  in
effect,  statement addresses (octal) will be included on the
program listing and the  symbolic  generated  code  will  be
output  to the CXP file (ie. 3rd output file spec on command
line) if any was specified.
Default: C-.
 
 
 
 
4.3 Debug: D
 
A symbolic interactive debugger can be included in  a  task.
The  program  has  to be compiled with option D+. The option
can be switched on and off in the program  but  the  program
statement  must  be compiled with D+ in effect. The debugger
is described in a separate document.
 
 
 
 
4.4 Extended instruction set, EIS: E

The compiler generates MUL and DIV instructions if option E+
is  selected,  otherwise  these  operations  are   performed
through subroutines. (E+ is implied by F+ or G+)
 
 
 
 
4.5 Floating point processor, FPP: F

The floating point processor hardware for some PDP-11 models
can  be  used if option F is selected. For a program made up
of several  separately  compiled  modules,  if  any  of  the
modules are compiled with the F option then the main program
module must also be compiled with F.
 
 
 
 
4.6 Floating instruction set, FIS: G

The  PDP 11/35 and 40 floating point hardware can be used if
option G is selected.
 
 
 
6-NOV-1985                - 35 -               PDP-11 Pascal


 
 
4.7 Error handling and conversion selection: H

When a Pascal program is executed certain errors can  occur,
i.e.  index  out  of  bounds.  See appendix F for a complete
list. They are  grouped  into  three  categories:  messages,
warnings and fatal errors. Message and warning printouts can
be  suppressed,  and  it  is  possible to continue execution
after warnings and even after errors. It is also possible to
choose to skip spaces after reading integers  and  reals  in
addition  to  only  before.  The choices are made through an
integer following H+. The value is the sum  of  any  of  the
following selections:
 
        Value   Meaning
          1     print warnings
          2     continue after warning
          4     continue after fatal error
          8     print messages
         16     skip spaces after read integer/real
 
        Example:   (*$H+19*).
 
Default 3 = print warnings and continue after warnings. H is
not selectable through a command line switch.
 
The  value  of  the  selection  can  also be modified by the
program by calling the SLCTDF procedure (see appendix H).
 
 
 
 
4.8 Include source file: I
 
The compiler can include source text from a given file. This
is  particularly  useful  for  declaring  global  types  and
variables  to  separately  compiled procedures. The included
source may include source from another  file  to  a  nesting
depth  of three. A complete file specification (in uppercase
only) with device and  directory  can  be  given  after  I+.
Defaults are SY0: and file type .PAS. If the I- form is used
then  the  listing of the included source will be suppressed
(equivalent to L-). No other option can appear in  the  same
comment after one of these.
Example: {$I+DM1:[77,1]COMTYPES.PAS}
          {$I-FILEA}
 
 
 
 
 
6-NOV-1985                - 36 -               PDP-11 Pascal


 
 
4.9 Program listing: L

Listing  of  the  source  program may be switched on and off
during compilation. Default: L+. If no  listing  at  all  is
wanted,  the  listfile specification can be omitted from the
command line. There is no corresponding command line switch.
 
 
 
 
4.10 Line width: L

The  maximum  number  of  characters  printed  per  line  is
selectable  in  the same way as the page width (P). The line
splitting can occur in the middle of a Pascal symbol.
Example: /LW:72, /L132.
Default: /L132.
 
 
 
 
4.11 Main program: M

It is possible to compile a set of procedures and  functions
separately.  In  this case, no PROGRAM statement and no main
program may be given, and the source text must begin with an
option selection of  M-.  The  last  procedure  or  function
should  end  with  a  period (.) instead of a semicolon (;).
Default: M+.
 
 
 
 
4.12 Page width: P

It is possible to select the maximum number of lines printed
per page through a switch on the  list  file  specification.
Normally  a  suitable  page  width  is  selected at compiler
generation time
Example: /PW:50, /P29
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 37 -               PDP-11 Pascal


 
 
4.13 Page eject: P

There are two ways to force the compiler to start on  a  new
page after the current line. The character form feed and the
option P+ both give this effect. P+ is reset afterwards.
 
 
 
 
4.14 Frequency measurement: Q

It is possible to get the compiler to insert instructions in
the generated code that count the number of times statements
are  executed.  The measuring points are inserted before the
first beginning of a statement in each line  of  the  source
code.
 
Example, (**) = measuring point:
        (**)    for i:=1 to 5 do
        (**)    a[i]:=0;
        (**)    if i=3
                then    (**)    x:=2.0
                else    (**)    x:=0.0;
 
This  option  must be selected before the program statement,
but may be switched on and off after the program statement.

After execution of a program compiled with Q+ or /Q, a  file
of  name <source file name>.FQV is produced. It contains the
measuring information in a form ready for printing (i.e. PIP
EX.FQV/SP).
 
If R- is selected only  the  beginnings  of  procedures  and
functions  are measured, and if both R- and T- are in effect
no measuring at all is performed.
 
Note that the storage for the execution  counts  is  in-line
with  the  code being executed. As such, frequency measuring
destroys the read-only nature of the generated code.
 
 
 
 
4.15 Runtime checks: R

This option controls the generation of in-line  object  code
to   perform   important   runtime  checks  of  a  program's
execution. These checks include array index checks and value
 
 
6-NOV-1985                - 38 -               PDP-11 Pascal


 
 
range  checks  on  assignment  to  subrange  variables   and
parameters.  Other  error  checks  required  by  the  Pascal
Standard are not currently performed. These include: variant
record errors, range errors on sets, dereferencing through a
nil pointer, no assignment to function result, illegal  uses
of  variant  records  allocated  with NEW, and case selector
errors. Default: R+ (generate checking code).
 
Other errors such as division by  zero,  square  root  of  a
negative  number,  attempt  to read beyond end of file, etc.
are detected and reported by the runtime  library  routines.
The error checking in these routines is always enabled.
 
 
 
 
4.16 Trace: S
 
The  compiler  will generate calls to a runtime routine that
will display the current line number on  the  TI:  terminal.
The  trace  points are at each source line where a statement
begins. The option may be switched on/off at  any  point  in
the program or selected on the command line.
Default: S-.
 
 
 
 
4.17 Dynamic storage checks: T

The  compiler  can  generate  checks  of dynamic storage and
stack allocation at procedure and function entry  and  calls
of NEW. Default: T+.
 
 
 
 
4.18 Spool listfile: U

The  listfile is normally not spooled. It will automatically
be printed if  the  switch  /U  is  given  on  the  listfile
specification in the command line.
 
 
 
 
 
 
 
 
6-NOV-1985                - 39 -               PDP-11 Pascal


 
 
4.19 Object module version: V

The  object  modules  that  are  generated  can  get version
information, which the linker will print  on  the  map.  The
version   identifier  consists  of  up  to  six  alfanumeric
characters after V+. Example: (*$V+PAS500*). There is no  /V
switch in the command line.
 
 
 
 
4.20 Warning suppression: W

Error  messages  classified as warnings may be suppressed by
selecting option W-. Warning error numbers are > 900.
Default: W+.
 
 
 
 
4.21 Conditional compilation: X and Z

It is possible to write test statements which generate  code
only if option X+ is selected.
Default: X-.

The  conditional  parts  of  the  code must be enclosed in a
special option parenthesis, (*$Z+*) <conditionally  compiled
code> (*$Z-*).
 
 
 
 
4.22 Object module splitting: Y

The  generated  object code can be split into several object
modules (in one file) by means of option Y+.  All  procedure
bodies whose compilation start with Y+ in effect will become
separate  object  modules in the object file. This option is
implemented to allow large programs to be  overlaid  in  PDP
11.
Default: Y-.
 
 
 
 
 
 
 
 
6-NOV-1985                - 40 -               PDP-11 Pascal


 
 
5 REPRESENTATION

5.1 Scalars

Integers,  booleans  and  characters  occupy  one word each.
Reals occupy two words with one sign bit, one exponent  sign
bit,  seven exponent bits and a mantissa of 23 bits plus one
bit hidden. Sets of up to 16 members  occupy  one  word  and
sets of up to 64 members occupy four words.
 
 
 
 
5.2 Arrays
 
Character  arrays are always packed two characters per word.
Booleans, in unpacked  arrays,  occupy  one  word  each,  in
packed arrays, one bit each, that is, 16 per word.
 
 
 
 
5.3 Files

See  also  RSX/IAS I/O Operations Reference Manual. Non-text
files are represented as fixed length record files with  one
record  for  each  file  component. Text files have variable
length records, one line per record with a  maximum  of  132
characters  per line. I/O is done in locate mode unless ran-
dom or update access  has  been  selected.  File  descriptor
blocks  are  allocated  in  the stack and a file declaration
thus reserves 108 bytes plus the size of one record  of  the
file. For text files, a 132 byte buffer is reserved.
 
 
 
 
5.4 Stack and heap

The  stack and heap are given a contiguous area in which the
stack grows from one end and the heap from the other. Dynam-
ic storage is allocated on the heap while  static  variables
and  parameters  are  placed  on  the  stack. This area is a
P-section named $99999 which is normally  allocated  at  the
end  of  the  task image. Runtime errors will occur if it is
not  placed  there  (except  for  memory  resident  overlaid
tasks). (See sections 1.2, 1.3)
 
 
 
6-NOV-1985                - 41 -               PDP-11 Pascal


 
 
5.5 Parameter transmission

A  Pascal program has a special stack for allocation of data
and for parameter transmission. The Pascal stack is accessed
through register R5. The first parameter is pushed first and
the last item pushed is a special link word.  This  link  is
used  for  accessing variables at intermediate levels and is
of no value to assembler routines. An assembler routine, de-
clared in a Pascal program as:
 
        function A ( i, j: integer;
                     c: char;
                     var x: xtyp;
                     string s ); extern;
 
will receive a stack as follows:
 
        14.(R5):        reserved for result (functions only)
        12.(R5):        value of i
        10.(R5):        value of j
         8.(R5):        value of c
         6.(R5):        address of x
         4.(R5):        address of first character of s
         2.(R5):        length of s in bytes
           (R5):        link
 
Each parameter occupies an area large enough to hold its va-
lue, ie. entire arrays and records are copied to the  stack.
However, for parameters declared with the VAR attribute, on-
ly  the  address of the actual parameter is transmitted. For
arrays, the address given is the address of  a  hypothetical
zeroth  element  of the array (this can be odd for character
arrays).
 
The link and all parameters must be removed from  the  stack
before  return  (by  RTS PC). For functions, an area for the
result is reserved on the stack before  the  parameters  are
pushed. At return, R5 will thus point to this area.
 
Assembler routines called from Pascal can alter registers 0,
1 and 2 but must preserve registers 3, and 4.
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 42 -               PDP-11 Pascal


 
 
6. The Runtime Environment
 
The Pascal runtime system uses only local event flag #5.
 
Logical  unit number 5 is always assumed by the runtime sys-
tem to be the initiating terminal, TI:. It is used as  stan-
dard file TTY as well as for reporting runtime errors. Logi-
cal  units  1 to 4 and 6 to 17 are used for all other Pascal
files including standard files INPUT and OUTPUT. The maximum
number of Pascal files  that  can  be  used  simultaneously,
apart from TTY, is sixteen.
 
I/O  to/from  file  TTY is done with direct QIO's. All other
Pascal I/O is done via FCS except when BLOCK access is spec-
ified (see 2.8.4). Therefore, the number of  FCS  I/O  block
buffers  required by a task is equal to the number of simul-
taneously used Pascal files (excluding TTY). This is  speci-
fied  to  the  task builder with the ACTFIL option. Also, if
more than 5 files are to be used, the task builder  must  be
informed  with  option  UNITS=n  where  n  is  the number of
non-TTY files, plus one, that will be used simultaneously.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 43 -               PDP-11 Pascal


 
 
7.  Comparison with Standard Pascal

The following sections describe the relation of DECUS Pascal
to the ISO and ANSI/IEEE Pascal Standards. The International
Standards Organization's  (ISO/TC  97/SC  5)  standard  7185
(Level  0)  and  the American National Standards Institute's
Pascal Standard (ANSI/IEEE 770X3.97-1983) are, for all prac-
tical purposes, identical and will be referred  to  as  'the
Standard'.  The Standard differs with and extends the origi-
nal definition of Pascal published in the Pascal User Manual
and Report (2nd edition)  by  Kathleen  Jensen  and  Niklaus
Wirth (Springer Verlag 1978). The differences are too numer-
ous and detailed to list here.
 
DECUS  Pascal  was originally developed before the emergence
of the Standard and therefore has many features that deviate
from the Standard. Recent modifications have brought it into
closer compliance with the Standard. But it has been a poli-
cy to avoid making drastic changes so that existing programs
will compile with few or no changes under  new  versions  of
the compiler.
 
 
 
 
7.1  Conformance
 
Conformance to the Pascal Standard is the property of a Pas-
cal  processor (compiler and runtime system) that enables it
to process a correct standard Pascal program  in  accordance
with the Standard.
 
DECUS  Pascal  fails to conform to the following sections of
the Standard:
 
a. Section 6.1.3, Identifiers
   The Standard stipulates that identifiers can  be  of  any
   length  and that all characters of an identifier shall be
   significant.  This  implementation  recognizes  only  the
   first 10 characters of identifiers.
 
b. Section 6.1.9, Lexical Alternatives
   The  alternative comment delimiter pairs {} and (* *) are
   not treated as equivalent as required  by  the  Standard.
   Therefore  a  comment  that  is opened with { will not be
   closed with *) and a comment that is opened with (*  will
   not be closed with }.
 
 
 
6-NOV-1985                - 44 -               PDP-11 Pascal


 
 
c. Section 6.2.2, Scope
   There  is  a subtle problem with the overlapping of scope
   of identifiers. This is best explained with an example.
 
           program prog;

           type
               node = real;

           procedure proc;
           type
               p = ^node;
               node = boolean;
           var
               ptr: p;
           begin { proc }
               new (ptr);
               ptr^ := true;
           end; { proc }

           begin { prog }
           proc;
           end.
 
   This correct program will not compile properly because at
   the type definition statement (p=^node) the type of  node
   will be taken as real when it should be boolean.
 
d. Section 6.4.3.4, Set Types
   The  implementation  of  set  of char is restricted to 64
   members, [' '..'_'].
 
e. Section 6.6.5.4, Transfer Procedures
   Statements calling the required procedures pack  and  un-
   pack  will  compile  correctly but will have no effect at
   execution time.
 
f. Section 6.6.6.2 Required Arithmetic Functions
   The arctan function is not implemented.
 
g. Section 6.7.1, Expressions
   A set constructor expression of the form [x..y]  where  x
   and  y are variables cannot be compiled with this version
   of the compiler.
 
h. Section 6.8.2.4, Goto Statements
   A goto statement that attempts to transfer  control  out-
   side of its containing procedure/function is not allowed.
 
 
6-NOV-1985                - 45 -               PDP-11 Pascal


 
 
i. Section 6.9.3.4, Writing Real Numbers
   Real  numbers  written to a text file do not have exactly
   the representation required by the Standard.
 
 
 
 
7.2  Deviation
 
The compiler accepts many variations of  the  language  that
are  not part of Standard Pascal. These deviations generally
do not impare the compiler's ability to correctly process  a
Standard  program.  Programmers attempting to write portable
programs should beware of these deviations.  The  deviations
are  listed  here with the number of the relevant section of
the Standard.
 
 
- 6.1.2: Extra reserved words are defined (see Appendix C).
 
- 6.1.2: 'NIL' is not a reserved word.
 
- 6.1.2: Colon and '..' are equivalent.
 
- 6.1.2: Ampersand (&) is accepted  as  a  substitution  for
  'and'.
 
- 6.1.6: Labels greater than 9999 are accepted.
 
- 6.1.7: A null (zero length) string is accepted.
 
- 6.1.7: Indexing into a constant string is acceptable.
 
- 6.1.7: Unpacked and packed char arrays are compatible.
 
- 6.1.7: Strings can have lower bound not equal to one.
 
- 6.1.7:  Packed  arrays of subranges of char are compatible
  with strings.
 
- 6.1.8: No space is required between a number  and  a  word
  symbol.
 
- 6.1.9:  Assignment  to  a  function identifier outside the
  function is not flagged as an error.
 
- 6.3: A sign in front of a char is accepted.
 
 
 
6-NOV-1985                - 46 -               PDP-11 Pascal


 
 
- 6.4.3.2: Strings can be  defined  with  non-integer  index
  types.
 
- 6.4.3.3:  In the definition of a variant record type, more
  case constants are allowed than are available in the  type
  of the tag.
 
- 6.4.5: The Pascal Standard defines the notion of type com-
  patibility  and  requires,  in general, that types must be
  the same in order to be considered compatible.  This  com-
  piler  however  uses a much more lenient interpretation of
  compatibility, requiring that types only have to have  the
  same  structure  to  be compatible. Consider the following
  example program fragment.
 
 
          type
              t1 = record
                   a: integer;
                   b: boolean;
                   end;
              t2 = record
                   a: integer;
                   b: boolean;
                   end;
              t3 = t1;

          var
              r1:  t1;
              r2:  t2;
              r3:  t3;

          begin
          r1 := r2;   { Non-standard }
          r1 := r3;   { Standard }
          end
 
 
  This program is acceptable to this compiler but the  first
  assignment statement is between variables that do not have
  the  same  type  and  would  therefore  be  rejected  by a
  non-deviating compiler.
 
- 6.6.2: Functions can have non-simple types.
 
- 6.6.3.3: A variant record tag field is allowed  as  a  var
  parameter to a procedure.
 
 
 
6-NOV-1985                - 47 -               PDP-11 Pascal


 
 
- 6.6.3.3: A char component of a packed structure is allowed
  as a var parameter.
 
- 6.7.2.5:  Comparison  of records or arrays for equality is
  allowed. Note that, if this feature is used, care must  be
  taken  against  comparing  structures that contain 'slack'
  bytes in their representations. For example, the record
 
          r:  record
              a:  char;
              b:  integer;
              end
 
  has an unused byte between the char and  the  integer  be-
  cause the char occupies only one byte and the integer must
  be  word  aligned in memory (on an even byte address). The
  programmer has no control over what may be stored  in  the
  slack  byte since it cannot be directly assigned to. A di-
  rect comparison of two structures is implemented by a run-
  time routine that scans through the  structures  comparing
  all  bytes  of the two structures. Therefore random values
  in slack bytes will cause incorrect results.
 
- 6.8.2.4: The rules in the Standard limiting  the  destina-
  tion  of  a goto are not enforced. Use extreme care if you
  attempt a goto into a case or for  statement.  Most  often
  this will corrupt the runtime stack.
 
- 6.8.3.9:  The  control  variable of a for statement can be
  altered by an assignment or a read  statement  inside  the
  for statement.
 
- 6.8.3.9:  Making  use of a for loop control variable after
  the for statement without first reassigning to it is  per-
  mitted (but not advisable).
 
- 6.10: Non-distinct program parameters are accepted.
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 48 -               PDP-11 Pascal


 
 
7.3  Error Handling
 
The  Pascal Standard stipulates various conditions of a pro-
gram which should be reported as errors  either  at  compile
time or at run time. Several of these are not implemented in
DECUS  Pascal.  They are listed here along with the relevant
section numbers in the Standard.
 
 
- 6.2.1: Use of an uninitialized variable.
 
- 6.4.3.3: Illegal references to variants of a  variant  re-
  cord.
 
- 6.4.6:  Assignment (or use as a var parameter) of a set of
  a subrange type T1 to a set defined with a  different  su-
  brange  T2  when  the T1 set contains elements outside the
  range of T2.
 
- 6.5.4: De-referencing through a nil or undefined pointer.
 
- 6.5.5: Changing the current file position of a file  while
  the buffer variable is an actual var parameter to a proce-
  dure.
 
- 6.6.2:  Exiting  from  a function without assigning to the
  function result.
 
- 6.6.5.2: Doing a put to a file while eof is not true.
 
- 6.6.5.3: Making use of a variant record that  was  created
  with  new, as an actual parameter, in an expression, or on
  the left side of an assignment statement.
 
- 6.6.6.2: Invoking the logarithm function ln with  a  nega-
  tive argument.
 
- 6.6.6.5:  Invoking function eoln on a file that is positi-
  oned at eof.
 
- 6.7.2.2: Integer overflow.
 
- 6.7.2.2: i mod j with j negative.
 
- 6.8.3.5: Executing a case statement when the case selector
  value does not match any of the  case  constants  and  the
  otherwise clause is not present. (Control just goes to the
  next statement after the case.)
 
 
6-NOV-1985                - 49 -               PDP-11 Pascal


 
 
- 6.8.3.9:  Nested  for statements that use the same control
  variable.
 
- 6.9.3.2: Using a negative field width  value  in  a  write
  statement.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 50 -               PDP-11 Pascal


 
 
                         APPENDICES
                         ==========
 
 
 
A. Character set

The  compiler accepts all ASCII characters in the source in-
put. Lower case characters will be listed as such  but  will
be treated as uppercase except in strings. Two control char-
acters  are recognized, HT (tab) and FF (formfeed); all oth-
ers are converted to  SP  (space).  The  formfeed  character
forces  the  listing to a new page. Comments can be enclosed
in braces: {...}.
 
For historical reasons, comments may be enclosed in  percent
and backslash characters ( eg. %Comment\) as well as (*...*)
and {...}.
 
In  Pascal programs, character variables can take on any va-
lue from chr(0) to chr(377B). However, since sets are limit-
ed to 64 elements, only a limited range of characters can be
elements of a set of characters. This range is encircled  in
the following table.
 
 
            0   1   2   3   4   5   6   7

        00  NUL SOH STX ETX EOT ENQ ACK BEL
        01  BS  HT  LF  VT  FF  CR  SO  SI
        02  DLE DC1 DC2 DC3 DC4 NAK SYN ETB
        03  CAN EM  SUB ESC FS  GS  RS  US
   --------------------------------------------
   I    04  SP  !   "   #   $   %   &   '     I
   I    05  (   )   *   +   ,   -   .   /     I
   I    06  0   1   2   3   4   5   6   7     I
   I    07  8   9   :   ;   <   =   >   ?     I
   I    10  @   A   B   C   D   E   F   G     I
   I    11  H   I   J   K   L   M   N   O     I
   I    12  P   Q   R   S   T   U   V   W     I
   I    13  X   Y   Z   [   \   ]   ^   _     I
   --------------------------------------------
        14  `   a   b   c   d   e   f   g    
        15  h   i   j   k   l   m   n   o    
        16  p   q   r   s   t   u   v   w    
        17  x   y   z   {   |   }       DEL 
 
 
 
 
6-NOV-1985                - 51 -               PDP-11 Pascal


 
 
B. Special symbols

Table of special symbols with their meaning.
 
    Stand-  Altern- Meaning
    ard     ative(s)

    :=              assignment
    +               with one operand: identity
    -               with one operand: negation
    +               with two operands: addition
    -               with two operands: subtraction
    *               multiplication
    /               real division
    div             integer division
    mod             remainder
    =               equal
    <>      #       not equal
    <               less
    >               greater
    <=              less or equal, set inclusion
    >=              greater or equal, set inclusion
    in              set membership
    not             negation
    or      !       disjunction
    and     &       conjunction
    +       ! or    set union
    -               set difference
    *       & and   set intersection
    {       (* %    start of comment
    }       *) \    end of comment
     .              decimal point
     .              end of program
     ..             subrange constructor
    ,               comma
    :               colon
    ;               statement separator
    '               string delimiter
    (               left parenthesis
    )               right parenthesis
    [       (.      left bracket
                    set constructor
    ]       .)      right bracket
                    set constructor
    ^               pointer constructor
    $               option constructor
 
 
 
 
6-NOV-1985                - 52 -               PDP-11 Pascal


 
 
C. Reserved words


The following words are reserved:
 
        if      do      of      to      in
        or      end     for     var     div
        mod     set     and     not     then
        else    with    goto    loop    case
        type    file    exit    begin   until
        while   array   label   const   others
        repeat  record  downto  packed  extern
        forward function        otherwise  procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 53 -               PDP-11 Pascal


 
 
D. Pre-defined procedures

This is a list of pre-defined procedures, with an indication
of parameter types.

    Input/output:

      RESET (FILE, STRING, STRING, STRING, SET)
      REWRITE (FILE, STRING, STRING, STRING, SET)
      GET (FILE)
      GET (FILE,INTEGER)
      PUT (FILE)
      PUT (FILE,INTEGER)
      PAGE ([FILE])
      READ ([FILE,] INTEGER or REAL or CHAR or STRING, ... )
      READLN ([FILE,] INTEGER or REAL or CHAR or STRING, ... )
      WRITE ([FILE,] INTEGER or REAL or CHAR 
                             or BOOLEAN or STRING, ... )
      WRITELN ([FILE,] INTEGER or REAL or CHAR 
                               or BOOLEAN or STRING, ... )
      BREAK
        Where FILE is optional, the standard text file INPUT
        or  OUTPUT will be implied by default if it has been
        declared (ie. in the program statement).  Otherwise,
        the text file TTY will be assumed if it has been de-
        clared.  If none of these have been declared then an
        error will be flagged.
 
    Execution control:

      HALT

    Administration of dynamic storage:

      NEW (POINTER)
      NEW (POINTER, variant selector, ... )
      NEW (POINTER: size)
      MARK
      RELEASE

    Miscellaneous:

      DATE (STRING)     ( packed array [1..10] of char )
      TIME (STRING)     ( packed array [1..10] of char )
 
 
 
 
 
 
6-NOV-1985                - 54 -               PDP-11 Pascal


 
 
E. Pre-defined functions

This is a list of pre-defined functions with  an  indication
of parameter types.
 
      Mathematical functions:

        ABS(INTEGER or REAL): INTEGER or REAL
        COS(INTEGER or REAL): REAL
        EXP(INTEGER or REAL): REAL
        LN(INTEGER or REAL): REAL
        SIN(INTEGER or REAL): REAL
        SQR(INTEGER or REAL): INTEGER or REAL
        SQRT(INTEGER or REAL): REAL

      Conversion routines:

        ROUND(REAL): INTEGER
        TRUNC(REAL): INTEGER
        CHR(INTEGER): CHAR
        ORD(any type occupying one word): integer;

      Miscellaneous:

        ODD(INTEGER): BOOLEAN
        EOF([FILE]): BOOLEAN
        EOLN([FILE]): BOOLEAN
        IORESULT([FILE]): INTEGER
        PRED(any scalar except REAL): same as argument
        SUCC(any scalar except REAL): same as argument
        RUNTIME: INTEGER
        SPLITREAL(REAL,INTEGER): REAL
        TWOPOW(INTEGER): REAL
        SIZE (STRING-PARAMETER): INTEGER
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 55 -               PDP-11 Pascal


 
 
F. Error codes


F.1 Compile-time errors

       1      error in simple type
       2      identifier expected
       3      error in value part
       4      ')' expected
       5      ':' expected
       6      illegal symbol
       7      error in parameter list
       8      'of' expected
       9      '(' expected

      10      error in type
      11      '[' expected
      12      ']' expected
      13      'end' expected
      14      ';' expected
      15      integer expected
      16      '=' expected
      17      'begin' expected
      18      error in declaration part
      19      error in field list

      20      ',' expected
      21      constant expected
      22      'program' expected

      50      error in constant
      51      ':=' expected
      52      'then' expected
      53      'until' expected
      54      'do' expected
      55      'to'/'downto' expected
      56      'if' expected
      57      'exit' expected
      58      error in factor
      59      error in variable

      101     identifier declared twice
      102     low bound must not be greater than high round
      103     identifier is not of appropriate class
      104     identifier not declared
      105     sign not allowed
      106     number expected
      107     incompatible subrange type
 
 
6-NOV-1985                - 56 -               PDP-11 Pascal


 
 
      108     file not allowed here
      109     type must not be real
 
      110     tag field must be scalar or subrange
      111     incompatible with tag field type
      112     index type must not be real
      113     index type must be scalar or subrange
      114     base type must not be real
      115     base type must be scalar or subrange
      116     error in type of standard procedure parameter
      117     unsatisfied forward reference
      118     forward referenced type identifier in variable
              declaration
      119     forward declared: repetition of parameter list
              not allowed

      120     function result type must not be files
      121     file value parameter not allowed
      122     forward declared function:
              repetition of result type not allowed
      123     missing result type in function declaration
      124     fixed format for real only
      125     error in type of standard function parameter
      126     number of parameters does not agree with
              declaration
      127     illegal parameter substitution
      128     result type of parameter function does not
              agree with declaration
      129     type conflict of operands

      130     left operand of set membership test is not scalar or
              right operand is not of set type
      131     tests on equality allowed only
      132     strict inclusion not allowed
      133     file comparison not allowed
      134     illegal type of operand(s)
      135     type of operand must be boolean
      136     set element type must be scalar or subrange
      137     set element types not compatible
      138     type of variable is not array
      139     index type is not compatible with declaration

      140     type of variable is not record
      141     type of variable must be file or pointer
      142     illegal parameter substitution
      143     illegal type of loop control variable
      144     illegal type of expression
      145     type conflict
 
 
6-NOV-1985                - 57 -               PDP-11 Pascal


 
 
      146     assignment of files not allowed
      147     label type incompatible with selecting 
              expression
      148     subrange bounds must be scalar
      149     index type must not be integer
 
      150     assignment to standard function not allowed
      151     assignment to formal function is not allowed
      152     no such field in this record
      153     type error in read
      154     actual parameter must be a variable
      155     control variable must not be formal
      156     multiply defined case label
      157     too many cases in case statement
      158     missing corresponding variant declaration
      159     real and string tag fields not implemented

      160     previous declaration was not forward
      161     again forward declared
      162     slice variant separator is colon
      163     missing variant in declaration
      164     missing slice variant in declaration
      165     multiply defined label
      166     multiply declared label
      167     undeclared label
      168     undefined label
      169     error in tag field

      170     variant must have the same type as tag field

      180     standard file not in program statement
      181     'input', 'output' or 'tty' missing in program
              statement
      182     parameters to external Fortran routines must be
              var parameters
      183     body not allowed when not main
      184     assignment to function only in its body
      185     an element in a packed array of boolean may not be
              passed as a var parameter
      186     case label OTHERS must be last

      201     error in real constant: digit expected
      202     string constant contains 'eol'
      203     integer constant exceeds range
      204     8 or 9 in octal number
      205     real constant exceeds range
      206     octal output format for integers only

 
 
6-NOV-1985                - 58 -               PDP-11 Pascal


 
 
      250     too many nested scopes of identifiers
      251     too many nested procedures and/or functions
      253     too much code produced
      254     too many string/set/real constants in this
              procedure
      255     too many errors in this source line

      399     not implemented

      400     compiler error
 
      600     indextype of boundless array must be of scalar
              type (but not of type real)
      601     colon in parameter list must be followed by
              identifier or array symbol
      602     boundless arrays must be var specified
      603     standard functions/procedures are not allowed as
              actual procedure parameters
      604     ordinal numbers of setelements must lie in the
              range 0..63, or ' '..'_' for characters
      605     the set variables in an expression do not have
              the same base type
      606     base types of sets are incompatible
      609     fortran routines are not allowed as actual
              parameters

      610     integer constants required as actual parameters
      612     parameter list structure of formal and actual
              procedure are not the same
      617     parameter must have stringparm form

      626     only string parameters allowed as parameter to
              size function


      900-999 warnings only

      900     undeclared label
      901     unused declared label
      902     undefined option switch

      920     program statement missing ('input' and 'output'
              assumed)
      921     extraneous program parameter ignored

      931     too many procedures with the first 6 characters
              in their names equal

 
 
6-NOV-1985                - 59 -               PDP-11 Pascal


 
 
      940     source code "include" nesting > 3 not allowed
      941     error opening include file
      950     possibly unclosed comment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 60 -               PDP-11 Pascal


 
 
F.2 Runtime errors

Runtime  error messages are written on the terminal, and ap-
pear in the form

        PASRUN -- ERROR  nn mmmmm vvvvv

        where   nn = error number, see list below
                mmmmm = line number where error occured
                vvvvv = offending value (error 12 only).
 
The line number is not correct if the  error  appears  in  a
part  of  the  program  where  the runtime check option R is
switched off (R-). In such a case, the displayed line number
will be that of the last executed statement where R+ was  in
effect  or  the  starting line of the last entered procedure
where T+ was in effect.
 
It is possible to redefine the error  handling  at  compiler
generation  time, or in the source code through the option H
(see 4.7). Normal actions for the  three  classes  of  error
are:
 
  F:    Fatal errors.
        Continuation of the program is normally not
        possible or useful, and the program is
        therefore terminated.

  W:    Warnings.
        After having printed the error message, the
        program will continue execution.
        See the comments.

  M:    Messages.
        Conversion errors are normally only signalled
        through IORESULT, but messages can be printed.
        Execution continues afterwards.
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 61 -               PDP-11 Pascal


 
 
                       RUNTIME ERROR SUMMARY
                       ---------------------

Number  Kind of operation       Comments
------  -----------------       --------
    Class
    -----

10  F   Procedure entry or      Stack overruns heap
        dynamic allocation      or heap overruns stack.
                                Too many dynamic variables
                                created with NEW, or too many
                                recursive procedure calls.
                                (40 words left)

11  F   Same as 10              Hardware stack overflow
                                (20 words left)

12  F   Assignment or           Subrange overflow
        indexing in array       Index out of bounds
 
13  F   Program start           Floating point task was not
                                built with /FP switch.
 
20  F   Integer division        An attempt was made
        or modulo               to divide by 0

21  F   Integer division        Divisor was -32768
        or modulo               (most negative number)

23  F   Integer multiplication  First operand = -32768

30  W   All real operations     Exponent overflow
                                MAXREAL assumed

31  W   All real operations     Exponent underflow
                                Floating zero taken

33  F   Trunc or round          Floating number too
                                large

34  F   Real division           Attempt to divide by 0

40  M   Read integer            No digits after sign,
                                zero taken

41  M   Read integer            Number too large,
                                32767 taken
 
 
6-NOV-1985                - 62 -               PDP-11 Pascal


 
 

42  M   Read real or integer    Too many digits
 
44  M   Read real               No char's read,
                                floating zero taken

50  W   Exponentiation          Exponent overflow
                                MAXREAL taken

51  F   Square root             Square root of negative

60  F   Substring parameter     Substring range
                                out of bounds

61  F   Indexing in substring   Index out of bounds

66  F   Read or get             Attempt to read beyond
                                end of file
 
 
 
 
F.3 Result codes after I/O operations

The result codes received by IORESULT are the RSX/IAS codes.
Six new codes are added:
 
-101    too many files (RESET/REWRITE)
-102    file not opened (GET/PUT)
-103    too many digits (read integer or real exponent,
        MAXINT taken)
-104    no digits read (read integer or real exponent,
        zero taken)
-105    integer overflow (read integer: MAXINT taken,
        read exponent: MAXREAL taken)
-106    no digits read and "." or "E" not found
        (read real, 0.0 taken)
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 63 -               PDP-11 Pascal


 
 
G. Options and switches


All  default  values  can be changed at compiler generation.
The values listed are from the distribution set.


Name    Default Option/switch used for

A       3       Predeclaration level (switch only)
B
C       -       Printing of octal relative addresses
D       -       Debug
E       -       EIS
F       -       FPP
G       -       FIS
H       3       Runtime error handling (option only)
I       -       Include external source file
J
K
L       +       Listing on/off (option only)
        132     Line width ( switch only )
M       +       Main program
N
O
P       -       Page eject ( option only )
        55      Page width ( switch only )
Q       -       Frequency measurements
R       +       Runtime checks of indexbounds etc.
S       -       Trace
T       +       Runtime checks of stack/heap overflow
U       -       Spool listfile ( switch only )
V               Object module version
W       +       Print compiler warning messages
X       -       Conditional compilation
Y       -       Object module splitting
Z               Conditional compilation
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 64 -               PDP-11 Pascal


 
 
H. ADDITIONAL PROCEDURES AND FUNCTIONS


The following procedures  and  functions  are  available  in
SYSLIB/PASLIB and can be used if declared as:

      procedure GCML ( var s: line; var len: integer );
        extern;
        (* type line = array [1..80] of char .
           Returns the MCR command line in s and its
           length in len. *)

      procedure closef ( var f: <filetype> );   extern;
        (* closes the external file associated with
           the file parameter *)
           When more than one kind of file must be closed in
           the  same  program,  multiple declarations can be
           made by  using  the  following  procedure  names:
           CLOSF1, CLOSF2, CLOSF3, CLOSF4.

      procedure attach ( var f: <filetype> );   extern;
        (* issues a QIO with IO.ATT to the file *)

      procedure detach ( var f: <filetype> );   extern;
        (* issues a QIO with IO.DET to the file *)

      procedure slctdf ( i: integer );   extern;
        { Changes the error handling and conversion selection
          value to i  (see section 4.7).                      }

      procedure exitst ( i: integer );  extern;
        { Do task exit with status value i                    }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6-NOV-1985                - 65 -               PDP-11 Pascal
