25012 C_North_Star_Pascal_Version_1_Rev_3_Dec79 C North Star Pascal Version 1 Rev 3 Dec79

25012-C_North_Star_Pascal_Version_1_Rev_3_Dec79 25012-C_North_Star_Pascal_Version_1_Rev_3_Dec79

User Manual: 25012-C_North_Star_Pascal_Version_1_Rev_3_Dec79

Open the PDF directly: View PDF PDF.
Page Count: 333

Download25012-C_North_Star_Pascal_Version_1_Rev_3_Dec79 25012-C North Star Pascal Version 1 Rev 3 Dec79
Open PDF In BrowserView PDF
f\JorthSbrCanpulrzrslnc.
1440 Fourth Street
Berkeley, Ca. 94710

North Star Pascal
Version 1
System Reference Manual

PAS-DOC
Revision 3
25012-C

*****************

*
*
*
**
*
*

NORTH STAR PASCAL
version 1
SYSTEM REFERENCE MANUAL
PASCAL-DOC Rev 3 December 79
North Star Computers, Inc.
1440 Fourth Street
BerkeLey CA 94710

*
*
*
**
*.
*

*****************

t:!Q!1fE
North Star PascaL, version 1, is a speciaL release of the UCSD Pascal (TM)
program development system, prepared jointLy by the Institute for Information
Systems, University of CaLifornia, San Diego, and North Star Computers, Inc.
("UCSD PascaL" is a trademark of the Regents of the University of California,
San Diego Campus.) Version 1 is compatible with UCSD PascaL (TM) version 1.5.
This SYSTEM REFERENCE MANUAL is a corrected reprint of the Yf§Q f~§f~l 1.2
§~§1~m M~D~21.
AdditionaL information, incLuding specific detaiLs about the
North Star impLementation are contained in the ADDENDUM TO NORTH STAR PASCAL
SYSTEM REFERENCE MANUAL, which accompanies this volume.
For technical assistance with difficulties encountered while using or
configuring North Star Pascal, consuLt your dealer, or calL the North Star
TechnicaL HotLine in Berkeley, at (415) 524-9202, during the hours of
10:00am-4:00pm Pacific Time.

********************************

* Copyright (C) 1979 Regents of the University of CaLifornia,
*
San Diego Campus. This software, its source, object,
*
and aLL other forms, is the property of the Institute
*
for Information Systems and may be used or copied by
others onLy with written authorization from the Insti*
*
tute for Information Systems.
*******************************

*
*
*
*
*
*
*

*********************

*

TABLE OF CONTENTS

*

*********************
VeT'S i on

I. 5

SECTION
1 THE UCSD PASCAL SYSTEM
1

INTRODUCTION AND ,OVERVIEW

2

FILE HANDLER

3

SCREEN ORIENTED EDITOR

.,
1-

1

INTRODUCTION

31

:2

GETTING STARTED.

32
3b

3

DETAILED DESCRIPTION OF COMMANDS

4
5

REFERENCE...
EXPER I MENTAL LAHGE F

IL~E

VERSIOf\·1

(f,,2)

51,
33

YET ANOTHER LINE ORIENTED EDITOR - VALOE
1.';

'-.. J

DEBUGGER
Ft\SCAL COMP ILER

7

BASIC COMPILER
LIN~~ER
ASSE~!HLER

99

2 THE UCSD PASCAL LANGUAGE
1

INTRINSICS
STRING
1
INPUT/OUTPUT

11 '1
ll9
1~23

Lel·j l.EVEL GRAPHICS

S
6

129

CHARACTER ARRAY
MISCELLANEOUS.

DI~FERENCES

BETWEEN

1 :3:3
ST\t\NDARD PASCAL

1 :35

1.

Cf'\SE STATEMENTS

13:;

2

COMMENTS

3
4·

1 ~J6
136

EOF .

OYNAMIC MEMORY ALLOCATION
EOLI\;

6
7

FILES
GOTO AND EXIT STATEMENTS

8

PACKED VARIABLES

9

PARAMETRIC PROCEDURES AND FUNCTIONS

10

P ROGR AJ'>1 HEAD I NGS

11

REt!\D AND REpiDLN

138
1:3D
149
loll ~

J·!!-4
11~

?

RESET
1 :3

RE~IRITE

14

SEGMENT PROCEDURES
SETS
STRINGS
WRITE AND WRITELN
IMPLEMENTATION SIZE LIMITATIONS

150
151

EXTENDED COMPARISONS

1 ~~tl,

15
16
17
18

1 S'
20
21
22

1 ~)6

LONG INTEGERS

1 ~j6

UNITS .

136
156

.

.

.

TABLE OF UCSD INTRINSICS

3 IMPLEMENTORS' GUIDES
1.

DHA~JLINE

3

FILE FORMATS
SPECIAL UCSD PASCAL SYNTAX (USE OF)
1
SEGMENT PROCEDURES
;;.~

lJN I '1~8 .

..J,
1 1::0
163

165
"J .. ~L.~'
.. f

A

4

3
LONG INTEGERS "
INTERPRETER NOTES "

;5

INTRODUCTION TO '"HE P.<\SCAL

6

BYTE SWAPPING

179
PSEUDO~-MACHINE

183
201
213

4 UTILITY PROGRAMS
CALCULATOR
LIBRAR IAN .
3
4·

SETUP - SYSTEM RECONFIGURATION
BOOTSTRAP COPIER
PATCH/DUI'1?

(::.,

7
8
9

RT11 TO PASCAL CONVERSION KIT
GOTOXY PROCEDURE BINDER
DUPLICATE DIRECTORY
P-CODE DISASSEMBLER

227
229
~2:j3

.235
237
239

LIBRAR'f MAP " .

243

1
2
3

EXECUTION ERRORS

249
251
253

.5
6

SYNTAX ERRORS
ASSEMBLER SYNTAX ERRORS
AMERICAN STANDARD CODE fo~ INFORMATION INTERCHANGE
P-MACHINE OP-CODES
UCSD PASCAL SYNTAX DIAGRAMS

10

8

A

.""..

21.7
221

IORESULTS
UNI TNUt'tBERS
PEN8TATES .

257
261
265
267
26liA

ADDENDA, ERRATA AND NOTES
NOTES ON OTHER MATERIALS AVAILABLE
BRINGING UP THE PASCAL SYSTEM
.t

2
3
4

ON PDP-l j, . . . . . " .
ON 8080/180 SYSTEM WITH CPIM AND 3740 DISKS

DIFFERENCES AMONG IMPLEMENTATIONS FOR DIFFERENT PROCESSORS.
CHANGES MADE IN 1_ 5 FROM (1.4; I.4b) SYSTEMS

B INDEX .

" .

)~

..

~

~

,.:.:, ( .i.

273

277
279

NEW SUBSCRIBERS: See Section A for details of bringing up
UCSD Pascal on your machine.
DISCLAIMER~

These documents and/or the software they describe
are subject to change and/or correction without
notice.
The tJCSD Pascal ProJect cannot be held
responsible for implementations on processors where
the imp lemt.'!ntation work was not done at UCSD,
Users
with systems obtained From sources other than UCSD
must contact their supplier for support.

ACKNOWLEDGEMENTS:
The work described in these notes bas been supported
significantly by the following organizations:
United States Navy Personnel Research and Development
Center, Sp~rry UniVac Minicomputer Operations, EDUCOM,
Di 9 ita 1 Eq u i pmen t C OT'P orat ion, Proc essor Tec hnc 1 og y
Inc., Springer-Verlagl Terak Corporation, General
Automation Corporation, The UCSD Computer Center,
grants from thE University of California Instructional
Improvem~nt Program,
Te~trnnix Corporation,
Micropolis
Inc., Computer Power and Light, Phillips Research Labs,
Lawrence Livermore Labs, Pascal Computing.
The work described in these notes has been made possible
by the drive and direction of the Director of the lIS:

Kenneth L.

Bowle~

Documentation Authors:
Ac k land, S. Ddle Ander, Lucia A. Bennett,
Charles "Chip" Chapin.
Gary ...J,
Julie E. Erwin, Shawn M. Fanningl.
Mary K. Landauer, J. Raoul Ludwi g, Joel J. McCormac k,
Mark D. Overgaard, Keith A. Shillington,
David A. Smi th Roger T. Sumner, Dennis J. Vol peT'.
Gillian M.
Raymond S.

Causey!
o i. smll k eSt

I

Software Authors:
Dale Ander} Marc Bernard, Charles "Chip" Chapin,
Greg Davidson, Barry Demchak, William P. Franks,
C. Richard G'f'unsky, Robert J. Hofkin, Albert A. Ho-Pfman,
Richard S. Kaufmann, Peter A. Lawrence, Joel J. McCormack,
Mark D. Overgaard, David A. Reisner, Keith A. Shillington,
David M. Steinor~, Roger T. Sumner, Steven S. Thompson,
David B. Wollner.
S.

J.

Collected and Edited by:
Keith Allan Shillington and Gillian M.

Ackland.

***************************** ***************

*

INTRODUCTION AND OVERVIEW

* *

Section 1. 1

*

***************************** ***************
VeT'sion I. 5 September 1978

The UCSD Pascal system described in the following document is a
system intended to run on stand alone micro- and mini-computers.
This
system is highly machine independent since it runs on a pseudo-machine
interpreter commonly referred to as the uP-machine".
All the system
softwa~e

is written in Pascal,

except

fo~

the P-machinQ

inta~p~Qt8~

and

a few run-time support routines written in assembler for efficiency,
resulting in relatively straightforward software maintenance and
enh~'lncement.

The system is designed to be used primarily with a CRT teT'min~l
acting as the CONSOLE devicei howeverl the system is flexible enough to
be reconfigured for slower hard-copy terminals.
For further
information rega~ding coropatability between various types of equipment
and this system see the "SETUpu document in Section 4.3.
This docume'(1t
is intended for programmers who are familia~ with the Pa$cal
progi~amming language and have some experience in writing computer
pr ogt'am'5
The following

is

a tutorial book on PASCAL:

Kenneth L. Bowles,
(Microcomputer) Problem Solving Using PASCAL
Springer-Verlag, New York; (c)1977
w~

suggest the following book as a PASCAL reference guide:
Kathleen Jensen and Niklaus Wirthr
PASCAL. U!';er Manual and RepoT't
SpT'ingeT'-VeT'lagi New YOT'k~ (c) 1975

For documentation concerning the differences between UCSD
Pascal and Standard Pascal see Section 2.2.

1. 1. 1

THE UCSD PASCAL SYSTEM: AN OVERVIEW
The structure of the UCSD Pascal system is best
in terms of the "tr.ee-like" stT'uctlJre diagT'am figure 0.1

con~ept(Jalized

at the end of this sub- section.
The diagram in figure 0.1 depicts the outermost level of the
system.
In terms of ~~ "tref!tI OT' structurE d:iagT'f30'b thE IIroot"
C01'T' e S p 0 n d s tot: h e 0 ute r m0 S t I e vel t
wh j. ). e the u 1 ea v e s II (i. e. the box e 5
wit h nob ran c h e s t 0 low tf r 1 eve 1 s) c {) r i' f1' «5 P 0 n d t o t h e 11) wt? l' 1 eve 1 5 0 .p the
sysi~em.
~"hile a user is in a p.ci'rticult3T"- level,
the system dispL~ys a
list o~ available comm~~nd$ cal1~d th~ Hp.,"ompt-ltne
If the system is
running on a CRT screen type terminal, then the prompt-line will
usually appear at the top of the screen.
Commands are usually invoked
by typing a single character from the CONSOLE device.
For example, the
prompt-line for the outermost level of the system is:
H

,

C0 mm ia n d:

