Directory of image this file is from
This file as a plain text file
^^
.margins 9,72
.tabs relative
.page top 0,1
.page bottom 1,6
.header bottom center roman mixed
.title ##==================##P#A#S#C#A#L#-#S##==================
.page 1
PASCAL-S is a subset of the programming language PASCAL, defined by Niklaus Wirth
in Report No. 12 of the Institute for Infor- mation Science at the E.T.H. in
Zurich. This implementation of PASCAL was designed for a PDP-8/E with 28-K
words of processor memory, running under the OS/8 operating system.
.skip
RUNNING PASCAL-S
.p 8,1,4
Source program text may be created or revised with any of the OS/8 File Editors,
including MUTOR(1), EDIT and TECO. The standard source program suffix is .PS .
.footnote 5
^^
.margins 5,76
.blank 1
.c;________________________________________________________________________________
(1)MUTOR is a multi-user File Editor developed at HTL-Moedling. Version 04
is specially adapted to writing PASCAL source code, as it permits in-
clusion by reference of previously-written PASCAL procedures.
!
.skip
To compile and run PASCAL-S programs:
.skip
.indent 8;_.R PASCAL
.NO FILL
.indent 8;*DEV:OUTPUT.EX<DEV:SOURCE,DEV:INPUT.EX/Option(s)
.indent 10;output file source input file
.SKIP
#[ the default input and output 'file' is the user's terminal ]
.fill
.skip
SEQUENCE of OPERATIONS
.SKIP
1. The Compiler prints a header, with version and date.
.skip
2. The source program is listed on the user's
console. On the left
of each line is the decimal address of the code generated by the line.
.skip
3. If syntax errors are detected, they are flagged on a line immediately
below the source program line, thus:
.skip
.no fill
###20 COUNTER=COUNTER-1;
_#_#_#_#_##########_#51 (the = is an error)
.skip
.fill
At the end of the source program listing, the numeric error codes are
explained in plain language. PASCAL-S then returns to the OS/8 Monitor.
.skip
4. An error-free program is executed. At its termination,
the OS/8 Monitor is recalled. The user may re-run his program by typing START
in response to OS/8's prompt ('.'). This option is useful when I/O
is from/to the user's terminal. There is no way to respecify file I/O
without recompilation; PASCAL-S has no RESET or REWRITE.
.skip
Defaults common to other OS/8 programs apply also to PASCAL. For
example, an output file without a device name is written onto DSK:.
.page
SWITCHES (Decoder Options)
.skip
/S Silent compilation, i.e., no program listing is printed.
/H Halt after compilation, return to OS/8, wait for .START.
.skip
EXAMPLES:
.skip
_.R PASCAL
.LEFT MARGIN 21
.INDENT -12
*ROOT/S#####This runs DSK:ROOT.PS . No program listing is printed. The input
and output default to the user's terminal.
.skip
.indent -12
_.R PASCAL
.indent -12
*PLOT:<SYS:SPIRAL The program SPIRAL.PS on SYS: is compiled, listed,
and run.
Output goes to PLOT:, presumably a plotter.
Input, if required, is taken from the user's terminal.
.skip
.indent -12
_.R PASCAL
.indent -12
*DTA3:LIST.80<WAGES.DV,PTR:/H
.INDENT -12
_.START######DSK:WAGES.DV is compiled and listed. When the program is
STARTed, output goes to LIST.80 on Dectape _#3; input comes from the paper tape
reader. Handlers for PTR: generally prompt with _^ ; the user, when ready,
strikes the Return key or equivalent.
.left margin 9
.skip
The internal handler for terminal input prints ? whenever EOLN=true and
keyboard input is wanted. EOLN is forced on when a program starts to run.
The user then enters a line of data as required; the usual OS/8 facilities
(rubout, _^U, linefeed display) are available.
.skip
Numeric data should end in one or more blanks (spaces), even if the number
ends its line. Typing no blanks and Return triggers a repetition of the
? prompt.
.skip
RUN-TIME ERRORS
.p
These take the form ....Text.... ERROR AT xxx. The pro-
gram run is aborted. It can be re-_.STARTed (with, one assumes, different data).
The address #xxx# should be compared with the compiler listing of the source
program to localise the error.
.skip
SOURCE CODE
.p
This is written, interestingly, in excellent English and includes some
useful tables of core and field usage. PASCAL.SV uses fields 0-5 at compile-time,
with field 6 holding the error message explanations and the run-time
initialization routine. At run-time, fields 3-6 form the stack; the top two
bits of the stack pointer, plus 3, determine the field.
.PAGE
.C;Version#2:##EXTENSIONS#and#ENHANCEMENTS
.C;-------#-###----------#---#------------
.SKIP
1. A predefined procedure ASCII( ... ) with variable number of arguments,
intended to output special characters. The format is
.indent 8;ASCII(Arg1, Arg2, ... , Argi_i)
.skip
where the arguments may be any legal PASCAL expression of type Integer and
specify the decimal ASCII code of the desired character. All 8 bits are
transmitted, except that:
.skip
.indent 6;##0#gives unpredictable results (the contents of
.indent 10;location CHAR). Use 256 for a pure null character.
.indent 6;141#(octal 215) gives CR _& LF, 13 gives CR only.
.skip
2. A predefined function RANDOM of type Real without argument
returns random numbers uniformly distributed in the open interval 0,1 .
The cycle length is around 2_^33. The random numbers always appear in
the same sequence: to randomize, enter the sequence at an arbitrary point
by "eating" some numbers.
.skip
.margins 15,66
[ Note: there is room in the once-only code at 06000 ff.
to include a call to a real-time or system clock, if available.
Cf. examples in PATCH.ES .#]
.skip
.margins 9,72
3. WRITE('string':m)...A field width expression is now allowed also
for strings and performs as described in the ^&PASCAL\&
^&User\& ^&Manual\& &_& ^&Report\&.
.SKIP
4. The Real Output Conversion Routine (SUP2) of Version 1 contained
a subtle bug. The routine has been completely redesigned and seems now
somewhat optimal.
.skip
5. A predefined procedure HALT, like STOP in BASIC or FORTRAN.
.skip 2
.c;========================================
.no fill
.skip 2
A U T H O R D I S T R I B U T E D b y
----------- --------------------------
Prof. Heinz Stegbauer Wolfgang Leber
HTL - Moedling Chairman, German 12-bit SIG
Austria Max Planck Institut fuer Hirnforschung
Deutschordenstrasse 46
D-6000 Frankfurt am Main 71
West Germany
.fill
.PAGE
.NO FILL
.MARGINS 3,75
/ P_P A_A S_S C_C A_A L_L . H_H L_L
/
/NOTES ON PASCAL-S COMPILER FOR PDP-8/E
/======================================
/
/
/
/ASSEMBLING INSTRUCTIONS:
/------------------------
/
/ .R PAL8
/ *DEV:PASCAL<DEV:PASCAL/K
/
/ .R ABSLDR
/ *DEV:PASCAL/9$
/
/ .SA SYS PASCAL;06000
/
/
/
/ COMPILER/INTERPRETER LIMITS:
/ ----------------------------
/
/ 512 IDENTIFIERS
/ 63 ARRAYS -- the listing says 64 !
/ 63 BLOCKS
/ 1980 STATEMENTS OF INTERMEDIATE CODE
/ 16 LEVELS
/ 8 CHARACTERS VALID IN IDENTIFIERS
/ 80 CHAR'S/LINE MAXIMUM FOR COMPILER INPUT (NOT PROTECTED!)
/
/
/
/ DIFFERENCES from "WIRTH'S" PASCAL-S:
/ ------------------------------------
/
/ MAXINT = 2_^35 - 1 = 34359738367
/ REALS BETWEEN 2.78E-309 AND 8.98E+307, PRECISION ABOUT 5.0E-11
/
/ MAX. ARRAY-BOUNDS
/ MAX. CASE-ITEMS : -2048 < N < 2048
/
/ EOF AND EOLN W I T H O U T (INPUT)
/
/ ADDITIONAL PREDEFINED PROCEDURE HALT
/
/ N O LINE-SPACING CONTROL CHARACTERS PROVIDED!
/ ( USE SPECIAL PREDEFINED PROCEDURE ASCII(N) )
/
/ OUTPUT LINE LENGTH NOT LIMITED (USER'S RESPONSIBILITY!)
/
.MARGINS 9,72
.FILL
.page
.C;CHANGES MADE to the MOEDLING CODE
.c;-------#----#--#---#--------#----
.skip
1. The compile-time error messages were rendered from German into English.
The run-time messages were in English from the beginning.
.skip
2. The liberty has been taken of mapping characters read from input files,
whether source (.PS) or runtime data input. The changes are shown in the table
below. Briefly, Horizontal Tab and lower-case letters are now legal
in source programs and in data input files. Note that comments in
PASCAL-S programs should be enclosed between (* and *), since { and }
become [ and ] respectively.
.skip
.no fill
.left margin 13
Octal Character Becomes
----- --------- -------
.skip
#11 (or 211) H. Tab One blank (space)
140 (or 340) ` (Accent Grave) One blank (space)
141 a A
142 b B
... ... ...
172 z Z
173 { [
174 | _\
175 } ]
176 ~ _^
177 Rubout (Delete) __
.left margin 9
.skip
PASCAL-S compiles the following correctly:
.skip;.margins 13,73
Program Above96 (Input, Output); (* show conversion *)
Var lowercase: integer;
Begin
for lowercase := 97 to 127 do begin
writeln;
write (lowercase,' ',Chr(lowercase-32))
end
End.
.margins 9,72
.fill
.p
Program#YourName(Input,#Output); syntax is standard for all PASCAL-S
programs(1). Read(ln) and Write(ln) are
directed to this standard Input and Output, respectively.
.footnote 4
^^
.skip
.margins 5,76
.c;________________________________________________________________________________
(1)See Eisenbach _& Sadler: ^&PASCAL for Programmers\&, Springer-Verlag
1981, Ch. 8, page 122, "large main-frame implementations of PASCAL...".
!
.p
'Lowercase' is significant to 8 characters ('lowercas').
At least one variable needs to be declared,
even if no variables are actually used.
.page
.skip
CHANGES MADE, continued.
.skip
3. According to John Easton, the University of Minnesota experimented
with PASCAL-S before deciding to write their own fuller implementation of
PASCAL. There were two grammatical oddities in PASCAL-S that disturbed
them:
.skip
#(A.) The use of double-quote (") to enclose text when other PASCALs
use single-quote (apostrophe: ' ); and,
.skip
#(B.) The use of pound-sign (_#) as a not-equals sign, like <>.
.p
Since the double-quote requires the programmer to do something not
standard in PASCAL, it has been removed. The quoting character is now
the apostrophe (single-quote). To quote an apostrophe, type it twice,
e.g. Writeln ('PASCAL''S syntax'); .
.P
The pound-sign doesn't impose itself on the programmer. It might be
considered an 'enhancement', a bit like ASCII(N) and RANDOM.
But the user should not expect enhanced code to be portable to
another version of PASCAL.
.skip
4. The source changes made in PASCAL.PA are shown in PASDIF.LS#.
Optional patches to RANDOM and to the '_#' syntax are
shown in PATCH.ES#.
PASCAL-S has no overlays; the .SV file is easy to patch
with ODT or with FUTIL.
.FOOTNOTE 5
^^
.SKIP
.C;________________________________________________________________________________
NOTE: N. Wirth's definition of PASCAL-S and a description of its compiler
have been reprinted in D. W. Barron: ^&PASCAL\&, ^&The\& ^&Language\&
^&and its Implementation\&, Wiley 1981/1982, Chapter 8.
!
.PAGE
.NO FILL
Program ASCCHR (input, output);
(* Compare Ascii(N) with Write( Chr(N) ) *)
Var
counter, asciicode: integer;
begin
for counter := 64 to 84 do
begin
asciicode := counter;
repeat
Write (asciicode,' ');
Ascii (asciicode);
Write (' ',Chr(asciicode) );
asciicode := asciicode+21
until asciicode > counter+42;
(* don't omit that semi-colon _^ ! *)
writeln
end
end.
64 @ @ 85 U U 106 j *
65 A A 86 V V 107 k +
66 B B 87 W W 108 l ,
67 C C 88 X X 109 m -
68 D D 89 Y Y 110 n .
69 E E 90 Z Z 111 o /
70 F F 91 [ [ 112 p 0
71 G G 92 _\ _\ 113 q 1
72 H H 93 ] ] 114 r 2
73 I I 94 _^ _^ 115 s 3
74 J J 95 __ __ 116 t 4
75 K K 96 ` 117 u 5
76 L L 97 a ! 118 v 6
77 M M 98 b " 119 w 7
78 N N 99 c _# 120 x 8
79 O O 100 d $ 121 y 9
80 P P 101 e % 122 z :
81 Q Q 102 f _& 123 { ;
82 R R 103 g ' 124 | <
83 S S 104 h ( 125 } =
84 T T 105 i ) 126 ~ >
.skip 4
G. Chase, O.S.B.
Portsmouth Abbey School
December 1982--February 1983
.page
.fill
.margins 9,72
.c;Some April Foolishness: footnotes to PASCAL(1)
.c;----#-----#-----------###---------#--#------###
.footnote 4
.skip 2
.c;----------------------------------------
^^
(1) PASCAL experts may not read this page. It's too embarrassing.
!
.skip
1. PASCAL is forgiving of type change from Integer to Real, thus
'If Trunc(X) = X then ...' is accepted even though Trunc() returns an
integer. But otherwise the language is very strongly typed.
Integers, Reals, Booleans, Chars: don't mix them!
.skip
2. PASCAL wants its semi-colons. Two favorite traps are after
Program Moo (Input, Output);# and Procedure Foo (var Wu: integer);#.
Likewise after# Var# Fee, Fie, Fo, Fum:# integer;#.
.p;In general, every complete statement is ended by semi- colon.
Note, however, #If J>K Then J:=K Else J:=1;# -- don't embed a semi-colon
between If and Else.
.p; The semi-colon may,
really should, be left out if the next word is End or Until (but an
End or an Until clause must itself be ended with ';' -- unless, of
course, it be followed by another End).
.skip
3. Programs MUST begin with PROGRAM ... and end with END.#.
This is the only END that may and must be followed by full stop.
.skip 2
.c;Errors
.c;------
.skip
4. Wirth's write-up on PASCAL-S mentions care taken to avoid
superfluous error messages: those resulting from an earlier program
syntax error. Still, PASCAL's structure makes this difficult.
You will often get error messages which seem to point at text which
is, in fact, perfectly sound -- and would be recognized as sound
IF there hadn't been that little mistake two lines before.
.p;The compiler flags an error when it's sure it's an error;
this may not be where the programmer made his mistake. Missing
semi-colons, for example, are usually missing ^&before\& the
text flagged with _#14#.
.page
.c;Printing Formats
.c;-------- -------
.skip
.left margin 13;.indent -4
5.##Write ('text':N) has been mentioned on Page iii.
.skip
Write (realnumber:8:2) resembles FORTRAN F8.2 or PRINT USING
"_#_#_#_#_#._#_#" . But format :8:0 prints in exponential format, not
in F8.0 . A rule of thumb is to make formats wider
than seems, at first sight, necessary.
.skip
Write (intvalue: 4) is the I4 or "_#_#_#_#" integer format.
.left margin 9
.skip 2
.c;Booleans
.c;--------
.skip
.no fill
.indent 4;'If STUFF'#####is equivalent to 'If STUFF = True'#.
.indent 4;'If Not STUFF' is equivalent to 'If STUFF = False'#.
.fill
.p;It is often necessary to parenthesize Boolean expres- sions.
The operator precedence can cause trouble.(1)
Warning: an 'And' will test both conditions even if the first be found
false. If you don't want this try, e.g., IF A<B Then IF C<D Then ...
.skip 4
.indent -2;PAS April, 1983
.footnote 5
^^
.skip
.c;----------------------------------------
(1) See ^&PASCAL for BASIC Programmers\&, Addison-Wesley 1983,
pages 54-55, "Operator Precedence".
!