E(di t

I

R(

un

I

F ( i 1 it?

C ( 0 mp ,

f

X ( e C 1I t

L. ( ink 1

A ( sse mJ

(:h

D ( e bug ,!

?

[r.

B Y t Y pin 9 ,. F tI the use l' W i l l ;. des c end 11 a .1 eve 1 wit h i nth e
s t T' lJ C t u T' e d i a 9 T' ami n t 0 ale vel calle d the F i 1 e T'
Up 0"" en t e T' i n 9 the
=iler, anothe~ prompt-line detailing the set of commands available at
the Filer level of the system is displ~yed. The Q(uit command causes
the use r toe x i t f l~ 0 m the F i 1 era n d a s r: end
b a c k t o t h e 0 ute l' m0 s t
command level o~ the system.
Now the user is back at the level in the
system from which he started after bootstrapping the machine.
Some
commands within the system prompt the user fo~ the name of some disk
flle
In these [a~e51 the user enters the name of the file followad by
a carriage return.
If an error is made in typing a portion of the file
nam~,
the backspace key (or e~uivalent key depending upon th~ system
II

It

t4

r:onfigIJration) may

bE~

u£.ed

to

;'back

II •

ovwr"

~nd

th~?

eT'Cise

erroneous

delete key (rubout ke~) may ba used to erase the entire
n~me.
thereby allowing the user to compl@te14 start over.
If the
uSe'r d (!' C i d f.." S not t 0 ace e p t iiP"! l:i f i 1 eo n .'71 m f' t;.; h .~r.;::: (\ ~.. v :::t 1"'
l:7 S ·c ape.!t f l' 0 ill t 11 i !.=.
c: 0 roma 1'1 d i -s b IJ en t ~ r i n 9 d f i 1 €I n.a !l'i ~ 0 oF l t~ T' 0 c: h .t':l 'f' act 0 r s , L f!t.. t y p e  .

part
File

The

lin~

I

,/

Notp that due to a limited amount of room on the prompt-line)
50me of the infrequently used commands
1 i nfL

A concept
;y~tem

::ar. b::

cent'i'i~l

ma~

to the design of

not appear on the promptth~

entire UCSD Pascal

commi3nd strllctOT'e is the' concept of th.:~ t'uJor~{filer:.
A !iJoT'k-File
th':-;Ught of as a ·!$cT'c."}tch~·pt~d" arf~a used for devt":tlopment of

programs and only one workfil@ is allowed at any ona time. If a us~~
dishes to begin a new workfile, the contents of the old one can be
sa',¥q~r.L
under a sep(.~rate fi Ie n~lm;£I, for 1 af,2T" rBfer-'ence by us ing the
3(ava command in the Filer lev~l of thp s~stpm,
When that file is
lat~;. . retrif?ved for fOT't:her tJJork on th~ contents1
it lE) possibl(~ that a
number of file~ (usually source and code) will be retrieved together
~nd in total they comprise the work-file

5J

1. 1.2

A.

OUTERt10Si LEVEL COMMANDS:.

AN OVERVIEW

E (d i t

Typ lng "Eli wh i Ie at the outel'i-rHJst c.ommand level of the system
the editor program to be brought into memory from disk.
The
use~ maYI
while in the edito~, inse~t or delete text inside his
work file D~ any textfile, along with many other powerful commands. See
Section 1.3 far details. The workfile text (if present) is read into
the editor buffert otherwi~e the Editor prompts for a file.
cau~~s

13

F(iler

HF" places the user in a level of the system called the Filer.
This section of the system contains commands used primarily for
maint~nance of the files stored on the disk.
The L(dir command allows
the user to list the titles and the last modification date, as well as
determine the number of blocks occupied by each file on the disk.
The
TCTBnsfer command is used to copy from either one disk to another, o~
from one area on a pal~ticular disk to another area on the same di~k.
For more documentation on the Filer level including commands associated
with the "getting", "saving", and "clearing" of the user's wOl'kfile see
Section 1. 2.

c.

C (amp

This command initiates the system compiler to compile the users
work-file.
If there is no work-file currently the user is asked '01' a
source text file name.
If a syntax 9rTO~ within the source is
detected, the campile~ will stop and display the error number and the
surrounding text of the program.
By typing a spacek the user can cause
the compiler to continue the compilation, Typing an  causes the
camp i leT' to abtirt & return to Command leve 1.
Typ ing 'E' wi 11, if the
system editor is the screen edttorJ call the editor placing the cursor
near the offending symbol.
If the compil,,'ltion is successful, (1. e. no
syntax errors we~e encountered) a codefil~ called *SYSTEM.WRK. CODE is
written out onto the user's disk and becomes part of the workfile.
FoT'
more documentation on the use of the UCSD Pascal compiler see Section
1. 6.

This command causes the codefile associated with the current
to be executed.
If no such code file currently exists, the
compiler is called in the same manner as described in C above.
If the
c6mpilation re~ujres linkage to separately compiled code the linker
will automatically be invoked and will assume the use of the file
*SYSTEM.LIBRARY.
After a successful compilation, the program is
work~ile

executed.

Page 3

E.

X(ecute

This command prompts the user fn~ the filename of a previou.ly
cod~file.
If the file exists, the codefile is executed;
o the T' w i set hem e s sag e
can ' t fin d f i 1 e
i s ret lJ T' ned.
( Not e : the

compiled

tf

P;

".CODEr.~

suffix on such a file is implicit»

I-P all

cod~

necessary to

execute the c:ode-File has not been linked in, the message "file <'Pileid>
not linked in is retu~ned.
It is convenient to X(ecute other prog~ams
which have already been. compiled because otherwise the user would have
to enter the Filer. G(et the file, Q(uit the Filer~ and then RCun the
program.

F.

A( 5sem

Just like C(omp except the
than the system compiler.
G.

sys~em

assembler is invoked rather

D( ebug

This command causes the cu~rent workfile to be executed.
If
the program in the wo~kfile has not been compiled, the compiler will be
called as in the case of the R(un command.
However if a run-time error
occurs.,

or a user-

de.pin~d

bre~lk-pojnt

OT'

halt is encountwred,

the

Debugger program i$ called.
The Debugger is a prog~am which allows the
user to examine the contents of variables within the program.
See
section 1. 5 Debugge~ for more details.
H.

L(ink

This command starts the

syst~m

linker program explicitly to

li-rk "'outi.nes fr-orn libra1"ies c·tf1~T' than
*SYSTEM.LIBPARY.
See section 1.8 for mDr~ inPormation
allol.",

tlSf:"oT'S

1.1.3

to

O~

the linker.

UTILITY PROGRAMS

There are many functions needed by users of any operating
system.
To attempt to make all these functions system functions would
result in a terrible proliferatlon of command letters as the base node
level.
In order to keep the COMMAND llne simple, we hav~ restricted
the functions available on it to what W~ feel i~ the bare minimum for
~rogram and te~t develo~rni?nt.
Th~· oth£'p usefult
but much less often
IJsed functions dT'e available through the X(ecute command.
The sort ofl
Functions which are available are the desk calculato~, the patch/dump
iJtility: the terminal configuration s€'tup prcgramJ a boot~Jtrap mcvel"l a
librarian and many others.
For a complete list of the utility programs

with the UCSD Pa~cal systRm. reFeronce Section 4 1n the
Any programs which you write and -Feel \.t.Jould be a
Jseful addition to our library of utilities will be welcome
:: ontr i b lit;. OTIS

10W avail~ble

rable of Contents.

'age 4

1.1.4

AN INTRODUCTION TO THE UCSD PASCAL SYSTEM

1.5 is the first release which contains the fully intergrated
and implemented concept of sepa~ate compilation and assembly.
I.4b was
the first to support multiple types of processors.

The great bulk of the system 50ftwa~e is written in Pascal and
runs on a ~elatively simple pseudo-machine.
If this pseudo-machine is
emulated by a machine language program on a new real machine, the
Pascal software will also run on that new real machine.
One class of differences among versions of the system is due to
aspects of the pseudo-machine that are not identicaly emulated by the
implementations for different types of processors.
A subsection in
$~ctton A contains a chart of differences between processors the system
currently run~ on.
Another clas$ of differences stems from variations in the
system lID environments rather than in the host processor.
Included
here are diffe~ence in system console terminal types (e. e. hard-copy vs
CRT vs stc~age tube) or command conventions and capabilities (eg.
in tel 1. i 9 en t " v S tl dum bite R T .. 5 >.
The s y 5 t em i s i n ten d edt 0 b e a b l e t 0
cope with this sort of va~iation.
Ver~ion I.4 had some troubles with
teTminals that ge~eTat9Jrequi~e two-cha~acter sequences fD~ some
contT'ols, and single-c:haT'acter sequences foT' othel's.
The utility
progj',am "SETUP" has been complet1i'ly regenerated for 1. 5 (see section
!I

4.3) .

In the PDP-i1 world these mass storage variations are not too
primarily b~cau~e there is considerable motivation to be
compatible with DEC devices and m~dia.
We hav~ written and support
driverg fo~ a few DEC incompatible devices but make no' claim to
SUppOTt users who want to develop their own such drivers.
See section
seriou~J

A f(lT' u,U3;'nings c-lbout

pT"obl~ros

you might encounter.

The situation in the BOaO/Zeo wo~ld is much more chaotic.
Since is wDuld not be practical fo~ the ProJect to write and support
drivers far the vast multitude of soao/zao 110 environments that exist,
we have chosen to take advantage of the wide5pread implementation of
Digital Research's CP/M operating system by structuring the pseudomachine's 110 operations as calls on CP/M's Basic I/O Subs~stem (BIOS)
primitiven.
Thereforel any 110 configuration on which CP/M has been
implem~ntcd should also be able to support the Pascal system.
We do
not gU~T'antee this.
For example·, Intel MDS disk controllers cannot
read disks generated here and some BIOS's we have encountered do not
completel~ meet all the requirements specifi~d for CP/M.
UCSD plan~ to
support some of the larger distribution SOaO-based machines directly.

Our dominant mode of distribution for soao/zao systems will be
on 3740 compatible diskettes,
One of the distTibution diskettes will
be CP/M oriented
This disk will be used, via a somewhat awkward twost~p process,
to bring up UCSD Pascal on a particular CP/M
configuration.
Look to section A for details on this process.
It also
describes tho configuration of a modi~ied BIOS, which will better
support the needs of the Pascal system.
Finally, directions are given
fOT making i t possible to boot directly to Pascal rather than
indirect14 through a CP/M program.

Page 5

A number of files on the disk start with "SYSTEM.'
SYSTEM,
SYSTEM.
SYSTEM.
SYSTEM.

speci~ically:

PVP-11

MICRO
PASCAL

FILER
SYSTEM. COMPILER
SYSTEM. SYNTAX
SYSTEM. EDITOR
SYSTEM. LINKER
SYSTEM. ASSMBL.ER
SYSTEM.SWAPDISK
SYSTEM.CHARSET
SYSTEM.LIBRARV
SYSTEM.WRK.TEXT
SYSTEM.WRK.CODE
SYSTEM. STARTUP
In most cases these files. contain the system segment of the
That is to say that the EDITOR, FILER~ LINKER,
:OMPILER, ASSEMBLER are the files that are invoked by the text editor
"hen 'E', 'F ' , etc. is typed. Some of the files aT'e machine specific.
[NTERP and MICRO are the files which contain the interpreters fo~ the
)articular machine being used.
CHARSET is a file which appears on
jisks meant for TERAK computers only and contains the definition for
the soft character set, and the data for the Triton logo prompt.
_IBRARV is a file containing separately assembled or compiled routines
POl' use by the Linke~ in producing executable code files.
PASCAL
:ontains the operating system, and the Debugger.
SWAPDISK is a file
Jsed by some of the system segments during compilation of "include"
Piles if a memory shortage exists. It is a 2048 byte file which gets a
)ortion of memory swapped to it when a directory needs to be read into
:ore.
When the dir9ctory work is complete, the memory is restored to
Lts original state. STARTUP is a file which can be created at the
J seT' ISO P t ion.
I f i t e xis t $ 0 n a dis k , t h e 0 per at in 9 s Y s t em con s id e r s
It a runnable code-'11el and executes it at initialize time.
This
tllows the user to have a program that runs before the main command
~rompt comes up, and will run anytime the I{nitiallze command is
;yped.
WRK.TEXT and WRK.CODE are the current work-file after some
lction has occurred to the work-file. They appear after having done
~ome text editing on a work-file (SYSTEM.WRK. TEXT) or compiling a workname they carry.

lile (SYSTEM.WRK.CODE).

All other files an the disk a~e user generated (in one fashion
The other important part'S of a disk are relatively
,nvisible to the user.
The directory resides at block 2 on the disk
Ind extends for 4 blocks if it is a single directory, a blocks i. i t is
I duplicated
(backed-up) directory.
The bootst1"ap can reside at any of
I number o~ places on the diskl
depending on the host machine.
In most
ases, blocks 0 and 1 are reserved fa~ the bootstrap.
~T'

anothE'r>'

Page 6

***************

*

FILEHANDLER*

*************~*

*

Section 1.2

*

*************** ***************
Version I.5
1.2.1

September- 1978

FILES

A fi.le is a discrete 'chunk: of information which is stored on
the disk and ~eferenced by a filename.
Each disk has a directory
which contains the filenamRs and locations of each file on the disk.
T h t:' F i 1 e han d 1 e'r
0 r F i b~ 1" ..
lJ S est tl e in f 0 T' ma t ion con t a i ned in the dis k
directory to manipulate files.
J

One of the attributes of a file is its t~pe.
The type of the
file determines the way in which it can be used.
File types are
assigned based on the file name.
Res~rved

type suffixes

TEXT

Fa~

filenames are:

Human readable text.

. CODE

Machine executable code .

. DATA

Data file.

, FOlD

A file containing one TERAK screen-image.
Intended to be a file containing a vector
list of a graphic imagn.
Cur~ently unused.

.8,.\D

1. 2. 2

An unmovable file cov~rln9
damaged aTea of a disk,

8

physically

VDLUt1ES

A volum~ is any 1/0 device; slJch 13B the printer'. the keyboard.
a dis k "
A b 1 t1 r: k - ~i t 'r" to, C t U T' e d" d e vic e i 5 0 net hat can h a v e a
d i r f~ c t n'" y a T'dJ f ~~ 1 e ~ , us tHl 1 1 \J a d j 5 k o.f 5 f.) ttl t"' SO 'T' t ,
A non blotk-structured device does not have internal structure; it sImply
prcduc~s Dr consumes a ~t~eam of characters.
The printer and the
key b car d I f ' 1" E l{ amp 1 ~:
.3 T' e non .- b 1 0 c k - s true t u T' e d .
The tab 1 e bel 0'"
illu.trate9 the reserved volume names used to Tefer to non-blockstf'uctuT'ed devi.ce-51 the 'unit number- i d~~or.iated with each device, and
the unit numbers as~ociet~d with the system (booted) disk and any
0,..

tI

IJ

al,t:;~T'nat~

disk~.

I

Unit Number
1
2
3
4
5
6
8

Volume ID

Description

CONSOLE:
SVSTERM:

GRAPHIC:
:


vDl.uMe

ID

FIGURE 2

)age 8

Volume i. d.

.

vo\nQ.Me

FIGURE 3

Volume names for block-structured volumes can be arbitrarily
assigned by the user.
A volume name must be 7 or less characters long
and may not contai.n '-::::.', '$', '?' or ','. Reserved volume names for
. non- block-structured devices are given in Figure 1.
The character '*'
i5 the volume ID of the 'system disk', the disk upon which the system
was booted. The character ': " when used alone, is the volume ID of the
'default disk'.
The system disk and default disk are e~uivalent unless
the default prefix (see material on P(refix) has been changed.
'.' is
time.

e~uivalent

to the name of the volume in the drive at that

A legal filename can consist of up to 15 cha~acters. In order
for the fil~ to be run the last 5 characters must be . TEXT, ,CODE, OR
. DATA.
Without these suffixes the file may be executed but not put in
the workfile to be run.
Lower-case letters will be translated
to upper-case, and blanks and non-printing characters will be removed
from the filename.
Legal characters for filenames are the
alphanumerics and the special c.haracters '_'i 'I', '\' , .r I, and ' . ' .
These special characteTs may be used to indicate hierarchic
relationships among file$ and/or to distinguish several related files
of di~Terent types.
The 1.5 Filer will not be able to access filenames containing
the charac-ters '$', ': 't '=', '?': and '~',
If files from previous
versions of the system contain these cha~acters, then they should be
removed be~ore attempting to use those riles with the I.5 System.
WARNING:

'=' and '7'1 are used to specify
The Filer performs the requested action on

The wildcard characters,
subsets of the directory.

all files meeting the specifications.
A file specification containing
the subset-specifying string 'DOC=TEXT' notifies the Filer to perform
the requested action on all files whose names begin with the string
'DOC' and end with the st~ing 'TEXT'.
If a '?' is used in place of an
'=', the Filer requests verification before afTecting each file meeting
the specified criteria. Either or both strings may be empty. For
example, a subset speCification of the form '=' or '='
OT' even '=' is valid.
This last case. where both subset- specifying
strings are empty, is interpreted by the Filer to specify every file on
the volume. so typing '=' or '?' alone causes the Filer to perform the
appropriate action on every file in the directory.
Given an example directory for volume MVDISK:
NAUGHTYBITS

6

23-'-'un-54

MOLD. TEXT
USELESS. CODE
MOLD. CODE
NEVERMORE. TEXT

4

29-,,'un-54

10
4

19-May'-54
29-·...Iun-54

12
5

5-Apr-54
lO-Sep-S2

GOONS

~age

10

EXAMPLE:
P~ompt:

Remove what file?

Re$pons~:

Typing

generates the message:

'N=~

MYDISK:NAUGHTYBITS
MVDISK:NEVERMORE.TEXT
Update directo~y?

removed
'removed

(At this point the user can type 'V' to remove or
type

~N"J

in whi.ch case the Tiles will not be

removed.
The Filer always requests verification
on an'J wi ldcard removes. )
Typin9

'N?' generates the

mes~age:

Remove NAUGHTYBITS: ?
After the user types a

respcnse~

the Filer as.ks:

Remove NEVERMORE. TEXT: ?
EXAMPLE:

Prompt.

Dir listing of what vol?

Response:

Typing '=TEXT' causes the Filer to list

f¥tOLi). TEXT

NEVERMORE. TEXT

4
12

29-,Jun--·54
5'-Ap '("-·54

The subset-specifying strings may not 'overlap'.
For example,
would not specify the file GOONS} whereas GOON=S wDuld

GOON~NS

be a valid

(although

pointles~)

specification.

Tha size specification information is predominantly useful in
the

COf~H'Il:;nds

T(rans-PeT' section 1. 2. S. 11 and M(ake section 1. 2.5.17.

Page 11

1.2.5

COMMANDS AND USE
Type "Fit at the

Command level to enter the Filer and the

following prompt is displayed:
Filer: G(et, S(ave, W(hat, N(ew, L(dir .. RCem, C(hng, T(ransl D(atEb G(uit
Typing '?' in response to this prompt displays more Filer commands:
Filer: B(ad-blks. E(xt-dirl K(rnch, M(ake, P(refix, Veals,

X(.amine.

Z(ero

The individual Filer commands are invoked by typing the
letter found to the left of the parenthesis.
FoT' example,
's' would invoke the Save command.

In the File~, answering a Yes/No question with any charact~r
other than'Y' constitutes a 'No' answer.
Typing an  will return
the user to the outer level of the Filer.
Fo~ each command requiring a file specification. refer to the
file specification diagram (Figure 2).
In many cases, the entire file
specification is not necessary, and in some case~~ certain parts of the
file specification are not valid.
See the required command in the
following section.

Whenever a Filer command re,uests a file specificationJ the
user may specify as many files as desired) by separating the file
specifications with commas, and terminating this 'file list' with a
carriage return.
Commands operating on single filenames will keep
reading fil~name$ from the file list and operating on them until there
ill' e non e 1 e of t .
Comma n d sop e l' at in 9 0 n t UJO f i 1 ena me s ( s u c has C ( han 9 e
and T(rans) will take file names in pairs and operate on each pair
until only one OT none remains.
If one filename remainsl the Filar
~ill prompt for the second member
the pair.
If an error is detected
in the list, the rest of the list will be flushed.

0'

)age 12

Loads th9 designated file into the

wD~kfile.

The entire file specification is not necessary.
If the volume ID is
not giv(~nl the default disk is a~r.umed>
l,.Jildcaros a~e not allowed,
and the ,sl.ze specification option is ignored.
Given the eXdmple

diTecto~y:

FILERDOC2.TEX'T
t';. OUT. CODE

FS.TEXT

ABSURD. TEXT
HYTYPER.CODE
STASIS. TEXT
LETTER1.TEXT

ASSEM.DOC . TEXT
FILER. DOC. TEXT
STASIS, CODE

EXAMPLE:
P~ampt:

~et

Response:

what file?
STASIS

The Filer responds with the message

'Text and Code file loaded'
since both text and code fil~ exist.
Had the user typed
'STASIS.TEXTt or' 'STASIS. CODE', the result would have been the
same - bath text and code versions would have been loaded.
In
the event that only one of the versions exist~, as in the case
of A.OUTI then that version would be loaded, regardless of
whether text or code was requested.
Typing 'A. CUT. TEXT' in
response to the prompt would gene~ate the message: 'Code file
loaded'.

Page 13

2) S(ave

Saves the workfile under the filename specified by the user.
The entire file specification is not necessary.
If the volume ID is
not given, th2 default disk is assum~d
Wildcards are not a]b;~H?d ..

and the

siz~

specification option

i~

ignOT~d.

~XAMPLE:

Prompt:

Save as what file?

ResponsE':
Type a filen.iame of 10 or le5s chNr,3~tf.\j':;;1
the f i 1 ~ n a tTl e con ve n t ion s i n ~ e c t ion 1. 2. 4 ' FILES
f.

obser·',/ing
T hi;:;.

caus~s the FILER to automatically remDVe any aId file having
the given ndm~. and to save the workfile under that name.
For
e:.BACK

exists.,

then the user is prompted:

Remove . BACK ?

4) G(uit
Return~

the user to the outermost command level.

No file specification allowed.
5)

W(hat

Identifies the name and state (saved or not) of the workfile.
No file specification allow.d.
6) V(olumes

Lists volumes
(devic~~

cu~rently

on-line. with their associated unit

numbers.

Page 15

No

specification allowed.

~ile

A typical display would be:
Volumes on-line:

1

CONSOLE:

2

SYSTERM:

3
4
6

GRAPHIC:
MYDISK:
PRINTER:

8

*

REMOTE:

9 # BIG:

Prefix is - MYDISK:
The system or "boot-disk" volume's name is pl'eceeded by a

'*'.

The system volume

is the default volume unless the prefix (see
PCrpfix) has been changed
Block-structured devices are indicated
by

I'

*

I

aT"

'4*

I ,

7) L(dir
Li'sts a disk directory.,
file specif-ied

or some

subs~t

thereof;

to the volume and

(default is CONSOLE:),

The user may list any subset of the directory, using the 'wildcard'
option! and may also write the directory., Or' any subset thereof~ to
a volume or filename other than CONSOLE.
File specification will
therefore be discussed in terms of source file speci'ication and
destin~tion fil~ specification.
Source file sp@cification consists of a mandatory volume ID,

and

optional subset-spPtifying string~1 which may be empty.
If subset~pecifying strings ara uSRd,
then on~ of th@ wildcard charactRTs
must be US"dH1.
A string <-Por example, the full fil~n(~m~
STASIS. TEXT) mav not be used as part of the source file
specification unless a wildcard character is used~

Source file informatiDn is 5Ppa r ated from destination file
1. nof ormat i on b 4 a c omm~ (~; ~).
Destination file specification consi&ts of a
volume is a block-structured device,

volum~

a filename.

ID,

and,

if the

File size

specifications will bp ignored.
The most frequent use of this command is to list the entire directory
of a volume.
The following display, which represents a complete
directory listing for the example disk MVDISK, would be generated
by typing an~ valid volume In for MYDISK (see Figure 2) in response
to the prompt,

~age

16

Or

Dir listing

what vol?

MVDISK:
FILERDOC2. TEXT

28

1-Sep-78

A.OUT CODE

10

1-Sep-78

F5.TEXT
ABSURD
HYTYPER.CODE
STASIS. TEXT
LETTER1.TEXT
ASSEMDOC.TEXT

8
4
12
8
18
20

1-Sep-78
1-Sep-78
1-Sep-78
1-Sep-78
1-Sep-78
1-Sep-78

FILERDOC1. TEXT

24

1-Sep-78

6

I-Sep-76

STASIS. CODE

10/10 files , 130 blocks used,

364 unused

(The bottom line or the display informs the user that 10 files out
of 10 files on the disk have been listed, that 130 disk blocks
have been used, and that 364 disk blocks remain unused. )
EXAMPLE:
L{di~

t~ansaction

Prompt:

involving

wildca~ds:

Dir listing of what vol?

User response:

#4:FIL=TEXT

generates the 'ollowing display:
MYDISK:

FILERDOC2.TEXT
FILERDOC1.TEXT
2/10 flIes

28
24

1-Sep-78
1-Sep-78

,

52 blocks used,

364 unused

EXAMPLE:
L(dir transaction involving writing the directory subset to a

device other than CONSOLE:
Prompt:

Dir listing of what vol?

User T'e·sponse:

*FIL=TEXT, PRINTER:

causes

IVJYDISK:

FILERDOC2. TEXT
28
1-Sep-78
FILERDOC1.TEXT
24
1-Sep-78
2/10 files , 52 blocks used, 364 unused

to

be w~en

to the

Pnint~.

Page 17

EXAMPLE:
L(dir transaction involving writing the directory subset to a
block-structured device:
Prompt:

Dir listing of what vol?

User response: #4:FIL=TEXTI#5:TRASH creates the file TRASH an
the volume associated with unit 5.
TRASH would contain:
MVJ}ISK:

FILERDOC2.TEXT
FILERDOC1. TEXT
2/ 10 f

8) E(xtended

j

1e5

28
24

1-Sep-78
1-Sep-78
<1 i s ted lin~" d j, r :> t 52 b 1 0 (: k S

U$

e d.,

364 v nus e d

list

Lists the directory in more detail than the L(dir command.
All files and uflused areas are listed along with (in this order>
thei'r block lengthl last modification dat9.1 the starting block
address, the number of bytes in the last block of the file, and the
filekind.
All wildcard options and prompts are as in the L(dir
command.

An f.')(ample displ;ty

MYDISK:
FILERDOC2.TEXT
A,OUT.CODE
F5. TEXT

28
10
8



10

ABSUnD

is shown below.

1-Sep-78
1-Sep-78
1-Sep-78

6
34
44

Textfile
Codefile

512
:512
512
512
512
512
512

Da t ,,:l'f'! i 1 e

Textfil@

52

4

1"-Seo---78

62

HYTYPER.CODE
STASIS TEXT

12
8

1-Sep-78
1-Sep-78

66
78

LETTER1. TEXT

18

1""Sep-78

86

ASSEMDOC. TEXT

20

1-Sep-78
1-Sep-78

104
124

FILERDOC1.TEXT
24
STASIS, CODE
6
1-SRp-78
148

354
154
10/ 10 f i 1 es .( 1 i s ted ./ i n -- d i 'r:>, 130 b '1 0 c k sus e d
~)

512
512
512

I

Cadefile
T£':.;tfi.le

Textflle
Texti'.;ile
Textfile
Codefile

364 :,; n us e d I

354 in 1 aT' 9 est are a

C(hange
Changes

~il~

or voluw@ name.

This command requires two file specifications.
The first of these
specifies the file to be changed, the second, to what it will be
changed.
The first specification is separated from the second
specification by either a -('ret:> OT' a comma (', ').
Any volume ID
info~mation in the second file speciFication is ignored,
since
obviously the 'old file' and the 'new file' are on the same vQlume~
Size specification Information is ignored.
'age 18

Given the example file F5.TEXT,
P~ompt

;

residing on the volume occupying unit 5:

Change what file?

User Response:

#5:F5. TEXT,HOOHAH

changes the name in the directo~y from 'F5. TEXT' to 'HOOHAH'.
Although filekinds are originally determined by the filename,
the C(hange command does not affect the filekind.
In the above
case, HOOHAH would still be a text file.
However, since the
S(et command searches for the suffix '.TEXT' in order to load a
text file into the workfile, HOOHAH would need to be renamed
HOOHAH. TEXT in order to be loaded into the workfile.
Wildcard specifications are legal in the C(hange command.
If a
wildcard character is used in the first file specification, then a
wildcard must be used in the second file specification.
The subsetspecifying strings in the first file specification are replaced by
the analogous strings (henceforward called replacement strings)
given in the second file specification.
The File~ will not change
the filename if the change would have the effect of making the
filename too long (~15 characters). Given a directory of example disk
NOTSANE: containing the files:

POEMS. TEXT
MAUNDER. TEXT
MALPRACTICE
MAKELISTS. TEXT
EXAMPLE:

Prompt

Change what file?

User response: NOTSANE:MA=TEXT;XX=GAACK
causes the Filer to report
NOTSANE:MAUNDER. TEXT
changed to XXUNDER.GAACK
NOTSANE:MAKELISTS. TEXT
changed to XXKELISTS.GAACK

Page 19

The subset-speci~ying strings ma~ be empty, as may the replacement
strings.
The Filer considers the file specification '=' (where b~th
subset-specifying strings are empty) to specify every file on the
disk. Responding to the C(hange prompt with '=,Z=Z~ would cause eve~y
~ilename on the disk to have a
'z' added at 'rant and back.
Responding to the prompt with 'Z=Z,=' would replace each terminal
and initial

'1

~

with nothi.ng"

Given thePilenarnes:

THIS. TEXT
THAT. TEXT
EXAMPLE:

Prompt
U~pr

Change what file?

Response:

T=T.=

The result would be to change
and

'THAT. TEXT' to

~THIS.

TEXTi to 'HIS. TEX',

'HAT. TEX'.

The volum€ name may also be changed b~ specifying a volume
to be changed, and a volume 10 to change to.

ID

EXAMPLE:

Prompt

Change what file?

User Response:
ge~~rates

NOTGANE_,WRKDISK.

the message,

NOTSANE'

changed to WRKDISK'

LO) R(emove
Remov~s

file entries from the dIrectory.

Thi~ command requires one file speci~ication for each file the user
wishes to remove.
Wildcards are legal.
Size speciflcation
information is ignored.
Given the examD12 files (assuming that they
are on the default vDlume):

AARDVARK. TEXT
t.
Wildcards are peTmitted~ and size
specification information is recognized for the destination 'ile.
This ct,mmand 'reQ.uires

that the user wis~e. to transFer the file FARKLE.TEXT
from tne dis~ MYDlSK to the dlSk ilACKUP.

AS6um~

EXAMPLE:
P~ompt:

Uqe~

Transfer what file?

R~sponse:

MVDISK:FARKLE. TEXT

Page 21

Prompt: To where?
(Note: On a one-drive machine, do NOT remove your source disk
until you are prompted to insert the destination disk)
User Response: BACKUP:NAME.TEXT
Prompt: Put in BACKUP:
Type  to continue
The user should remove the source disk, insert the destination
disk and type a .
The Filer then notifies the user:

MYDISK:FARKLE.TEXT transferred to BACKUP: NAME: TEXT
The Filer has made a copy of FARKLE and has written it to the
disk BACKUP giving it the name NAME. TEXT.
If the specified
file is large, the user may be prompted to alternately insert
the source and destination disks until the transfer is
completed.

It is often convenient to transfer a file without changing the name,
and without retyping the file name.
The Filer enables the user to
do this by allowing the chaTacter ~$' to replace the filename in the
destination file specification.
In the above example, had the user
wished to save the file FARKLE. TEXT on BACKUP under the name
FARKLE.TEXT, she could have typed:
MYDISK:FARKLE.TEXT,BACKUP:$
WARNING: Pl~ase try to avoid typing the second file specification
with the filename completely omitted! For example, a response to the
Transfer prompt of the form:

MYDISK:FARKLE.TEXT,BACKUP:
generates the message:
Possibly destroy directory of BACKUP: ?
iV' answer causes the directory of BACKUP to be wiped out!

Files may be transferred to volumes that are not block structured,
such as CONSOLE: and PRINTER:, by specifying the appropriate volume
ID (see Figure 1) in the destination file specification.
A file
name on a non- block-structured device is ignored.
It is generally
a good idea to make certain that the destination volumeis on-line.

age

22

EXAMPLE:
Prompt:

Transfer what file?

User Response:
Prnmp t:

FARKLE.TEXT

To whe.re?

User Response:

PRINTER:

causes FARKLE.TEXT to be written to the printer.
The user may also transfer from non-block-$tructur~d devices,
providing they aT~ input devices.
Filenames accompanying a nonblock-structured device 10 are ignored.
The wildcard capability is allowed for TCransfer.
If the source
file specification contains a wildcard character, and the
desti"ation file specification involves a block-structured device.
then the destination file specification must also contain a wildcard
character.
The subset-specifying strings in the SOUTce file
sp~cification will be replaced by the analogous strings in the
destination file specification (henc.fD~ward known as replacement
strings).
Any of the sub~et-5pecifying or r~placement st~ings may
be empty.
Remember that the Filer tonside~s the file specification
!=' t~ speci~y ev~ry file on the volume.

Giv~n

th~

PENALTY,

User

vo]um~ MYDISK containing the files PAUCTTYJ
and the destination ODDNAMZ:

Re~PDnse:

P=TY,QDDNAMZ'V=S

would cause the Filer to
i1VDISV. . : PAUC I TY

MYDISK:PARITY
r1YDISK: PENALTY

PARITY and

~eply:

transferred to ODDNAMZ:VAUCIS
transferred to ODDNAMZ:VARIS
t~an$ferred to QDDNAMZ:VENALS

Using '=' as the source filename sp~cification will cause the Filer
to attempt to transfer eye~y file on the disk.
This will probably
ove~flow th~ output buffer.
(The~e are easier ways to transfer
whole disks.
If you wish to do this, please refer to the material
in this section on volume- to- volume transFers. )

Page 23

Using '=' as the destination filename specification will have the
effect of replacing the subset-specifying strings in the source
specification with nothing.
A brief reminder: '?' may be used in
pla.ce of '='.
The only difference i.s that '?' causes the user to be
asked for verification before the operation is performed.
A file

can be transferred from a volume to the same volume by
specifying the same volume ID for both source and destination file
specifications.
This is frequently useful when the user wishes to
relocate a file on the disk.
Specifying the number of blocks
desiT't:d will cause the Filer to copy the file in the first-ou
area of at least that size.
If no size specification is
given, the file is written in the largest unused area.

If the user specifies the same filename
destination on a same-disk transfer,

TO~

both source and

then the Filer rewrites the

file to the Size-specified areal and removes the older copy,
EXAMPLE:

Prompt:

Transfer what file?

User Response:

#4: GUIZZES. TEXTI #4: GUIZZES. TEXT[20J

causes the Filer to rewrite QUIZZES. TEXT in the first 20-block
area encountered (counting up from block 0) and to remove the
previous version of GUIZZES.TEXT.
WARNING: Wildcard-type specifications do not always work very well
on same-disk transfers.
The results tend to be unpredictable,
the$e operations are not recommended.

so

It is also possible to do entire volume-to-volume t~ansfers.
The
file specifications for both source and destination should consist
of volume ID only.
Transferring a block~structured volume to

another block- structured volume causes the destination volume to be
'wiped out' 50 that it becomes an exact copy of the source volume.
Assume that the user desires an extra copy of the disk MYDISK: and
is willing to sacrifice disk EXTRA:
EXANPLE:

Prompt:

Transfer what file?

User Response:

MYDISK:fEXTRA:

Prompt: Possibly destroy directory of EXTRA:

Page 24

?

WARNING: The~e's no 'possibly' abDut this! If the user types
'V', the directory of EXTRA: !!till. be destT't)l.jed! An 'N'
response will ~eturn the use~ to the outer level of the Filer,
and a 'V' will cause EXTRA to become an exact copy of MYDISK.
Often this is desi~able f.or backup purpo~es, since it is
relatively easy to copy a disk this way, and the volume name
can be changed (see C(hng) iT desired.

Although it is certainly possible to t~ansfer a volume (disk) to
another using a single disk-drive, it is a fairly tedious process,
sine e the i n'~c or'e t,~an$ fer read s up th e i nfol' mat i on in rath er sma 11
chunks, and a g~eat deal of disk Juggling i~ necessary fo~ the
complete transfer to take place.
12)

O(ate

Lists current system date,
PT'omp t:

and enables the user to change the date.

Date Set: <1 .. 31>-- OR 6 the new date will be displayed.
Typing only a return
does not affect the current date.
The hyphens are delimiters for
the day, month and year -rl.eldsJ and it is possible to affect only
one or tWtl of th~se fields.
FoT' example, the year could be changed
by typing "--79',1 the month by typing '-Sep I, etc.
The entire month-

Th~

name can be entered, but will be truncated by the Filer.
Slash
(//') is alsD acceptable as a delimiter.
The most common input will
be a slngle number, which will be interpreted as a new day,
For
example, if yesterday was the 19th of August, the user would want to
type D20, which would have the desired effect of changing the
date tC.i the 20t;h of :'\U9t.'~~t.
The d~Hj'~"month-'ye:·ar' o'rder is inviolate,
h oweve t"

This date will be associated with any files saved during the current
session and will be the date displayed POT those 9iles when the
directory is listed.

13) P(refix
Chan 9 ~\;' the

C i....r 1-

e n t~ d e 'r. a u 1 t t o t h e vol u me s pee i fie d .

This command reqldT'es the 'Jser ·to type a volume ID.
An entire .file
specification may b~ entered, but only the volume ID will be used.
It is not necessary for the specified volume to be on-line.

Page 25

To determine the current defatilt

y61um~1

the user may Tespond to the

prompt wi th f.'
14) BCad blocks
Scans the disk and detects bad blocks.

This command requires the user to type a volume ID.
volume must be on-line.

The specified

Bad blocks scan of what vol?

Prompt:

Response:



Checks each block on the indicated volume for errors and lists
the number of each bad block.
Bad blocks can often be fixed or
marked (see eX(amine).
15) eX{amine

Attempts to physically recover suspected bad blocks.
This command requires the user to type a volume

I~·

The volume must

be on- line,
:::XAMPLE:

Prompt

Examine blocks on what volume?

Response :  generates the
Prompt:

Block number-range?

The user should have Just dane a bad block scan, and should
enter the block number(s) returned by the bad block scan.
If
any files are endangered; the fallowing prompt should appear:
Prompt:

File(s) endanger'ad:


T-ry to fix th em'?
Response:

#Y' will cause the FILER to examine the blocks and
return either of the messages:

Block  may be ok

in which

~ase

the bad block has probably been

~ixed,

or

Block  is bad
in which case the FILER will offer the user the option of
marking the block(s) BAD. Blocks which are marked BAD will
not be shifted during a K(runch, an~ will be rendered
ef~ectively harmless.
An 'N' response to the 'fix them?' prompt returns the user to
the outer level of the FILER.

WARNING: A block which is 'fix~d' may contain garbage.
'May be
ok' should be translated as 'is probably physically ok'.
Fixing a block means that the block is read. is written back
out to the block and i~~read again.
If the two reads are the
same! the message i~; 'may be 0;';
In th@event that the i'e"ads
are different} the block is declared bad and may be marked as
~uch if so desired.
i.

16) K(T'unch

Moves the files on the specified volume
combined at the 'end' of the disk.

50

that unused blocks are

This command r.quiT~5 the U$&T to type a volume 10.
The specified
volume mU5t be on-line.
It is strongly recommended that the user
perform a bad block scan of the vo10me before K(Tunching in order to
avoid writing filps over bad areas of the disk.
If bad blocks are
encountered, the~ must be ~ithe~ fi~ed or marked before the K(runch
(see

~X(,3mirH:),

As each file is moved, its name 15 reported to the console.
If
SYSTEM. PASCAL is mcved, the system must be reinitialized by
b 0 t s t T c\ P P 1 ri 9 .
Don 0 t t 0 U c: h t h t~ diE k r the h [\ Q t -.. S tlI i t c h 0 r the dis k drive door until KCrunch tells you It has completed its task.

t'

EXAMPLE;
Prompt

Crunch what vol?

Response : 

causes Filer to prompt with:
Prompt : Are you sure you want to crunch ?

Page 27

Response: 'V' initiates the K(runch. Typing an 'N' will return
the uSer to the outer level oT the FILER.

17) M(ake

Creates a directory entry with the BpecifiedPilename.
This command requires the user to type a file specification.
Wildcard characters are not allowed.
The file size specification
option is extremely helpful, since, if it is omitted, the Filer
creates the specified file by consuming the largest unused a~ea of
the di~k.
The Pile size is determined by following the filename
with the desired number of blocks, enclosed in square brackets
.I

r. /

an d

J'

J;,

Some special cases are:

[0]

e~uiyalent to omitting the size specification.
created in the largest unused ar~a.

The file is

[*l -

the file is created In the second largest area,
largest area, whichever is larger.

or half the

EXAMPLE:

Prompt

Make what file?

Response :

MYDrSK:FAR~LE.

TEXT[28J

Creates the file FARKLE.l"EXT on the volume MVDISK:
unused 28-block area encountered.

18)

Z(ero

Reformats the specified volume.
i rretr ievab 1 e.

The previDus

:::XAMPLE:

Prompt:

Zero dir af what vol?

Response:
PromptResponse:

~ag

in the first

e 28

 blocks?
Response: 'N' generates
Prompt: # of blocks?
Response: User will type number of blocks desired
(usually the maximum permitted for the system's disk
recording density, 170 for single-density, 340 for
double-density, and 690 for quad-capacity). Filer
proceeds with sequence below.

'Y' senerates
Prompt: New vol name ?
Response: User types any valid volume name.
Prompt:  correct?
Response:

'Y' causes the Filer to respond with the message:

 zeroed

Page 29

-t-l~s.

age 30

-.

**************************

*

SCREEN ORIENTED EDITOR

***~*************

* *

Section 1.3.1

*

************************** *****************
VeT'sion L 5

September 1978

This introduction, which describes the idea behind the Editor.
is the first of four sections.
The second section is a tutorial for
the novice"
While the Editor is designed to handle any files. the
tutorial section uses a sample program to demonstrate how to use the
most basic commands to madi'y a file.
The third section contains a
detailed description of each commdnd. with examples, and the fourth is
for tuick reference.
THE CONCEPT OF A 'WINDOW' INTO THE FILE

The Screen Oriented Editor is specifically designed for use
wit h Vi d ~ 0 Dis p 1 a y T e T min a 1 s.
On en t e l' i n 9 any f i 1 e
the Ed ito r
displays the start Or the file in the upper left hand corner of the
SCTe~n.
If the file is too long for the screen, only the first portion
is displayed.
This is the concept of a 'window'.
The whole file is
there and is accessible by Editor commands, but only a portion of it
can be seen through the 'window' of the sc~een.
When any Editor
command takes the user to a position in the file which is not
displayed, the uwindow" is updated to show that portion oT the file
i

THE CONCEPT OF A CURSOR

The cursor represents the exact posl~lon in the file and can be
used to move to any position.
The window shows that portion of the
file near the cursor.
To see another portion of the filel move the
cursor.
Action always takes place at the cursor.
Some of the commands
permit additipns; c:hange~ O'f' deletions of such length that the screen
cannot hold the whole portion of the text that has been changed.
In
those cases, the portion of the screen whe~e the cursor stopped is
displayed.
In no case is it necessary for the user to operate on
portions of the text not seen on the screen, but in some cases it is
cIj:d; i ana 1.

THE CONCEPl OF A PROMPT LINE

The Editor displays a prompt line as the top line of the screen
in order to remind the user of the current mode and the options
available for that mode.
Only the most commonly used options appear on
the prompt line as the following display shows:
:>E d .i t ; A ( d JUS t" C { P Y D ( 1 e t e F (i n ct

! ( Tn; r t

J { fi'I P

i~ P 1 ate

G { iJ i t

X( c h n 9 Z ( a p

NOTATION

The notation used in this ~ection corresponds to the notation
used to prompt the user in the editor.
Any input that is enclosed
between a < and> is requEsting that a particular key be used, not that
the partitule:.7' ;..)01"'0 be

tl~ped

out.

FOT"

~xample ..

(RET)- means that the

return key should tYPBO at that point.
When a particular sequence of
key strokes is required they will be contained within quotes.
For
examplEh ·'FILENAME":  refei-s to the typed sequence uFILENAtvIE"
foll{)w~d

by

t;~~ing

th0retu':rn

when typing Editor commands.

l{elj,

Lower

C.i'

upper' case may be used

[ E. 6 -

******************* *****************

*

GETTING STARTED

* *

Section 1.3.2

*

******************* *****************
ENTERING THE WORKFILE AND GETTING A PROGRAM.
On entering the Editor
No workfile is

pre~ent.

File?

 for no file)

appears,

There are two ways to answer this question
1) Wi th a name,

-POl"

examp Ie "STRINGl

'(T'et~>~',

The of i Ie named

STRING1 will now be retrieved.
The file STRING! could contain a
program, also called STRING1, as in Fig. 2. 1.
A~ter typing the name,
copy of the text of the 'irst part of the file appears on the SCTeen.

a

Figure 2.1
PROGRAM STRING! ,;

BEGIN

r SE '

)

WR I TE ( ;' YOU ARE')
WR I TELN ( I 1 ' ) i

i

WR I TE (

~

TOO

t~

i

WRITELN( 'TOO WISE');
WRITELN('YOU BE')
END.

2) With a (rEturn'. This implies thclt a new file is to be
started.
The only thing visible on the sc~een after doing this is the
editor prumpt line.
A new workfile is opened and currently has nothing
in it.
Type teI" to begin inserting a program or tE"Kt.
Workfiles: No questions are asked if a workfile already
The work~il~ is displayed and can be modified or can be
cleared, in order to start a file, by using the N)ew command in the
Fi ler.
exists.

Page 32

MOVING THE CURSOR
In order -to edit,

it is necessary to move the cursor.
On the
like triangles)1
which move the cursor. The  moves the cursor up one line, the
 and the cursor moves to the "W"in "WRITE".
SimilaT'ly at the "W" in "WRITE( "TOO WISE').i It, use '(left-arrow)- to move
to after the liN" in IIBEGIN",

Figure 2.2

BEGIN_
WRITE('TOO WISE ');
BEGIN
wRITE('TOO WISE

the th i

')j

If it is necessary to change the "WRITE('TOO WISE ')i" -Pound in
1 ine to a .lWRITE ( 'TOO SMART I) i u, the cursor must oF i rst be

l"d

moved to the right spot.
For example: if the CUT'SOT' is at the "P" in "PROGRAM STRING1; ",
go dawn two lines by pressing the down arrow 2 times.
To ma~k the
positions the cursor l.Jccupiesl labels aJ b, C a~e used in Fig. 2.3.
"au

is the initial position of the curso'f';
the first ;

"c u

,

"btl is where the cursor is after

after the second .

Figure 2.3

aROGRAM STRINGl
bEGIN
c WRITE( 'TOO WISE ');
Now,

using the right

aT~OWI

move until the cursor sits on the

"Wit of ItWISE".
Note that with the use of  the cursor
a p pea r s to be;) u t sid e the t E' X t .
Act u it 11 Y i 't iSiS t the ft WIf i n II WR I T E" ,

so do not be surprised when on typing the first  the cursor
j U in pst 0

-f; h e

'J

R II i n

II

WR I TE

If •

USING INSERT
item,

The Edit level prompt line shows that to I(nsrt (insert) an
The CUi"sor must be in the cOT'rect position befor'e

type !tIlt.

typing "Iii.
EaT'lieT'1 the Cl.1T'SOT' was rlH'J'-.ted to the "W" in IITOO WISE";
on t4ping III H , ;Hl in;!i.i::l·tion will be made before the "Wil.
The rest
of the line from the point of insertion will be moved to the right hand
side of the screen.
In the event that the insertion is lengthy, that

nOWI

Page 33

part of the line will be moved down to allow raomon the screen.
t y pin 9 "I u the of" 1 1 0 win 9 p 1" 0 mp t 1 i n e s h \'J U 1 d ap pea ron the 5 C l' e en:

Afte~

If that prompt line did not appear at the top Qf the screen it
is NOT insert mode and a wrong key may have been typed.
If the cursor is at the uWII, and on typing "IH the insert
prompt line appes'f.'e~:L HSMART" ma\J be in~ert~d by typing those five
letters.
They will appear on the sc~een ag th~yaT'e typed.
There remains one more important step.
Th~ choice at the end
of the prompt line indicates that pW$h1ng the  key accepts the

insertion, while pushing the  key rejects the insertion and the
text remains as it

~as

typir:g

bef.orE'

'11"

BEGIN WRITE( 'TOO SMART
Figure 2.5 (Screen after

WISE

');

~etx»

BEGIN
WRITE( 'TOO SMARTWISE ');
Figure 2.6 (Screen after , 'WISE'
must be deletedMove the cursor to the first of the items to delete
type flD" to put the Edi
line should appear:

and

:> Del e t

e.

(

") ·!:...M c- ''; 1 n 9

tOi'

{~Q ;n fll a rid

s>

into DELETE mode

{< e t x > t 0

del

€I

te,

The f'ollolding prompt

-( esc ). t

Each time  is typed a letter disappears.
example typing 4

spaces will

cause

0

abo 1" t }

In this

IIWISE'! to disappear.
Now the same
Type  and the proposed deletion

choice must be made as in insert.
is made or type  and the proposed deletion reappears and remains
part of the text.

Paae 34

It isl.gal to delete a carriage return.
At the end of the
line, enter DELETE made, and  until the cursor moves to the
beginning of the next line.
These are sufficient commands to edit any file desired.
The
next section describes many more commands in the Editor which make
editing easier.

LEAVING THE EDITOR AND UPDATING THE WORi-\FILE
When all the changes and additions have been made,
Editor .and "'save" a copy of the modified program.
typing

"G"

w~ic.h

exit the

This is done by

will cause the pTcmpting displa'J shown in Fig.

2.7.

Figure 2.7
)Quit:

U(pdate the work file and leave
EGuit.

e x pIa ins in

Page 35

************************************ *****************

*

DETAILED DESCRIPTION OF COMMANDS

* *

Section 1.3.3

*

************************************ *****************
COMMAND AND MODE
I~; t
t h i" E ct i t 1 ~ \I ~ J t h t? T' t? i-H' 0 ihH' q I) P tic 1'1 $ • ';;\ 0 me 0 .p "'J 11 i chat r e
referred to as commands and some as modes depending upen the appearance
of 'the prompt. I-f an option executes d task and returns control to ·the
Edit level. that option is called a cnmml~nd. If! an optinn issues a
prompt and gives the user another level of options, i t is called a
mod e . On en t e r i n 9 0 l' T' e t urn t n 9 t () thE? F d i t 1 ~ \/ E' 1 t the E ~ i t (') T' 1"' e dis P 1 ill Y s
the "Edit: I, prompt line.

REPEAT··FACTORS

Many of the commands allOW

Tepeat-facto~s_

A repeat-factor is

applied to a command by typing a number immediately before issuing the

command which is then repeated for the number of times indicated by the
T'epeat--t~act;or.

FoT' eiiample:

tlJping

 commma~d to he executed twice, moving the curSDr dawn two
lines
Commands which allow a repeat-factor assume the repeat-factor
to be 1 if no numb~r is typed bef~re the comm5nd.
A 'I' typed before
the command implies an infinite number.

THE CIJRSOR
It $hould be point:ed out that th~ cursor is never really :lata a
character.
The cursor is only allowed to be Hbetween" characters.
For
inst,,3nce, :lof th,.~ curSDr' looks 2.50 tho'-,gh it j.,:, ,3t the letter "R", l.t is
act1Jally between the

letter "R" and

t:hf~

Jettf"'"''

in fT'ont of it.

This is

most clea~ly cn the inse~t cnrnmanrl as it in~erts in front of
the c h a rae t e r the c ~rr ~ 0 r ~\J a s I, _s t " .
Qnt.: h £ S C '["' e e t1 the c U'1" SOT' i s pIa c e d
Hat tl IIR" to make it e-asie~ to display

notic~d

DIRECTION
C e i' t a inc. a mm ~ n G;:; a l' e a f' fee ted t,. !.j d i :" e ;;.: t i I::' ("f , 1 f t h {Z' d i 1"" 0' C t ion
of! 0 T W 2. r d I f: h \~ r"! they 0 (.,-:, !:" t ? f:: f' ~i' '0 r d t ~"; ':'; '.' 9 h. + ~; I~) -f j 1 e . t h ;:3, t h ei. 1"'l 9 ~:. Ii eo
s tan d aT' :j d ire c t; i I) n 0 f ~ - ~ d d 1 n 9 Eng 1 i :5 fL
L ;;i ':: h 1.:J d f' d s i s thE- reverse
direction.
When direct.1on ,aft'!ects the command it is Epec i t~.icall'J

i s

noted.

MOVING COMMANDS
'(d

own-aT' 'f' Ot,:.I)

!'1oves down
Mov'es LIp



-( 1 e.p t--arr ow:>
....c: H or " I U or

or !I.

:').11

11

l'1oves right

Moves left
~:r_'f

or tI+"

Changes the
Changes the

di~Ection

to backward

di~ection

to forward



Moves diT'Ection
Moves l~'ft

<1:ab>

Moves

<,..eturn)-

of 8 spaces from the left side of the screen
Moves to the beginning of the next line

Page 36

di~ection

to the next position which is a multiple

I

ne

a l' r

f)

W

......

~

l..J I

".~.

... . .

....... •• "'

_.

- •• -

r

- - -- . .-

-

-

indicates dir·ection; H<" foT' backward and ")" TO~ forward.
On entering
the Editor, the direction is forward.
The direction can be changed
by typing the appropriate comm~nd whenever the itEdit: II prompt line ],s
pre~ent,
The period and the comma can also be u~~d because on many
standard

key b o~rd S I

case for

iI-(lf.

;:.

II

is 1 O'.i.H~T'-·case for

I I ) II

and

U I

II

i

5

the 1 Qwer-

Repeat-factors can be used with any of the above commands.
For user convenience, the Editor maintains the column position
of the cursor when USiTtg  and .
When the CU~SoT'
is outside the text, the Editor treats the CU~SOT' as though i t were
i mme d i a t i? 1.J aft e T' t ~ 0 1 i;,} s t c ha l' act e r t '0 r b e for e the of iT'S t ) i nth e l i n e .

typing

JU!"IP mode< is T'l:acho?tl by

an
>JUMP

ent~rLng

B(eginning ECnd
T 'J P i 1"'9

" B"

end) of the fi!e,
p a 9 fi' 0 f thE': f i. 1 & .
1 i ne'

(o r

foT' ,J(mp while at the Edit

" . j'i

J0MP mode tne following prompt line appears:
M(arke~

/, E Ji)



m(: \.' f!' S

the

C!.J 'j' So 07'

t; 0

the beg j, in! 1 n 9

(o T' the

the edit prompt line and the first (or last)
T y pin 9 It i"'~ :a (:,~ i) ~ e s t h e Ed i t (I T~ to dis pIa y the p or 0 mp t

di;pla~s

The name of the marker must be entered followed by a .
The Editor will then move the cursor to the place in the file with that
n~me~

Ir the

ERROR:

i!H~l"k~n'

is not irithe ftl>? the Editor will display:

Marker not ·there.

rhe

Please press  to continue.

instructlofiS fo\' %etting

Mierell~neous

~

ln~.;)\'keT·

are detailed

in SET under

command~

PAGE
IS ex-s![ui:ed by 'typing "P" while at the Edit
Depending on the direction of the arrow at the beginning of the
prompt line, PAGE com~and moves the curSD~ one whole 5creenful up or
dewn,
The CUTsor alw~ys moves to the 3t~rt of the line.
A <~epeat­
fact.or) maij be us~d berore this comm~nd ·Fc.r moving several pages.

Pt1tGE cDmmand

le~el.

eQUALS

CCm\l~B·:~,J

li

~i:::CL,-,tt:'d

b;,.

t,ypiny

"::.;~"

while

at

the Edit

It causes the cursor to Jump to the beginning of the last
s~ction of te~t which was inserted,
found or replaced from anywhere in
the file.
Equals wo~ks f~om 3n~where in the file and is not direction
sensitive.
An INSERT. FINO or REPLACE cause the absolute position of
the beginning of the insBrtion. find or replacement to be saved.
TI,Jping "::::" c~uses the Cl!i'sor to Jump to that position.
I f a copy OT' a
deletion has been mad~ between the beginning of the file and that
absolute position, th~ cursor will not Jump to the sta~t of the
insertion as that absolute position will no longer be correct.
level.

Page 37

TEXT CHANGING COMMANDS
INSERT

INSERT mode is reached by typing "I" .par "I(ns .... t ll while at the
Edit level.
On entering INSERT mode the following prompt line appears:
Jlnsert:

Text «bs> a charJ acceptsl  escapes]

line}

One of the options here is to type in text followed by .

type .
The INSERT prompt line indtcates
and u a line",

th~se

by

" a char"

Typing  INSERT starts a new line at the levQl of
indentation specified by the options turned on in Environment section
of the SET mode.
S~e the section on the SET mode in order to set these
options.
AUTa·~, INDENT

If Auto-indent is True. a  causes the cursor to start
the next line with an indentation equal to the indentation of the line
above.
If Auto-indent is False, a  returns the cursor to the
first position in the nelCt line.
po~ition

Note:

i~

Filling is True,

the first

is the Left-margin.

FILLING
If

Fil1i~g

is True.

the Editor

fo~res

all

inse~tiDns

to be

between the right and leFt margins by automatically inserting
's between fiwOT'ds whenever 'the T'ight maT'gin would have been
exceeded and by indenting to the Left-margin whenever a new line is
started.
The Editor considers anything between two spaces or between a
space and a hyphen to be a word.
ti

If both Auto-indent and Filling are True, Auto-indent controls
the Left-margin while Filling controls the Right-ma~gin.
The level of
indentation may be changed by using the  and  ke~s
immediately after a <~eturn>.
Important: This can only be done
immediately after a .
Exa~ple

c"peate $

1: With Auto-indent true,

the following sequence

th e i nd en tat i on sh own in Fig ure 3. 1.

"ONE U ; (return)', i "TWO",
'(T" e turn)'; ,I THREE jJ, ,  
<~eturn) causes auto-indentation to level of line above
 changes indentation from level of line above

Example 2: With Filling T~ue (and Auto-indent False> the
following sequence creates the indentation shown in Figure 3.2:

"ONCE UPON A TIME THERE- WERE".
(Very n.rrow m.rgins have been used for simplicity. )
Figure 3.2
----_._--------------------------------------------------------------~-

ONCE UPON A

Auto-returned when next word would exceed margin
Auto-returned at hyphen

T It'1E THERE-

WERE
Level of left margin
Filling also causes the Editor to adjust the margins on the
portion of the paragraph following the insertion.
Any line beginning
with the Command character (see SET mode) is not touched when filling
does this adjustment and that line is considered to terminate the
paragraph.
by

The direction does not affect the INSERT mode,
the direction of the arrow on the prompt line.

If an insertion is made and accepted,
available for use in the COpy mode.
However,
is no string available for COPY.

but is indicated

that insertion is
if  is used, there

DELETE
DELETE mode is reached b~ typing nOli for "D(lete while at tht!
Edit level.
On entering DELETE mode the following prompt line appears:
ll

>Delete:

< >  «etx) to delete, , to abort}

In order to delete, the cursor must be in position at the first
character to be deleted.
On typing "0" and entering DELETE, the
Editor remembers where the cursor is. That position is called the
anchor.
As the cursor is moved from the anchor position using the
normal moving commands. text in its path will disappear.
To accept
the deletionl type i to escape/ type .
When  is typedl
del e ted
emp ty.

for COP Y t

0

use;

the Editor saves everything which was
but i f <: e 5 c:> i sty p e d the cop y b u f fer i s
I

Example:
In Figure 3.3:
1) Move the cursor to the liEn

<: n

in END.

T his c han 9 est h e d ire c t ion t 0 b a c k wa r d )
Type 110" to enter DELETE mode.
4) Type  .
After the fir~t return the cursor moves to
before the "W" in l..JRITELN and "WRITELN( 'TO BE. ') i ltd isappears. After
the second return the cursor is before the "W" in WRITE and that
line has di5appeared.
5) Now press . The program a~ter deletion appears as is shown in
Figure 3.4.

2)
3)

Ty pe

\I

(

Page 39

The two deleted lines have been stored in the copy buffer and
the cursor has returned to the anchor position.
Now use the COPY
routine to copy the two d~leted lines at any place to which the cursor
is moved.

Figure 3.3
PROGRAM STR ING2i

DEGIN
WRITE( 'TOO WISE

')i

WRITELN( 'TO BE. ')
END.

Figure 3.4

PROGRAM STRING2:
BEGIN
END.
The  may also be used to delete several lines as
once by prefacing a  or any other of the moving commands with a
 while in delete mode.
ZAP

The ZAP command is executed by typing HZ" for Z(ap while at the
Edit level.
This command deletes all text between the start of what
was previously found, replaced or inserted and the current position of
the cursor.
This command is designed to be used immediately after one
of the FIND, REPLACE or INSERT commands.
If more than 80 characters
are being zapped the editor will ask for verification.
repeat
zapped.

Repeat-factors and Zap: If a FIND or a REPLACE is made with a
and then ZAP, only the last find or replacement will be
All others will be left as found or replaced.

f~ctor

Whatever was deleted by using the ZAP command is available for
use with the COpy command.
COpy

The COpy c:ommand is executed by typing "e" for C(py while at
the Edit level.
On entering the Copy mode the following prompt line is
displayed:

>COPY: B(uffer F(ile



To copy text from another file,
will appear:

Page 40

type "F" and another prompt

>COPY: FROM WHAT FILE[MARKERIMARKERJ?
Any file may now be specified, . text is assumed.
In order to copy part
of a file, two markers can be set to bracket the desired text.
If
marker] or [marker, ] is used, the fi Ie wi 11 be cop ied from the
start to the marker or from the marker to the end.
On completion of
the copy command (from file), the cursor returns to the beginning of the
text Just copied from the file.
Use of the copy command does not
change the contents of the file being copied 'rom.
[

I

To copy the text in the copy buf-Fer, type,uB" and the Editor
immediately copies the contents of the copy buffer into the file at the
location of the cursor when ftC" was typed.
0" the completion of the
copy command the cursor returns to immediately before the text which
was copied.
Use of the copy command does not change the contents of
the copy buffer.
The copy buffer is affected by the following commands:
l)DELETE: On accepting a deletion, the buffer is loaded with
the deletion; on escaping from a deletion the buffer is loaded with
what would have been deleted.
2) INSERT: On accepting an insertion the buffer is loaded with
the insertion; on escaping from an insertion the copy buffer is empty.

3)ZAP:
the deletion.

If the ZAP command is used the buffer is loaded with

The copy buffer is of limited size. Whenever the deletion is greater
than the buffer available, the Editor will issue a warning upon typing
 with the line:
There is no room to copy the deletion.

Do you wish to delete anyway? (yIn)

EXCHANGE
EXCHANGE mode is reached by typing "X" while at the Edit lev.l.
On entering EXCHANGE mode the following prompt line appears:

>eXchange: TEXT «bs> a char} [ escapes;  acceptsJ
EXCHANGE mode replaces one character in the file for each
character of text typed.
For example in the file in Figure 3.5 with
the cursor at the "Wit in WISE, typing "X" , followed by typing "SM·'
will replace the "W" with the "S" and then the "I" with the "Mil le4ilving
the line as shown in Figure 3.6 with the curSOr before the second US".

Figure 3. 5

Figure 3.6

WRITE('TOO WISE ');

WRITE('TOO SMSE ');

Typing a  <<:bs» will back the cursor one character
and cause the original character in that position to reappear.
As with
most oth~r commands, when in EXCHANGE mode,  leaves the mode
without making any of the changes indicated since entering the mode,
while  makes the changes part of the file.
01'

~ 0 t e : E " c h fa n qed n e s not all 0 t11 "J2J!l?_i n 9 . pac; t the end
typing in a carrlage return.

0

f

the lin e

FIND AN.D REPLACE
In both modes the use of a  by the prompt
lines, is the target string and is refer~ed to by both command~ while
the other, called  by the p~ompt line, is the substitute and is
used only by REPLACE.
ThePollohling rules apply to both these strings.
Delimiters: Both delimiters Qf the string will be the same.
For exampl~: Wher in RrPLACE mcd@ th? following command is valid and
will replace the fi1"st occurrence of th~ churacter "[II with the
character "]": 11«<)])". Here II·C It and It)" are the delimiters,

The Editor considers any character which is nnt a
letter or a number to be a delimiter.  is a particularly common
del imi tel'.
Direction~
Both modes operate from the position of the cursor
to scan the text in the direction indicted by the arrow on the prompt
line.
The target pattern can only b~ found iT it appears in that
section of the text.
See the section on direction on order to change
the arrow

Literal and Token mode: In Literal mode, the Editor will look
for any occurrences of the target string. If you are in Token mode the
Editor will look for isolated occurrences of the target string.
The
Editor considers a string isolated if i t is surrounded by any
combination of delimiters.
FoT' examplel in the sentencf' "Put the beok
in the bookcasp.. "; u5ir~g the target st;1"ing "bock!!, literal mode will
find two occurrences of "book" while token mode will find only one} the
word "book" isolated by the delimiters .

To use token mode, type "Til after the prompt line and before
the target string; to use literal model type "L".
The de~ault value
found in the Environment may be over-ridden by typing ilL" or liT" as
appropriate.
Token mode ignores spaces within strings so that both
"( ',' )" and "(', ')" are considered to be the same string.

Paae 42

The Same op tion: In both commands typ ing "S" ind icates to the
Editor that it is to use the same string as used previously.
For
example, typing "RS/l" causes the REPLACE ·mode to use- the
previous target string, while typing "R//S" causes the
previous substitute string to b~ used.

FIND
FIND mbde is reached by typing "F" while at the Edit level. On
entering Find mode one of the prompt lines in Figure 3.7 appears.
Figure 3.7
>Find[ll: L(tt 

>FindC1J: Teak 

The FIND mode find~ the n-th occurrence of the  string
starting with the current position and moving in the direction shown by
thearT'ow at the beginning of the prompt line.
The number "nil is the
 and is shown on the prompt line in the brackets He]".
Example 1: In the STRINGl program with the cursor at the first
"P" in PROGRAM STRINGl type "F".
When the prompt appears type
'WRITE"'.
The single tl,uote mal'ks MUST be typed.
The prompt line
should now appear as:
II

)Find(ll: L)it 

=~'WRITE!

After typing the last quote mark the cursor Jumps to immediately after
the "E in the fir 5 t WR I TE.
f!

Example 2: In the STRING1 program with the cursor at the "E" of
fiEND. II type: u-(" "3" "FIf.
This will find the 3rd ("3 11 ) pattern in the
reverse ("<") direction.
When the prompt 1 ine appears type IWRITELN/.
The prompt line should read:
-(Find[31: L)it 

=>/WRITELNI

The cursor will move to immediately after the liN" in WRITELN.

Figure 3.8
PROGRAM STRINGli

BEGIN
WRITE('TOO WISE ' ) i
WR I TE ( , YOU ARE');
WR I TELN ( " ');
WRITELN('TOO WISE ')i
WR ITELN( 'YOU BE. ')

END.

<*CURSOR STARTS IN THIS LINE*)

Example 3:
the first "WRITE".
~Findr1l:

(*CURSOR FINISHES IN THIS LINE*)

On the first find we type flF/WRITE/".
This locates
Natal typing "FS" will make the prompt line flash:

L)it 

=~S

and the cursor will appear at the second WRITE.
REPLACE
REPLACE mode is reached by typing URn while at the Edit level.
On entering REPLACE mode one of the twa prompt lines in Figure 3.9
appears. In this example, a  of four is assumed.
Figure 3.9
>Replace[4J: L(it V(fy   =)
>Replace[4J: T(ok V(fy  =)
Example 1: Type "RL/GX//YZ/" which make the prompt line appear as:
>Replace[lJ: L)it V)fy   =>L/GXI/YZ/
This command will change: "VAR SIZEOX: INTEGER; It to "VAR
SIZEYZ: INTEGER; ".
Literal mode is necessary because the string OX is
not a token but is part of the token SIZEOX.
Example 2: In Taken made REPLACE ignores spaces between token~
when looking for patterns to replace.
For example, using the lines on
the left hand side of Figure 3.10 and typing: "2RT/(',' )/. LN ... Th.
prompt line should appear as:
>Replace: L)it V)fy   =>/(', ')/. LN.
Immediately after the last period was typed those two lines
would change to those on the right hand side.

WR I TE (
WR I TE (

I:

! I

WRITELN;

J);
~.);

WRITELNi

V)fy: The verify option permits examination of the 
string (up to the limit set by the rep@at factor) and deciding if
it is to be replaced.
The following prompt line appears whenever
REPLACE mode has found the  pattern in the file and verification
has been requested:
( dOEsn't

T Y pin g a 1': II R II a t; t; h j. ~1 P c :i n t {jj J 1], c au {'; fl i~ rep 1 ace men t OJ h i 1 e
typing a space will cause the REPLACE mode to search for the next
occurrence provided the  has not been reached.
The
 counts the number of times an occurrence is found, not
the number of times you

ac:tl..I~11y

typ.e

URI!.

Ufif? eI/" as a

'(T'epeat-·f\~r.toT':>

in order to replace every occurrence of the target string.
Editor can no longer find the target string, the prompt:

Once the

ADdUST
15 reached b~ typing HI'"," whi.le at the Edit level of
On entering ADJUST mode the following prompt line appears:

ADJUST. mode

Command.

>AdJust: L «etx> to leave}
The ADJUST mode is designed to make it easy to adjust the
indentation.
On any line the  and  commands
move tne whole line. Each time a  is t~ped the whole line
moves one space to the right.
Each (left-arrow> moves it one tD the
left. When the line 15 adjusted to the desired indentation pres~ <@tx>.
After prs5sing ,  cannot be used.
1'il

DT'd~:";"

t~1

':;'i,1.JUi;t

~

i.~JhC')l~~

s~~ql}(~r!f"f~

of li.nes;

adjust

one

then use  «down-arrow»
comm~nd5 and the line above
will b A automatically adjusted by the s~m~ amount.

C omm·!tf1 d s

Repeat-factors are valid when
wh i 1 e in AD·.)us"r ma de-.

u~ed

linf~§

(below)

before any of the 

AD,JUST mode can also center or ,Justi-fy text. Typing ilL" while
in ADJUST mode will cause the line to be left-Justified to the margin
set in the Environment. Similarly typing uR'; right~-Justifies to the sat
ma r gin and t \j pin 9 r. C W 1. l I e ~ u 'S e the 1 i net 0 b e c:: en t e l' 0 d bet l..0 e en the
set m~rgin5. Typing  (or  li~ .~'~~ I'I:Ui.h d'S pu~,sible withou'c violating
the above t~rep margins
See th~ EnviTonm~nt option under the SET mode
for how to set the margin values,
Example:

Ttt~

t h t'? p i:H'c:\ mf~ t e r son t h
bee n

Ml:'\R G

r N f.! d w t t h t

p":'lI·agi'arh In rl9~q~ ~~. 13 h-.'ds been Ml\RGINed with
1 €' f t w II i 1 e t. h f.:' S ~1!'\;?,' par .:E'q;p'~ ~ phi n F i 9 u r e 3. 1 4 has
l'"l t? p.3 r a In ~.' t f~ T'!~ 0 if the r l. 9 h t.

€'

L f? f' t --, ill::-! ';' 9 i;, :';
Right-·m.;J.rq tTl 1,2
P t:..~ 'r a 9 i' "~ P h _. if; d T q ,1 II

T his q u .~ rtf.? T,
arE-

s\.Ibst~T',t:i.all·y

of T" 0 m p"l' e v i Q tJ S
t; 0 0 k t II f~ ;:

wh (j

Figure

~i,

0.. U c3 i'

L. 1=1f' t·· .iT~'~1 r' gin 1 0
Right-mat'g in 70

a

Paragrdph-m~rgin

t h r~ e n, li i ;:: 1'f\ f! n t

di~'fF'r-0'n~,

:;!~;fd

t

ltl l 1.~

Y0

€' T ': .

0 I., i 'f' S ~.

P '~' f'

\j

i

U

0 ~ t :; ],~

thf:'

j

s d}

P of P T'

c:;"\:}·:-'t::~

b E' m i. s :l e d

toe 1" i e ;; t

~.i

('j

e p. t!

0

t h t? r.

{i

[.r~.!.:3niz\-:;:ti.on

iJ T' S. fl

is

mE:I t ~ r· i a 1 'S
d:i..ff~'l"~nt

if. you d €? P Po n rl up 0 n ·a f! 'r ]. end

v t c t.: h~:: co U T' ~~ if:'

14
thi: equlpment is d.iffeT'ent;, the course materials are
substantially different. and the courne o~9anization is
different from previous quarters.
You will be misled if
you depend upon a friend who took the course previously to

Thi"5 quarter,

GPient

ijou

tc

th:'?

!:OUT;~~.

------------------------------------------------------------------------------------

Pane 46

A paragT~ph is defined to be something occurring between two
blank lines.
To MARGIN a paragraph move the cursor to anywhere in that
paragraph and type "M?!.
Whan doing an exceptionally long paragraph it
may take several seconds before the routine is ready to redisplay the
SC1"'een,

COMMAND CHARACTERS
Portions of the text can be protected from being MARGINed by
the usa of the Command Lharacter.
If the Command character appears as
the first non-blank character in a line then that line is protected
from the MARGIN command.
The MARGIN command treats a line beginning
with the comm.snd characteT" as tlHHJgh l.t were fa blank line, that is, it
will consider that line to terminate (begin) the pa~ag~aph.
Warning: Do nat un~ the MARGIN command when in a line beginning with
the Command character.

MISCELL('~NEOUS

CDNHt-\NDS

SET

SET mode is ent~red by tvp l.ng "S" wh tle at the Ed it level..
The prompt for the SET command does net appear- on the "',)£:d l.t: II pT'ompt
line due to space limitations.
On entering the SET mode the following
prompt line appears:

>Set:

M(a~ker

E(nvironment



M.

so that lower and upper cases of the

same letter are considered to be dlfferent cha~acte~$.
Th~ marker will
f.~ 'f' e d 116 t
t h !E pes i ti (i n Q f the C U f' S 0 'r' i nth e t e ~ t j the i' e ·f Q rei of iT's t
move the cur90~ to the desired position before setting the marker.
(If
bee r; t
the

m~~keT'

alread\l

existed>

i t will be

T'e%·et.)

Only 10 markers are allowed In a fila at anyone time.
"8MH! the prompt:

Ii! on typing

Page 47

Figure 3. 15
Marker ov-F lw.
Which one to replace.
0) name1
1) namp.2
9)namel0

it is necessary to eliminate one in order to replace it.
Choose a number 0 thru 9. t~pe that numb~r and that space will now be
available fa~ use in setting the desired marker.
appears~

If a copy or deletion is made b9tween the beginning of the file
and the position of the marke~f the mar~pr will not subse~u&ntly return
to the desired place ~s th~ absolute position has changed.
E (nvi ronment:

Th. Editor

the us~r to set the environment which the
convenient fQ~ thp editing being done.
When
in the FET modf~ t~jpe "Ell fQ"!"' E or  tn le-i,v\?,
ACuto indent True

L(ePt mar-g:in

0

R( i 9ht
p (,:IT';~'l

79

ftH!tT' gin
m·~T' 1.1 i n

C(ommand

en

T(nken dE?f

,'.
Trul:,~

Patterns ~
= 'xyzr, =

'abc'

----------------------------------------------------------------------

Pane 48

B~

be changed.

typing the a.pp~opriate letteTI any or all of the options may
The options shown are the d~fault options for the Editor

on the Terak 8510A.
differ~nt

Implementations for other machines may have

defaults.

The Options;
A(uto indent:
Auto-indent affects only the INSERT mode of the Editor. Auto(tu'rnf:'?o on) h~l tuping "AT" and to False (turned

indent is s8t to Tr'u~
of of) b tj t IJ pin 9 .. AF II •

F(illing:
Filling affects the INSERT mode and allows the MARGIN command
to function.
Filling is s~t to True (turned on) btl typing JlFTJI and to
False by typing "FF".
L(eft fNaT'g:in
R ( i g h t: ffi.-:.'i l' gin

P ( a r a m;:,\ r- gin:

When Filling is
marg ins wh i ch affec t

affect the Cent~r and
t h P. L £? T t; ,- ma T' gin, t q P t~

T~ue

the

the margins set in the Environment are the

INSERT mod e and

the l'1ARGIN command.

They a 1 so

commands in the ADJUST mode.
To set
of 0 1 1. 0 lotH:' d h!.j -::I 13 0 ~ i t 1. ve 1. n t e geT' ,'a n d a <: 5 P ~'a {" @ :> .

Justi~ying
u

LH

The positive integer typed should replace the old value for the L(eft
margin in the prompt shown in Figure 3.16
All positive intege~s with
less than four digit~ are valid margin values.
C(ommand ch:
The Command character affects the MARGIN command and the
Fi 11 ing upt:3.on in the INSERT ITHHie a~ described in those sections.
Change Ct)mmand chaT'actel'$ b~J typing I'C H -folloloed btj any character.
For
example typing '~CH; Il~\.i' will change th~' Comm~nd cha'racter to u*".
This
change will be reflected in the p~ompt.
T( oken der:

This option affects FIND and REPLACE.

Token is set to True

typing "TTl! and to False by typing "IF!!,
If Token is True,
the dei!ault ,-;,nd if Token is False, Literal is the default.

b~

Token is

Page 49

VERIFY
The VERIFY command is executed
Th~~

Edit level.

status of

th~

by

typing "V" while at the

Editor is verified by displaying the

updated screen.
The Editor attempts to adjust the window sa that the
CUT'90r is at the center of the screen.
GUIT
GU I T mod e i
ent~ring

S

T'

e a c h e d b Y t y pin 9

f!

wh i 1 eat the Ed i t I e vel.

GU

On

QUIT mode the screen display is replaced by the following

p1"'ompt:

Figure 3.1"7
~;.G{'J

it:

UCpdate the work file and leave
E(xit without updating
R(etuT'n

to

the e-ditoT' without Upd2;t:i'ng

W(rite to a file name and return
On €I

0

f

t h F,!I f

0 IJ 1"

0

Pt i

Q

n5

m'.J s t

bEts e 1 e c ted

b y t Y pin 9 U, E J R

t} T'

W.

U(pdatf~'

This causes the Editor to

l.4ii'itF:

thE

fi1.~;.

just ffi:')difir:d

into the workfile and store it as SYSTEM. WR~. TEXT.
It is available
for either the Compilp O~ Run option~ o~ for the Save option in the
File"!'
Thp F~1f?7' treat5 SYSTEi1.WR~{ TFX'r ,~'3 +(Ji!r file
E(xit:
This

C2·iiS(;H'.i

the EditoT"

tn

11;?:~\-·E·

l~li

t.hnut

,'!!.;r.JGui t:

Namn of output file

Page 50

«C~>

to return)

-->

The cUr'sor
Gil. wa 5
t'JPing tlG1 1 .
rt

The modified file may now be written to any file name.
If it
is w~itten to the name of an existing file, the modified file will
replace the old file.
This command can be aborted by typing 
inste~d of a file name and ~eturn will be to the Editor.
After the
file has been written to disk, the Editor will prompt with the
followin9~

Figure

~J

19

:-;:·Gu i t
Writing .... _
Your file is 1978
Do.

you

Ui ..:\ n

t

lang.

b~tes

toE. (x,Lt f

i" 0

m

0,..'

R ( e t u r' n

t

G

the Ed ita or?

Ttj ping liE" ex its rl'o;n the Ed i tor and 'f'et urns to th e Command
lev(?l while typing "R!' returns the cursor to the exact position in the
of i 1 e as when
Q
wa s 1.; y p e d .
I!

it

********************* *****************

*

REFERENCE SECTION

* *

Section 1.3.4

*

********************* *****************


.(,:: 1 e of t-arT ow:>


 lines down
II
I;
1 i nes up
II
H
spaces right
Ii
spaces left
spaces in direction
"
,t
spaces le-pt
ffi0ves <~epeat-factor> tab positions in direction
moves to the beginning of line  lines in directic
tI

change dire~tion td backward
change direction to forwaTd
moves to the beginning of what
exchanged
A(dJu~t-

C(opy:

W3S

Just found/replaced/insertedJ

AdJust··~ the ind~~ntation of the line that ·the l::ur$O,- i$ on.
U5e
the ar~DW keys to move. Moving up (down) adjust line above
(below) by sam~ amount of adjustment on the line you were on.
Repeat-f~ctors are valid.

Copies what waG last inserted/deleted/zapped into the file at
the position of th~ cur50~.

D(elete:

Treat·s· the starting position of: the cursor as the anchor.
any moving

commands

to move the. cursoT'.

Use

 delates

everything between the cursor and the anchor.

Page 51

F(ind:

Operates in L)iteT'al or Tioken mode.

Rr.pea't-·factol's aT"e
string as b.fore

v/ijlid~

Finds the  string.

diT'Ectlon

i~)

applied .

HSU;::;:;

use 'same

Insert15 text, Can use  to reJEH:t part of
insertion.

I(nsert:

\lOUT'

.J (ump :

J u mP!i

M(argin:

AdJusts anything b@tw~en two blank lines to the margins which
been set. Command characters protect text from being
margined.
Invalidiltes the COP\} tHd~fl:.. r.

t o t h e beg inn in 9 ten d or

j:H' eo v

i

0 US

1 ~.f s ~ t

rna r k e r' .

hav~

P(age: Moves the cur~or one page in
valid: dIrection is applied.
G ( u it:

R( ep

Lea v ~ 5

the e d i t Gr.

~irection.

Y t) U may U) p d ate.

Repeat-factors are

E ) x i t; I

W) T> i t e

,!

0r

R)

e t tJ r n .

D p to:! 1" ate ~ ! n L < i t. ~ r ,3 l o r T ( 0 ken mQ de. Rep 1 ace s the .( tar g )string with th~  causes the
original Ch,:3T';;:~:t""TL to 'rg-'appe.3r.

mode-.

Z)ap:

Treat. the

position o~ the last thing
as an 2nchor ~nd d@let~s Dverything
between the anchor and the current cursor posItion
~ta~tin2

fnund!r~place1/in~eTted

 is any number typed
i n Fin i t f? n U ff) t ~,..' ,

Page 52

befor~

a

comm~nd

Typing a I

is the

************* *****************

*

* *

L2 EDITOR

Snction 1.3.5

*

************* *****************
Version L 5

September 1978

The L2 Editor is being released on an experimental basis.
Not
all option~ a~e yet fully implemented so this section may not be
complete. The main advantage of this version is that it is able to
handle files larger than can fit into the main memory buffer at one
time; the upper limit being determined by the space available on disk.
It al~o automatically makes a backup copy of the file being edited.
In
many Tflspects this Editor wa~ks exactly as this release and displays
the same prompt lin~s.
Whe~a the versions are the same,
the user is
dirncted to read the m0in Editor section,
Entering the
If~

ERROR:

WQrk~ile

and Getting a PrcgTam

on 't;yping E,

th::::re

not enough room on the disk;

i~

Not enough roam far backup!

will be displayed.
This dlSk must then be K(runched in order to
provide reom if that is possible, a file removed or another disk must
be used.

The same prompt line is displayed;

see section l. 3.2.

1) With a name.
If a file is chosen, a backup copy will be
made before the file is available for editing,

:::Ed it;

A·~

in

t his ";' ,~ 1" ).\~ ,;,,:

t. l] T'

s~ction

0 .f!

fi l' 0 m p t

1 in e S I t h ifJ

fir s t

p ~ l' tor

the

t ext

1.3 2.

Th8

pa . tagr~~phs

sectittn 1.3. 2.

~,hould

Ofl

be

mt'hiir'lg

th;;~

curE,OT'·

InffieT't and Delete

in

'f'ead and ar'f! applicable here.

Leaving the Editor and Updating the workfile
When all changes and additions have been made, the Editor is
ex i ted b tJ t ~J ft .i D 9 II Q 1= a 11 r. t h (~ f 0. lID tl:' i n 9 p 'r 0 mp t i s dis pIa y e d.

Figt:re 5.2
U(pd~te the wnrkfile and leave
ECxlt (but workfile not updated)
R(eturn to the Editor without doing anything.
_ _ _ _ _ _ _ , _ _ _ .......... _ _ ,.

_

...... _ _ ~ _ _ _ _ r _ _ _ _' U... _ _ _ _ _ _ _ _ _ _ _ _ _. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ . . , . . _ _ ~ _ _ _ - - - - -

Notice that the Write aptian is no longer available.
One of
these three options must be chosen.
S~e also Miscellaneous commands
in section 1.3.3,

lHpdate:

This works in the same manner, however additional in~ormation
is supplied indicating the name 09 file updated and the length.

When a new file is cTeated,

the fallowing appears:

Figure 5.3

Writing.*
The work~ile,

When an

*SYSTEM.WRK. TEXT,

is n blocks long,

file has been used,
now given:

exi~ting

info~mation

this exarople shows the extra

Figur'e 5.4

Writing.*
The wcrkfile. *X:Fl.TEXT, is 44 blocks long.
The backup file is X:Fl BACK
The newly edited file is referred to as . TEXT, while the . BACK file
cont~ins the original file with no modifications.
E(xit:

This ca~ses the Editor to return to the command level without
making any changes in the workfile.
No . BACK file is made and the
existing . BACK is removed,
For example, if Fl. TEXT is the file being
used, then a copy Fl. BACK will be made an ~ntering the editor and on
leaving by using the E option, Fl.BAC~ will be removed and only Fl. TEXT
HrHJ:evel~,

will remai.n.

since Fl. TEXT is a

will be in different place in the

ropy of the o'''igin4:'11"

it

di~ectory.

R(et.uT'n:

This is the same.
MOVIN(i

c; .:L'

i)

'I

See section 1,3.3.

COt'1t~ANOS

n"

Jump mode displays the same prompt line as befure.
and

" E " r e -f ii! 'f' t o t h e beg inn j n 9 ( en (1

j

(}

f

beginning(end) of the file.
Typing

\lt1"

causes the Editor to display:

In this

the b (J ~ f e'f' not t h it

Jump. to what marker?
It is now possible to use 20 ma~~ers and these will be set in
tl1e ';5·:.?m~ !Af~y as in section 1. 3, 3..
To JDmp to the desired mSr'keT'1 type
in to@. namf:?,
l'r the rnt2r'!Q?r is pT'esent. tht:! Editor will Jump to that
position, otherwisel the Editor' will Jump to the last position of the
CUTSO~ in the file.
If Find needs to search a section 0 ' the file,
o t. 1'1 ~ l' t h -tH1 t h tl b v f of eo r
L e ,3 p i it g. . ' . ., will bed i s pIa y e d' .
BANISH
J

lev~l_

This is a new command and is reached by typing US" at the Edit
This is the p~ompt that will appear:

:> B ':'H'! i

h:

~

Tot h f.To L ( ~... 'F t;

0 T'

R( i 9ht

(esc»

Prior to doing a large insertion or copy, in order to provide
more room in the buffer and avoid buffer overflow, it is possible to
move charactflTs from t~~ buffer into the stack.
There is a left and a
right stackj

left being ahe-c1d of the

and right,

CUT"SOT'

behind the

cursor

The USRr can make the choic~ acco~ding to the current
situ~tion,
In general, the screen is the boundary for the operation.

NEXl
In

ordfi.~r

The following

tp move beyond

p~ompt

the

b~,)lJndc;~

of the bufFer,

type

t'Nti.

will then be displayed:

implicit h.:lni~.d~ nCCt.p"'~; using the r.U'P~fji' {Z\'; thE' point of
e
F' {:'. T' {-n:~:re mp ]. p ; ttl hen ., F II i s t IJ P ~ d ! ~: '\." ~ l' Y t h :i n gab Q v e t h e top 0 of!
the screen is b~"ished to the left stack.
More characters are added to
the bottom of the SCTeen to extend the buffpT in the fD~ward
di·i"'fi'ction.
Wh~n "Ef: .is us~d the charerb?T's tH:lt::lt\,l the CUT'sor ST'e
ban i .~ fl edt c the rig h t s t: a c k and p (~l' t o f t h e ~> Cf' e en w.i 11 bee 0 me b 1 ~3 n k .
l'n!',

"r"

':?' t·

:!'

Mor~

ii~rl

'r' ~~ n

,-;'

charactp~s

Fi gUT'S 5.

aro added above the

'window' of the screen.

SVi'-1BOLIC FILE

t)

lef:t

: B.n r.

~t;,r.!(

in~'.a l' d 'EJ

BUFFER

right stack
FOT'ward
End

Page 55

PAGE
See section 1.3.3.

EGUALS
See section 1.3.3.

TEXT CHANGING COMMANDS
INSERT
See section 1.3.3.

DELETE
See section 1,3.3.

ZAP
See section 1.3.3,
COpy
See section 1.3,3.

EXCHANGE
Sae section 1.3.3.

FIND
Read section 1.3.3. The Editor' wi,ll display:
and if the patte~n is not in the buffer:
End of buffer encDuntered.

Get more

f~Dm

disk?

Finding ...... .

(YIN)

On typing !ly,r, the Edito'f' will move another section of the file
into the buffer to conti.nue searching.
Find is still directional

See section 1.3.3.

FORMATTING COMMANDS
AD.JUST
802

Page 56

$e~tion

1.3.3.

MARGIN
See section 1.3.3.

MISCELLANEOUS COMMANDS
SET

See section 1 3.3.

The same prompt line is displayed.

Read section 1.3.3.
The namos of the markers can be seen by
'POl' Set Environment while at the Edit level.
To set the
marlleT·; tlJPe USt'1".
In the ev~nt that 20 melrkers have already been set,
this will be indicated by:
typing

USE~\

Mar k er over-P 1 00.1.

Which one to replace? (Type in the letter or 

E

t (') 1 e 21 \l ~

ACuto Indent False
F(illing True
L('lJP3
August

15,

1978:

Last updated August 15t

1978 (Revision 1).

By typing th9 appropriate letter, an4 or all of the options can
changed.
SeQ section 1.3.3.
Thp arrow before the mark~r name
indicates th~ relative position o~ the marker in the file to the
buffer.
No arrow indicates that the marker is in the current buffer.

Page 57

It is now pt,1ssible to vary the tabstops.
Type usn while in the
environment and the following prompt will appear:

At pregent, the~e are not yet fully implemented so that the effect of
using any of them is to have a variable tabstap instead of being set at
eight characters apart.

VERIFY
See section 1.3.3.

Page 58

******************************************** ***************

*

YET ANOTHER LINE ORIENTED EDITOR - YALOE

* *

Section 1.4

*

******************************************** ***************
VeT'~

S(~P

i on I. 5

t emh el"

1978

This text editor is intended for use on systems that do not
have paw~~ful ~creen terminals.
It is designed to be very similar to
the text-~ditor which accompanies DEC's RT-l1 system.
1 h e e d ito r ass IJ me S J b li t i s n {) t ct e p. E~ n den t 0 rl, the e xis ten ceo f
the workfile text.
Upon reading i t YALOE will proclaim 'workfile STUFF
read

If it does not find such a file,

in~.

file 't"OcHi

in',

This means that

i t will proclaim 'No
you ent;e1"ed YALOE with an empty

wo~k

From this point you may create a file in YALOE; and whpn you
t b Y t Y pin 9 , au ..
you i' l*J t1 f' k f i .1 e w j, 1 1 n c 1 (j n geT' bee mp t y .

wD~~f11e.

e )( i,

I

The editor operates in one of two modes: Command Mode or Text
In command mode all keyboard input is interpreted as commands
inst~urtinq th~ editor to perform some operation.
Wh~n you fi~~t enter
thp editor ~ou will be in the Comma"d Mode.
Thp Text Mode is ent~~ed
wherleY~7 the user type~ a command which must be followed by a text

Mode.

string,
filt~1

the' commf"3nd F(ind,

Af.teT'

G(et.

l is

~'·J(T'it:?

chsr~cteTg

Nnte: Wh~H-' typed  echoes a '$".
The  terminates the
and causes the editor to re-enter the Command Mode, at
which point ~ll characters are again considered commands.
t~Jped.
t~xt

st~ing

NOTE:
execut~
t'.

Fallow command

them.

st~ings

in YALOE with  to

(This is unlike the rest of the systems 'immediate'

ommr:;r;\.i s. j

1, 4. 1

SPECIAL

~EY

COMMANDS

Vi:JT'ious chaT'1:'lctel'5 have special meaningsl

as

dt-~sc"'ibed

below.

of these apply only in YALOE.
Many have simila~ efFects in the
rest of the system; for thesE thp ASCII code to which th~ system
responds as indicated can be changed using the program SETUP, described
inS ~~ c t i "n 4. 3. ( <:: esc. :> i s thE in 0 ~ t P a"f' tic u 1 a 1" an 0 rna 1 y toY ALOE.. )

Echoes a ~$'.
A single  ax@cutss the command st~ing.

Som~

RUBOUT

Deletes

<1 int'ch'l>

'(Zt\p'

On hard-copy terminals echoes
return,
On othersl it clears
the current line on the screen.
In both cases the
contents of that line are discarded by the editor.
cu~rent

and

a

line.

st~in!

caT"'r'i~ge

Page 59

CTRL H


Deletes character from the current line.
On hardcopy terminals it echoes a percent sign ¥ollowed by
the character deleted.
Each succeeding CTRL H the
by th. user deletes and echoes another character.
An enclosing percent sign is printed when a key other
than CTRL H is typed.
This erasure is done right to
left up to the beginning of the command string.
CTRL H may be used in both Command and Text mode.

CTRL X

Causes the ~ditor to ignore the entire command
string currently being entered.
The editor
responds with a  and an asterisk to
indicate that the user may enter another
command,
For example:
*IDALE AND
KEITH'(CTRL

X>

*
A  would cause deletion of only KEITHi

CTRL X

would erase the entire command.

CTRL 0

Will switch you to the optional character set
(i. e. bit 7 turned on).
This works only on the
TERAK 8510A.
The CTRL a is used as a toggle
between the character sets.
NOTE: You may find
while in the editor that weird characters are
showing up on the terminal instead of normal
ones.
It could be because you accidentally
typed CTRL O.
TQ get bac k Just type CTRL 0
again.



All output to the terminal is discarded by the system
until the next CTRL F is typed.

CTRL S
-(-stop)

CTRL S is. typed,

CTRl. F

All output to the terminal is held until another

All ather control characters are ignored and discarded by YALOE.
COMMAND ARGUMENTS

1. 4. 2

Acommmand argument precedes a command letter and is used
either to indicate the number of times thF command should be performed
or to specify the particular po~tion of text to be affected by the
command.
With some commands this specification is implicit and no
a~gument is needsdi
other commands, however, require an argument.
CDmmand arguments are as follows:

P~nn

Lf\

n

n stands for any integer.
It may be preceded by a + or -.
If no sign preced&s n, i t is assumed to be a positive number.
Whenever an argument is acceptable in a command. its absence
implies an argument oT 1 (O~ -1 if only the - is present).

m

m is a number O.. 9.

o

10;

I

I

I'

refe~s

to the beginning oT the current line.

means 32700.

f_/'

means -32700.

It is used for a large

T"€1opeat factoT".
-

1. 4. 3

I~is used only with the J, 0 and C commands and
Tapresents -n, wh~re n is equal to the length of the
lSit text argument used~ for example
*GTHIS$=D$$
finds and removes THIS.

CDMMAND STRINGS

All EDIT command strings are terminated by two successive s.
Spaces, ca~riage returns and tabs (CTRL Il within a command string are ignored
unless they appear in a text string.
Several commanas can be strung together and executed in
sequenc:e.

For'

exampl~:

GTHE INSERTED$

-3CING$

5K

GSTRING$$

As a rul~, commands are separated from one another by a single
-(esc:>.
This separa'ting ; a second
 signals the end of a command st~ing; which will then be
execut~d.
When the e~ecutian of the command string is completej the
e d ito 1" p r' G mp t s for' t h 8 n ~ x teo mm.a n d wi -t h I.nlo

J' •

If at any paint in &xecuting the command, an error is
enc{ltJnteT'~,d;

thp comm..:)nd wi 11 be teT"min.;:1ted.

leaving the command

executed only up to that point.

1. 4. 4

THE TEXT BUFFER

The current version of your text i~ stored in the Text Buffer.
This buffer's area is dynamically allocatedi its size and the room laft
for expan&ion may be ascertained by using the? command.

Page 61.

The editor can only work ~n files that fit entirely within th~
Text Buffer.
The Screen Oriented Editor in the next major rele~se will
not have this limitation.

14.4

THE CURSOR

The "cursor" is the position in your text where the next
command will be executed.
In other words it is the current
"pointer" into the Text Buffer.
Most edit commands function with
respect to the cursor:
Moves it.
text from where it is.
U, I ,R ;
Add text to where it -is.
C,X:
Remove and then add text at it.
L,V:
Print the text on the terminal from it.

A,B,F,Q,J:
0,10<.:

1.4.5

R~move

INPUT/OUTPUT COMMANDS
L(ist, V(erify. W(rite, R(ead, G(uit, E(rase, and 0

The L(ist command print~ the specified number of lines on the
console terminal without moving the cursor.
Prints all characters starting at the second
preceding line and ending at the cursor.
*4L$$

Prints all characters beginning at the cursor
and terminating at the 4th .
Prints from the beginning of the current line up
to the cursor.

The V(erify command prints the current text line on the
terminal.
The position of the cursor within the line has no effect and
the cursor is not moved.
No arguments are used.
The V(erify command
is equivalent to a OLL (list) command.
The W(rite command ia of the form
*W$
File title is any legal file title as decribed in Section 1.2
less the file typP.
The editor will automatically append a '.TEXT'
suffix to the file title given unless the filp. title ends with '.',
']', or '. TEXT'.
If the filename end'S in a ' " the dot will be
stripped from the filename.

Page 62

Th. W(rite command will w~ite the entire Text Buffer to a file
with the giv~n file title.
It will nat move the cursor no~ alt~r the
contents of the Text Buffer.
If there is no room for the Text Buffer on the volume specified
giv~~n,
the message:

in the file title

OUTPUT ERROR. HELP!
will be printed.
It is still possible to write the Text Buffer out by writing
it to anothe~ volume.

The R(ead command is of the form
*R$

The editor will attempt to read the file title as given.
In
the event no file with that title is present~ a '.TEXT' is appended and
a new search is made.
The R(ead ~ommand inserts the 3pecified file into the Text
Buffer at the CU~SD~.
The cursor remains in the Text Buffer before the
text in.erted.
If the file read in does not fit into core buffer, the
entire Text Buffer will be undefined in contentl
unrecoverable error.

The Q(uit command has

au
GE
,GR

G

seve~al

i. e.

this is an

farms

Quit and update by writing out a new SYSTEM.WRK. TEXT
Guit and escape session;
do not alter SVSTEM.WRK.TEXT
Don't Q.uit; retu'rn to the edito'!"
A prompt will be sent to the terminal giving all the
above choices) enter option mnemonic (U, E, or R) only.

Executing the OU command is a special case of the write
commandt and the attempt to write out SYSTEM. WRK, TEXT may fail.
In
this ca;e use the W command to w~ite aut your file and then BE to exit
the editoi'.
typed~

The GR command is used on thn occasions when a G is accidentally
and ~ou wish to return to the editor rather than leave it.
The E(rase command (intended for CRT terminals) erases the

Sf:re~n.

The 0 command (also intended Tor CRT terminals) can be used to
have the (ontext around the cursor displayed on the screen each time
the Ct.H;$\H' i.~ mt"!v~H.1,
The argument of the 0 command deter-mines the si ze
(# of lines) in that context.
This aption is initially disabled when
the editor is entered and can be enabled by issuing an 0 command.
A

second 0 command
@nable-,

di~sbles

disabltre etc.

The

the aptian;
CU'rso-r

is

succeeding

denr~ted

'D's successively

as a split in the line.

Pi~g €I

63

1.4.6

CURSOR RELOCATION COMMANDS
J(ump,

A(dvanc:e.I B(eginning,

Q(et .. F{ind

When using character and lina oriented commands, a positive (n
or +n) argument specifies the number of cha~acters or lin~s in a
forward direction, and a negative argument the number of characters or
lines in a backward direction.
The editor recognizes a line 01 text as
a unit when it detects a  in the text.
Carriage return character& are treated the same as any othe~
character.
For example assume the cursor is positioned as indicated in
the following text (A rep~esent$ the current position of the cursor and
does not appear in actual use
It is pre~ent here only far
cldrification):

THERE WAS A CROOKED MANA
AND HUMPTY DUMPTY FELL ON HIM
The J(ump command moves the cursor over the specified number of
character$ in the Text Buff~r
The edit command -4J moves the cursor
back 4 characters.
THERE WAS A CROOKEDA MAN
AND HUMPTY DUMPTY FELL ON HIM
The command 10J moves the cursor forward 10 characters and
places it between the 'H' and the 'U/.

THERE WAS A CROOKED MAN
AND HAUMPTY DUMPTY FELL ON HIM
1 ines.

The A(dvance command moves the CUT'$or a specified number of
The cursor is left positioned at the beginning of the line.

Hence the command OA moves the cursor to the beginning of the
current 1 ine.
THERE WAS A CROOKED MAN
·. .·AND HUMPTY DUMPTY FELL ON Hlt1'(CR>

The command -lA (or -A)

mov~s

the cursor back one line.

ATHERE WAS A CROOKED MAN
AND HUMPTY DUMPTY FELL ON H!M
is typed.
The cursor 19 positioned immediately after the last
character of tria insert.
Occasionally with large insertions the
temporary insert buffer becomes full.
Before this happens a message
will be printed on the console terminal, 'Please finish'.
In response
tYPf: two 'SfJcces5ive s.
To continue, type I to return to the Text

mode.
NOTE: Forgetting to type the I command will cause the text
entered to be executed as commands.
The [Helete command removes a s.peciflied numbel' of cha'r.3cters
from the Text Buffer, starting at the position of the cursor,
Upon
completion of the command_ the cursor's position isat the first
charact~r following the deleted text,

Page 65

Deletes the two characters immediately preceding
the cur'soT'.

*B$FHOSE

$=D$$

D@letes the first string 'HOSE · in the Text
Buffer, since =D used in combin~tion with
a search command will delete the indicated
text string.

The K(ill command deletes n lines from the Text Bufferj
starting at the position of the cursoT'.
Upon completion of the
command. the cursor's position is the beginning
the line following
the deleted text.

0'

*2K$$

Deletes characters starting at the current
cursor position and ending at (and including)
the second ~
1',11 COfTH'!H'H1ds are legal in
a macro command string.
Example of a macro definition:

*5M%GBEGIN$=CEND BEGIN$V$'l.$$
This defineG macro number 5.
i t

to i l l

1 t,10 k of! i".H' t h I?

S

t r-:i n 9

, BEG r N

When macro number 5 is executed,
change it to

'END BEGIN'

when defining a marra,

the message

I

v

then display the change,

If an

e~ror

o~curs

'Error in macro definition'

I

and

will be printed, and the macro will have to be redefined.

string.

The execute macro command, NI
The form of the command is:

executes a specfied macro command

nNm$

Here n is simply any command argument as previously defined; m
is the macro number (an int~ger O.. 9) to be executed.
If m is omitted,
1 is assum@d.
Becaus. the digit m is t.chnically a command text
string, the N command must be terminated by an .
Attempts to execute undefined macros cause the error message
'Unhappy macnum'.
Errors encountpred during macro execution cause the
message 'Error in macro'.
Errors encountered in macro command syntax
cause the message 'Error in macro definition'.
The? command prints a list of all the commands and the sizes
of the Text Bufferl Save Buffer, and available memory left for

expAnsion.

Page 68

SUMMARY OF ALL C O~tt1ANDS

1.4.9

n'-

nA:
B:
ne:
nD:

E:

m -

an sT'gument

macT'O number

Advance the cursor to the beginning af the n th line from the
current position.
Go to the Beginning of the file.
Change by deleting n characters and inserting the following
te x t.
Te-rmi nat~ te x t wi th .
Delete n

chal"acteY's.

Er:3se the screen.

nF:

Find the n th occurrence from the current cursor position of

nG:

the following string.
Get
- ditto -

Terminate target string with .

,- i nVlll i d -,

P:

Insert thp following text.
Terminate text with .
Jump cursor n characters.
Kill n lines of text.
If cur~ent cursor position is not
at the start of the line, the first part of the line. remains.
L i 5 t n 1 i n e S 0 f t .~ x t.
Define macro number ro,
Perform macro number m, n times.
On . 0 f 'P t (J f~ g 1. e.
I f! c n ~ n 1 in e t. 0 f ,t ext will bed i s pIa y e d
above and below the cursor each time the cursor is moved.
If the cursor i~ in the middle of a line then the line will
be split into two parts.
The default is whi:ltevf.'T'fills the screen.
Type 0 to turn off.
- invalid -

G:

Quit this session,

1.:
n,,",:
n~.:

nL :
mM:
nNm:
nO:

R:

nS:

U: (pdate
Write out a new SYSTEM.WRK.TEXT
E: {scape
Esc.ape TPom session
R': (~turn
Return to ed i tor
Read this Tile into buf~er (insert at cursor);
'R' must be followed by  i
WARNING:
IT the file will not fit into the bUrrerJ the
cont~nt of the bufger becomes undefinpd!
Put the next n lines of text from the cur~or position into the
S-.:lVf.\

T:
U:
V:
W:

nX:

rollol!.Ied by:

Bu.p';~\r

- invalid Insert (Unsave) the contents of the Save Buffer into the text
at the curSQr; does not dpstroy the Save Buffer.
Verify:
display the current line
Write this file (fr'om start of bufrer);
'W~ must be followed by  
D~lete n lines of t~xt, and insert the following

texti

terminate with .

Y:
Z:

invalid -- invalid _.

Page 69

-

NOt~~5

-

VUE TO THE LARGE NUMBER OF BUGS IN THE VEBUGGER, WE HAVE OMITTED THE
DEBUGGER, AND ITS CORRESPONDING DOCUMENTATION FROM THE SYSTEM RELEASE.
THE DEBUGGER WILL BE AVAILABLE AT SOME TIME IN THE FUTURE, ANV YOU WILL
BE NOTIFIED OF THIS FACT. PLEASE VO NOT ASK US ABOUT THE DEBUGGER, AS
THE REPLY YOU GET WILL BE THE SAME AS THE MESSAGE ON THIS PAGE.
Thank. you nOlL YOM patienc.e in tlUA mati-elL.

Pag~

ed.

74 thfLough 80 have been omitted.

Pag~

71 .. 7

- note!.> -

Page!.> 72 •• 80

******************* ***************

*

PASCAL COMPILER

* *

*******************
Version 1. 5

Section 1.6

*

********~******

September 1978

The UCSD Pascal compilerA a one-pass recursive descent based on
P2 portable compiler from Zurich, is invoked by using the C(ompile
or R(un command of the DutermO$t level of the UCSD Pascal system. If a
wOT'kfile exists.; it compiles that.
Othe'f'wlse, it prompts the user for
a SOUTce file name.
It generates codef11es to run directly on the
Pascal interp~etive machine.
th~

Unless the HAS SLOW TERMINAL boolean inside the system
(5 e e sec t ion 4. 3) i s t rue l the com pi! e or , d uri n 9 ,t h e
course of compilation. will display on the CONSOLE device output
detailing the progress of the compilation.
This output can be
suppress~d with the G+ compiler option (see section on compiler
options below),
Below is an example of the output which appears on the
CONSOLE device:
corum u n 1 c. a t ion aT' e a

PASCAL complIer [1.5 unit compiler]
0:> . . . . . .

P 1 (7050]

<

19)- ...

P2 (3040)
.(

61>0

~

. :

TEST [30(3)

<: 11 9>, , . . . . , . ,
The identifiers appearing on the screen are the identifiers of
program and its prDcedu~e5.
The identifier ~or a procedure is
displayed at the moment when compilation of the p~ocedure body is
started.
The numbers within [
] indicate the number of (16 bit) words
available for 5ymbol table sto~age at that point in the compilation.
The numbers enclosed within < > are the current line numbers.
Each dot
on the screen represents 1 source line compiled.
th~

! f the compilation is success~ul, that is, no syntax errors
detected, the compiler writes a codefile to the disk called
*SYSTEM. WRK. CODE.
Thls is ths codefile which is executed if the user
had typed the R(un command.
See Section 1.1 INTRODUCTION AND OVERVIEW
for further details an the system commands.

Should the compiler detect a syntax error, the text surrounding
the error and an error number together with the marker 1««
' will
point to the symbol in the source where the error was detected.
In the
event that both the Gaod L options are set, the compilation will
continue, with the syntax e~ror going to the listing file, and the
console remaining undisturbed. The compiler will the give the user the
option of typing a space, an  Dr 'E'.
Typing a space instructs
the compiler to attempt to continue the compilation, while escape
causes the termination oT the compilation. and liEU T'esults in a call to
the editor, which automatically places the cursor at the symbol where
the error was detected.

Page 81

Most of the syntax errora detected by the UCSD Pascal compiler
are the standard ones listed in Jensen & Wirth.
A complete list of all
UCSD syntax errors can be found in Table 5.
All error numbers will be
accompanied by a textual message upon enty'y to the editor if the file
*SYSTEM.SYNTAX is available.
1. 6. 1

COMPILE TIME OPTIONS

Compile time options in the UCSD Pascal compiler are set
according to a conventiDn described on pages 100-102 of Jensen and
WiT'th~
where compile time options are se't by means of special "dollar
sign" comments inside the Pascal program text.

The syntax used

in

UCSD's compiler control comments is essentially as described in Jensen
and Wirth.
The actual options and the letters associated with those
options bear only little resemblance to the options listed on pages 101
and 102 of Jensen and Wirth.
If a '+' Dr '- , is not specified after
an option letter, '+' is assumed.
The following sections describe the
various options currently available to the user of the UCSD Pascal
compiler.
D:
This option causes the compiler to issue breakpoint
instructions into the codefile during the course of the compilation in
order that the interactive Debugger can be used more effectively.
See
Section 3.2 uDEBUGGER u for details
Derault value:

D-

D-:

causes the compiler to omit breakpoint instructions
during the course of the compilation.

D+:

causes the compiler to emit breakpoint instructions.

G:
Affects the boolean variable GOTOOK in the compiler. This
boolean is used by the compiler to determine whether it should allow
the use of the Pascal GOTO statement within the program.
Default value:

C:

Page B2

G-

G+:

allows the use of the GOTO statement.

G-:

causes the compiler to generate a syntax error upon
encountering a GOTO statement.

The (*$C eomment*) plae~ the eomment, (80 eh~aet~ maX£mum*) ~n the eode
nile gen~ated. Th-iA option ~ M ed at UCSV to plaee eopYJvtght ~nnoJuna.tA,on
~n the eodenile..

The G-optian has been used at U.C.S.D to restrict novice
programmers from exces5i~e uses of the GOTO statement in situations
wher9 more structured const~ucts such as FOR, WHILE, or REPEAT
statements would be mere approprlate.

I:
When ,an '1'" lS fol1o\ol?d imm£>di-ately by a '+' OT' ' .._', the
control comment will affect the boolean variable IOCHECK within the
compiler
An alt~rnative use of 'I' in a compiler control comment
causes the compiler to include a diffe~ent source file into the
cQ~pilation at that point.
See section INCLUDE-FILE MECHANISM for
s~nta)'.

.IOCHECK. OPTION

1+:

instructs the compiler to generate code after each statement
\J.;hich performs any 1/01 in or'oel' to check to see if the 110
operaticn was accomplished successfully. In the case of an
unsuccessful 110 operation the program will be terminated
with a run time error.

1-<

lnstT'ucts the compiler not to genIS-rate .:irty I/O checking
,~)de.
In the case of an i.Jnsuct::e~sFul 110 operation the
program is not terminat@d with a run time error.

The !~·'option is use~ul f!OT" system level programs which do many
110 operations and also checks the IORESULT function after each 110
operation. The ~y5tem prog~am can then detect and report the 110
€ \" r ':.'i :' 5 •
!,J.d t h .0 U t b ~. .i n g t ~ T- m 1 ro, il t: Ii? d /~ b n !,... 'f' m d .1. 1 i~ ~:J i t h ar' l.J n t i in e error.
HDw~Ve~
tj
would cause the file TURTLE. TEXT to be compiled into the program at
that point in the compilation.

would cause the saUTee file +FARKLE.STUFF to be included into the
compilation.

If the initial attempt to open the include Pile fails, the
compiler concatenates a ". TEXT" to 'the file"-name and tries again.
If
thi. second attempt fails~ or some liD error occurs at some point while
reading the include file, the compiler resp~nds with a fatal syntax
erroT'.
The compiler accepts include files which contain CONST, TYPE,
VAR, PROCEDURE. and FUNCTION declarations even though the original
program has previously completed its declarations.
To do so, the
include compiler control comment must appear between the original
program's last VAR declaration and the first of the original program's
PROCEDURE or FUNCTION declarations.
Nate that an include file may be
inserted into the original program at any point desired, provided the
rules governing the normal ordering of Pascal declarations will nat be
viDlated.
Only when these rules are violated does the above procedure
app 1 y,
Th e camp i 1 er cannot keep tra c k of nested inc 1 ud e C ommentsl i. e.
an include file may not have an include rile control comment.
ThlS
results in a fatal syntax error.

The include file aption was added to the compiler at U.C.S.D in
order to make i t easier to compile large programs without having to
have the entire source in one very large file which in many cases would
be too large to edit in the existing editors' buffer.
L:

Controls whether the compiler will generate a program listing
of the source text to a given file.
The default value Qf this aption is
L-, which implies that no compiled listing will be made.
If the
character following

aL" is Ii+H,

then the compiled listing will be sent

to a diskfile with the title '*5YSTEM.LST.TEXT'.
The user may override
thi~ default destination for the compiled listing by specifying a
f i 1 (-HI ~ mi? fa 1 1 ow i n 9 It L
For e 1. amp 1 a t h e of 0 1 1. 0 win 9 con t r ole 0 mm ~ n t (.IJ ill
0\ •

cause the compiled
i'DEi>101, TEXT't ,

Page 84

listing to be sent to a diskfile called

<*$L DEM01.TEXT*>
To specify a file-name inside a control comments see the
section describing the include file mechanism.
Note that listing files which are sent to the disk may be
edited as .ny other text file provided the filename which is specified
~

ins the
S l)f fix AI. TEXT It •
Wi tho u t the f/ • TEXT" s u f fix t h eo f i 1 e \IIi 1 1
be treated by the system as a datafile rather than as a text file.

con t

The compiler outputs next to each sou~ce line the line number,
segment procedure numbe~, procedure number, and the number of bytes or
words (bytes for code, wOTds fOT data) requir~d by that procedure's
declarations or cade to that point.
The compiler also indicates
whether the line lies within the actual code to be executed or is a
part of the dec: lard';inns for that procedure by Qutputing a uD u for
declaTation and an integer 0 .. 9 to designate the lexical level of
statement nesting within the code pa~t.
If the D+ option is set then
the listing fila will includ@ an asteTisk on each line where it is
appropriate f0T a user to specify a breakpoint while in the interactive
Debugger.
This information can be very valuable for debugging a large
program since a run time error mE~5age will indicate the procedure
iHH1. b tH' 1 and t. Ii e 0 f f 'S e t w her ~ the '::::1' r 0 roc C 1,.11"' 'f iE'd .
G:
The G compiler option is the "quiet compile" option which can
u5?d to supp~es$ the output to the CONSOLE device of procedure names
and line numbers detailing the progress of the compilation.
be

Default value:

is set equal to CUTrent value of the SLOWTERM
attribute of the system communication record
SYSCOM",·.

(actoally SYSCOM ...... MISCINFO. SLOWTERM)

G+"

causes the compiler to suppress output to CONSOLE device.

G-:

causes th~ compil~r to send procedure name and line number
output to the CONSOLE device.

R:
This op~lDn affe~ts the value of the boolean variable
RANGECHECK in the compiler.
If RANGECHECK is true, the compiler will
Dutput additional code to perform checking on array subscripts and
assignments to variables of suDrange types.

P:
TIU..6 option C.a.U6M the. futing to c.ontiYl.u.e. 6Jtom top-06-6ofLm.

i.e.. the. c.ompileJt

dOM:

PAGE(LISTFILE)

Page 85

Default value: R+

R+'

turns range checking on.

R--

turns -range chet.::king

c-ff.

Note that pT'ogT'arn~ compiled with thl!: R-option 'Set will T'un
slightly faster; however if an invalid index occurs or a invalid
assignment is made~
the p~Dgram will not be terminated with a run time
error.
Until ~ program has been completely tested and known tD be
COTTect, it is usually best to compile with the R+ option left on.

s;
This option determines whether the compiler operates in
"swapping" mode.

There are two main parts of the compi.ler':

processes declarations;
moor.-:,

cnly

the other handles statements.

one of these parts

is in main memory at a

one

In swapping
time.

This makes

about 2500 addItional wo~ds available for symbol table storage at the
cost Qf ~lo~~r compilation speed due to the overhead o~ swapping the
cornpilt'?T' segment

in fT'om disk.

On flJllsizel

Single d-:nsity floppy

this amounts to a factor o¥ two reductio" in compile speed.
option must occu~ prior the the compiler encountering any Pascal
di~ks

This

syntax.

Default value:

S-

S+:

puts compiler in swapping mode

S'-;

puts compiler

in non,"swapping mode.

U:

USER PROGRAM OPTION:
ThlS option S2tS the boo12an variable SYSCOMP in the compiler
.j e t f': T' m 1, new h •.?t 1:21' t h 1 S Co iJ mp i 1 Cit t 'i wn .i s
::o!'!qJll~~t;iGn c:f a systf~m program.

h i s v' ~-:; e d b IJ the com p i 1 t? r t Q
a user PT'ogT'.an: compi.lationl or a
ttl hie

\ ,.,1I...
••

u-:

infDrms the compiler that ~hts tompilation
on the user program lex level,

i~

to take place

informs the compiler to compile the program at the system lex
level. This s~tting o~ th~ U compil~ time 0ption also causes
the following options t;J h~! ..set- R-. G+! I-.

PaGe 86

NOTE: This option will generate programs that will not behave
as elpected.
Not recommended for non-systems work without knowing its
method of operation.

USE LIBRARY OPTION:
In this ve~sion of the 'u' optionl the U is followed by a file
name.
The named file becomes the libraTY file in which subsequent
USEed UNITs are sought.
The default file for the library is
*5YSTEM.LIBRARY.
(see section 3.3.2 for more details on UNITs)
Following is an example of a valid USES clause using the

'u'

option:
USES UNI Tl, UN! T2!
A. cong}

.i n ~SYSTEM. LIBRARY.)

UNIT3.,
B. LIBRt'RV}
UNIT4, UNIT5i

Page 87

- Notes -

*********************** ***************

*

UCSD BASIC COMPILER

* *

***~*******************

Section 1.7

*

***************

September 1978
This section has been designed for prDgramme~s who are already
familiar with B~sic.
Its intent is to describe to those experienced
users the details of UCSD Basic in a manner sufficiently detailed so as
to iz:nab 1 e th l \.;jr i t i 1"19 :n~ mnd if i c;:-:t: i on Q-t programs ina manne.r
compati~le with thE UCSD Basic Compiler.
The first section contains a brief description of the features
includ~d

in UCSD

B~sic;

the

-second.

the descriptions of the

~eatu,..es

unique to UCSD Basicl and the third a list of those features which we
intend UCSD Basic to allow, but which are not yet implemented.
The UCSD Basic Compiler has been written in the Pascal
language.
Some of the intrinsics of the Pascal language, which are not
found in standard Basic, are found within the UCSD version of Basic.
Many of these are noted in the first sEction, ~ll of them are noted or
recapped in the second.

The l}CSD BASrC Compiler

i,S

invoked

Just like the Pas1:al

compllerl provided tho compiler code is named *SYSTEM.COMPILER,
Originally it will be named BASIC, COMPILER.
If you want a disk to be
BASIC oT'iented~ you must change the name of, or remove, the Pascal
compiler: arid change the name of BASIC. COMPILER to *SYSTEM.COMPILER.
T tu; t dis k l a n d ,~n y con j e s of it., ld i l l now C Q mp i 1 e BASIC pro 9 't" am s as a
rEsult of the CCompile OT R(un command.
DESCRIPTION OF FEATURES INCLUDED

The BaSiC complier has only real and string variables. When
applying a real to indexing or ether integer purposes the rounded value
of the number is used. In the ~uncticn5 below x and y can be ~eal
variables ar expressions which evaluate to real values. Similarly 51
and 52 can be st~ing variables or expressions which evaluate to a
string.

VAR IABLE Nf\t'lES

Rea 1

'i Q

String

r i

~

b 1 ~"S :

1 et t ~. 1" ( dig i t ) .
lettel'(dig.i"t)$.

\.'=:'11301$5.

The digit is

option~l.

Page 89

INTRINSIC ARITHMETIC FUNCTIONS
ATN(x)

R~turn~

EXP(x)

Returns the base of the natural logarithms raised to the power x.

INT(x)

Returns the value of x rounded to the nearest integer.

LOG(x)

Returns the log (base 10)

the angle in radians whose tangent is x.

0'

x.

Returns the natural log of x.
MOD(x,y>

Returns x modulo y.

SIN(x)

Returns the sine of the angle

COS(x)

Returns the cosine of an angle x.

~.

Where x is in radians.
Where x is in radians.

INTRINSIC STRING FUNCTIONS
CAT$(sl. s2 . . . ) Returns a string which is equal to the concatenation of
all the strings in the parameter list.

COP*Csl, x,q)

Returns a copy of the portion o~ the string sl, 4
chsracte~s,
~t5rting wlth the characte~ at position x.

cD"~ecutive

DEL$(s11 x,y)
RetuTns the contents of the string 51 with y consecutive
characters ~eleted. The deletion sta~ts with the character at
position x.

Returns the contents of string 52 with string sl inserted
immediately hefore t~e ~haracter which is at position x.

INS$(;lts2: x)

LENCsl) R9turns the length Df the string 51.
POS(sl,s2) Returns an integer which is equal to the position of the
first characte~ in the first OCCUT~enre of the string sl in the
string s2.

OTHER FUNCTIONS
ORD(s) Returns the ASCII value of the

~iTst

character of the string s.

STR$(x) Returns the string containing the chSTRcter associated with the ASCII
value x.

Page 90

:ET$ Reads a single character from the keybosrd without prompt or echoing,
and returns it as a string.
GETS requires no arguments.

DLD(c, $;
NEW(c,s) c is a numeric constant without a fraction part, which becomes
3~~ociated with the disk file whose name is in s.
OLD expects that
file to alresdy exist, NEW creates a new one with the name s, removing
any previows file of that name.
These functions must occur before
associated print or input statements.
The numbers may not be
reassigned and must be in the range 1 .. 16. For best results. use only
at the top of a program.
In order that a file created by NEW be
editable with either oT the system editors, '. text' mt..'st be appended to
the file title.

Tn eserunc ti ons return IORESUL T as df;\scr ibed in section 2. 1.

PROGRAMMING STATEMENTS
Arithmetic statements and operations
I
+
subtract/add
I I .*
d i v ide: mu 1 tip 1 Y
Relational

Qpe~ato~s

-c:>

I

<

_>=

<=

I
I

:>-c

=>
:-.:<

equals
not equals
greater than
less than
greater than or equal
less than or equal

INPUT list
or
INPUT #c list

In put s f rom the main system d e vic e U $ U a 11 y the keyboard. I of the
optional 8c is p~e5ent, INPUT inputs from the disk file number
c The input list may contain any combination of real variables and
string vBTiables. When a prDgram expects input the prompt "?II is
printed. Input of real numbers may be terminated with any non-numeric
character. Input of strings must be terminated with a return.
I

PRINT li5t
or
PRINT ftc: li;;t
to the main output device the list following the PRINT command.
If thD optional He is pT9sent, PRINT outputs to the diskfile number c.
The output list may contain ~ny Y~~iable, subscripted aTray variable,
any arithmetic OT' s'cring expl"essionl OT' any literal text. The list may
be sepa~ated b4 commas or semi-colons. If the list ends in a semi-color

W~ites

the carriage return is suppressed. Literals may be enclosed in either
Double quotation marks prints a single

type of quotation marks.
ti!.!otatio'n mSH'!c.

Page 91

FOR val"

= expl

TO exp2 STEP exp3

NEXT var
Each execution of the lOL1p increments the loop countar "varr" by the

amount of expression 3. If the STEP is umitted it is assumed to be 1.
Only increasing STEP values are allowed. Evaluation of limits and
increments is done at the beginning o~ the loop_ Note that RETURN's into
or GOTO~s into a FOR loop may cause the loop to b~ undefinad.
IF expl

(r~l~~ion

operator) eyp2 THEN (line number)
GOTD

Either 'the reserved word

THEN or GOTO can be l}sed

in this st;atement.

lOP

the ~elation b~tween the alpl and exp2 is 'ound to be true the b~anch
occurs, A sti'ing is c>Jnsidered to be less than another string if it is
lexicographically smaller.
IN e j( p GO TO:; 1 re 1.. 1 n 2., .

~

If the eXprp.5stCHj, ~iJh~n rounded, evaluates to 1 it goe's to the f'i,..st
line number (In!) if it evaluates to 2 it goes to 1n2, etc. This is the
only form of the computed GOTO which is available. If the expression is

out of range an error occurs.

DEF FNname(list)=expression

or

DEF FNname(list)
FhiEND

Single Ilne and multi-line functions are allowable. The function name
must be a legal variable name for the tupe of value returned. Functions
;nay be defined recuT'sively. Th
directly after the PROGRAM 
For mo~e information on
Ui'-J ! l' 5
S !? !;;' Sec t i Q n~1. 3., :2;
il

J

Any files which referE!\Ce UNITs or EXTERNAL rQutines and have
not yet been linked may be c0mpil~d and saved. but will need to be
1 i fl ked b e .f 0 '1'" e t ~~; eye ~~ \'1 bee!: e c ~j. ~t a ~l
1. 8_ 1

US ING·

T~!E

L II\W.E.R

If the program in the warkfile contains EXTERNAL declarations.
or uses UNITs, typing R(un will automatically invoke the LINKER afte~
the compiler.
The LIN~ER will search the file *SYSTEM.LIBRARY for the
routines or UNITs specified, and will attempt to link them into the
wo~kfile,
If the UNIT or EXTERNALly dec!a~ed routine is not present in
*SYSTEM_ LIBRARY, the LINKER will respond with an appropriate message:
Prot,
F' unc
Glob·all
I

or Public (identifier> undefined

Page 95

The LINKER may also be invoked explicitly, and,
be invoked explicitly in cases where

in fact,

must

1) the file into which UNITs or EXTERNAL routines are to be
linked is not the
(2)

the

wcn~kfile~

e~ternal

01"

routines to be linked reside in library files

other than *SYSTEM.LIBRARY.
( Not a : I nth e C tJ'f/ 1" e n t 1.11 P 1 e (!H.~; n t a ·t 1. 0 n UN ITs ~'Tl us t T' e sid e i n
*SYSTEM.LIBRARY at the time of compilation in order to be USED by a

PASCAL program. )

In orde~ to e~plicitly invoke the LINKER,
Command level and receives the prompt:

the user types 'L' at

The hostfile is the file into which the routines or UNITs are to be
linked.
The LINKER appends . CODE at all file names typed in except for
*.
Typing a  In 1"eHipOnse +:0 thE p;·ompt::,.~U~·H;;;i: the LI!\~KE:R to
use the workfile as the hostfile.
The LINKER then asks for the name(s)
of the libra~y files in wh~ch the UNI1s or EXTERNAL ro~tines are to be
found:

Lib file? 
Up to eight library files ma~} be refel"enced.
Typing '*' in
respcnse to a request ¥or a libfile name will cause the LINKER to
reference *SYSTEM.LIBRARV.
The user will be notified about each
library File that is ~uccessfully opened.
Example:

Lib

fi_u~?

*

('l'E-t:)

Opening *SYSTEM.LIBRARY

For information on LIBRARIES and the LIBRARIAN see Section 4.2.
Wh~n all relevant libfile names have b~en entered the user
must type  to proceed.
The LINKER will now prompt with:

Map file? 
following the owtput ~ile name has been tqpe1.
An em~t4 line, <~et~
onlYI

causes the output Pile to be

~J~·S'l·~~1'" E:M ~ ~~lHl ~\.

'C 0 DE

pl~ced

in the workfile e g.

being linked as well as all external routines being copied
into the output codafile.
The linking process will be aborted
if any
I
required segments or routines are ffilssing or undefined.
The user will
be info~med of their absence with messages as described at the
bpginning of this s~ction.
~~gment5

1" 8 . ;2

NOTES ON LINKER CONVENTIONS AND IMPLEMENTATION

cont~ins

Codefiles may contain up to 16 segments.
Block 0 of a codefile
information regarding name, kindl relative address and length
infof'ma'iJi~)·r.

of each cede ·segment.
This
is ~~p~esentsd as Q ~ecord:

is ":flled the segtable}

and

RE.CORD

RECORD

CODELENG, CODEADDR: INTEGER
SEGNAME:

ARRAY[O .. 153 OF PACKED ARRAY[O .. 71 OF CHARi

:3EG;V~IND

t'RRAVrO,. 15J OF

(LIN~\EDI

HOSTSEGt SEGPROCI tJNITSEG,
SEPHTSEG) ;

END
and CODEADDR give,

~ODELFNG

code

~,egrnent

l.n b4t;esl

and

the

r9;pectival~,

block~rld're~s

of

the length of the

the code

A

$.egment,

descrlption of SEGhINDs folluws:
L I Nrt ED :

Ttl e

c

(1

d ~ ~ e 9 m'E! n t

ts f!II 1 U

~:{ ~ C ',I 't .~

(UNITs or EXTERNALs)
non e tu ere P T' e '5 & n t
re~erences

ti 1 e .

E i t Ii e r a 1 1 ext ern a 1
have been resolved, or

HO~rfSEG':

the 5f:~9kind ~s.sigrH2'q t;o the Quter block of a PASCAL
p r ~. g r {;;j in i F t Ii e pr c, 9 l' ;.:;:Hll has '.!n: t~ e r f"') a 1 l' e fer en c: e s .

SEGPROC:

the

segkind

assign~d

to

\3

PASCAL segment procedure .

t~~

s~gklnd

~ssign0d

to

~

compiled SEGMENT.

UNITSEG:

(see Section

3, 3. 1)

SEFRTSEG:

This

sE'gk~:nd

15

assi.gned

to a separately compiled

procedure or function.
Assembly language codefiles are
aJways of this type. 9S well as Pascal UNITs which are

Page 97

For an unlinked code segment (that is, a segment containing
unresolved external refe~ences) the compiler generates linker
information.
This information is a series of variable-length records,
one for each UNIT, routine or variable which is refe~enced in, but not
defined in the SDurce.
The first 8 words of each recD~d contain the
following information:

LIENTRY=RECORD
NAME:

ALPHAi

CASE LITYPE:

LITVPES OF

UNITREF~

GLOBREFt
PUBLHEF,

PR!VREF,
SEPPREFI
SEPFREFI
CONSTREF:
( FOFt i'1A T :
NREFS:

NWORDS

OPFORMAT;
INTEGERJ

LCRANGE);

(format of lientry.name can be
any of! BIG.. BYTE or WORD. )
(# of rererences to lientry. name in
compiled cDd~ segment)
(size of privates in words>

GLOBDEF:


E X"l""r:'UNC I

SEPFUNC:
CSRCPROC' PROCRANGE;
NPARAMS:

INTEGER);

(procedure number in source segment)
(number of parameters expected)

EOFi1ARK:

(NEXTBASELC: LCRANGE)

(private var allocation info)

END <. 1 i en t r' U ) ;

If the L!TVPE is

!H10

of- tho first r.asi?

v.~Ti~;lt;

thc·'jj following

this portion a' the reco~d is a list of pointers into the code
segment.
Each of these pointers i~ the absolute byte address within
the code segment of a ~eference to the variable, UNIT or routine named
in the lient~y.
These are 8 wD~d ~eccrds, but nnly the first NREFs of
th€ili ar-e valid.

rage 98

***'***.*****4t"*******'!-f*** "",***-*'*,J(.**.******

*

* *

ADAPTABLE ASSEMBLER

*

***************

~**********************

,} e r s ion I. 5

Section 1.9

S.ep tember 1978

Use. 1" '3 .J 'r ~j c ~:,i) ~:\ d S C ~1;. r) C '': ~:';',~, : cc ,:;) 1 1 ~J n e Q d t ,:1 /,\.(r i t eo and
ass ~'m b l:~ 'f' <.) uti n ~ 'S iHT' i t. i.; en :i nth e 1 ~ n 9 wag €I p f: the h 0 S t

s m:3 1 1.

ere cut e
m3 chi n e ,

These routines ~ould be used withl" a Pascal program to p~ovide lowlevel or time critical facilitips.
The UCSD Arlaptable As~embler (in
conJunctl,nn with

the UCSD

Ll.nk~r)

has bEen deSi;;rned

to meet those

The UCSD Pascal Project ~il1 be maintaining all our Pascal
t rd: ~ l' P 'f ~ t; e' 'f' S ",J S 'l n g t'; h t ',; \:; ~j ~-; .:, 1': b 1 ~:::q" j nth~' "'H:3 r of \l t. Ln'" e .
R Y 1; h t;i· pro c e s s
the users of the UCSD Pascal system will b~cDme essentially independent
of any manufacturer's sy~t.m software,

n~eds,

This assembler was mod~lled dfter The Last Assembler (TLA)
deve!opeJ at the University of WateTloo.
The b3Sic concept behind both
the TL{>, r:lna

th{:? Uf.:SD Adaptable

A~S'?lnt.ier5

15

the

~~e

of; a

ce.ntral

machine LndepenJent core that is com~Qn to all versions of the
aBs9mbler
This central core is augmented with machine specific code
t <0 han ri 1 ~ t n e pee 11 ) i aT" i t i ~ s of S!"~ c h i -n (j i v i d I..J.3 1 in ~ r. h i n e '
For the 1. 5 release

PDP-~ll

and Z80

,~5semb

lers wi 11 be

adaptations took longer than one person-

.at

le~st

This
one

ODC!}''ni?qt
'E,HisE~r:d'jltJ

!s inten,jed for
It:lngwagE>

;;

'I'€3df:1"

liJhl;j

l~·

alre~d!J

fluent in

USAGE
BefoT~

~tt~mpting

spf:cifl,t:-: machine;

an

to

opc~d~?

~i?~ute

locat?d on the sqstem disk.
contains the error messages that are
~ 5 $ ~~ iTt b

1.

f.~~ ~

TO

This
riql\t

~i!l

Th

~'~!'1

US€;

+~

t~~

i. SOl) t ;, fi r~ ~ 1 }

1·f

the UGSD ,ass€lmblpr,

SKecu~~

·,,::,t-;~i\,P'-i

i l

of~

SYSTEM, ASSEMBLER,
t;h~

the assembler program for a

1"i Ie Cl80.0PCDDES Ol" 11. OPCODES) must be
The erro~s file (ZBO.ERRORS OT 11. ERRORS)

a~sembler

us~d
t.! r~~.

ed}

for e~rDr flagging during the
i t mtJ s t a l S 0 a p pea l' 0 nth e

tyPf: A( ssem for'om the Command
(T~e

{PDP-1t

user should

~rrange

or 1.80) h.ave t.hat

line.

that the

title.)

The program displaysJ the version of the asssembler being
;:H1 d a s ~ t' ,;l e <; t h ~ t
the CUT' l ' ~ n t '.U 1) or k of! i 1. e i s the 1) net 0 b e
assembled
t f the~e is no (\Jrrert wQrk~ile then the prog~am asks which
e :x e cut e d

fil'.:

is to be

,£j'Ss~mblf;·d,

Page 99

The next prompt line is:
Output file for the assembled listing «CR> for none):
As usual for a console or printer output the wards CONSOLE or
PRINTER nU_Ist b~ f;:.~11Qlnwd b~:3 ':..olu'(u j, f:. CONSDLX':;:'"
I f the cclon is
neglected the uutput is sent to a file of the name given.
At this
point. the pTQg~am reports whether O~ not the output devic~ (if any) is

on line
The assembled code is written out to a file called
*SVSTEM.WRK.CODE which cannot be executed by itself but must be changed
to link in with a host file.
er'i"OT"$

T r. e p T' 0 g T' 2d1~ t h f:HI s t ,;; i' 't ~
they 3re f-ound, If' ,E:t'l

~s

cl $ S

~j

e mb lin 9 the wCl 1'" k f i 1 e
1- 1 ;39 gin 9
other than an 110
j

el't'Qr~

error, is found, a general message indicates the natu~e of the error
and also gives the option to continue or exit.
The error message will
bet a k ~ n f'r om the ER ROR S f i 1 e i f P 0 S sib 1 e. r f t h l~ t i $ not p 0 S s :i b 1 e.. d (J e
to space limitations or the absence of the errors file, the error
message number 15 given. The assembly is aboTted if the 110 error
encountered is not due to data typed in by the user, otherwis~ the user
is prompted to try again.
\S~e the complete list of Assembler syntax
eT''rorg 2!nn ffiitichinc,

dot TOT"

s.pt"?fii:i.c..

eT'T'OT~S

in

l~hle

6,)

The COD$cltl' cii;.;pla\jsl on t:h~ i.;!f-r, hand sid~? of the 'c~C'1'0er~, onf:'
eat:h Ilno cd:> ~~nde as'r:d'~mbled and a l:i'tH~ c.rH}nter ev(,:;.'r.'Y 50 lines.

When an include file

is started,

the console displays:

INCLUDE

At the end

the assembly the assembler program indicates that
tells the user how m~n~ errors were found.
In
addition an alphabetic symbol table i~ generated.
c~

i t is finished and

The
col u mn

symbol table consists of three parts.
The first
t s t tH~ S ~.~ mb t) 1 i d f:.' n t i f i 2;' 'r' ; the 'T:,; e c O~ (1, the 5 tJ (rd1 {J 1 t I:! f.h~
the lotation that it is defined or the value i t has.

refe~ence

T' e p T' e S E\ n

j

and the third,
Actual values are givR~ for the symbols representing absolutes and
definition locations are given for the symbols representing labels.
The location number lS given as a hi-byte first number and corresponds
to the Index numbers on the left hand side of the listing. Only symbols
which have definition locations o~ absolute values have numbers in the
third ccluffi!1i

Pagt: 10!)

othel'

typ,~s

IH~V(~

d,~:)sh'i:'s,o

PAGE -

1

00001
MemoT' y a f
0000:
OOOOi

PRIMARYZ FILE: #5: PRIMARY. Z
PR Il"lARYZ

· PRDC
t~·{'

6068

initi;.all.ldt:ion:
FL.DPP'-{
8F.:Cr-1EM

0000:

· EaU
· EQU

OBFDH
9000H

;Rom-based floopy driver
iFirst location in memory of bo
;Entry point of b~otstrap
;Sector start of second bootstr

t
OOOO~

· EGU

9000H

OOOO~

,EQU

OSH + 1700H

P
0000;

B 1 D~:H-\

.EGU

10H + 1700H

OOOO~

D2D'3it~

.E~U

ISH

L

1700H

OOOOl
0000:

,Sector start of BIOS part 1
iSectcr start of BIOS part 2

;Primary bootstrap for ZILOG DO

10001
1000: FD 21 ~.,***
1004: CD FDOB

1007; FD ",~.L ~;;' k,~t·k
100H: CD FDOH
lOOE: FD ·1 ~..~:.~,"t"
,t'>'j

~

PH IM!''\RY LD
C,!\LL
L.u
C~LL

IV, 'SECREriD
fLUF? '>(
Iy' bth'Ff...,D
J

F~'

LD

IVI

CD FDOB

Cll,LL

10151
l018!

C:'i 0090

JP

FLOPPY
SECENT

~:.. 1-

1002* 181.0
101S:

G£'t block

.'

Gf:'t

,;

Ge-t block for part 2 of BIOS

i

dump into second bootstrap

for

~ec.ond

bootstrap

block rcn" par·t 1 of BIOS

L.. r] F:) F~ \(

1012~

;~\

;.

B~-2nEAD

SECREAD

1018! 00
1019: O!-~

· BYTE $--$
BYTE O(\!·:
· WORD SE:C(o'il::N

lOlA: 0090
10lel 0002
101E: 0000

,

102.0 l

0010

10221

00

· l,.HJRD PR !!"iARY
. IiYTE $-$
· WORD SEe DSI"'..

~~HJR D

· WORD

l023i 0817

200~f

$~"$

I Unus,ed
; Read commtar~d

;Memory location for second boo
jNumbe~ o~ byte5 in boot
;Completion return address
;E~ror in return address

iCompletion result code
iDisk

block of second boot

1009* 2510

B1READ

102;-; ;

· EYTE $-$

1 O;2f,: 00
'lO;?iS i OA

· BYTE

O~\H

. WORD SECMEN+300H
L,·;ilR.D
10~2Dl

OG10

102F; 00
1030; 1017
10a2:

1082:

2(~'/·~·~·~~

. WORD $-$
WORD PRIMARY
,BYTE $-$
· WORD DtDSK

;Unused
i

Head

comm~31"",d

iMemory location or BIOS part 1
; f~J~J;11rJt.~~r n-F bfjtes in 13108 p'-!'irt 1
;Ccmpletion return address
iErro~ return add~ess
;Completion result code
:Disk block of BIOS part 1

B2READ

Of)
10:::-:i3 ~
1034:

;MRmory location cfd BIOS part
;Number of bytes in alaS part 2
;Cumpletion ~eturn address
,ErTor return address
Page 101

103C: 00

· BYTE $ ... $

103D:

· WORD B2DS!{

1817

l03F:
103Fl

;Completion result code
jDisk block o~ BIOS part 2

· END

PAGE-

2 PRIMARYZ FILE: #5: PRIMARY. Z

AB
RF
PB

-

Absolute
Ref

LB

Public

PV

DF

-

Label

un

Def
Private

PR

BIDSK

AB 1"110:

B1READ

FLOPPY
SECENT

AB OBF!)!

PRIMARY
SECMEM

AB 90001.

CS

SYMBOLTABLE DUMP

--

-

Me

Undefined

Fe -

PT'CC

Constant

LB 1025;
LB 1000:
AD 9000;

PRIMARYZ

SECREAD

Macro

Func

AS 1718:

B2READ

PR _._--:
LB 101.8:

SECDSK

LB 1032:
AB 1708:

r. !OTES:
The location
locatlon~

ip

t~G

valu~s

in th? sVmbol

table dump refer to the

listing.

The ****'s in the listing call attentIon to the use of a

label

not yet defirted.
i f a stal' (*> appears after the location number at the left of
the listing . i t indicates that a forward reference occurring earlier in
the ar;semhly ha"3 bf>f'r! resolved.
Then'-lmbf:~'r to thp IBf-t of the
'*' is
t h (~ 1 0 cat ion wh ~H" e +; h r T' ':~ F 2 'f' F' n c F.: 0 C r: ~,) ~, .,.... 2 ~ { t.,! h ... 1 '8' t h 0 ret; rn b {~ T t o t h t:~ i' t 9 h t

is the new contents of that location

HIGH-l.EVEL SYNTAX

L 9. 2

All ob.Jpcts (!!.~':~.a'red
a v ail a hIe of 0 r LI set r. '!" 0 t: g h c tI t

generated before

th~

tfJ:c,re

Lhf::'

at t.he beginnj.ng of each. PROC OT'
FUNC
the- start of the f i r s t . PROC OT' . FUf\V~

Only labels may

begi~

. PROC or . FUNt": are
No cod e i s a l lowed t 0 b e

Fi1'i:;t:

t h f.' ass e in h 1 'J
first .PROC or . FUNC.
tCl

The

symbol table is reduced

thf:'

p0.inf;

where

it

llU~5

at

in the fjrst column and may optionally

be follcbJp.d by a colon.
Local labels most havf? "$' in the first
column and may be up to 8 digits long.
If the statement has no labell

the fiT'st column most contain a space.
All assemblies must end with a END.
. FUNC need not because they ara ended by the
,PROC or . FUNe.

Page 102

Orlly

the

last one need:;

i:i

.

However each. PROC or
of the next

occur~ence

END.

A general railroad diagram for all assembly files looks like:

a.ny nen-cede

genera.ltng

oper'Q.llons

~(
I

/'

.

codeg~nerQttng
operQ.~J.,ons nnd

1 - - -_ _- - - :
....

EHD

dtrecltves

Page 103

The non-code generating operations are:

.EGU, .DEF, . REF, . PAGE, . TITLE, . LIST, . MACRO, . IF
The code generating operations are anv other pseudo-ops and all
assemb1v code for the program.
1. 9. 3

EXPRESSIONS (one-pass restrictions)

Since the Adaptable Assembler makes onl~ one pass through the
source code, something must be assumed (upon encountering an undefined
identifier in an expression) about the nature of the identifier in
order for the assembly to continue.
It is therefore assumed that the
undefined identifier will eventually be d~fined as a label, which is
the most probable case.
Any identifier which is not a label must be
defined before it is used.
Labels may be e~uated to an expression containingeither labels
and/or absolutes.
One must define a label befo~e it is uspd unless it
will simply be equated to another label.
Local labels may not occur on
the left hand side of an equate (.EGU).
Local labels are mainly used to Jump around within a small
segment of code without having to use up storage area needed by regular
l.bel-s.
The local label stack may hold up to 21 labels.
These are cut
back every time upon encountering a regular label and are thus rendered
invalid.
An example of the use of local labels is shown below, the
Jump to label $04 being illegal.
$03

REALLAB
$04

Page 104·

STA

4

JP

NZ,S03

JP

NZ,S04

. EGU $
. EGU $

iLEGAL USE OF LOCAL LABEL

iILLEGAL USE OF LOCAL LABEL

Identifiers a~e character strings starting with an alpha
character.
Other cha~acters must be alphanumeric or the ASCII

underline (' '),
Only the ~irst 8 characters are used by the assembler
even though more may he entered.
The following operators can be used in expressions processed
by

this

assemble~,

For

un~ry

'+'

operations:
plus

,_ I

minus

'''V ,

ones complement

For binary ope~ations:
'+'
plus.
'- ,
minus
exclusive or
multiplication
I '
truncating division
t.. '
remainder division
I ..... f
,~,

(

I
t

I
I

I
I

,

bi·t

&

~

bit wise
eqtJal (v~lid anly in . IF )

=
.... --..
I

I

I .........,'!I I

wis;:~

nat equal (valid only in

IF

All constants must start with an integer 0-9.
All operations are applied to whole words.

The default radix is Hex fDr the leO version and Octal fOT the PDP-l1.
1.9.4 ASSEMBLER DIRECTIVES:

OVERVIEW

Assembler dir-er:tives (also referred to as "pseudo-ops") allow
the programmer to instruct the as~emble~ to do various function5 othe~
than provide direct executable code.
The following directives are
common to all UCSD versions but may differ from manufacturer's standard

syntax.

In the following pseudo-op descriptions s~uare brackets, [l,
are used to denote optional el~ments.
If an element type is not listed
it cannot be used in that situation.
As usual, angle brackets,<>,
denote meta symbols.

FoT"

e~ample:

(label]
. ASCII
"-(char-cater string)-II
indicates that a label may be given but is not necessary
and that between the double quotes must go the character
st~ing to be converted (not necessarily the words
"charar.ter string")_

Page 105

The foll~wing terms represent general concepts in the
explanation of each directive:
value

•

= any

valuelist =

numerical valuel
is a

label,

constant,

expression .

list of one or more values separated by commas.

idlist = a list of one or more identifiers separated bV commas.
expression = any legal
identifier: integer

l~st

expre5~ion a~

=

defined in Section 1.9.3.

a list of one or more identifier-integer
pairs seperated by ~omma~. The
colon-integer is optional in ea~h pair
and the default is 1.

Small examples are included after each p~eudo-op definition to
supply the user with a reference to the specific synta~ and form of
that directive.
The larger examp Ie, inc luded in section 3.3.2, is used
to show the combined use and detailed examples of directive operations.

1.9.4.1

ROUTINE DELIMITING DIRECTIVES

Every assembly must include at least one .PROC o~ . FUNC, and
one . END, even in the case of stand-alone code which will not be linked
into a Pascal host (i. e. an interpreter>.
The most frequent use of the
assembler, hO~lever, will be small routines intended to be linked with a
Pascal host.
In this case, .PROCs and . FUNCs are used to identify and
delimit the assembly code to be accessed by a Pascal external procedure
or function.
The . END appears at the end of the last routine and
serves as the final delimiter.
References to a .PROC or . FUNC are made in the Pascal host by
use of EXTERNAL declarations.
At the time of this declaration the
actual parameter names must be given.
For example, if the Pascal
declaration is:

PROCEDURE FARKLE(X, Y: REAL); EXTERNALi
the associated declaTation for the .PROC

~ould

be

PROC FARKl.E,4
A .PROC, . FUNC, or any assembly routine should be inserted into
the *SYSTEM.LIBRARY (execute LIBRARIAN) 50 that it can be referenced by
the *SYSTEM.LINKER and linked in at run time
An alternate method ~ould
be to execute the LINKER and tell it what files to link in.
Either
method works. Howeverl if the Pascal host is updated and the assembly
routines aren't in the *SYSTEM.LIBRARY, the linker will have to be
executed after each update.
Therefore, we suggest that the routines be
inserted into the *SYSTEM. LIBRARY to avoid this repetition.
If the

Page 106

linker is called auttHhstlcally using the Runc:ommand, it will search
the *SYSTEM.LIBRARY for the appropriate definition of the assembly
routine and link the two together.
· PROC

Identifies a procedure that returns no value. A .PROC is
ended by the occurrence of a new .PROC,.FUNC, or . END.
FQRt'1:

.PROC

C,expression]

[expression) indicates the number of words
of parameters expected by this routine.
The
EXAMPLE:

· FUNC

deft~ult

. PROC

is O.

DLDRIVE.2

Identifies a function that returns a value.
Two words of space to be used fOT the function value
will be placed on the stack before any parameters
A . FUNC is ended the same way as the .PROC .
FORM:

. FUNC

C,expressionl

[exp~essionJ
indicates the number of words
of parameters expected by this routine.

The
EXA!'1PLE~

· END

def~ult

. FUNC

is 0,

RANDOM. ·4·

Used to denote the physical end of an assembly_

1.9,4.2

· ASCII

Converts cha~acte~ values to ASCII equivalent bijte constants
and plac@s the equivalents into the cod~ stream.
FORM:

r. 1 abe 1 )
. AS C I I
<: c h a 'r a. c t e 1" s t T' i n 9 >,.
where  is any string of printable
ASCII chaT'acters~ including a space.
The length
of the string mu~t less than 80 characters. The
double quotes are used as delimeters for the
characters to be converted.
If a double quote is
dt?~ired· in the string;
i t must be specifically
inserted ustng a . BYTE.
l!

Page 107

· ASe r r

EXAMPLE:

lIHELLO"

for the in5~rtian of
constructed as:

AB~CD

the code must be

· ASCII
· BYTE

· ASCI I
Note:

The 34 is the ASCII number far a double quote in hex.

The representation actually used will depend on the
default radiI of the particular machine in use .
. BYTE

Allocates a byte of space into the code stream for each value
list~d_
Assigns the assoc:iated label, i-F any, to the address
at which the byte was stored.
Expression must have a value
between -128 and +255.
I' the value is outside of this range
an error will be flagged.

[ 1 abe 1 ]

FORJ1:

. B VTE

rVf.l.luelistJ

the default for no stated value is 0

. BLOCK.

AlloCBt~s

listed
(if

4

TEt1P . BYTE

EXAMPLE:.:

a block of

jnto code stream for ~ach value
Associates the label
with the starting address of the block allocated.
spac~

Amount allocated

pr~sent)

[ 1 f~ bel J

is in bytes.

. BLOC f.<.

<:length:> is thr:> th~ nl~mb·eT' of tH~t~s to held the <:value:>
s pee i fie d
T h P. d f.~ fat! 1. t .p 0" n (1 s t r3 ted v {:t 1 U ~ i sO.

EXAMPLE:

TEMP . BLOCK

4, 6

the a$sociated output would be:
Of;)

06

06

06

Page 108

( f D wr'

hy t

~~ ~

ll,~

i t i l t he val tJ e 06

)

. WORD

Allocates a word of space in the code stream for each value
in the

v~lu~list.

As~o(jatp.s

th€* decla'ration label with the

word space allocation.
FOR~1:

CIa bel]

EXAMPLE:

TEMP . WORD



. WOR D

0,2,4, ...

the associated output would be:
0000

0002
000,,1

EXAMPLE:

Ll

. WORD

(words with these values in them )

L;2

if L.C l!J·mt;; 50 4~t ttH! ,EQU
t h Eo ;~ ~ soc i .;,;y t ~ d Gut; p n t IJJ n v 1 d be:

. EQU

0050

(*

assign(r,t::nt due

0005

(*

a~signment

Assigns a value to a
~?~pT'e!i!:~!:ion

cont~ining

label.
either

to tho L2 valLIe

due to tho

*)

WORD 5 *)

Labels may be equated to an
lables and/or absolutes.

Dne

must deFine a label before it is used unless it will simply
be equated to another label.
A local label may not appear
on the left hand side of an equate ( .EGU ).
FORI'-1:

. EGU


R6

. ORG

~, t h ~ cur T' en t
1 0 cat i 0 it C 0 U T'I t ? r ( L C) t o t h e 'of a 1 u e
It would normally be used in a stand-alone program.
there is one. ORG In the 8G80/Z80 interpreter .

S IJ~ t

0

f

the . OR G .

For example,

. ORG .L6 cuNLenUy impiemented oni..lj 60ft advancing the iocation c..oun..tetL.
not cunnentilj po~~ibie to ~et the iocation count~ back.

It.-iA

Page 109

1.9.4.3

MACRO FACILITY DIRECTIVES,

A macro is a named section of text that can be defined once and
repeated in other plac~s simply by using its name.
The text of the
macro may be parameterized, so th.::1t each invocation results in a
different version of the mac~o contents.

At the invocation point, the macro name is followed by a list
of parameters which are delimited by commas
(except for the
last one, which is terminated by end of line or th~ comment indication
( ' i ' ) >.
At invocation time, the text of the macro is inserted
(conceptually speaking) by the assembler after being modified by
parameter substitution. Whenever i.n (where n is a single decimal digit
greater that zero) occurs in the macro d~'inition, the text aftha nth
parameter is substituted.
Leading afid trailing blanks are stripped
from the parameter before the substitution.
If a reference occurs in
th~ macro definition to a parameter not provided in a particular
invocation, a null string is substituted.
A macro definition may not contain another macro definition.
nit ion can c e r t a i n 1 Y I h owe v e r l i n c 1 u d Po ma c r 0 in v 0 cat ion s .
Th i 5
"nesting" of macro invocations is limited to five levels deep.

d e of i

The expanded macro is always included in the listing file (if
listing is enabled at the pOint of invocation).
Macro expansion text
i s f loa 9 9 e d l i n the lis tin 9 , b y a ' #' JUs t i e f t 0 f e a c hex pan de d line.
Comments occurring in the macro definition are not repeated in the
expansion .
. MACRO Indicates the start of a macro and gives it an identifier .
. ENDM

Indicates the end point of a MACRO .
FORM:

. MACRO 
(ma.c1"'O

body)

. ENDM

EXAMPLE:

. MACRO

HELP

STA

'X1

LDA

%2

-( comment :>
<: comment :>

. ENDM

The listing

Page 110

where the macro call is made may look like:

A

HELP
51"1'.,.

LDA

FIRST. SECOND
FIRST
SECOND

The 5tatem~nt HELP, calls th~ macro and ~ends i t two
parameters. FIRST and SECOND.
These parameters are in turn
referenced inside the macro using the identifiers Xi for the
va~iable FIRST,
and 1.2 for the variable SECOND.
CONDITIONAL ASSEMBLY DIRECTIVES

1.9.4.4

Conditionals are used to selectively exclude or include
sections of cod~ at a$sembly time.
When the assembler encounters an
. IF directive, it evaluates the associated expression.
In the simplest
case, if th~ ~xr~eSSiD" is falsel the assemble~ simply di5ca~ds the
text !.inti 1:~
E!\!D( 1.·E 'if~.'Elrhert
If· there is ,~n
ELSE direr.:tivp. bet{z.!fH~n
t h flo
rFan d . ENOC d .1 T' ~ c t: :i \l i~ S i t h e t ext b ~p 0 'r ~ the . ELSE i os s e 1 e r. ted if
thf~ s'q)T't:s<;;, on is t1'U€~.
mnd the t~xt !3ftr~T' the
ELSE if! the condition
is false
The unassembled part of the condition~l will not be included

Conciitjonals may

b~

nested.

sion ti!j~(e~~ one of tldO fOT'ms.
The first
is the no~mbl a~ithm.tic/logical expres~ion used elsewhere in the
assembler.
This typm of exp~essicn is considered false if it
ev~luAte~ tn zerOi
true othe~wise.
The second farm of conditional
Th~

condit

tiJn~l

expr-E'SSlOn is COmf.H~·r'j,son
and ' . "~.: ~
r e ~;q) i? C t i \/ ely 'a~tthmRttc!logical

· IF

ff'XPT8Si

for' equality or inequality
0n€

!(i~;~ ~J

C. 0

mpaT' B

5

t r i n9 s •

(indicated by
c h a rae t e -r' S t

'=1

Of'

expressions.

ldentlfias the beglnning of the conditional_

· ENDC
· ELSE

Identif.:ies

th~

exp~ession

is egual to 0 then the else is used.

FORM:

[lr.ibel]

alte-rn3te to the. IF.

IF

. ELSE

If -the conditionall



(*

only if there is an else *)

. ENDC

Page i i i

where the expression is the conditional expression to be met.
· IF LABELI-LABEL2
iarithmetic exp~ession
This text assembled only if subtraction
result is now zero

EXAMPLE:

IF

"%1" ;:::"STUFF!I
icomparison expression
This text assembled if subtraction above
was true and if text of first parameter
(assume we a~e in macro ) is equal to "STUFF"
.ENDC
iterminate nested condo
· ELSE
This text assembled if subtraction result
i

was zero

· EN DC

iterminate outer level
iconditional

PASCAL HOST COMMUNICATION DIRECTIVES

1.9.4.5

The

di~ective5

.CONST,

. PUBLIC, and . PRIVATE allow the sharing

of information and data space between an assembly routine and a Pascal

host.
These external referenc.es must eventually be resolved by the
Linker.
Refer to Section 1.8 Linker, for further details.

.CONST

Allows access

globally declared constants in the PASCAL host
in a program
to replace 16 bit relocatable obJects.
o~

by the assembly routine . . CaNST can only be used

. PUBLIC

Page 112

FORM:

,CONST

EXAMPL.E:

<* see example after . PRIVATE



Allows



of the assembly routine to be

va~iables

sto~ed

in the

global data segment and yet be inaccessable to the Pascal host.

These

va~iables

retain their values for the entire execution of

the p-rog-ram .
FORM:

. PRIVATE



the integer is used to communicate the number of
words to be allocated to the identifier.
EXl'~lPLE:

(*

for .CONST,

. PRIVATE,

. PUBLIC *>

Given the following Pascal hast program:
PRO(~RAM

EXAMPLEi

CONST SETSIZE=50; LENGTH=80i

VAR I,J.F/HOLD,COUNTER,LDC: INTEGER;
LST1:ARRAY[O .. 9J OF CHAR,
BEGIN

END.

and the following section of an assembly routine:
_ CONST

LENGTH

. PRIVt.. TE

PRT .• LST2: 9
LDCI I I J

. PUBLIC

This will allow the canst LENGTH to be used in the assembly
routine almost as if the line LENGTH. EGU eo had been
written. (Recall the limit~tinn mentioned above for the use
. CONST identifiers. ) The vaT':i~3bles LOC, I. J to be used by both
'the Pase a 1 hO$ t and tile assemh 1 y~. outi ne, and the variables

PRT, LST2 to

be

used only by the assembly routine.

the LST2:9 causes the

va~iable

b fl gin n i n goof a 9 tal 0 1" d b 1 () c~·
segment"

0 oF

Furthe~,

LST2 to correspond with the
spa c e i nth e 9 1 t., b aId a ta

Page 113

1. 9. 4. 6

EXTERNAL REFERENCE DIRECTIVES

The use of . DEF and ~REF is similar to that of . PUBLIC . . DEFs
and . REFs associate labels between assembly language routines rather
than between an assembly routine and a Pascal host program.
Just as
with . PRIVATE and .PUBLIC~ these external references must eventually be
resolved by the Linker.
If such resolution cannot be accomplished, the
Linker will indicate the offending label.

cannot be expected to flag these errors,
other assemblies.
. DEF

. REF

Naturally!

the assembler

since it has no knowledge of

Identifies a label that is defined in the current routine
and availabl~ to be used in other .PROCs or . FUNes.
FORfYi.

.DEF

EXAt1PLE:

<*



see listing in section 3.3.2.3

'O~

example *)

Identifies a label used in this routine which has been
declared in an external .PRQC or . FUNC with a .DEF.
During the linking proce$s~ corresponding .DEFs and .REFs
are rna t

t:

hed.

FORM:

. REF



EXAMPLE:

<* see listing in section 3.3.2.3 far example

*'

Nate: The .PROC and th0 . FUNC directive also generates
a . DEF l~ith the same ntune.
This allows assembly
procedures to call. PROC and . FUNes if they have
been defined in a . REF.

LISTING CONTROL DIRECTIVES
· LIST
&
· NOL.IST

Allow. selective listing of assembly routines.
If no Dutput file is declared then the default is CONSOLE:
when a . LIST is encDuntered. The . NOLIST is used to turn off
the .LIST option. Listing may be turned on and off
rRpeatedl~ within an assembly.

FORM:
· PA(-1E

, LIST

01"

.

NOLIST

Allows the programmer to explicitly ask for top of form
page breaks in the listing.

i6 no ruUng ouitpld nile M ,t,pecJ..6ied then
dhc.e.c.Uvualte .6imply ignoJted.

au. . LIST and

.NOLIST

FORM:

. PAGE

Allows the titling of each page if desi~ed.
The title may be up
to 80 cha~acters in length.
At the start of each procedure the
title is set to blanks and must be T'eset· if title is desired"

. TITL.E

The title;

INTERP
shown in

1, 9.4.8

. INCLUDE

SYMBOL TABLE DUMP

S~ction

1.9.1 was caused by a . TITLE directive.

FORM

<:t i t 1 e:'-'"
. TITLE
where  is a string

EXAMPLE

.1ITLE

**

GRC12 interpreter

FILE. DIRECTIVES
Causes the indicatgd source file to be included at that point .
FORM:

. INCLUDE  where the file
identifier is any file to be included.
Only spaces

are allowed between the end of the file name and the
end

o~

the

Includ~

line .

CORRECT EXl\MPLE.:

. INCLUDE

SHORTSTART TEXT

CORRECT EXAI'1PLE:

. INCLUDE

SHORTSTART.TEXT
i

IN-CORRECT EXAMPLE: . INCLUDE

For a
m/H~ h j

**

list of
!1 !'.' '! S

:; p ;::,

gene~al

callo; starter

SHORTSTART.TEXT

errors and also notes on the

zao

calls starter

and PDP-11 based

T.3 h 1 e 6.

Note:' The.ti:Ue iJ.> only c.£.eCVted a;t the -6.taJtt 06 .the {yUe. In -6 eetion 1.9. 1 the :ti.:tle
SYMBOL TABLE DUMP Wa6 not f.:,et by a . TITLE cUJtec.:tive. That heading iJ.> a,fu)aY-6
tL6 ed on page!.> c.ontMMng f.:,ymboUabie dump-6.
Upon M-6 emblinga 6wvthetL
pJtoc.edwr.e the heading pJtinted JtetWtn6 to what i l WM f.:,et to be60Jte the
-6ymboltabie dump.

Page 115

- Notes -

********************* ***************

*

SYSTEM INTRINSICS

* *

Section 2. 1

*

********************* ***************
Version 1. 5

September 1978

WARNING
Mast of the UCSD int~insics assume that users are fluent in the
use Or PASCAL and are experienced in the use of the system.
Any
necessary range or validity checks are the responsibility of the useT'.
Since some of these intrinsics do no checking for range validity. they
may easily cause the system to die a horrible death.
Those intrin5ic~
which are part1cularily dangerous are noted as such in thei~
descriptions.

PARAMETERS
Required parameters are listed along with the function/procedure
identifier.
Optional parameters are in [square bracketsJ.
The default
values for these are in {metabrackets} on the line below· them.

NOTE
Following a~e some definitions of terms used in these
documents.
They tend to take th~ place of formal paTameter~ in the
dummy declaration headers that preface each description of a particula~
routine, or set of routines,
ARRAY
a PACKED ARRAY OF CHARacterG
BLOCJ.(.

one dl.·sk blQckl

BLOCKS
BLOCKNUMBER

an INTEGER number of blocks

BOOLEAN
CHARACTER

any BOOLEAN value

DESTIN/,TION

EXPRESSION

FILElD

a nab S \1 11) ted i

'2

{512, bytes}

k b 1 0 c k add T' e s s

any expression which evaluates to a character
a PACKED ARRAY OF CHARacters to write into or

a STRING, context dependent
part or all of an exp~essionJ to be specified
a -filt? identifier~ ~'i:ust be
VAR fileid: FILE OF ;
or

INDEX
NUMBER
RELBLOC~

SIMPLVARIABLE

TEXT;

01'

INTERACTIVE;

OT"'

FILE;

an index into a STRING or PACKED ARRAY OF CHARacters,
context dependent or as specified.
a literal or identifier whose type is either INTEGER
or REAL.
a relative disk black address. relative to the start
of the file in co~textj the fir~t blork beIng
block zero.
any declared PASCAL va~iable which is oT one of the
f (I 1 1 m~J 1. n 9 TYP E s: :

Page 117

BOOLEAN

CHAR

REAL

STRING

SIZE

or PACKED ARRA.Y[ .. ] OF CHAR
an INTEGER number ofbyte~ or characters; any integer

SOURCE

a STRING or PACKED ARRAY OF CHARacters to be used as a

SCREEN

an array 9600 bytes long;

VJ..':jlup.

T'ead-only array,

STRING
TITLE
UN I TNllMBER

VOLID

**

context

d~pendent

or as specified.

**

or as needed.

any STRING, call-by-valuD unless otherwis. specified,
i. e. may be a Q,lIoted stT'ing, or string val'iable
or function which evaluates to a STRING
. a STRING con5t~ting of a file name
physical device number used to determine device handler
used by the interpreter
a volume identifier, STRING[7J

i. e. in .6vung in.tJzA.n.6ieo, SOURCE i.6 go-Lng to have to be a .6;tJU,ng, -Ln A..nvun.6ieo that
deal with pac.ked aJVLay.6 06 c.hafLac.telt-6, it may be eitheJt. A wOJtd 06 c.auUon
about U6ing STRING.6 in {n:tJvtn.6ieothat expec.t c.ha.Jta.c.teJt aJVLay.6, the zeJtoeth
Uement 06 :the .6.tJU.ng -fA the length byte, whic.h may c.aU6 e the pJtogJtammeJt
.6ome unexpec.ted pJtoble.m6. (Wvr.e he not awMe 06 that 6ac.t!) ed.

Pqge 118

********************* *****************

*

STRING INTRINSICS

* *

*

Section 2. 1. 1

********************* *****************
Version l.S
September 1978
FUNCTION LENGTH ( STRING ) : INTEGER
Returns the integer value of the length of the STRING.

Example:
GEESTRING := '1234567';
WR ITELN (LENGTH (GEESTR INC),'

" LENGTH (

I

,

)

);

Will print:
7

FUNCTION POS ( STRING

I

0

SOURCE ) :

INTEGER

This function returns the position of the first occurrence of
the pattern in SOURCE to be scanned.
The INTEGER value of the position
of the first cha~acter in the matched pattern will be returned; or if
the pattern was not found, zero will be returned.
Example:
STUFF := 'TAKE THE BOTTLE WITH A METAL CAP';
PATTERN := 'TAL';
WRITELN(POS(PATTERN,STUFF»;
Will p"rint:

26
FUNCTION CONCAT ( SOURCEs ) : STRING
There may be any number of source strings separated by commas.

ThislTunction returns a
all the str-i.ngs passed to

it.

st~ing

which is the concatenation oT

Ex.ample~

SHORTSTRING := 'THIS IS A STRING';
LONGSTRING : = 'THIS IS A VERY LONG STRING. 'i
LONGSTRING := CONCAT('START ',SHORTSTRING, '-', LONGSTRINO)J
WRITELN(LONGSTRING);
Will print:

START THIS IS A STRING-THIS IS A VERY LONG STRING.

Page 119

FUNCTION COpy ( SOURCE

INDEX

I

I

SIZE ) : STRING

This function return~ a st~ing containing SIZE characters
copied from SOURCE starting at the INDEXth position in SOURCE.
Example:

TL := 'KEEP SOMETHING
WR ITELN (KEPT) i

HERE';

KEPT

COPV(TL,POS{'S',TL),9);

Wi 11 print:

SOME.THING
PROCEDURE DELETE ( DESTINATION ,

INDEX

SIZE )

I

This procedure removes SIZE characters from DESTINATION
starting at the INDEX specified.
Example:
OVERSTUFFED:

=

'THIS STRING

H~~S

F.CtR TOO MANY CHARACTERS IN IT.

'j

DELETE(OVERSTUFFEDJPOS('HAS',OVERSTUFFED)+3,8)~

WRITELN(OVERSTlWFED);
Wj 11 print:

THIS STRING HAS MANY CHARACTERS IN IT.
PROCEDURE INSERT ( SOURCE

I

DESTINATION

I

INDEX

This inserts SOURCE into DESTINATION at the INDEXth position in
DESTINr',T InN.
Example:

ID :

=

I

INSERTIONS' I

MORE := ' DEMONSTRATE';
DELETE (MORE, LENGTHCMORE) , l)i
INSERT O'iOREI ID. POS ( 'IO! 1 10) ) i
WRITELN( ID);
Will print:

PROCEDURE STR ( LONG

Page 120

I

INSERT DEMONSTRATIONS
DESTINATION )

This converts thy lang integer LONG into a st~ing.
The
string is placed in DESTINATION.
See section 3.3.3 for
about the use of long integers.
~esulting

mo~e

Example~

INTLONG ;= 102039503;
STRCINTLONG,INTSTRING);
INSERT( '.

~

I

INTSTRING, PRED(LENGTH( INTSTRING»);

WRITELN( '$', INTSTRING)i
Will print:
$1020395.03

Note about using

st~ing$

and

st~ing

functions:

In order to maintain the integrity of the LENGTH of a st~ing,
only st~ing functions or full string assignments should be used to
alter strings.
Moves and/or single characte~ assignments do not affect
the length of a string which means it probab~ecome$ wrong.
The
individual elements of STRING are of t~pe CHAR and may be indexed
1 .. LENGTH(STRINO).
Accessing the string out~ide this range will have
unpredictable ~e$ults if range-checking is off or cause a run-time
error (1) if range checking is on.

Page 121

- Notes -

age 122

******************************* *****************

*

INPUT AND OUTPUT INTRINSICS

* *

Section 2.1.2

*

******************************* *****************
Version 1. 5
PROCEDURE RESET ( FILEID,

September 1978

[TITLE]

)j

PROCEDURE REWRITE ( FILEIDI TITLE

)j

These procedu~es open files for reading and writing and mark
the file as open.
The FILEID may be any PASCAL structured file, and
the TITLE is a st~ing containing any legal file title.

The difference between them is that REWRITE creates a n.w file
for output filesi RESET slmply marks an already existing file
open for 1/0.
(Note: if the device specified in the title is a nondirectory structured device, e. g. PRINT~R:
th~n the file is opened
Tor in put IOU t put, 0 r bot h in e i the rca 5 e.) 1 f t h e f i 1 e wa sal rea d y
open. and another RESET O~ REWRITE is attempted to it~ an error will be
returned in IORESULT.
The -filei's state will remain unchanged.
on

di~k

I

RESET (FILEID) witho~jt optional string parameter urewinds" the
file by setting the -file pOinters back to the beginning (zero th
~ecoT'd) oT the -file.
The boolean functions EOF and EOLN will now be
set by the implied GET in RESET.

These procedures behave differently with files of type
INTERACTIVE.
RESET on files of types other than INTERACTIVE will do an
initial GET to the file, setting the window va~iable to the first
l' e COT' din the f i 1 e ( as des c rib e din Je n 5 en & Wi r t h ) .
RESE Ton a of i 1 e
of type INTERACTIVE will not do an initial GET.

PROCEDURE UNITREAD
PROCEDURE UNITWRITE

UNITNUMBER. ARRAY, LENGTH,
UNITNUMBER, ARRAYI LENGTH.

[BLOCKNUMBER], [INTEGER] );
CBLOCKNUMBERJp [INTEGER] );
{ sequential} { 0 }

THESE ARE DANGEROUS INTRINSICS
These procedures are the low-level procedures which do 110s to
The UNITNUMBER is the'· integer name of an 110 device.
The ARRAY is anq de~lared packed a~raYI which may be subscripted to
indicate a starting position.
This is used as the starting address to
do the transfers from/to.
The LENGTH is an integer value designating
the number of bytes to transfer.
The BLOCKNUMBER is required only when
u~ing a hlock-structured device (i. e.
a disk) and is the absolute
blocknumber at which the t~ansfer will start from/to.
If the
BLOC~NUMBER i5 left out, 0 is assumed.
The INTEGER value is optional
(assumed 0) and indicates (if 1) that the t~ansfer is to be done
asynchronously.
The blocknumbe-r is not necessary.
A '"Yl.' wut be
varioun d~v,.c.es.

sufficient,

6aUlitieA *)

(See UN!TBUSY and UNITW?,IT.)

(*when

U6iYl.g

the

aoYYl.C.h!tOYl.OU6

I/O

FUNCTION UNITBUSV ( UNITNUMBER ) : BOOLEAN;
This function returns a BOOLEAN value, indicating if TRUE that
the device specified is waiting foT' an 110 transfer to complete.
Example:
UNITREAD(2{non-echoing keyboa~d}jCH[OJf
l{for one character}, {no block no.}, l{async:hronous},);
WHILE UNITBUSY(2){While the READ has not been completed} DO
WRITELN(OUTPUT,'I am waiting for you to type something'};
WRITELN(OUTPUT, 'Thank you for typing a

.. I CH[OJ)i

Execution of this example will continuously type out the line
'I am waiting far you to type something' until a character is struck on
the keybo;:~T'd,
Suppose a ' ! ' were tlJpedo
The me'ssage
'Thank you foT'
typing a · ' will then appear, and program execution will proceed
nOT'ma 11 y.

PROCEDURE UNITWf-\IT ( lINITNUMBER ) i

This waits for the sppci'ied d.vice to complete
It can be simulated by:

th~

110 in

prog~es~.

WHILE UNITBUSV(n) DO {waste a small amount of time};
PROCEDURE UNITCLEAR ( UNITNUMBER );

UNITCLEAR cancels all IIOs to the
hardware to its power-up state.
FILEID,
FILEID,

FUNCTION BLOCKREAD

FUNCTION BLOCKWRITE

ARRAY,
ARRAY,

spe~iFied

BLOCKS.
BLOCKS.

unit and resets the

(RELBLOCKJ )

INTEGER~

[RELBLOC~'{

INTEGER,

J

)

{ sf'quential }

These functions
blocks of data
(1. e. F : FILE;

actll(~lly

).

T Ii f.\

an INTEGER value e~ual to the number of
tT'ansferred.
The FILE must be an untf,~ped file
1 eng tho -f' AR R A V 5 h 0 U 1 d b e ani n t. e 9 Po r mu 1 tip 1 e 0 f
retu~n

BLOCKS is the number o~ blocks you want
tran':;ft:>rr'ed.
RElBLOC!, is the blocknomoC\;, reL:::"tive to the staT't 0; the
file# the zeroeth block being the first block in the file.
If no
RELBLOCK is specified, the reads/writes will be done sequentially.
A
random access 110 moves the file point~rs.
CAUTION should be exercised
when using thesel as the array bounds a~e nat heeded.
EOF(FILEID)
becomes true when the last block in a file is read.
bytes-per-di~k-block.

Page 124

Pf~GCE.DURE

CLOSE ( FILEID OPTION ) i

OPTION may be null or "
',CRUNCH',

LOCK't or "

NORMAL', or "

PURGE', or

(Note the commas!)

If OPTION is null then a NORMAL close is done, i. e. CLOSE
simply sets the file state to closed.
If the file was opened using
REWRITE and is a disk file, it is deleted from the directory.
The LOCK option will cause the disk file associated with the
FILEID to be made permanent in the directory if the file is on a
dfrectD~y-structured device and the file was opened with a REWRITE;
othe~wise a NORMAL close is done.
The PURGE option will delete the TITLE as~ociated with the
FILEID fram the directory.
The unit will go off-line if the device is
not block structuT~d.
T h 1;:' CR UNC Hop t i. 0 n

The intent is to ID~k a
u.eful information.

i

~~

fil~

as y n tun d e fin (~ din

ll' hat

i t

wi 11 do.....

with the minimum number of blocks of

All CLOSEs rega~dlegs of the option will ma~k the file cloned
and will make the implicit variable FILEIDA undefin~d.
CLOSE on a
CLOSEed file causeG no action.

FtJNCTHlt. .l EOF (FILEID)

:

BOOLEAN.;

FUNCTION EOLN (FILEID) : BOOLEANi
If (FILEID) i's nt,1t present, the fileid INPUT is assumed (e. g.
IF EOF THEN ... >.
EOLN and E.OF return fl.~.lHe d'fter the file specified is
RESET.
They both return tr-ue on a c lased fi le.
When EOF (FILEIO) is
t~ue~
FILEIDA is undefined.
When GET (FILEID) sets FILEIDA to the EOLN
character OT the EOF character; EOLN (FILEID) will return true, and
FILE!'fY" (in a FILE OF CHAR) will be s~t; to a bIanlc,
If) while doing
puts or writ.s at the end of a file, tho file cannot be ~~panded to
accommDdate th~ PUT or WRITE~ EOF(FILEID) will return true.

FUNCTION IORESULT

INTEGER;

I~d"t;(?r any I/O opf~r.ations
IORESULT c.ontains an INTEGER value
corresponding to the values given in Table 2.

Page 125

PROCEDURE GET ( FILEID );
PROCEDURE PUT ( FILEID )i
These procedures are used for operations on typed files.
A
typed file is any file for which a type is specified in the variable
dec 1 a rat ion l i e . ' FILE I D : FILE OF <: t YP e"
T his i s a sop p 0 sed to
untyped files which are simply declared as: ' FILEID: FILEi'.
'F: FILE
OF CHAR' is equivalent to 'F: TEXT'.
In a typed file each logical
record is a memD~y image fitting the description of a variable of the
associated .
t •

GET (FILEID) will leave the contents of the current logical
record pointed at by the file pointers in the implicitly declared
"window" variable FILEIDA and increment the file pointers.
PUT (FILEID) puts the contents of FILEIDA into the file at the
location of the current file pOinters and then updates those pOinters.

PROCEDURE READ{LN} ( FILEID, SOURCE )i
PROCEDURE WRITE{LN} ( FILEIDi SOURCE )j
These procedures may be used only on TEXT (FILE OF CHAR) or
INTERACTIVE fi les for. 110.
If 'FILEID, , is omi tted, INPUT OT' OUTPUT
 true.
This means that any subsequent READs of
STRING variables will return the null string until a READLN or
READ(chara~acter) is executed.
There are three files of type INTERACTIVE which are
predeclared: INPUT, OUTPUT, and KEYBOARD.
INPUT results in echoing of
characters typed to the console device.
KEYBOARD does no echoing and
allows the programmer complete cont~ol o~ the response to user typing.
OUTPUT allows the user to halt or flu~h the output.

PROCEDURE PAGE ( FILEID );
This prOCedUT'E'1

as described in Jensen & Wirth

P.

*********************************** ***************

*

LOW LEVEL GRAPHICS INTRINSICS

* *

Section 2.1.4

*

*********************************** ***************
Version I. 5
CAUTION

September 1978

(*U,6e.d only with the. TERAK 8510a. miCJtoc.omputeJt*)

Thes~ routines do no range checking of the parameters they are
passed.
If any of the paramteT's are "out of range", these routines
will happily move bit patterns throughout main memory, much to the
dismay of the operating system and your program.

See Table 4 for modes and penstates

fQ~

these intrinsics.

The DRAW intrinsics are available only for the Terak 8510a in
this r~lea5e.
Additional display units will be supported in later
releases, but no details are currently available.
Probable implementat ion ( s ): T e k tor 0 nix 4006.

PROCEVURE VRAWBLOCK(VAR SOURCE; SRCROW,SRCX,SRCY:INTEGERj VAR VEST; VSTROW,VSTX,VSTY:INTEGER;
CNTX, CNTY, MOVE: INTEl
(*

non~

of these are optional *)

This p~o~edure is w~itten for the Terak 8510a graphic displa~
mode.
The TERAK screen displays words consecutively with the most
significant bit of the word on the right.
DRAWBLOCK will work only on
screens who;. graphics operates in

thi~

manner.

WARNING:

No range

checking is performed.
DRAWBLOCK transfers a bit matrix SOURCE, which starts on an
word boundary, to a specified point (STARTY, STARTX) in the bit matrix
SCREEN.
All parameters are integers except SCREEN, which is a bit
matrix o~ width ROWSIZE (1. e. BITMAP: PACKED ARRAY[O .. MAXROWJ OF PACKED
ARRAV[O .. ROWSIZE-IJ OF BOOLEAN;)

The SOURCE is SIlEX bits wide by

SIZEY bits high.
The first COPYX bits of each row are copied into the
destination.
MODE is defin~d in TABLE 4.
PRDCEDURE DRf\WLINE

VAR
(RANGE: INTEGER; VAR SCREEN; ROWWIVTH, XSTART, YSTART, VELTAX,
VELTAY, PENSTATE: INTEGER);
(* none

of these are optional

*)

In order the parameters are: INTEGER IDENTIFIER, ARRAY
IDENTIFIER. and the remaining six, INTEGER EXPRESSION.
RANGE will
contain the results of a Radar scan.
This parameter is untouched
unless PENSTATE is sent as 4.
The value returned is the number of dots
that would hav. be~n drawn before encountering an obstacle.
SCREEN may
be subscriptpd to determine a starting position in the array.
ROWWIDTH
is the width of SCREEN in number of words; this determines how DRAWLINE
will consider the rectangularity of the array.
XSTART is the starting
horizontal coordinate; YSTART is the starting vertical coordinate.
DELTAX is the distance to. move in the horizontal plane.
DELTAY is the
distance to move in the vertical plane.
PENSTATE controls the action
taken; sea TABLE 4.

**fJ 0 te.:

the deelaltation6

a6

in oltdeJt to U,6 e. the6 e. ltO utine6 , the. t.M eJt mt.M t add
above., a.nd the. lte6eJtve.d woltd EXTERNAL;

Page 129

-~ares..

Page 130

-

******************************************** *****************

*

CHARACTERARRAV MANIPULATIONS INTRINSICS

**

Section 2.1.5

*

******************************************** *****************
Version I. 5

September 1978

CAUTI.ON
Th e·s e in t T' ins i c: s aT" e a 11 by teo 1" i en ted.
Use them wit h car e.
Read the descriptions carefully before trying them out as no range
chec.king of any sort is performed on the parameters passed to these
routines.
The p~ogTammer should know exactly what he is doing before
he does it since the system does not protect itself from these

opera'tiofHL

FUNCTION SCAN ( LENGTH,

PARTIAL EXPRESSIONI

ARRAY ) :

INTEGER;

This Funtt10n returns the number of characters from the
starting position to where it terminated.
It terminates on either
matching the specified LENGTH or satisfying the EXPRESSION.
The ARRAY
should be a PACKED ARRAY OF CHARACTERS and may be subscripted to denote
the starting point.
If the exp~ession is satisfied on the character at
whir.::h ARRAY is pointed, the value returned uJill be zero.
I f the length
passed was negative, the number returned will also be negative, and the
function will have scann~d backward.
The PARTIAL EXPRESSION must b~ of
the TOT'm:
OT'

U<::;:-II

11=11

folluwed by

;
MDVELEFT(A[O],A[l],n-l)i
but FILLCHAR is twice as fast,
source.

as no memory reference is needed for a

See the note about word move optimization in the section on
MOVELEFT.
The notes about MOVELEFT also apply to FILLCHAR.
The intrinsic SIZEOF (Section 2.1.6) is meant for use with
it is convenient not to have to figure out or
remember the number of b~tes in a particular ~ata structure.
these intrinsic$j

Page 132

************************** *****************

*

MISCELLANEOUS ROUTINES

* *

Section 2.1.6

*

************************** *****************
Version I.5

September 1978

FUNCTION SIZEOF ( VARIABLE OR TYPE IDENTIFIER ) : INTEGERi
This function returns the number of bytes that the "item"
passed as a parameter occupies in the ~tack.
SIZEOF is particularly
useful fur FILLCHAR and MOVExxxx intrinsics.
FUNCTION LOG ( NUMBER

~

REALi

This function returns the log base ten of the NUMBER passed as
a

paT"amet~r"

PROCEDURE TIME (VAR HIWORD,

LOWORD'

INTEGER);

This procedure returns the current value of the system clock.
It is in 60th? of a s~cond.
(This is somewhat hardware-dependent; we
assume a 16-bit integer size and 32-bit clock word.
The HIWORD
contains the most significant portion.
WARNING! The sign of the LOWORD
may be negativ~ since tile time is represented as a 32-btt unsigned
number. ) Both HIWORD and LOWORD must be VARiables of type INTEGER.
FUNCTION PWROFTEN (EXPONENT:

INTEGER) : REAL;

This function returns the value of 10 to the EXPONENT power.
EXPONENT must be an integer in the range O.. 37.
PROCEDURE MARK (VAR HEAPPTR: AINTEGER)
PROCEDURE RELEASE (VAR HEAPPTR: AINTEGER);

These procedures are used for returning dynamic memory
HEAPPTR is o~ type AINTEGER.
MARK sets

allocations to the system.

HEAPPTR to the curT'ent top-·of-heap.
to HEAPPTR,

RELEASE sets top'-of-heap

pointer

PROCEDURE HALT i

This procedure generates a HALT opcode that, when executed,
causes a nan-fatal run-time error to occur.
At this point in
execution. the D~buggeT' is invoked, theT'efore, if the Debugger is not
in core when this occurs, a fatal run-time errol', #14, will occur.

PROCEDURE GOTOXY{ XCaORD

I

YCOORD );

ThlS procedure sends the cursor to

(XCOORD,

YCOORD).

the coordinates specified by
The upper left corner of the screen is assumed to be

(0,0).
This procedure is wTltten to default to a Datamedia-type
terminal.
If your system uses ather than a Datamedia or Terak 8510a,
you will need to bind in a new GOTOXY using the GOTOXY package
described in Section 4.10.
Pag.e 133

-NO\"ES -

Page 134

********************************************************** ***************

*

DIFFERENCES BETWEEN U.C.S.D.

PASCAL AND STANDARD PASCAL*

*

Section 2.2

*

********************************************************** ***************
Version

.r.

5

September 1978

This section is a summary and quick referrence guide which
notes the areas in which U.C.S.D. Pascal differs from the Standard
Pascal, and refers the user to the appropriate documents which explain
various 5$pects of U. C. S. D. Pascal. The Standard Pascal referred to by
this section is defined in PASCAL USER MANUAL AND REPORT (2nd edition)
by Kath 1 een .Jensen and Ni klaus Wi T'th (Spr i ng er"-Y'er lag, 1975 >.
Many of the differences lie in the area of FILES and I/O in
general.
It is recommended that the reader first concentrate upon· the
sections which describe the diffe~ences associated with the standard
procedures EOF, EOLN. READt WRITE, RESET, and REWRITE.
2.2.1

CASE STAiEMENTS
Jensen and Wirth on page 31,

state that if there is no label

equal to the value of the case statement selector,

the result of the

case statement is undeflned.
U.C.S.D. Pascal defines that if there is
no label matching the value of the case selector then the next
statement executed is the statement following the case statement.
For
example, the following sample program will only output the line "THAT'S
ALL FOLKS·! since the case statement will "fall through" to the WRITELN
statement following the case statement:
PROGRAM FALLTHROUGHJ
VAR CH: CHAR;
BE.GIN
CH:

=: '

A ';

CASE CH OF
. B": WR I TELN  on pages 116118 of Jensen ~nd Wirth: the U.C.S.D. Pascal compiler will not permit a
semicolon befoT'ethe IIEND!! of a case va-riar.t field declaration within a
RECORD decla~ation.
See Table 6 for revised s~ntax diagrams for -.

Page 135

2.~.2

COMMENTS

The U.C.S. D. Pascal compiler recognizes any text appearing
between either the symbols n<*n ·and "*)H aT' the ~ymbol~ u-e and It}" as
a comment.
Text appearing between these symbols is ignored by the
compiler unless the first character of the comment is a dollarsign, 'in
which case the comment is interpreted as a compiler control comment.
See section 1.6 "Pascal Compiler" for details on compiler control
comments.
ft

0'

Note that if the beginning
the comment is delimited by the
symbol, the end oT the comment must be delimited by the matching
n*>" symbol, rather than the II}" symbol. When the comment begins with
the "{If symbol) the comment continues until the matching U}" symbol
app ears.
Th is feature a llows a user to "c omment out II a sect i on of a
program which itself contains comments.
For example:
"(*ff

{

XCP

XCP +

1;

<* ADJUST FOR SPECIAL CASE ... *>

}

Note that the compiler does not keep track of nested comments.
When a comment symbol is encountered, the text is scanned for the
matching comment symbol.
The following text will result in a syntax
error:

<* THIS IS A COMMENT

2.2.3

<* NESTED COMMENT *>

END OF FIRST COMMENT *)
'·'error here .

DYNAMIC MEMORY ALLOCATION

The standard procedure DISPOSE defined on page 158 of Jensen
and Wirth is not implemented in U,C.S. D. Pascal.
HOWEver, the function
of DISPOSE can be approximated by a combined use of the U.C. S.D.
intrinsics MARK and RELEASE. The process of recovering memory space
described below is only an approximation to the function of DISPOSE as
one cannot .explicitly ask that the storage occupied by one particular
variable be released by the system for other uses.
The cur~ent U.C.S.D implementation allocates sto~age for
variables created by use of the standard procedure NEW in a stack-like
s t rue t u r e c a 11 edt he" h e a p
T h efo 11 0 wi, n 9 p 1" 0 9 T' ami s a s imp 1 e
demonstration of how MARK and RELEASE can be used to change in the size
of the heap.
PROGRAM SMALLHEAPi
PI •

TYPE

PERSON=
RECORD
NAME:

PACf.(.ED ARRAV(O.

ID: INTEGER
ENDi

Page 136

15) OF CHARi

VAR P:

'''·PERSON;

<* .........

means "pointer to" as defined in J&W

*>

HEAP: . . . INTEGER,
BEGIN
l"'iAR~< (HEAP) ,;
NEW(P) i
p ...... NAME: 'FARKLE,
p ...... ID: == 999;
RELEASE ( HEAP) i
END,

=

HENRY J. ';

The above program first calls MARK to place the address of the
current top of heap into the variable HEAP.
HEAP being declared to be
a pointer to an INTEGER is not really importantl as HEAP could have
been declared as pointing to almost anything.
The parameter supplied
to MARK must be a pointer variable, but need not be a pOinter that is
declared to be a pointer to an INTEGER. This is a particularly handy
construct for deliberately accessing the contents of memory which is
otherwise inaccessable.
Below is a pictorial description of the heap
at this point in the program's execution:

<--- HEAP

TOP OF HEAP --:>

contents of heap at

start of program

Next the program calls the standard procedure NEW and this
results in a new variable pA which is located in the heap as shown in
the diagram below:

TOP OF HEAP ---:>
<---~

HEAP

contents oT heap at
start of program

Page 137

Once the program no longer needs the variable pA andwi~hes to
"release" this memory space to the system .pOl' other usess it calls
RELEASE which ~esets the top of heap to the address contained in the
val' iab 1 e HEAP.
If the above sample program had made a series of calIsta the
standard procedure NEW between the calls to MARK and RELEASE, the
storage occupied by several variables would have been relea~ed at
once.
Note that due to the stack nature
the heap it i . not possible
to release the memory space used by a single item in the middle of the
heap.
It is for this reason the use of MARK and RELEASE can only
approximate the function of DISPOSE as described in Jensen and Wirth.

0'

Furthermore, it should be noted that careless use of the
intrinsics MARK and RELEASE can lead to "dangling pointersll, pointing
to areas of memory which are no longer part of tne defined heap space.
2.2.4

EOF(F)

To set EOF to TRUE for a textfile F being used as an input file
from the CONSOLE device1 the user must type the EOF character.
The
system default EOF character is the control-C character.
The EOF
character can be altered by a suitable reconfigu~ation of the system
variable SYSCOMA.CRTINFO.EOF using SETUP.
For further information
concerning system configuration and the SETUP program see Section 4.3.

If F is closed, for any FILE FI EOF(F) will return the value
TRUE If EOFCF) is TRUE
and F is a FILE of type TEXT,
EOLN(F) is
also TRUE. After a RESET(F), EOF(F) is FALSE.
IF EOF(F) becomes TRUE
during .a GET(Fi OT' a READ(F, ... ) the d·:3ta obtained thereby is not
I

val id.

When a user program starts execution. the syst~m performs a
RESET on the predeclared files INPUT, OUTPUTJ and KEYBOARD,
See
section 2.2.11 READ for further details concerning the predeclared file
~.EYBOARD.

As defined

refer to

2,2.5

in

~'2n&en

.and l..Ji.rth.

EOF and EOLN by def-ault will

the file INPUT if no file identifier is specified.

EOLN(F)
EOLNCF)

i~

d~fined

the  of the l.;Jindoul

onl~

if F is a textfile.
F is a textfile if
F"'~l
is of type CHAR.
EOLN becomes

va~i3ble:

TRUE only after reading the end of lin~ character.
The end of line
character is a car7iage ~eturn
In the example program below, care
must be taken as regards when the carriage return is typed while
inputing

Paae 138

datt~:

PROGRAMADDLINES.
VAR Ki SUM: INTE-:GER;

BEGIN
WHILE NOT EOF(INPUT) DO
BEGIN
SUM: ~O,
READ ( INPUT, K)

j

WHILE NOT EOLN(INPUT) DO
BEGIN
Sut'1: =5UM+K i
READ( INPUT, K);
END;

WR I TELN ( OUTPUT)

j

WRITELN(OUTPU'L "THE SUM FOR THIS LINE IS
END;

'~

SUM);

END.

In o~d~~ for EOLN(F) to be TRUE in the above program, the
carriage return must be typed immediately after the last digit of the
last integer on that line.
If inst~ad a space is typed followed by the
carriage return, EOLN will remain FALSE and another READ will take
p lac e.

2.2.6

FILES

Changes we~e made in order to b~ing U. C.S.D.
the standard definition of the language.
A.

Pascal

clo~er

to

INTERACTIVE FILES

Files of  INTERACTIVE behave exactly as files of 
TEXT.
The standard predeclared files INPUT and OUTPUT will always be
defined to be of  INTERACTIVE.
All files of any  other
than INTERACTIVE, are defined to operate exactly as described in Jensen
and Wirth.
For files which are not of (type> INTERACTIVE, the
definitions
EOF(F), EOLN(F), and RESET(F) are exactly as presented
in Jensen and Wirth.
For mare details concerning files of 
INTERACTIVE see spction 2.2.11 "READ AND READLN" and sec.tion 2.2.12
"RESEl" and sec t ion 2. 1. 2 ..

0'

B.

UNTYPED FILES

U.C S.D. Pascal has one type of file declaration which i~ not
found in the syntax of Jensen and WiTth.
This type and its use 15
demonstrated in the sample program below:

Page 139

<*$1-*)
PROGRAM FILEDEMO;

VAR G,F: FILE;
BUFFER:

PACKED ARRAY[O .. 511J OF CHARi

BLOCKNUMBER, BLOCKSTRANSF'ERRED: INTEGER;

BADIO: BOOLEAN;
program reads a diskfile called 'SOURCE. DATA' and
copies the file into another diskfile called 'DESTINATION'
using untyped files and the i~trinsics BLOCKREAD and

(* This

BLOC Kf.,.JR I TE '.)

BEGIN
BADIO: =FALSE;
RESETO»;
BLOCKNUMBER:=BLOCKNUMBER+l~

BLOCKSIRANSFERRED:=BLOCKREAD(G,BUFFER,l,BLOCKNUMBER)i
END;

CLOSE (F J LOCK) ;
END.

The two files which aTe declared and used 1n thp above sample
program are both untyped files.
An untyped filg F can be thought oP as
a file without a window variable FA to which all liD must be
accomplished by using the functions BLOCKREAD and BLOCKWRITE.
Note
that any number of blocks can be transferred'using either BLOCKREAD or
BLOC~<.WRITE.
The functions return the actual number of blocks read.
A
somewhat sneaky a,p~oach to doing a quick transfe~ would be:
WHILE

BLOCKWRITE(F,BUFFER,BLOC~READ(G,BUFFER,BUFBLOCKS»>O

DO <*IT*)i

This is. howgyer considered unclean.
The program above has
been compiled using the I-Compil~ Tim. Option, thereby requiring that
the function IORESULT and the number of blocks transferred be checked
after each BLOCKREAD or BLOCKWRITE in order to detect any I/O errors
that might have occurred.

Page 140

c. RANDOM

ACCESS

The U.C.S. D.
ability to randomly
the intrinsic SEEK.
Tile identifierl

OF

FILES

implementation of st~uctur~d files supports the
individual ~ecD~d~ within a file by means of
SEEK expects two p~rameters~ the first being the

acces~

and the sec.ond,

an integer speci-Pying the record

number to which the window should be moved.
stT'uctuT'~·d

file is otHobe'red record O.

The first record of a

The foilowingsample progT'2Im

demonstrates the use of SEEK to randomly access and update records in a
-Pi 1 e:

PROGRAM RANDOMACCESS,
VAR DISK: FILE OF
RECORD
NAME: STRING[20J.
DAY, MONTH! YEAR: INTEGER;
ADDRESS: PACKED ARRAV[O .. 49] OF CHAR;
ALiVE: BOOLEAN
ENDj

RECNUMBER:
CH:

INTEGER;

CHAR;

BEGIN
RESET(DISK, JRECORDS. DATA')

i

WHILE NOT EOF(lNPUT) DO

BEGIN
WRITEUJUTPUT,

fEnte'(~

l"€cord number ----:;.');

READ(INPUT,RECNUMBER)i
SEEK(DISK,RECNUMBER)i
GET (DISK) I
t4ITH DISl,,'"

DO

BEGIN
WRITELN(OUTPUT,NAME,DAY, MONTH, YEAR,ADDRESS);
WRITE(OUl'PUTi tEnter cOT"T'ect name

---:>') i

READLN(lNPUT,NAME)i

ENDi
SEEK(DISK, RECNur·1BER.)

i

 Must point the window

back to the record since
GET (DISK) advances the

window to the next record
afte~

loading DISKA *)

PUT,OISK)i
END.
END.

Page 141

Attempts to PUT

reco~ds

beyond the physic.al end of file will

sst EOF to the value TRUE.
(The physical end of file is the point
where the next record in the file will overwrite another file on the
disk. ) SEEK always sets EOF and EOLN to FALSE.
The subsequent GET or
PUT will .et these conditions as is app~opriat~.

D. READ AND WRITE FROM ARBITRARILY TYPED FILES
It is not currently possible to READ Dr WRITE to files
other than TEXT or FILE OF CHAR.

2.2.7

o~

type

GOTO AND EXIT STATEMENTS

V.C.S.D. has a more limited form of GOTO statement than is
defined as the standard in Jensen and Wirth.
U.C.S.D. 's GOTO statement
prohibits a GOTQ statement to a label which is not within the same
block as the GOTO statement itself.
The examples presented on pages 3132 of Jensen and Wirth are not legal 1n U.C.S,D. Pascal.
EXIT is a U.C.S.D. extension which accepts as its single
the identifier of a procedur~ to be exited.
Note that the
use of an EXIT statement to exit a FUNCTION can result in the FUNCTION
returning undefined values if no assignment to the FUNCTION identi~ier
is made prior to the execution Qf the EXIT statement.
Below is an
example of the use of the EXIT statement:
paramete~

PROGRAM EXITDEMOi
VAR T: STRINGi
eN:

INTEGER;

PROCEDURE Gi FORWARD;
PROCEDURE Pi

BEGIN
READLN(T) i
WRITELN(T) ;
IF T[lJ='#1 THEN EXIT(Q);

WRITELN('LEAVE P');
END;
PROCEDURE Q;

BEGIN
Pi
WR I TELN ( LEAVE G t
ENDi
J

Page 142

) ;

PROCEDURE Ri
BEGIN

IF eN

<= 10 THEN

WRITELN(iLEAVE

Gi

R')i

END;

BEGIN
eN: =0;

WHILE NOT EOF DO
BEGIN
eN: =CN+l;

Ri
WRITELNi
END;
END.

If the above program were supplied the following input
THIS IS THE FIRST STRING
#
LAST STRING

the following output will result:
THIS IS THE FIRST STRING
LEAVE P
LEAVE G

LEAVE H

*'LEAVE

R

Lf\ST STR ING

LEAVE P
LEAVE Q
LEAVE P
The EXITCQ) statement causes the PROCEDURE p to be terminated
followed by the PROCEDURE G.
Processing continues following the call
to Q i.T1side PROCEDURE R.
Thus the only line of output following "#" is
"LEAVE R .at the ~nd of PROCEDURE R.
In the two cases where the
EXIT(Q) statement is not executed, processing proceeds normally through
the termlnations of procedures P and Q.
U

If the procedure identifier passed to EXIT is a recursive
procedure, the most recent invocation of that procedure will be
exited.
If, in the above exampleJ one aT' both oT the pT'ocedure4J P and
G dec 1 are dan d 0 pen e d s 0 me I 0 cal r i 1 e s , an imp 1 i cit CLOSE ( F ) i s don e
when the EXIT(Q) statement is executed, as if the procedu~es P and Q
terminated normally,

Page 143

The creation of the EXIT statement at U.C.S.D. was inspired by
the occasional need ~or a stT'aightforward means to abort a complicated
and possibly deeply nested series of procedure calls upon encountering
an error.
An example of such a use of the EXIT statement can be found
in the recursive descent U.C.S.D. Pascal compiler.
The routine use of
the EXIT statement is, nevertheless, discouraged.
2.2.8

PACKED VARIABLES
A.

PACKED ARRAYS

The U.C.S.D. compiler will perform packing of arrays and
records if the ARRAY or RECORD declaration is preceded by the word
PACKED.
For example, consider the following declarations:
A: ARRAY[O .. 9] OF CHARi

B: PACKED ARRAyrO .. 9J OF CHAR;
The array A will occupy ten 16 bit words of memory, with each
element of the array occupying 1 word.
The PACKED ARRAY B on the other
hand will occupy a total of only 5 wordsl since each 16 bit word
contains two 8 bit characters.
In this manner each element of the
PACKED ARRAY B is 8 bits long.
PACKED ARRAYs need not be restricted to arrays of type CHAR,
for examp Ie:

c:

PACKED ARRAY[O .. 1] OF O.. 3;

D:

PACKED ARRAY[l .. 9J OF SET OF 0 .. 15i

D2: PACKED ARRAyeO . . 23910 . . 3191 OF BOOLEANi
Each element of the PACKED ARRAY C is only 2 bits long, since
only 2 bits are needed to represent the values in the range O.. 3.
Therefo~e C occupies only one 1.6 bit word of memory,
and 12 of the bits
in that word are unused.
The PACKED ARRAY D is a 9 word array, since
each element of D is a SET which can be represented in a minimum of 16
bits.
Each element of a PACKED ARRAY OF BOOLEAN, as in the case of D2
in the above example, occupies only one bit.

The following 2 declarations are not equivalent due to the
recursive nature of the compiler:
E:

PACKED ARRAY[O .. 9] OF ARRAY[O .. 3J OF CHARi

F: PACKED ARRAY[O .. 9;0 .. 3] OF CHARi

Page 144

The second occurrence of the reserved WD~d ARRAY in the
declaration of E causes the packing option in the compiler to be turned
off E becomes an unpacked arra~ of 40 words.
On the othe~hand, the
PACKED ARRAY F occupies 20 total words because the ~e$erved word ARRAY
occurs only once in the declaration.
If E had been declared as
E:

FAC!J..ED ARRAYEO .. 93 OF PACKED ARRAYCO .. 3:1 OF' CHARi

or as

E:

ARRAY[O .. 9] OF PACKED ARRAY[O .. 3J OF CHARi

F and E would

h~ve

had identical configurations.

The reserved word PACKED only has true significance before the
last appearance of the reserv~d word ARRAY in a declaration of a PACKED
ARRAY.
When in doubt a good rule of thumb when declaring a
multidimensional PACKED ARRAY is to place the reserved word PACKED
before every appearance of th~ reserved ward ARRAY to insure that the
re5ultant ar~ay will be PACKED.
The
the
8

al"ray

bits or

~esultant

less.

array will only be

pac~ed

if the final

type of

subrange, or a set which can be represented in
The Tinal type can also be BOOLEAN Or' CHAR. The

isscalaT'i

OT'

following declaration will result in no packing whatsoever because the
final type of the array cannot be represented in a ~ield of 8 bits:
G:

PACKED ARRAVfO .. 3] OF 0 .. lOOOi

G will be an array
P~cking

~hich

occupies 4 16 bit words.

never occurs across word boundaries.

This means that

if the type of the element to be packed requires a number of bits which

does not divide evenly into 16,

there will be some unused bits at

the high order end of each of the words which comprise the array.

Note that a string constant may be assigned to a PACKED ARRAY
OF CHAR but not to an unpacked ARRAY OF CHAR,
Likewise, comparisons
beb..vl':;.::n at', ARRAY OF

G~·,!t:\H

and

a

str'ing

c\.)nstant are

illegal.

(These are

temporary impl~mentation Te~tTictions which will be removed in the next
major release. ) Because of theiT different sizest PACKED ARRAYs cannot
be tompar~d to ordinary unpacked ARRAYs,
For further information
regarding PACKED ARRAYs OF CHARacters see section 2.2.16 HSTRINGS".

A PACKED ARRAY OF CHAR may be output with a single write statement:
PROGRAM VERY8L!CK;
Vl-,R T.
BElJIN

PAChED ARRAY[O.

10J OF CH/\R;

T::'HELLO THERE';
\...JR I TELN ( T ) i

END.

Page 145

Initialization of a PACKED ARRAY OF CHAR can be accomplished
very efficiently by using the U.C.S.D.

intrinsics FILLCHAR and SIZEOF:

PROGRAM FILLFASTi
VAR A:

PACKED ARRAyeO .. 10J OF CHAR;

BEGIN
FILLCHAR (A[OJ J 51 ZEOF (A)
END.

I

'

1');

The above sample program Tills the entil~e PACKED ARRAY A with
For Turther documentation on FILLCHAR, SIZEOF, and the other
U.C.S.D. intrinsics see section 2.1.:; uCHARACTER ARRAY MANIPULATION
blanks.

INTR INSICS".

B.

PACKED RECORDS

The following RECORD declaration declares a RECORD with 4

fields.
The entir~ RECORD occupies one 16 bit word as a result of
declaring it to be a PACKED RECORD.
VAR R:

PACKED RECORD
I, J, f.<.: 0 .. 31;

B: BOOLEAN
END;

The variables I, ~, K each take up 5 bits in the word.
The
boolean variable B is allocated to the 16'th bit of the same word.

In much the same manner that PACKED ARRAYs can be
multidimensional PACKED ARRAYs, PACMED RECORDS may contain fields which
themselves are PACKED RECORDS or PACKED ARRAYS.

Again,

slight

differences in the way in which declarations are made will affect the
degree of packing achieved.
For example, note that the following two
declarations are not equivalent:

VAR B: PACKED RECORD

VAR A: PACKED RECORD
C: INTEGER;

C: INTEGER;

F:PACKED RECORD

F:RECORD
R: CHARi
1-<..: BOOLEAN

R:
K:

CHAR;
BOOLEAN

END;

END;

H:

H:PACKED ARRAY[O .. 3] OF CHAR·

PACKED ARRAY[O .. 3J OF CHAR

END;

END;

As with the

rese~ved

word ARRAY,

appear with every occurrence of the

the

~eserved

word PACKED must

word RECORD in order for
the PACKED ,REGORD to T',etain its ~h1c~~ed qualities throughout all ~ields
of the RECORD.
In th~ abcive ~xample, only RECORD A has'ali of its
-Pields ,packed. int,O one word.
In B; 't;he F field is not packed and·
therefoT"e occup ies i;wo it.; b i t ~41cq·ds.
It is important to note ,that d
p~~ked or unpacked ARRAY or RECORD which is a fIeld afa PACKED RECORD
re5e~ved

will always start at the beginning of the next word boundary.
This
means that in the case Qf A, even though the F field does nat
completely fill one word, the H field starts at the beginning of the

next word

bounda~y.

A case variant may be used as the last field of a PACKED
RECORD, and the amount of space allocated to it will be the size of the
large.st varian.t amoung the varlOU$ cases.
The actual nature of the
packing is faT beyond the scope of this document.
VAR

RECORD
B: BOOLEAN;
CASE F: BOOLEAN OF

K~

PAC~ED

TRUE:

FALSE:
END

(Z: INTEGER) i
(M~

PACKED ARRAY[O .. 3J OF CHAR)

END;,

In the above example the Band F fields are stored in two bits
of the first 16 bit word of the record.
The ~emaining 14 bits are not
~'sed.
The 5i!? of the cas'=? var':!.a;nt; 'Field is always the size of the
largest vt3-ri,ant, so i'n the above example~ the case vaT'iant field will
ocrIJP~~ two tl-J(n~ds.
Thtl~ the entire fACIA.ED RECORD will occupy 3 words.
C.

USING PACKED VARIABLES AS PARAMETERS

N0 element of
pass@.d as a variable
FUNCTION.

p,-;rameteT's,

D.

P·.3ckt'rl

\.ij"'·~F ...'CK

PAC~ED

ARRAY or field of a PACKED RECORD may be
p~)T'ameteT' to a PROCEDURE or

vaT:i~ble?i

ma.y~

hCIU(7:'Viil',

be paS':sed

£3£

call

b\J

value

as stated in ..Jensen and Wirth,

PACK AND

V.C.S.D.
and

~

(call-'bY"-'i"eferen\~eJ

as

UNPAC~

STANDARD PROCEDURES

Pascal does not support the standard procedures PACK

defined

in Jensen and t,JiTth

on page

106.

PARAMETRIC pnOCEDURES AND FUNCTIONS

2. 2. 9

U, C.S. D. Pascal does not suppcrt the construct in which
PRDCEDURfS ~~d FUNCTIONS ma4 be decl~Ted as formal parameters in the
P2"!' f~.d':"?e 1::~;"I" 1 is t Co f .;.~ FROCEDURE or F UNC T ION.

See Section 6,6 for a revised syntax ctiagram of 
INTERACTIVE.
If the program wishes to declare any additional files,
these file declarations must be declared together with the pTog~am's
other VAR declaration~.

2.2.11 READ AND READLN
Given the following

declaratio~$:

VAR CH:CHAR;
F:

TEXT;

C* TYPE TEXT

=

FILE OF CHAR

*)

the statement READ(F,CH) is defined by Jen~en and Wirth on page 85 to
be equivalent to the two statement sequence:
CH: :;;.:F-· ..·;
GE.T (F)

i

In other words, the standard definition of the standard
procedure READ requires that the process of opening a file load the
., win dew va r i ~3 b 1 e" F·.... wit h the fiT' S t c Ii a T' act e r 0 f the f i 1 e.
I nan
interactive progTdmming environment, it is not convenient to require a
user to type in the first character of the input file at the time when
the file is opened.
If this !.~H!r-e the ,case, every pT'ogT'-arn would Ilhang"
until a character was typed, whether or not the program performed any
input operations at all.

In ur-del'"' to overcome this probleml

U. C. S, D.

defines an additional file  called INTERACTIVE.
Declaring
a file F to be of  INTERACTIVE is equivalent to declaring F to be
of type TEXT, the difference being that the definition of the statement
READ(F,CH) is the reverse of the sequence specified by the standard
definition for files of  TEXT: i. e.
Pa~cal

GET \ F);
CH: =F·····;

This difference affects the way in which EOLN must be used
within a program when~eading from a textfile of type INTERACTIVE.
As
in section 5 I EOLN ~ecome5 true only after reading the end of line
character, a carriage return.
When this is read, EOLN is set to true
and the character returned as a result of the READ will be a blank.
In
the following example

I

the left

fTag!1!i?fit

is taken from Jensen and

Wirth; only the RESET and REWRITE statements have been altered.
The
program on the left will correctly copy the textfile represented by the
file X to the file Y.
The pro1ram fragment on the Tight performs a
similiar task, except that the source file being copied is declared to
be a file of  INTERACTIVE, the~eby forcing a slight change 1n the
program in order to produce the desired result.

Page 148

PROGRAM UCSDVERSIONi
VAR X,V: INTERACTIVE;

PROGRAM ",JANDW;

VAR X,Y:TEXTi
CH:

CHARi

CH: CHAR.

BEGIN

BEGIN
RESET(X, 'CONSOLE: ');
REWRITE(Y, 'SOMETHING. TEXT');
WHILE NOT EOF(X) DQ
BEGIN
WHILE NOT EOLN(X) DO
BEGIN
READ(X,CH)i
IF NOT EOLN(X) THEN

RESET ( X, "SOURCE. TEXT' } ,

REWRITE(Y, 'SOMETHING. TEXT');
WHILE NOT EOF(X) DO
BEGIN
WHILE NOT EOLN(X) DO
BEGIN
READC X: CHi;
WR I TE ( V: CH ) i

WR I TE (Y , CH) ;
END,

END;

READLN( X);
WR I TELN ( Y ) i

READLN( X);
WR I TELN ( Y ) i
END;
CLOSE (V, LOCK);

END;
CLOSE{Y, l.OCK);
END.

END.

Note that the textfiles X and Y in the above two programs had
to be opened by using the U.C.S.D. e~tended form of the standard
procedur~5 RESET and REWRITE.
The IF statement in the

inte~active

version of the

prog~am

fragment an the left is needed in order for the file Y to become an
exact cop~ oT the textfile X.
Without the IF statement, an ext~a blank
is appended to the end of each line of the file Y.
This
ext T' a b 1 an k c Co I" T' e';.; p on d s to the en d 0 of 1 i nee h a r· a c: t e ~ ace 0 T' din 9 to the
standard definition in Jensen and Wirth.
Nate that the CLOSE intrinsic
was applied to the file Y in both ve~siDns of the p~og~am in order to
make it a permanent file in the disk directory called
"SOMETHING. TEXT",
Likeu.\ise, the textfile X could have been a diskfile
instead of coming from the CONSOLE device in the right hand version of
cha~acter

the pT'ogrdm.

There a~e three predeclared text9iles which are automatically
opened by the system for a user progr3m.
These files are INPUT,
OUTPUT, and KEYBOARD.
The file INPUT defaults to the CONSOLE device
and is always defined to be of  INTERACTIVE.
The statement
READ(INPUT.CH) where CH is a character variable. will echo the
character typed from the CONSOLE back to the CONSOLE device.
WRITE
s tat e men t s t o t h e f i 1 e OUTP UT wi 1 I, b Y d e .p au 1 t i C au $ e the 0 U t put to
appear on the CONSOLE device.
The rile KEYBOARD is the non-echoing
equ i va lent to INPUT.
Fo~ e xamp 1 e,
the two statements

READ(KEYBOARD,CH)i
WRITE(OUTPUT/CH);
are equivalent to the single statement READ(INPUT,CH).

Page 149

·Formore documentation regarding the use o-ffiles see sections
2.2.6 HFILES", 2.2.4 "EOF", 2.2.5 "EOLN u , 2.2.17 'WRITE AND WRITELN'*1
and 2.2.12 ·'RESET".
See section 2.1.2 "INPUT/OUTPUT INTRINSICS" for
more details on the U. C. S. D. intrinsics.

RESET(F)

2.2.12

The standard procedure RESETf as defined tin page .9 of Jensen
and Wirth, resets the rile window to the beginning of the file F.
The
next GET(F) or PUT(F) will affect record number 0 of the file.
In
addition, the standard dei~initiQn of RESET(F) states that the window
variable FA be loaded with the first record in the foile.
The U.C.S.D.
implementation of RESET(F) operates ex~ctly as the standard definition,
unless the file F is declared to be Or -(type> INTERACTIVE in which case
the statement RESET(F) points the file window to the start of the ~ile,
but does not load the window variable FA,
Thus, for files of 
INTERACTIVE, the U.C.S.D. equivalent of the standard definition of
RESET(F) is the two statement sequence:
RESET(F)i
GET (F) i

U.C.S.D. Pascal defines an alt~rnative form of the standard
procedure RESET which is used to open a pre-existing 'ile.
In it,
RESET hSfS two parametersf the first being the fi Ie identifieri the
second, either a STRING constant or variable which corresponds to the
directory Tilf~name of the file being opened.

See section 2.1.2

IfINPUTlOUTrUT INTRINSICS"f.oT' more infromation on this wse of RESET.

2.2.13

REWRITE(F)
The standard procedure REWRITE is

us~d

to open and

c~eate

a new

REWRITE has two parameters, the first. b~ing the file
identifier, the second corresponds to the directory filename of the
file being opened, and must be either a STRING constant or variable.
For example, the statement REWRITE(F, 'SOMEINFO. TEXT', Cc'3uses the file F
to be. 0 pen e d f Q r output, and I if the file .is 1 o'c k € don t o t h '!! dis k I the
filename o-F the rile in the director'Y will be "50MEtNFO 'TEXT".
REWRITE
performs exactly as the V.C. S. D OPENNEW intrtnsl~ and will eventually
replace OPENNEt,.J.
See section 2.1.2 "INPUT/OUTPUT INTRINSICS" for
file.

further documentation regarding the use Qf REWRITE to open a file.
2.2.14

SEGMENT PROCEDURES

The concept of the SEGMENT PROCEDURE is a U.C.S.D. extension to
Pascal, the primary purpose of which is to allow a programmer the
abili~y to explicitly p~rtition a
13~gp program into s~9ments,
09 which
only a~ew need be resi~ent in m~mory at anyone time. The U.C.S.D.
Pasc;31 'Slj5tem is .necessa-rily partitinn!?d in this manner becot!se it is
too large to f i t into the memory o~ mC3t E~~ll interactive computeT's
at one time.

Page 150

The fallowing is an example of the use of SEGMENT PROCEDURES:

PROGRAM SEGMENTDEMOi

*>

GLOBAL DECLARATIONS GO HERE

(*

PROCEDURE PRINT(T:STRING);

FORWARD;

SEGMENT PROCEDURE ONE;
BEGIN
PRINT('SEGMENT NUMBER ONE');
ENDi

SEGMENT PROCEDURE TWO;
SEGMENT PROCEDURE THREE;
BEGIN
ONE;

PRINT('SEGMENT NUMBER THREE');
END;

BEGIN

<*

SEGMENT NUMBER TWO

*>

THREE;

PRINT('SEGNENT NUMBER TWO');
END;

PROCEDURE PRINT;
BEGIN
WRITELN(OUTPUT,T);
END;

BEGIN
TWO;
WR I TELN ( I i ' / M DONE') i
END.

The above program will give the following output:
SEGMENT NUMBER ONE

SEGMENT NUMBER THREE
SEGMENT NUNBER TWO
I'M DONE
For furthe~ documentation on SEGMENT PROCEDURES, their use and
the syntax governing their declaration see Section 3.3 "SEGMENT PROCEDURES".
2.2.15

SETS

V.C.S.D. Pascal supports all of the canst~ucts defined 'or sets
on pages 50-51 of Jensen and Wirth.
Sets Cof enumeration values) a~e
limited to positive integers onl~.
Space is assigned, rounding up to
word boundaT'ies~ in a bitwise f£;Hihion, ::t£::lT,ting at zero} up to 4079,
inclusive.
Therefor a set can be at most 255 words in size, and have
at most 4080 elements.

Page 151

Comparisons and operations on sets are allowed only between
sets which are either of the same base type or subranges of the same
underlfJing type,
FaT' example, in the sample program below, the base
type of the set 5 is the subrange type 0 .. 49, while the base type of
the set R is the subrang e typ e 1.. 100.
Th e under ly 1ng type of both
sets is the type INTEGER, which by the above definition of
compatabilitYI impli~s that the comparisons and operations on the sets
Sand R in the ~o11owing program are legal:

PROGRAM SETCOMPARE;
VAR S: SET OF O.. 49,

R: SET OF 1 .. 100;

BEGIN
S'- [0,5,10,15/20:25,30,35.40,45];
R"=

IF S

(10,20,30.40,50,60~70,80,90];

=

R THEN

WR ITELN< ' .. ,

oop

S

. . . ")

ELSE
WRITELN('sets work');
S + Ri

S
END,

In the following example, the construct
I = J
two sets ar~ of two distinct underl~tng types.

is not legal since the

ILLEGALSETSi
TYPE STUFF=(ZERO.ONE~TWO)i
VAR I: SET OF STUFFi

PROGRAM

J:

SET OF 0 .. 2;

BEGIN
I':: [ZERO);
,J:= [l,2J;
IF r :::~ ,J THt:::N
END.

STRINGS

2.2.16

U. C.S.D.

Pascal has an

addition~l

Variables of type STRING are essentIally

pred~c13r~d

PAC~ED

type STRING.

ARRAYs OF CHAR that

have a d~namic LENGTH attribute, the y~)ue of ~hich is returned by the
STRING intrinsic LENGTH.
The default maximum LENGTH of a STRING
variable is 80 cha~acters but can be ove~ridden in the declaration of a
STRING variable by appending the desired LENGTH of the STRING variable
within [ J after the re5~T'ved type identifjer STRING.
Examples of
declarations of STRING variables are:

Page 152

TITLE: STf 'SAMETHING' THEN

!J

S)i

WRITELN(S, I is greater than SAMETHING '),
IF S = 'SOMETHING
' THEN

WRITELN( "BLANKS DON' "T COUNT

I,

ELSE
WRI1ELN(IBLANKS AFPEAR TO MAKE A DIFFERENCE').
S:='XXX';

T: -..

I

r~ECDEF

," i

tF S > T THEN
WRITELN

BUFFER);

END.

lhe above con~truct will work only if the ARRAY is a PACKED
ARRAY OF CHAR. See section 2.2.8 PACKED VARIABLES for further
i nrormat i on.
The following program demonstrates the effects of a field width
specification within a WRITE stat~ment for a variable of type STRING:
PROGRAM WRITESTRINGSi
VAR S: STR INGi

BEGIN

s; ~. r THE BIG BROWN FOX JUMPED... 'i
t"JR I TELN ( S > i
WRITELN(S: 30);

WRITELN(S: 10) i
END.

The above program

~ill

produce the following output:

THE BIG BROWN FOX JUMPED ...
THE BIG BROWN FOX JUMPED ...
THE BIG DR

Note that when a string variable is written without specifying
a field wtdthi the actual number of cha~acters written is e~ual to the
dynamic length of the string.
If the field width specified is longer
than the dynamic length of the string. leading blanks are inserted and
written.
If the fi~ld width is smaller than the dynamic length of the
string, the excess characters will be truncated on the right.

Page iSS

IMPLEMENTATION SIZE LIMITS

2.2.18

The following 1s a list of maximum size limitations imposed
upon the user by toe current implementation of U. C.,S. D. Pascal:
1.

Maximum number of bytes of object code in a PROCEDURE or
FUNCTION is 1200. Local variables in a PROCEDURE or FUNCTION
can occupy a maximum of 16jS~ words Qf memory.

2.

Maximum number of characters in a STRING variable is 255.

3.

Maximum number of elements in a SET is 255

*

16=4080.

4. Maximum number of SEGMENT PROCEDUREs and SEGMENT FUNCTIONs
7 are

is 16. ( 9 are reserved foT' the Pa~cal system,
available for use by the user p~ogram )

5.

Maximum numhpr of

PROCEDURF~

or FUNCTIONs within a segment

is 127.

2

~l.

EXTENDED COMPARISONS.

19

u. C. S. D.

allows

ra5~al

=

and

<>

comparisons of any

aT'ra~

or

record structure.

2.2.20
3.3 3

LONG INTEGERS.
UCSD Pascal allDws integers of 0p to 36 digits.
for details ~egarding long int~ge~s.

Se~

section

UNITS

2.;;': 21

UCSD Pascal now
sec t ion 3. 3. 2 for

2.2.22

SUMMARY

INTRINSIC

BLOCI-<.WR I TE

Page 156

~upports

de -t ail S

OF

SECTION

l'

U. C.S. O.
#

the modularity concept of UNITs.

See

e 9 i3 r din 9 UN I T ~ .

INTRINSICS
DESCRIPTION

2. 1. 2

Furtction whi~h reads a variable number of blocks
'rom an untyped fjl~.

2.1.2

Function which writes a variable number of blocks
from an untyped file.

CLOSE

2. 1.2

Procedure to close files.

Cor-·feAT

2. 1. 1

STRING intrinsic used to concatenate strings together.

DELETE

.c.:..

,..,

1. 1

STRING intrinsic used to

d~lete

characters from

STRING variables.
DRA~:JLINE

...,

c;. •

1.4

intrinsic for use on the Terak 8510a.

G~aphics

DRAWBLOCK

2. 1 . 4

Graphics intrinsic for use on the Terak 8S10s.

EXIT

2. 1.7

Intrinsic used to exit PROCEDURES cleanly.

GOTOXY

2. 1.6

Procedure used for

cu~sor

addressing whose two

parameters X and Y a~e the column and line numbers
on the 5c~een where the cursor is to be placed.

Fast p r ocedur2

F ILLCHt\R

HALT

2.1.6

ID5EARCH

~or

initializing

PAC~ED

ARRAYs OF CHAR.

Halts a user program which may result in a call to
the in~eractive Debugger.
f-ioutine used 1J\j

a5

f£,. ';;'

the Pascal

~ompilel'l

and the PDP-ll

mb 1 ~ T' .

2. 1. 1

51'RING intrinsic used to insert characters in STRING

IORESlJLT

2. 1.. 2

Function returning the result of the previous I/O
operation.
(See Table 2 for a list of values)

t.E~·!GTH

2, 1

STRING intrinsic which

MARI~

'-~
e_.

1

1. 3

Used to
memor~

t10VELFFT

the dynamic length

the current top of the heap in dynamic

allQcation.

2. 1 5

Low level intrinsic for moving mass amounts of bytes.

.-~

Low level intrinsic

c.

P !,.!~ OF I EN

m~~k

Teturn~

i

.I.

5

~or

moving mass amounts of bytes.

d. 1 ;2

Procedur~

for opening a new file.

2,

.

PI'DL~:cture

for' ;Jpening an existing file.

t::!
'"' ..

L 1

l.

2. L

".,
f~

,~

STRING int~insic returning the position of a
pattern in a STRING variable,
Fvnction which retu~n5 as a REAL result the number
10 raIsed to the paw.r of the integer parameter
supplied.

Page 157

RELEASE

2. 1.3

Intrinsic used tOT'elease memory occupied by
variables dynamically allocated in the heap.

SEEK

2. 1.2

Used far random accessing of records withing a file.

SrZEOF

2. 1.6

Function returning the number of bytes allocated
to

~l

v~riable.

STR

2. 1. I

Procedure to convert long integer into string.

TIME

2. 1.6

Function returning the time since last bootstrap
of system. (returns z~ro if microcomputer has
no real time clock)

TREESEARCH

Routine used solely by the Pascal compiler.

UNITBUSY

2.1.2

Law level i~triniic For
a peripheral device.

UNITCLEAR

2.1.2

Low level intrinsic to cancel 1/0 from a peripheral

det~rmining

tha status of

device.

UNITREAD

2.1.2

Low level intrinsic for reading from a peripheral
device.

UNITWAIT

2.1.2

Low level intrinsic for waiting until a peripheral
device has completed an I/O operation.

UNITWRITE

2.1.2

Low level intrinsic used for writing to a peripheral
device.

Paqe 158

************************************ ***************

*

DRAWLINE

AN IMPLEMENTOR'S GUIDE

* *

Section 3.1

*

************************************ ***************
VeT'S i on

I. 5

September 1978

The DRAWLINE Intrinsic uses an incTemental technique to plot
line segments on a point-addressable matrix. The algorithm guarantees a
best (least squares) approximation to the de~ired line. In general this
appr'f.}:cifHatiQn

be

C Q'1" 1" e c

chec~ing

n,~;i,~

J.s

i'epi'e-S\?nt~t:ions

'tOT'

DF~t..!LIf·iE

ufd,qtie.

(T\~;H;

pick

line depfi'nding on the

d

diffe!"erit

~tQT'ting

point.

(This could

ted 1.1 \J a 1 W-3 Yss. tar tin 9 at the same end of the 1 i n e. ) No
is performed an parameters passed to thi~ intrinsic,

The

1'" a n 9 e

IS essentially the one described in Newman and
of Intersttive Computer Graphics a~ the Digital
DiFfeTentiel AnAlyzer
It has been modified to perform only integer
9Tithmetic
P~~c~l
SQUTee cnde is included b~lDW, The procedure first
rl e t e-T m i 'i -:? d '\l,! h e t h f; 'f' the 1 i 11 ~ ;1) i l l h f.' ,~i C':' ~ h (') 1" i 7 c.~ 1; t,~ 1 ,)"r~ \? f~ T' ,t i c ~ 1 . ! nth e
d :i. s r_ u ;'~ ':: i i'1 n b •.£.' 1. 

ELSE <*WE MIGHT GO THROUGH A LINE*>
IF SCREEN [Y+l~ Xl THEN
GOTlT := SCREEN [Yt X+l1;
IF GOTIT THEN
BEGIN
RANGE : =: COUNT,
EX IT ( DRA~JL 1 hiE)
ENDi
END (*R/itDi\R*)

i

BEGIN (*DRAWDOT*)
eliSE 1NI-\ OF
o <*NONE*):
1 (*~~HITF..:*):

2

(*BLACV~*):

3

(*REVERSE *)

4

(*RADf'R*):

END

EX IT (DRAWLINE);

:

<*THEY HAD NO BUSINESS HERE*>

SCREEN LY;

XJ

TRUE,

SCREEN [V,

X]

FAtSE;

SCREEN [Y,

)( J

NOT SCREEN (V,

Xli

RADAR

(*CASE~')

END <*DRAWDOT*)i

PROCEDURE DOFORX;
VAR ERRORJ

BEGIN
IF DELTAX

I:

=

INTEGER;

0 THEN EXIT (DRAWLINE);

<*THEV'RE GOING NOWHERE*>

ERROR := DELTAX DIV 2;
I

::= DELTAXi

REPEAT
ERROR := ERROR + DELTAY;
IF ERROR >= DELTAX
X : = X + XINC,
DR l\t·JDDT;
I := 1 - 1 ;
UNTIL I ::: 0;
END (~fnOFORX*);

Page 160

END;

PROCEDURE DOFORY;
VAR ERROR, 1: INTEGERi

C*MORE VERTICAL*)

BEGIN
ERROR
I

:

;=

DELTAY DIV 2;

= DELT?\Yi

REPEAT

ERROR

:=

ERROR

+

DELTAX;

IF ERRDR :'.,:-:; DEL TA'Y
THEN BEGIN EHROR
Y :::: Y + VINCI'
DRAJ...'DOTi
I := I - 1;

::~

E'RHOR .- DELTAY::

x

x

+

XINC

END;

UNTIL I :: Oi
END (*DOFORY*) ;

BEGIN <*DRAWLINE*)
X :;;.; XSTAHTi
IF DELTAX <: 0

THEN BEGIN XINC

-1;

DELTf~X

--1,

DELrAY

··nrL TAX

END

·-l)~.LTAY

END

EL SE X INC ::.: 1 i
Y :::: YSTART;

IF DELTf"lY <: Q
THEN BEGIN Ylr~C
ELSE Y INC :
COUNT :~.;;; OJ

=

-

1i

IF DELTAX >= DELTAY THEN DOFORX
IF IN~ = 4 (~nADAR*) THEN RANGE
END <*DRAWLINE*)i

E.L SE {jUF OR Y ;
CDU~..rr;;

<*HIT THE LIMIT GIVEN*>

Page 161

- Notes-

**************** ***************

*

FILE FORMATS

* *

Section 3.2

*

**************** ***************
Version I. 5

September 1978

Text files are of the format:
<1024

b~tes>

header page,

information for editors.
This space
and is respected by all
portions of the system.
When a userprogram opens a TEXT file, and
REWRITEs or RESETs it with a title ending in '.TEXT', the 1/0
subsystem will create and skip over the initial page.
This is done to
facilitate uses editing their input andlor output data.
The filehandler will transfer the header page only on a disk-disk transfer, and
will omit it on a transfer to a serial device.
(i.e. transfers to
PRINTER:, and CONSOLE: will omit the hea~er page)
is reserved for use by the text editors,

<1024 byte pages> where a page is defined:
<[DLElCindent]Ctext][CRlCDLE][indent][textl[CRl ... [nulls]>
Data Link E~capes are followed by an indent-code, which is a
byte containing the value 32+(. to indent).
The nulls at the end of
the page follow a [CRJ in all cases, the~ are a pad to the end of a
page.
The reason for the nulls is that the compiler wants integral
numbers of lines on a page.
The Data Link Escape and corresponding
indentation code are optional.
In a given text file so~e lines will
have the codes, and some won't.
Foto files are declared in PASCAL as follows:

= PACKED

TYPE SCREEN
VAR FOTOFILE:

ARRAY[O .. 239,0 .. 319J OF BOOLEAN;
PACKED FILE OF SCREEN;

or something similar,

which takes up the same dimensional

space.
Data files are up to the user.
Code files have one block of information which describes the
code kept in the file.
First is an array of 16 word pairs, the first
word in the pair describes the block which starts the code of the
segment which is numbered as the position in the array.
The second
word is the number of bytes in that segment.
For example if the third
word in the first block of a code file is an 8. and the fourth work is
1084, you now know that segment 1 of this code file starts on block 8
of the file, and has 1084 bytes of code.
Following this array is an array of arrays of characters.
The
is an array of 8 character arrays which describe the segments b~
name.
These 8 characters are those which identify the segment at
compile time.
Here again, the position in this array corresponds to
the segment number.
arra~

Page 163

Fa 11 ow i n g the aT' l' at)

0

of n a me s i s an aT' ra y I

ag a i n 16

til 0 1" d $

1 on 9 I

of state descriptors.
The values in this array indicate what kind of
segment is at the described location.
The values far this array, at
present, are: LINKED,HOSTSEGtSEGPROC.UNITSEG,SEPRTSEG.
The rem,:lindeT' of the block,
use by later versions of the system.

144 \uor'ds,
The

is reserved for future

fermat of the

will mast probably change completely foT' version 11.0.

Pt~ge

164·

fi~st

block

~-*{HH**·i:'*·l:HHH~·,*·***·******Fi-R*j:Hi·

*

SEGMENT PROCEDURE NOTES

,***************~*

* *

*******~*******************

Section 3.3.1

*

*****************

Version 1,5
September 1978
Declarations of SEGMENT procedures and functions are identical
to standard Pascal procedures and functions except they are preceded by
tiH.~'

'SEGt'1ENT',

l"e's€t'fved ulord

SEGMENT PROCEDURE

fOl'

ei:,~mpJ~:

!NITIALIZE~

BEGIN
(*

PASCAL codE *)

ENDi

Program behavior diff~rsl however~ as code and data for a
SEGMENT procedure (function) are in memory only while there is an
active invocation of that prCfAdure,

The usel' mialj now put large pieces of one-time code, ego
in:itial i :u~tj on corle, into a SEGMENT pr'oceduT'e.
After performing the
initialization. for eyamplel th~ new-useless code is taken out of
memory thus increasing the available memory space.
Furthe~more
sp~~:i~icallu

the user ma4 now compile his/her program in chunks,
Ttl{'; LINV.ER program (described in Section
1 ink t (J get ffH:' j' t b~: s e p d rat e s e 9 me n t s t (j P r- c due e on e

in SEGt"1ENTS.

1. 8) c: at n L c' l.,.i s e ~1
large code f:ile.

t


pclygon~/)j

READf_N(SIZE) i
WRITE(~How many sides?i)j

READLNCNUMSIDES);
FOR 1:=1 TO NUMSIDES DO
Bf:~rN

MOVE ( S J Z E )

j

TURf\! (360 D I \/ hP')MS I DES);
ENDj

END.

A program must indicate the UNITs that i t USES before the LABEL
declaration part Q~ the program.
At the occu~rence of a USES
statement, the compiler references the INTERFACE part of the UNIT as
though it were part of the host text itself Therefore all public
con s t (.1 n t 5 . t Y P t?!.) : va r i ~ b 1 e S 1 fun c: t i en 5 J and p ·r c t: e d lJ T' f? 5 are 9 1 Q b a 1 . Name
conflicts may a~ise if the U5~r defin~s an id~ntifier that has alre~dy
been defined by the UNIT.
PTocedur~s and function~ may not USE UNITs
localllJ.
UN I T rUPTLJ:':~CRAPHT. CSi
I ~.rn::·? F !\ ~ F

PRoc!:~n!..InE

IN I TTI.IRTLEi

In t P.g e 1" ) ;
PROCEDURE MDVE( REL.DISTANCE: !nt~gE~'
PRDCEDURi-: MDV~.TO( X, 'y"
Integer ) i
PHOCEDURE TURN ( HFLANGLE..

PROCEDURE TURNTO( ANGLE, Intege'r' )i
PROCEDlJRE PENGOL.OR ( PCOLOR, TGCOLOR

! ~1PLEMEN T'A r ION

TER xsr ZF = 319:
"fER'y'S:: 7E - 2,39;

Paoe 168

)i

)i

TYPE

=

SCREEN

Pi.=:!C ~ed

,";T'T'dY

TERXSIZE, O.. TERVSIZEJ of Boolean;

Y~riables

*)

VAR

<* Private
TGXPOB:
TGYPClS:

Integer;
Integer;

TGHEADING:
TGPEN:

!nteger~

TGCDLOR;

1;

d:

S:

SCREEN;

Int.eger-j

Externally clssembled

(*

P~OCED1)RE

DRAlfJL,INE(

Var

~rocedure
RADI~R.

*)
Integer;

Val'S:

ROW, XO, VOl DX, DY, PEN:
EXTERNALi

<*

External declaration

SCREENi

Integer );

*)

PROCEDURE INITTURTLEi
BE(~

IN

Fillchar-(

SCREEN_,

SilHOf(SCREEN),

0);

UnitwTite( 3, SCREEN, 63 );
HEADING : = 0;
TGXPOS
.-- 0;
TGVPOS
0;

ENDi
PROCEDURE MOVEi (*
BFGr,lN

Public

procedu~el

pa~ameters

declared above

*>

MOVETO{ Round(TURTLEX + DIST*Cos(TURTLEANGLE/RADCONST),
RoundCTURTLEY + DIST*Sin(TURTLEANGLE/RADCONST) );
END;

PROCEDURE MOVETOi
VAR R:

I n t e 9 e r'- i

BEGIN

DRAWLINEC R} 91 20! 160+TURTLEXi 120-TURTLEY.
X-TURTLEX, TURTLEY-¥, ORD(TURTLEPEN) );
ENDi
PROCEDURE TURt-t;

BEGIN
HEADING

(-~"

PUt,l-11C

iJrQt:ed\._:re~

P<'H'.3f1'HE?tfH'S

dec lal'ed above

- ( HEADING+RELANGLE ) mod 360;

~::J'..JD;

Page 169

*>

PROCEDURE TURNTO;
BF(JIN

HEADING

ANGLE;

END;

PROCEDURE PENCOLOR;
BEGIN

peDLOR,

TGPEN
END;;

END.

(*

End of, unit

*)

EXAMPLE B
Example B is a skeleton for a TURTLEGRAPHICS UNIT.
the procedures MO\lEf

TURN.

and

INITTURTLE,

Nat~

that

·11lnd th,? TYPE TGCOLOR;

declared in the INTERFACE part and are avsilable

fo~

are

use by the host

program. Since the procedure DRAWLINE is not part of the INTERFACE; it
is private, and may not be used b~J the host.
The sfJntr3X foT' a UNIT
definition is shown below
Thp declarations of routine headings in the
INTERFACE part are similar to f~~ward declaration9j therefore) when the

corresponding bodies
parampter

defined in the IMPLEMENTATION part,

ar~

formal

are not repeated

sp~cjfication~

A UN I T fr:;j:} ;3 j ~,'J U~;.~E .ari o~: h ~-:'T' UN T·r., i;"i wh:\. c.. h r: 21 s. ~ t h G' USES
declaration must appear at the beginning of the INTERFACE part.
In
example C, PICTUREGRAPHICS indicates in the INTERFACE part that it
USES TURTLEGRAPHICS.
Note that th. program USEGRAPHICS, which USES
PICTUREGR,.,\PHICS, indicatp.s that it I....iSES TURTLECR,.\PHICS be-fore lising

It

PICTUREGR~'\rhIC;::~

TURTLEGRAPHICS
it,

is

ili;;~(,;i·}.,~:·,l

·th.~t.

t;-:··,

I1\iTF:RFt'~.~E

P;~T't

defined before PICTUREGRAPHICS makes

thp.T'efore thi.s or\:ierinq

o·f

refe~ences

to

is 1'equiT'ed,

NOTE: Variables of type FILE must be d~clared in the INTERFACE
UNIT
A FILE declaT'ed in the IMPLE~1ENTATION part will cause
s~ntax error upon compilation.

part

a

be

o~

a

UNIT PICTUREGRAPHICS;
INTERFACE.

USES TUR1LEGRAPHICS;
TYPE

(~,

f*

T!...!RTtFGRAPHTCS
·~,;\;st8m

PVEC TOR="'"VEC TDR.
\/EG TOR:::.-:RECORD

DELHEADING: INTEGER.
DFlDISTANCE: INTEGEP;
PENDOt,JN. BOOLEAN;

NEXTVEC:PVECTOR
END; (* rec ord *)

Page 170

t~

libT'~T~q

defined in ·the
see section III below

Vf\R

START:PVECTORi
HEf-\P: ...., INTEGER;

(* Head

of list

o~

lines

*>

PROCEDURE MAKESUBPICTURE;
PRDCEDURE DRAWSUBPICTURE,
IMPLEMENTATION
PROCEDURE MAKESUBPICTURE;

BEGIN
(* Calculates

n~xt

subpicture and stores on heap *)

END;
PROCEDURE

DRA~.JSUBP

ICTUREi

BEGIN
LPVEC:=START;
WHILE LPVEC<>NIL DO
WITH L.PVEC·"'· DO

(* Start at beginning

C* and

d~aw

of list *)
each that's there *>

BEGIN
TURN(DELHEADING)i
MOVE{DELDISTANCE);
IF PENDOWN THEN TGPEN:=WHITE
ELSE TGPEN:=NONEi

L.PVEC:=NEXTVEC;
END;

<*

END;

drawsubpictu~e

*>

END.

PROGRAM USEGRAPHICSj
USES TURTLE~RAPHICS!PICTUREGRAPHICSi
BEGIN
INITTURTLE!

<*
<*

picturegraphics uses
turtlegraphics

REPE.~T
Ml~. RK

( HEAP) ;
I CTURE;

M~.KESUBP

DRAWSLJBPICTURE;
RELEASE ( HEAP) :;

UNTIL START=NIL;
END.

EXAMPLE C

Page 171

Compilation unit)

<:.

.::: Progl"am heading:> ;

< Uses part
<:. Un i

<
<
<

<: Unit definition>

~

_< llDit_

< Block> :

d ~ ~ i nit i (') n >-1.__ <:. Un i

t

unit heading Ji
Interface part>
Implemrntation pa~t

t

de.finitiQn :>
de f in i t

lQ.!l...2-.

>

End

<

Unit

h~ading

Unit < Unit identifier> ;
Separate unit < Unit identifier>

>

< Unit identifier)

<

.( Identifier' ,)

part :>

Int~rface

Interface
-( Use·s
~

<
<
<
< Implementation

<

U~e

5'

par t

..

part>

-

)-

Constant definition part>
Type definition part)
Va~iable declaration pa~t >
Procedure heading> : < Function heading :>
Implementation.

< Label d~claration part>
< Constant definition part>
< Type definition part>
< Vclriable declaration part ~
< P~Dcedure and runction d@claT'ation part :>
Uses

;>

paT't;

<

Unit idantifier
ftn t j. f .-LE T' ~: __

_..!...___ ~~_~1J.i..t...Jd

>
-( Empty

>

D I AGR t,\r1 D
The

US!;?!'

host program.

may define a UNIT in-liner

In this case the

us~r

a-Pt?T' the heading o-f! the

compiles both the UNITt

and the

host p""o~p'''am 'ioget"h!?1'.
Any subs.~quent f:hangp.(;) in the UNIT OT' host
P j Ci f}1' .a m 'r e qu irE:' the 1I s er t (} r e com p i 1 e b n 't" .
The use T' mc~ IJ a 1. t) 0 d e fin e

and compile a UNIT ( or a group of UNITs) separately, and use the
library manager to store it (or them) in a library.
After compiling
a host program that u~essu~h a UNIT, the user must link that UNIT into
the code file by executing the LINKER.
lrying to R(un an unlinked code
file will cause the LINKER to run automaticallYI trying to X(ecute an
unlin~ed file causes the system to remind you to link the file.
Changes in a h09t program require only that the user recompile the
pro~ram and link in the UNIT.
Changes in the IMPLEMENTATION part of a
UNIT only ~equire the user to compile the UNJTj and then to ~elink all
compilation units that use that UNIT. Changes in the INTERFACE part of
a UNIT require that the user recompile both the UNIT and all
compilation units that use that UNIT.
In this cas~ all the~e
compilation unjts mU5t again be linked.
For more information see
section 1.8 LINKER or section 4.~ LIBRARIAN.

Page 172

i

The compiler genft~ates LINKER info~mation in the contiguous
blocks that follow a program that uses UNITs.
This information
contains locations of references to externally defined identifiers.
The LINKER document explains the format of this information,
3.3.3.2 PASCAL TO ASSEMBLY LANGUAGE LINKAGES -- EXTERNAL PROCEDURES
External procedures are prima~ily separately assembled assembly
language procedures, $tored in a LIBRARY on disk.
Host programs that
require ext.rnal procedures must have them linked into the compiled
code file. Typically the user w~ites external procedures in assembly
language, to handle low-level operations that Pascal is not designed to
p~Dvide.
External assembl~ language procedures are also used for their
comp,aT'~·t;ive

spe(~d

in

'real time' applications.

A host program declares that a procedure is external in much
w~y a~ a procedure is declared FORWARD.
A standard heading is
p~ovided:
fGllowed by the keQwnrd EXTERNAL.
Calls to the external
procedure use standard Pascal syntaxl and the compiler chec~5 that
calls to the extern~] agree in type and number of parameters with the
external declaration.
It is the user's re5ponsibility to assure that
the as~embly langu~ge procedure respects the Pascal exte~nal
declar~tion.
The linker checks only that the number o~ words of
paramete~~ agree b~tw~en the Pascal and assembly
language declarations.
For more info~mation see section 1.8 Linker and 1.9 Assembler(s).
the same

The conventions of the surrounding sytem conce~ning register
use anM tBlling spqu?nces must be ~estri~ted by write~s of ~ssembly
languclge ~'Dl.,ltin~::::..
ThElse conventions TOT' the PDP-l1 and l80/8080
implem~ntation~ ara given he~e.
First,
use;

fo~

n'th.e1~s.

any

the

PDP-l1~

The following call and

restorod on exit

recommend0d fo~ rro~eduras.
made directly from assembly
- PROC E.NrRY,~

PARAMl

. EGU

PAR AM:;:

. EGU

RET t'\DDR

LOCALl

,EGI...J
EGlJ
o
,EGU-2

LOC,.'L2

. EGU

Ot.~DR5

retu~"

on entry and
is

se~uence

It has the advantage that calls can be
as w~ll as ~rom Pascal.

languag~

2

6
4
2

~

--4

MOV

R5,-(SP)

MO~.}

SP,R5

CLR

-(SP)
-(SP)

CLR

registers RO and Rl are available for

by a T'ol"ltine must bp. saved

f3ff-f.'cted

j

Of-Pset ror

i

Off-set fur second paramtel'

fiT'~t

p~'3rameteT'

; Of-fset for r'gtu1'n address
i Offset foT' or 1. 9 S. na 1 value
; O'F-fset for f-ir-st local
; O.pf's€t for second local

o~

R5

iSave contents o~ R5
;Use R5 to get at locals and parameters
iReserve and Initialize
iTwo local variables

Inside routine
MOV
PARAM(RS),LOCAL1(R5)

;Sample statement

Page 173

MOV
MOV
MOV

EXIT:

ADD
",r1P

R5, SP

(SP)+,R5
(SP)+,RO
#NPARAMSiSP

@RO

;Cut back to entry SP
;Restore p~evious R5
iGet return address
iDiscard parameters
iReturn to caller

In zeo assembly language routines, all registers are available
for use, and the recommended interface sequence follows: (This code
would work for both 8080's and ZSO's.
Optimizatinns are possible if
the zeo instructions aT'e available. )
. PROC

ENTRY,

2

. PRIVATE
RETADDR,LOCALIJLOCAL2,PARAM1,PARAM2
iReserve static storage for this routine.
Much easier to
ireference obJects like this rather than relative to
iregister as on PDP-11
iGet return address
POP
HL
LD
(RETADDR),HL
; and save it
iGet and save PARAM2
POP
HL.
LD
(PARAM2),HL
;Get and save PARAMl
POP
HL.
LD
(PARAM1),HL

LD
LD

HL., (PARAM2)

; Move PARAM2

(LOCALl ), Hl.

; to LOCl\ll

LD

HL, (RETADDR)

iGet

JP

(HL)

EXIT:

return address

. END

For assembly language functions
essentially the same, except that:

(.FUNC's) the sequence is

1) Two words of zeros are pushed by the compiler before any
parameters are put on the stack.
2) After the stack has been completely cleaned up at the
th2 . FUNC must push the function result on the

routine exit time,
st':::iC

k.

Here is an example Qf an external assembly language procedure.
This example takes a very primitive
approach to interrupt handling (which might still be useful in some
applications).
The~e is no provision for handling inte~rupts'from the
device where a collected buffer is being written to disk.
Support for
continuous interupts would be mare complex, involving multiple buffers
and exclusion mechanisims to assure that buffer switching would occur
reliably.
The ProJect intends eventually to provide synchronization
and a program that uses it.

P~n~

'174

capabilities at the Pascal level~ so that inte~rupt handling can be
accomplished with great~r convenience and safety.

Name of ~outine for use by
Public. constant .
Public variable.

DRCOlLECT#O

. PROC

. CONST

PUBLIC
DRADDR
DR\"ECT

linke~.

167770
140

. EGU
. EGU

BIB

#DRfHJFFER! R!
:f* 1 00, @#DR ~"DDR

;Load address of inteT'Tupt
; handler and set p~iority.
iload RO with size of buffer.
;Load Rl with address of buffer.
~Enable interrupts on DR interface.

TST

RO

:Extt loop when buffeT' full.

BNE

LOOP

SIC

*1.001 @#ORADDR

R"f'S

PC

;Disable interrupts.
iReturn to PASCAL host program.

@#DRADDR+2e {Rl)+

j

PO

; i,nCl"f'ment Rt.

#HANDLR,@#DRVECT
:tt340.@#DRVECT+2

MOt;
MOV
MOV
MOV

L.DOP·

DRBUFLENG
DRBUFFER

#ORBUFLENG~RO

DEC

RTI

LOfid

buffer with next word,
decremE'nt RO.

iReturn from interrupt.

PRO(;Rtd'1 CDL L.FCTDATA.

CDNST
TYPE
DfY1ABUFFEH _. At'T'atj

1:

(1.. DRHUF'LENGJ of integer;

Integ~1'T';

DRBUFFER:

DAT~BUFFER;

DATAFILE: File of DATABUFFER;
PROCE.DURE' DRCOLLECTi
ExterD31j

Rp~,)!"i

te ( DATAFILE.

'SAMPLE. DATA;

)

j

Far 1:=1 to 10 do
DRCOLLECT;
OATAFILE~:=DRBUFFER;

Put (
END .•

DATi~F!LE

C 1 c s ~ ( Dl). T ;\F I LE ~

);

L (J r= k

);

F~:r,

Page 175

3.3.2.3 ASSEMBl.Y LANGUAGE TO ASSEMBLY LANGUAGE LINKAGES
The third way in which separate routines may share data
structures and subroutines is by linkage f~Dm assembly language to
assp.mbly language.
This is made possible through the use of the .DEF
and . REF pseudo-ops provided in the UCSD assemblers.
These generate
link information that allows two sepa~ately assembled procedures to be
L(inked together.
One possible use for this will be the linking of
separate routines and drivers in constructing new UCSD interpreters.

The following are very abbreviated versions of two assembly
language routines which make sepa~ate references. They are used
externally by the UNIT PSGRAPHICS:
The first routine decla~es thr'ee public variables and declares
a .DEF for a label to be referenced by the second routine ( Note that
this is only a skeleton oT the actual MOVETO routine ):

MOVETO,6

. PROC

THE 3 REAL PARAMETERS OCCUpy 6

PROCEDURE MOVETO{X, V,

t~ORD8

Z: REAL);

COMPUTES A NEW PSXPOS & PSYPOS FROM PSMATP AND
AN ASSUMED 1.0 AS THE INPUT VECTOR HOMOGENOUS
COORDI.NATE ...

(X Y Z 1) dot PSMATp A

P 8 XP as

x

I

I W' ;

PSYPOS . -

y

I

IW '

-

(X' V' Z' W')

i

THESE ARE GLOBALS IN THE PASCAL HOST
,PUBLIC PSXPOS
. PUBLIC PSYPOS

. PUBLIC PSMATP

MOVE TO ENTRY POINT
MOV
MOV
MDV
rA~AMCTER

x
v
z

w

·
·
·
·

EGU
EGU
EGU
EGU

R5,-(SP)

R5 USED AS FRAME POINTER

SP/R5

@#PSMATPJRO

RO IS TOS MATRIX POINTER

DISPLACEMENTS FROM R5 FRAME POINTER
14
10
4

-4-

COMPUTE W', HOMOGENEOUS COORD
AND LEAVE IT ON STACK

Page 176

COr-1PUTE PSXPOS

NOW COMPUTE PSYPOS
CLEAN UP
ROUND:

I

STAC~

AND RETURN

ROUND REAL ON STACK TO INTEGER
IF < 0 THEN SUBTRACT O. 5 ELSE
ADD O.

5~

THEN TRUCATE .

. END

r h e: sec 0 ~ d r' 0 uti neT' e f e 1" en c e s t h ~ of 1 r s t l' 0 uti n e a s us ell a s ttl e
separately assembled DRAWLINE routine.
MOVETO must be linked into
LINETO befoTB the routine can be linked in as an external procedure to
a PASCAL UNIT Dr PROGRAM .
. PROC LINETO,6 ;

PAR/"tMETERS OCCUpy 6 WORDS

PROCEDURE LINETO(X, V, Z: REAL);
DRAWS A LINE FROM THE LAST POINT CONTAINED IN
PSXPOS & PSYPOS TO THE NEW TRANSFORMED POINT

GIVEN BY X, V, & Z...
SAVEX

- PSXPOSi

t'lQVE"TfJ ( X,

SAVEY := PSYPOS;

Z) ;
DR/\tl"Llr~E(.JUNJ.\~
PSBUFp .....·,
y.

20,

160+SAVEX,

120-~SAVEY,

PSXPOS-SAVEX.
·
·
·
·

SAVEv-PSYPOS,

l)j

PURL Ie PSXPOS
PUBL 1 C PSYPOS
PUBt Ie PGHUFP
PH I\JATE RANGE

.REF MOVE TO
.Rt:F DRAWLINE
LINETO ENTRY POINT
R5, -(SP)
SP, R5

MOV

MOV
Sr\VEX

SAVEY
X
y
Z

EQU
EGU
EQU
EQU
EGlJ

USE R5 AS STACK FRAME POINTER

--2
--4
1.11

lC}
4

SAVEX "= PSXPOS;

SAVEY

PSYPOS;

Page 177

JSR

PC,@#MOVETO
DRAWLINE( ... ) i

JSR

PC,@#ORAWLINE

; ALL DONE ...
Jf'lP

RETURN

@RO

. END

For examples and

mo~e

information see section 1.9 ASSEM

***************** *****************

*

LONG INTEGERS

* *

*~*~#************

SECTION 3.3.3

*

*****************

A new addition to V.e.S.D. Pascal p~edecla~ed type INTEGER is
the optional use of a length attribute (available only on LSI 11/PDP
11 based micros).
This essentially constitutes a new t~pe and will,
in the remainder of this document, be referred to as LONG INTEGER.
The LONG INTEGER is suit~ble for business, scientific or other
applications in which the need for extended number length with
complete accura~y is felt.
This extension supports the four basic
st3ndard INTEGER arithmetic operations (additiont subtraction,
division and multiplication) as well as routines facilitating
conve~slon to strings and standard INTEGER~.
Stl'ong t~pe checking is
enforc.;\r.! throughout to reduce potential errors. Input/Output, in line
declaration of constants and inclusion in $tructu~ed types are all
fully $IJpported and are analogous to the usage of standard INTEGERs.

LONG INTEGERs are declared using the standard identifier
INTEGER followed by a length attribute in squaTe brackets.
This
length is an unsigned number, not larger than 36, denoting the minimum
number of decimal digits repre5ent~ble by the LONG INTEGER.
For
exan'lple, a variable called 'XI capable of storing at least an eight
decimal digit signed number would be created by:
VAR X:

INTEGER(8J;

Constants aTe defined in the normal manner:

CONST RYDBERG
In the above

=

10973731;

exampl~

RYDBERG would be

b~

default a LONG INTEGER

and could be used anywhere a LONG INTEGER could be used.

In general LONG INTEGERs may be used an~where it is
correct to use REALs (nat fully implemented until II.Oi
for now LONG INTEGERs are limited to aritmetic operationsl assignment
synt~ctically

statementrj

(biJt not as<:!ignment

to a

R~;;:AL)}

TRUNC,

and STR);

howf!ve"f'

care must be taken to ensure that sufficient words have been allocated
by thp derl~red length att~ibute for storage of the result of
assignment or arithmetic expression statements (see note in next
subsection fo~ complete details).
INTEGER expessions aTe implicitly
co~verted as required upon assignment tnJ
or arithmetic operations
with, a l..ONG INTEGER.
The T"even"S~ i~ not true,
UrH1T'y plus/minus is
correctly handled.

Page 179

VAR

r·

INTEGER j

L:
S:

INTEGER(NJj
REALi

1:= Li

L:=-L;

=

L:.
I~
l'= Si

where N is an acceptable length

cOffinile time error; see TRUNC(L) below
correctf with~he usual exception
ll!-UQ.Y,.Lf..fLl'...!:Ji.U

never acceRted
S:= Li will be implemented with II.O
Arithmetic operations which may be used in conjunction with
LONG INTEGERs are any or allr'rom the set + .. -I*tDIV,una . . . y
plus/minus.
On assignment the length
the LONG INTEGER is adjusted
(during execution) to the decla~ed length attribute of the va~iable,
th~refDre an interrupt (overflow) may result.
An interrupt (overflow)

0'

occu~s only wh~n t~e intermediate result exceeds the number of words
required to store (as a minimum) thirty-seven decimal digits, or when
the final result is assigned to a variable with insufficient length
attribute. (On the matter of the length attribute and what it
defines: a length attribute of 5 thru 9 may store up to and including
2147483647, length att~ibutes of 10 thru 14 may store thru

140737488355327, 15 thru 18 .. 9223372036854775807.
It is left to the
interested reader to compute any larger length att~ibute storage
capacities.
Thus it would be unwise to attempt to use a LONG INTEGER
as a subrange.
This range of length att~ibutes all having the same
upper bound is a result of the allocation of a full word as the least
amount of additional storagel 1. e. 5 th1"u 9 represent a two word
INTEGER, ) All of the standard relational operators may be used with

mixed LONG INTEGER and INTEGER.
The function TRUNCCL), where 'L' is a LONG INTEGER, will
convert 'L' to an INTEGER .
SEGTABLE:

3.4.3

contains the segment

dictlonar~

for the pascal system.

EXCEPTION HANDLING - XEGERR

Whenever a run-time error occurs, the P-machine stops executing the
current instruction (ideally leaving the evaluation stack in as nice a
condition as possible) and t~ansfe~s control to the XEGERR routine.
This ~outine
1) enters the error code into SYSCOM A • XEGERR.
2) calculates what MP will be after step 41 and sets SYSCOMA.BOMBP to
that.
~The size of EXECERROR's activation record must be known
by the P-m·ac:hine. )
3) stores the current value of IPC into SYSCOM-.BOMIPC.
4) points IPC to a CXP 0,2 (call operating system procedure
EXECERROR) inst~uctiDn.
5) resumes execution of interpreter code, starting with the expo

3.4.4

OPERAND FORMl\ TS

Although an element of a structure may occup~ as little as one bit,
as in a PACKED ARRAY OF boolean, variables in the P-machine are
alwa~s aligned on word boundaries.
All top-of-stack operations expect
their operands to occupy at least one wardJ even if not all the
infa~mation in a word is valid.
The least significant bit of a word is
bit OJ

th~

most significant is bit 15.

Page 185

BOOLEAN:
One wo~d.
Bit 0 irtdicates the value (false=OI true=l),and
this is the ~nly information used by boolean comparisons.
However,
the hoolean operators LAND, LOR, and LNOT operate on all 16 bits.
INTEGER:
One word, two's complement,
the range -32768 .. 32767.

One word,

SCALAR (user-defined):

capable of representing values in

in range O.. 32767.

CHAR:

One WOT'd~ with low byte containing character.
Th~ internal
c h a rae t e 1" set i 5 II ext en d e d U ASC I I I wit h 0.. 127 l' e pre s en tin 9 the
standard ASCII set, and 128 .. 255 as a user-dpfined character set,

REAL:

Two wO'r'dsl

is arranged

50

with fOT'mat

implementation dependent,

The system

that only the interpreter needs to know the detailed

internal format of REALs (beyond thp fact that they occupy twa
Following are th. two detailpd formats for the CPUs we now

words)
(a~

or

1.

suppur't.

4)

PDP 11;

o

15
llfQ'T'd

low mantissa

1;

15 14

7

o

6

high mantissa

exponent
zeO/SOBO:
15

8

'1

o

15 14·

8

7

o
exponent

high mantissa

UlOT'd

0:

Both

repT'esent~tj.on::.t

mantisr;a ti)at is alw.ays.

hav~

an

e;c:,:~ss'-'128

normalizE:~dt

exponent . .

expont1nt oa£if.? 2.

a fl"ac:tional
an implicit

24th mantissa bit, and zero represented by a zero exponent.
(See
PDPll processor manual or ZaO/SOBO interpreter listing for greater
de ta i 1. )
POINTER.

One or three words,

Par..cal pointers;,

depending on type of pointer.
one word, containing a word

internal word pointers:

address.

Intern.Sll bytl? pointers: one WOT'd, containing a byte addr-ess.
Internal par,ked field pointers: three words.
word 2: wOT'd pointer to word rield is in.
WO!"' d 1:
of!:i ~ 1 d _w i d t ~ < j n bit; 5 )

word 0: right_bit_numbeT' of field.
SET:

'

(1,

Page 186

255

tool'd~

in

d.~tM

segm~ntl

:t ,256 words on stack.

Sets are

imp 1 em e n t ed ,:a'$ bit vee tar s , a 1 Wa y s wit halo we-r in d e x 0 f z e l' o.
A
set vlH',iable declared as set of m.. n is allocated (n+15) div 16
words.
When a set is in the data segment, all words allocated
contain valid info~matian.
When a set is on the stack, it is represented by a word
containing the length, and then that number of words. all of which
contain valid information.
All elements past the last word of a
set are assumed not to be elements of the set.
Before being stored
bark in the data segment, a set must be forced back to the size
allocated to it, and so an ADJ instruction must be issued.
-RECORDS and ARRAYS: any number of words (up to 16384 words in one
dimension).
Arrays are stored in row-major order, and always have
a lower index of zero.
Only fields or elements are loaded onto the
stack - neveT the structure itself.
Packed arrays must have an
integral number of elements in each word, as there is no packing
across word boundaries (it is acceptable to have unused bits ineach word),
The first element in each WOT'd has bit 0 as its loworder bit.
1 .. 128 words.
Strings are a flexible version of packed
al"rays of char. A string(nJ occupies (n div 2)+1 words.
Byte 0
of a string is the current length of the string, and bytes
1 .. 1ength(string) contain valid characters.

STRINGS:

CONSTANTS: constant scalars, sets, and strings may be imbedded in
the instruction stream, in which case they have special formats.
All scalars (excluding reals) not in the range 0 .. 127:
two bytes.
low byte first.
Strings: all string literals take length(literal)+l bytes, and
are byte aligned.
The first b~te is the length, the rest are the
actual charact~rs.
This format applies even if the literal should
be interpreted as a packed array Q£ char (see SiP and S2P
below.) .

Reals and sets:

3.4.-5

word alignedJ

and in

~!~

word order.

INSTRUCTION SET FORMAT

Instructions on the P-machine are one or two bytes long, followed
zero to four param~ters.
Most parameters specify one word of
information, and are one of five basiC types.

by

UB
SE
DB
E

unsigned byte: high orde~ byte of parameter is implicitly zeT'o.
signed byte: high order byte is sign extension Qf bit 7.
don't care byte: can be treated as sa or UB, as value is always in
the range 0 .. 127.
big: this parameter is one byte long when used to represent values in
the range O.. 127, and is two bytes long when representing
values in the range 128 .. 32767.
If the first byte is in
0 .. 127J the high byte of the parameter is implicitly zero.
Otherwise} bit 7 of the first byte is cleared and it is used as the
high order byte of the param~teT'.
The second byte is used

Page 187

W

as the low order byte.
the next ttJlO byte"5i1 low byteriT'stt

word:

is the paT'ysmeter value.

Any exceptions to these formats are noted in the instructions where
they occur.

ENGLISH INSTRUCTION SET DESCRIPTION

3.4.6

In thp fallowing section~ refprencEs to an element on the stack are
context-dependentt and can mean anyw~ere from one word to 256 words.
A1 so} tf n 1 e s ssp e c i. -F i cally n () ted t o t h e c on t l' a l' y , 0 peT' and s aT' epa p p e d 0 ~ f
the stack - they are not left a'r'ound.
Abbreviations a~e used widelYI but use fairly simple conventions.
Paramete1's are written as X or X_", where X is UB, SBI DB, B, or W, and
n is an integer indicating the param~ter position in the instruction.
Tos means the operand on the top of st~~kJ toa-l the next operand;
etc.
Mark Stack CDntrol Word is abbreviated to MSCW,

Many instructions re-Fer to the activation record of a procedure. and
this document assumes the reader has a general knowledge of procedure
calling in stack machines, and thp concept of stack frames.
An
activation reco~d as defined in this document specifically consists of:
1) the local data segment o~ the procedurej and
2) the MSCW, containing addressing information (static links), and
Information on the calling procedure~ environment when the procedure
wa~;

called.
(See Section 3.5.

figure 7. ,

Thp dune~ic chRin re'ers to th~ calling chaln. traversed u~ing the
MSCW MSDYN links.
The st8tic chain l'ef~r~ t~ thv lexical or ancestor
chain, travl;:\T'sed u~ing the MSCW. MSSTAT links,

OP-CODE

MNEMONIC

PARt,\METERS

FULL NAME AND OPERATION

5. A VARIABLE FETCHING, INDEXING, STORINGJ AND TRANSFERING
S.A.l ONE WORD LOADS AND STORES

S.A.I.a
SLDC

CONSTAN7 ONE WORD LOADS

o ..

12'7

Short load word constant.
c:pCOdl·...

Page 188

U))t;t:

high

bytp. zero,;

Pushes the
cinto stack.

l .• DCN

159

LDCI

199

5.A. 1. b
SLDLl

Load con5tant ni~.
Pushes the
implementation-dependent valur. of nil.

w

Load constant word.

Pushns W.

LOCAL ONE WORD LOADS AND STORE
SLDLx fetches
Short load local word.
wo~d with off&et x in MP activation
reco~d and pushes it.

216

the

SLDL16

231

LDL

202

LO~3

B

d 1 !H'.i'J 1 wor d.
Fete h es th e wO'f'd wi th
~n MP activation record and pushes

offset B
LLA

lqe

Load

B

lo~al

the (11 aT' d wit h
and pushes it,

STL

204

0

Store loc.al

B

Fetches addre&5 of

add~ess.

f of ~~ e t

it.

13 i n I"tP act i va t 1. 0 n r e c. 0 r d

UJo1~d.

St*.ll'eS

ttjEj

into word

wltn offsFt B in MP activation record.

5.A. 1. c
SLDOl

GLOBAL ONE WORD LOADS AND STORE
2:-12

SLD016

247

LOO

167

Short load global UJor-d.

SLD()~

fetches

the tlJord wi.th offset x in BASE a.euva.uon
record an~ pushes it.

L c;} d (] 1 1) b a 1 ltJ tH' d .
Fe tc h e 5 the I» 0 r d wit h
oFfset B in BASE activation record and pushes
i·t.

LAO

Lo.~d

B

9 1 oba 1 addl'ess.

Pushes the

word

addre5s of the word with offset B in BASE
~ctivation record.
SRO

Stor~

1.71.

word

5-A. I. d

wit~

globAl word.
Stores tos int.D the
of~5et B in BASE activation record.

INTERMEDIATE ONE-WORD LOADS AND STORE

LDD

LO(';ld

intermetii.a-te wal'd.

DB

indicates the

number or static links to traverse to find the
activation record to use.
B i . the ofFset
within the activation record.

LDA

178

STR

184

DE,B

Load intermediate address.
Store intermediate word.

Page 189

5.A. 1.

'INDIRECT ONE-WORD LOADS. AND STORE

e

STO

154

SINDO

248

store indirect.
Tos is stored into the
word pointed to bytos-1.
Load indirect.

5.A.2MULTIPLE WORD LOADS AND STORES (SETS AND REALS)
LDC

179

UB, 
Load multiple word constant.
UB is the
number of words to load, and  is a
word al igned bloc k of UB words, in reverse
word order.
Load the block onto the stack.

LDM

188

UB

Load multiple words.
Tos is a pOinter
to the beginning of a block of UB words.
Push the block onto the stack.

STM

189

UB

StoT'emultiple words.
Tos is a block of
US wordsl tos-l is a word pointer to a
similiar block.
Transfer the block from the
stack to the destination block.

5.A.3

BYTE ARRAYS

BYT

210

Byte conversion.
Cctnvert word pointer
tos to a byte pointer.
(NOP on the PDP11 and
ZSO/S080 imp lementat ions. )

LDB

190

Load ,byte.
Push the byte (after zeroing
high byte) pointed to by b~te pointer tos.

STB

191

store byte.
Store byte tos into the
location specified by byte pointer tos-l.

MVB

169

IXB

209

5.A.4

STRINGS

Page 190

B

Move bytes.
Tos is a byte source
pointer to a block of B bytesl tos-l is a
byte destination pointer to a similiar
block.
Transfer the SOlfT'Ce block to the
destination block.
(This instruction is
redundant due to word alignment. and will
be rep la c e d by MOV in the f u t u l' e. )
Index byte array.
Push a byte pointer
formed from the integer index tos and the byte
pointer tos-l.

LeA

166

UB, 
Load constant string address.
Push a
byte pOinter to the location UB is contained
in, and skip IPe past .

SAS

170

us

SIP

208

String assign.
Tos is either a SOUT'ce
byte pointer or a character.
(Characters
always have a high byte of zero, while
pointer never do. ) 10s-1 is a destination
b~te painter.
UB is the declared size of
the destination string.
If the declared
size is less than the current size of the
source string, a run-time er~or occurs;
otherwise all bqtes of source containing
valid information are transferred to the
destination string.

Stl' i ng to pac ked c onveT'S i on on tos.
Tos
is a bl.Jte pointer to a string, and is
inc~emented by onp byte in order to point to
the first character of the string.

S2P

String to packed conversion on tos-1.

157

tos-l are byte pOinter$I and tos-l is
incremented by one b~te.

Tos and

IXS

Index string aT'T'C:Hj.
Performs the same
operation as IXB, except before indexing the
index is check~d to see if it is in the range
1 .. cur~ent length.
If notl a run-time error

155

DC

5. A. 5
MOV

SINDO

r: UT' $,

RECORD AND ARRAY INDEXING AND ASSIGNMENT
168

B

pointer to
destination
pointer to a similiar block.
Transfer the
block From the source to the destination.

Mo.ve ""Q'rds.
Tos is a
a block of B wards, tos-l

SQU1"ce

is a

Short index and load word.

SINDx indexes
pointer tQS by x wordsl and pushes
the word pointed to by the result.

248

the word

SIND7

255

IND

163

B

Static index and load word.
Indexes the
word pointer tos by B words, and pushes the
wOl'd pointed to.

INC

162

B

Increment field pointer.
The word
pointer tos is indexed by B words and the
T@iliultant pointer i5 pushed.

IXA

164

B

Index array.
los is an integer indexl
tos-l is the array base word pointer, and B
is the size (in words) of an array element.
A word painter to the indexed element is
pushed

Page 191

IXP

UB_l,UB_2

192

Index packed array.

Tos is an integer
tos-1 is the array base word pointer.
DB_1 is the number o~ element-per_word, and
DB _2 is the fie 1 d _w i d t h (i n bit s ) .
Camp ute
and push a packed field pointer.
index,

LDP

186

STP

187

5.A.6

Loa d a p a·c ked fie 1 d .
Pus h the fie 1 d
described by the packed field pointer tos.
store into a packed field.
Tos is the
data, tos-1 is a packed field pointer.
Store
tos into the field described by tos-1.

DYNAMIC VARIABLE ALLOCATION AND DE-ALLOCATION

NEW

158

1

New variable allocation.
Tos is the size
(in words) to allocate the variable, and
tos-2 is a word pointer to a dynamic
variable.
If GDIRP is non-nil, cut NP
back to GDIRP and set GDIRP to nil.
Store
NP into word pointed to by tos-1, and
increment NP by tos words.

MRK

158 31

Mark heap.
Release GDIRP and set to nil
if necessary, then store NP into word pOinted
to by tos.

RLS

158 32

5.B

Release heap.
Set GDIRP to nil,
store word pointed to by tos into NP.

then

TOP OF STACK ARITHMETIC AND COMPARISONS

5.B.l

LOGICAL

LAND

132

Logical and.

LOR

141

Logical or.

LNOT

147

Logical not.

EGUBOOL

175
183

NEGBOOL
LEGBOOL
LESBOOL.
GEGBOOL
GTRBOOL

180

181
17.6
177

6
6
6
6
6
6

Boolean

And

Or tos into tos-l.
Take one's complement

oOP tos.

=,
·C>;
'-(=,

<,

>=,
Compare bit 0 of tos-l
true OT' fa 1 se.

Page 192

tos into tos-l.

and ). comparisons.
to bit _0 of tos and push

5.B.2
ABI

INTEGER
128

Absolute value of integer.
Take absolute
value of integer tos.
Result is undefined if
tos is initially -32768.

ADI

130

NGI

145

SB!

149

MPI

143

Multiply integers,
Multiply tos and tos-l.
This instruction may cause overflow if result
is larger than 16 bits.

SGI

152

Sq,W;!:lT'e
over-of low.

DVI

134

Divide integers.
Divide tos-l by tos and
push quotient.
(PDPll ~uotient defined as in
Jensen and Wirth; Z80/8080 quotient defined
by floor(tos·-·1/tos), )

MODI

142

Modulo integers.
Divide tos-l by tos and
push the remainde~ (as defined in Jensen and
Wirth)

Add

integers.

Negate integer.
complement of tos.

Add

Take the two's

Subtract integers.

integer.

tos and tos-l.

Subtract tos from tos-l.

Stluare tos.

May cause

Check against subrange bounds.
Insure
that tos-l <= tos-·2 (= tOSI 1 eavi ng tos-2 on
the stack.
If conditions are not sati~fied
a run-time error occurs.

CHI-<

EGUI
NEGI

195

IntegeT' :,

<>,

203

LEG!
LEST

200

<=,

201

GEGr

196

GTRI

197

5.B.3

and )comparisons. Compare tos-l to tos and push
true or Talse.

REAL.S

Allover/underflows cause a run-time error.

FLT

138

Flo at top -. a f
conve~ted

.~. s t a c k .
The in t e 9 e r to s i s
to a floating point number.

Page 193

FLO

Float next to top-o-F-'stack.
Tos is a real,
tos-l is an integer.
Convert tos-l to a real

137

number.,

TNC

158 22

Truncate real.
The real tos is truncated
(as defined in ~ensen and Wirth) and
converted to an integer.

RND

158 23

Round real.
The real tos is rounded (as
1n .Jensen and Wirth), then truncated
and converted to an integer.
defined

ABR

Add T'eals.

129

Take the absolute value

o~

the rea I tos.
Ad d tos and

tos-l.

ADR

131

Ad d rea Is.

NGR

146

Negate real.

SBR

150

Subtract real s.

Subtract tos from tos-1.

MPR

144

Multiply reals.

Multiply tos

SQR

153

SquST'e T'eal.

DVR

135

Divide reals.

POT

158 35

Negate the real tos.

an~

t4s-1.

Divide tos-l by tos.

Power of ten.
The integel' tos is check
<= 38, a run-time error
occuTT'ingi~ the conditions aren't satisfied.

for 0 <.= tos

The implementation dependent value 10

A

tos

This facility:allows the rest of
the systam to be ind9pgndent of floating
poi n t f- 01" rna t .
is pushed.,

SIN
COS
ATAN
EXP
LN
LOG
SGT
EGUREAL
NEQREAL
LEQREAL
LESREAL
GEGREAL
GTRREAL

158
158
158
158
158
158
158

Sine.

25

28

Cosine.
Arctangent.
Exponential.
e A
Natural logarithm.

26

Log base 10.

30

Sttuare root.

27
29

175

2

183

2

180
181
176
177

the sine of the real

24

'2

Real

Take

tos.

t05.

::::t,

<>,

2
2
2

and

Push TRUE or FALSE.

>

comparisons.

5.B.4

SETS

ADJ

160

SGS

151

us

AdJust set.
The set tos is 90rced to
occupy US words, either by expansion (putting
zeT'oes IfbetweenH tos and tos-1) OT"
compression (chopping o~ high WOT'ds o~ set),
and its length word is discarded.
Build a singleton set.
The integeT' tos
is checked to insure that 0 <= tos <= 4079, a
run-time eT'T'or occurring if not.
The set
[tosJ

SRS

is pushed.

Sui Id a subrange set.

148

and tos-l

INN

[ t 0 s -1. . to S

J

pushed i f

0 S

t

in set tos,

UNI

i s pus h e d .
'--1 :> t 0 5. )

Set membership.

139

The integers tos

checked as in SGS, and the set

a~e

( The set [ ]

i s

See if integer tos_l is

pushing TRUE OT' FALSE.

Set union.
The union of sets tos and
is pushed.
(Tos .2.!. tos-l. )

156

tos-l

INT

140

Set intel·section.
The intersection of
sets tos and tos-l is pushed.
( To S and to S -, 1. )

DIF

133

Set difference.
The difference of sets
tos-l and tos is pushed.
(tos-l and n,.Q..t_ tos. )

EGUPOWR
NEGPOWR

175

8

LEGPOWR

183
180

8
8

GEGPOWR

176

<:>,
-(: (subset of),

a

and :>=
(superset of) comparisons.

5.B.5

EGlJSTR
NEGSTR
LEGSTR
LESSTR
GEGSTR
GTRSTR

STRIl~GS

175
1.83

4
4

180
181

4

176
177

4
4

4

String

=,
<:>,

<=,

and >
comparisons. The string pointed to by word
pointer tos-l is lexicographically compared
to the string pointed at by tos.

Page 19:

BYTE

5.B.6

EGUBYT

ARRAYS

LEGBYT
LESBYT
GEGBYT
GTRBVT

=,

By te array

175 10
1.83 10
180 10
181 10
176 10
177 10

NEGBYT

emitted fOT

and

~c:ked

:>

and > are only
arrays of char.

<=1 <, >=,

comparisons.

5.B.7 ARRAY AND RECORD COMPARISONS
EQU1~ORD

175 12

NEGWORD

183 12

Word or multiword structure =

5. C

<:>

and
C ompar

i sons.

JUF1PS

Simple (non-case statement) Jumps a~e all two bytes long.
The
first byte is the op-code, the second is a SB Jump offset.
If this
offset is non-negative, it is simply added to IPC.
(A value oT zel"O
for the Jump offset will make any Jump a two-'byte nap.) If sa is
negative,

then

is set to the
U.JP

185

sa llY
byj~..!t

2

is used as a wo'rd

offset

into

~TABJ

and

IPC

addT'e5s(JTAB·.... [SB div 2J) - JTAStSB &1y. 2J.
Unconditional Jump.

SB

Jump as described

above.

FJP

161

SB

EFJ

211

SB

NFJ

212

5B

False Jump.

if tos is false.

Equal false Jump.
"Jump iT integer tos
't05-1.
Not imp lemented in I. 4.

Not equal ·f-alse Jump.

tos
X.JP

~ump

=

tos-·l.

J{Jmp

if integer

Not implemented in 1.4.

172
Case Jump.
W_l is lllord-aligned, and is
the min i rou min d e x 0 of t h eo tab 1 e.
W_2 i s the
maximum index.
t"'_3 is an unconditional

Jump instruction past the table.
The case
table is W._2·-W_l+1 words long, and contains
self-~elative locations.
If tOSI the actual index, is not in the
'r'.ang e W_J,. W_.21 ttl en IPC is poi n ted at
W_3.
Otherwise; tos-W_.1 is us.ed CiS an

index into the table, and IPC is set to
no e x -mi n_i nd ex)casetable[index-min_indexJ.
by te~_~d dr'ess (c as etab 1 et: i

<>

5.0

PROCEDURE AND FUNCTION CALLS AND RETURNS
The general scheme used in procedure/function invocation is
1) Calculate the data_size and parameter_size of the called
procedure by using the information in the current procedure

(pointed to by SEG).
2) Extend stack by data_size bytes.
3) Copy parameter_size bytes from the old top-af-stack to the
beginning of the space Just allocated.
4) Build a MSCW, saving SP, IPC, SEQ, JTAB, MP, and a pointer
to the most recent activation record of the called procedure's
immediate parent.
5) Calculate new values for SP, IPC, JTAB, MP, and if necessary,
SEG. Check for stack overflow.
6) If the called procedure has a lex level of -lor 0 save BASE
and calculate a new BASE.
dictiona~y

CLP

206

UB

Call local procedure.
Call procedure UB,
which is an immediate child of the currently
executing procedure and in the same segment.
Static link of MSCW is set to old MP.

CGP

207

UB

Call global procedure.
Call procedure
UB. which is at lex levelland in same
segment.
The 4itatic link of the MSCW is set
to BASE.

CIP

174

UB

Call intermediate procedure.
Call
procedure VB in same segment as the
currently executing
procedure.
The static
link of the MSCW is set by looking up the
call chain until an activation record is
found whose caller had a lex level one I
less than the procedure being called.
Use
that activation record's static link as the
static link of the new MSCW.

CBP

194

UB

Call base procedure.
Call procedure UB,
which is at lex level -lor O.
The static
link of the MSCW is set to the static link
in BASE' ~ act i vat ion r e cor d .
The BASE i 5
saved, after which it is pointed at the
activation record Just created.

CXP

205

013_1, UB_._2

Call external procedure.
Used to call
procedure not in the same segment as
the calling procedure, including procedures
at lex level -lor O.
It works as follows:
1) Is desired segment in memory? This
is determined by traversing up the call
chain until an activation record of a
procedure in the desired segment is found,
or the DPerating system's resident
gP,~

esp -- ed6 note: it

WM po~nted

:t.fU.6 doc.ument.

enn oJtt •

ou:t thM. op-c.ode 158 -fA esp, and)A .6c.aZteJted thJwughoLLt
ThL6 will be c.leaJr.ed u.p ~n the next maj Oft doc.umentaUon

Page 197

activation ~ecord is encounte~ed,
2a> no: read in segment from disk using
th~ information in the segment dictionary,
then build an

~~H:ti\fatiDn

recoT'd.

However,

extend stack by data_size+pc;ramsize in step
2.

yes; b u i 1 d act i va t ion 1" e c 0 i" d nor ma 11 y .
3) calculate the dynamic link foT" the
MSCW: I f the called procedure has a lex
level of -1 or O. set as in esp, otherwise
set as in elP.
2 b)

RNP

DB

173

Return from !1on~-base procedure.
DB is
the number of words that should be returned
as a function value (0 rOT' procedures, 1 .pOl'

non-"i"eal functions,

and 2 ·r-or real functions).

DB words are copied 9rom the bottom of the
data segment and "pushed" onto the caller's
top -' 0 f - s t a c k .
Th e i n f 0 T' ma t ion in the MSC W
is then used to restore the caller's
correct environment.

REP

DB

193

Return ·j!rom base procedure.

Th~

saved

base is moved lnto BASE, a,ter which things
proc9.ed as in the RNP instruction.

EXIT

158

4

Tos is the
Exit from procedure.
~J r e n u mh p. 'l".
t !:: ~ - 1 i~; t h I.?' f.;? 9 ml? rl t
number.
This operato~ sets IPC to point to
the exit c~de of the cU~~9nt]4 executing
P'!" 0 red

proc~du'i"e,

th€n

sees if the :;:uT'T'ent

procedure is the one to exit Prom.

If i t

is. control returns to the instT'uction
retch loop.

Otherwise,

each MSCW has its saved IPC
exit code of the
it, until the
desired procedure is found.
If at any time the saved IPe of main body
of t~e ope~ating system is about to be
c h\3 n 9 ed, a
run -~ tim e e T" 'r Q T' 0 C cur s .

changed to point to the
procEdure that invoked

5.E

SYSTEMS PROGRAMS SUPPORT PROCEDURES
See Section 2.1 for desci'iption o.,! these procedures.

BYTE ARRAY PROCEDURES
FLC

Page .198

158 10

Fillcnar(dst,

len,

char).

seN

158 11

5can{maxdisp,

start,

MVL

158 02

Moveleft(srci

dst,

MVR

158 03

Moveright(sT'c,

dst,

forpast,

char,

mask).

numbytesL
numb'ltesL

COMPILER PROCEDURES (still undocumented>

TRS

158

08

Treesearch.

IDS

158

07

Idsearch.

DEBUGGER
BPT

Breakpoint (conditional HALT)

213

MISCELLANEOUS
TIM

158

XIT

21,4

09

Time.

Page 199

-

Jage 200

Notes .-

********************************************* ***************

*

INTRODUCTION TO THE PASCAL PSEUDO-MACHINE

* *

Section 3. 5

*

********************************************* ***************
VeT'sion 1. 5

September 1978

UCSD uses an interp~eter based implementation of Pascal.
This
implementation is interpreter based. This means that the compiler emits
code for a pseudo-machine which is emulated at ~un time by a p~ogram
writt~n in the machine language of the host.
The compiler, program
editori small stand-alone operating system, and various utilities are
themselves w~itten in Pascal and run on the same interpreter.
Thus the
entire system can be moved to a new host machine by rewriting the
interpreter Tor the new host.
Figu~e 3.5.10 (the last page of this document)
is a skeleton version
a large Pascal program; here-·in-a{~ter refer-red to as "The Program".
This document is a top-down description of the realization of that
program on the UCSD Pascal system.
We will make occasional use of a
helpful coincidence: The Program is the framework of the portion of
the UCSD P~scal environment that's written in Pascal.

Or

If The Program were expanded to a complete Pascal system, it
would consist of at least 6000 lines of Pascal and compile to more than
501000 bytes Df code--too big to fit all at once into the memory of a
small machine (by our current definition of small).
We have therefore
extended Pascal so that a progT'ammer can explicitly partition a program
into segmentsi only some of which need be resident in main memory at
a time.
The s~nta)( o-r this extension is shown in figure 3.5.1. (Any
syntactic objects not defined explicitly there retain their standard
interpretation as defined by Jensen & Wirth: Pascal User Manual and
Report. )
 ::=   ::= 

Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2013:04:06 14:31:05-08:00
Modify Date                     : 2013:04:06 16:21:23-08:00
Metadata Date                   : 2013:04:06 16:21:23-08:00
Producer                        : Adobe Acrobat 9.52 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:fc2785ac-0c25-402f-843d-41df13235847
Instance ID                     : uuid:1e9f0891-7b82-4a51-8899-4fa08cc1a62d
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 333
EXIF Metadata provided by EXIF.tools

Navigation menu