CNTX, CNTY, MOVE: INTEl
F: TEXT; C* TYPE TEXT = FILE OF CHAR *)
2.2.20 LONG INTEGERS
UCSD Pascal allDws integers of 0p to 36 digits.
3.3 3 for details ~egarding long int~ge~s.
Se~ section
2.;;': 21 UNITS
UCSD Pascal now ~upports the modularity concept of UNITs. See sec t ion 3. 3. 2 for de -t ail S l' e 9 i3 r din 9 UN I T ~ .
2.2.22 SUMMARY OF U. C.S. O. INTRINSICS INTRINSIC SECTION #
2. 1. 2
BLOCI-<.WR I TE 2.1.2
Page 156
DESCRIPTION
Furtction whi~h reads a variable number of blocks 'rom an untyped fjl~.
Function which writes a variable number of blocks from an untyped file.
CLOSE 2. 1.2
STRING intrinsic used to concatenate strings together.
STRING intrinsic used to d~lete characters from STRING variables.
G~aphics intrinsic for use on the Terak 8510a.
Graphics intrinsic for use on the Terak 8S10s.
Intrinsic used to exit PROCEDURES cleanly.
Procedure used for cu~sor addressing whose two STRING intrinsic which Teturn~ the dynamic length
Used to m~~k the current top of the heap in dynamic
RELEASE SEEK SrZEOF
STR
TIME
TREESEARCH UNITBUSY
UNITCLEAR
UNITREAD UNITWAIT
UNITWRITE
Paqe 158
2. 1.3
2. 1.2 2. 1.6
2. 1. I 2. 1.6
2.1.2
2.1.2
2.1.2
2.1.2
2.1.2
Intrinsic used tOT'elease memory occupied by
variables dynamically allocated in the heap.
Used far random accessing of records withing a file.
Function returning the number of bytes allocated to ~l v~riable.
Procedure to convert long integer into string.
Function returning the time since last bootstrap of system. (returns z~ro if microcomputer has no real time clock)
Routine used solely by the Pascal compiler.
Law level i~triniic For det~rmining tha status of a peripheral device.
Low level intrinsic to cancel 1/0 from a peripheral device.
Low level intrinsic for reading from a peripheral device.
Low level intrinsic for waiting until a peripheral device has completed an I/O operation.
Low level intrinsic used for writing to a peripheral device.
************************************ ***************
*
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 J.s n,~;i,~ ufd,qtie. DF~t..!LIf·iE (T\~;H; pick diffe!"erit
i'epi'e-S\?nt~t:ions 'tOT' d line depfi'nding on the ~tQT'ting point. (This could be C Q'1" 1" e c ted 1.1 \J a 1 W-3 Y ss. tar tin 9 at the same end of the 1 i n e. ) No 1'" a n 9 e
chec~ing is performed an parameters passed to thi~ intrinsic,
The alQo~ithm IS essentially the one described in Newman and
Sp~oul, P~t~ci~19s 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 . ! n t h e d :i. s r_ u ;'~ ':: i i'1 n b • .£.' 1. <j W I we a saw in e the h C i' i z 0 n t B 1 c. 1:1 s e : v e r t i ca 1 i IS S i mil a r .
There will be DELTAX points p10t~~d with horIzontal increment of 1 ~ach" The vertic~l increm4?nt will be. ,\BS (DELTAY I DELTAX)
<=
1.The Y coordinate arithmetic is scaled by DELTAX to eliminate fractions.
An additional savings in execution time has be~n gained by maintaining
t h 2:::; L~J 'f' ,',2 '::.; S .) f ":" ~~ ::' p 'f' h~ V i t) u ~:.. pet:,,\ t . ~ n d doing 0 n 1. y .a d d i til) n and
subtraction to reach the next point to be plotted.
The Hp.,D/\F~p~ .. "lc.tion i~ C':t.l!1'i/:ili,:,,:,:::tc7d . .:::s twa :Lr:te-T'se·:ting lines may
hay~ no plotted pU1nts in common. Tha detection conditIon is either (1) t i H? C Q (;1 put e d p cd n t i:; T Ii l.iE 1 D T' <~?) bot h t h eo n e x ,t tH',H" i Z 0 n t d 1 and the n e 'f. t ',! e r t :i c. e 1 yed n t saT' e T R UF.:: Con d i t ion ( 2 ) could be weakened; when
t h li:'! i n e :\ s m C11 e ;.; C f' 1, '! I) n tal' ; en 1 lj t Ii e n ext VeT' tic. a l p 0 i n t need b e checked.
Ref e i' .t; Q S .2 C to: i Q it 2, 1. .1- for .~ ct e E! s:: r' i p t 1. 0 n 0 of the paT' a m e 't e r e a l l i n 9 seq u e nee.
Page 159
PROCEDURE DRAWLINE (VAR RANGE: INTEGER, VAR SCREEN: SCREENTYPEi ROWWIDTH, XSTARTI YSTART, DELTAX~ DELTAYJ INK: INTEGER)j
VAR X. V, XINC,· VINe. COUNT: !Nl'£GFP,
PROCEDURE DOFORY; C*MORE VERTICAL*) VAR ERROR, 1: INTEGERi
BEGIN
ERROR ;= DELTAY DIV 2;
I :
=
DELT?\YiREPEAT
ERROR := ERROR + DELTAX;
IF ERRDR :'.,:-:; DEL TA'Y
THEN BEGIN EHROR ::~ E'RHOR .- DELTAY::
x
Y :::: Y + VINCI' DRAJ...'DOTi
I := I - 1;
UNTIL I :: Oi END (*DOFORY*) ;
BEGIN <*DRAWLINE*) X :;;.; XSTAHTi IF DELTAX
<:
0THEN BEGIN XINC
EL SE X INC ::.: 1 i
Y :::: YSTART;
IF DELTf"lY <: Q
THEN BEGIN Ylr~C
ELSE Y INC :
=
1 iCOUNT :~.;;; OJ
-1; DELTf~X ··nrL TAX
--1, DELrAY - ·-l)~.LTAY
E.L SE {jUF OR Y ;
x
+ XINC END;END
END
IF DELTAX
>=
DELTAY THEN DOFORXIF IN~ = 4 (~nADAR*) THEN RANGE CDU~ .. rr;; <*HIT THE LIMIT GIVEN*>
END <*DRAWLINE*)i
Page 161
-
Notes-**************** ***************
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, 144 \uor'ds, is reserved for future use by later versions of the system. The fermat of the fi~st block will mast probably change completely foT' version 11.0.
Pt~ge 164·
~-*{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.~' l"e's€t'fved ulord 'SEGt'1ENT', fOl' ei:,~mpJ~:
SEGMENT PROCEDURE !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 the user ma4 now compile his/her program in chunks,
sp~~:i~icallu in SEGt"1ENTS. Ttl{'; LINV.ER program (described in Section 1. 8) c: at n L c' l.,.i s e ~1 t <J 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 large code f:ile.
Requirem2nts and limitations:
The disk which holds the codefile fer the program must be on-line (and in the same drive as when the program wae started) whenever one of SEGMENT protedUTe~ i~ to he c211ad Otherwise the sy.tem will attempt to retrieve and execute whatever information now occupies that particular 11Jcati..on on the d1<slc· u5ual1tJ hJlth verlJ displeasing and cErtaInly Ln&xpected results.
available to the user
SEGMENT procedures reust be the f1rst pro~eduTe declarations containing code-generating statements.
For furth~r details and exampJes see Section 3. 5~ INTRODUCTION TO THE P!~SC:AL PSE:UDD Mt;CH!NE
Page 165
-
Ntd.:;e~,-~age 166
****R*****~**~********************
*****************
~;, L T f.!V.!\C:: Tn [';~ TERfU\!. L Y COMP I L.ED
* *
Se c t ion 3. 3. 2*
*
AND ASSEMBLED ROUTINES* * *
********************************** *****************
Vtn"sion 1. 5 Se p temb En" 1978
EXTERNAL COMPILATION UNITS
The ucsn Pas,cial 1. 5 stjstem SUppOl"ts a facility foT' integrating externally compiled and assembled routines and data st~uctures. Use of separately compiled st~uctures allows the user to create files of
of T' e G. iJ f~ n t 1 U USE' d l" 0 u t j 11 C· 'S . [\ f t t? r- d s t; "[" u c t; U "f' f' i '!. C em p j 1 e d I the u '5 era d d s i t to a library, using the library maintainer. Files that reference that structu~e need not compile i t directly into their code file,
l' a the l' J t ~~ E' 1 i n ir: e T' cop 3. 9 S the e xis tin 9 r.: c ~j f~' i n t o t h e h 0 s t e o d e of i 1 e . Separate compilation or assembly is supported in these areas: between
portions of programs written in Pascal; between assembly language T'ctrt:ines ar,tj Pa~)c,31 hosts; .3nd fin~~11y, bf~tl!.:een assembly language
routin~s. Each o¥ these areas is discussed in turn by the following sections.
3, 3. 2 1 PASCAL. TO PASCAL LINft,AGES - - UNITS
A UNIT IS a group of interdependent proceduresl functions, and associated data st~uctures which perform a specialized taSk. Whenever
this task 15 needed within d prograffit the program indicates that it USES the UNIT. A UNIT consists of two parts, the INTERFACE pa~t, which dec 1 a j . e s r: n n ~ t ~~ n t <,:;- t tj P f~S j V a:\ r i s b 1 e s .~ pro C eo d l.l't' e s a 1"1 d of u net ion s t hat are public and can be used by the host program. and the IMPLEMENTATION
paTt~ which declares constants! types, variables .. procedures and
functions that ~re private, These are not available to the host program and are used b~ the UNIT. The INTERFACE pa~t declares how the program will communicate with the UNIT while the IMPLEMENTATION part defines how the UNIT will accomplish its task.
TURTLEGRAPHICS ( example B ) is a UNIT which enables the user to draw pictures using a graphics turtle. The INTERFACE consists of procedures like MOVE, TURN, and PENCOLOR} which allow the user to move the turtle and change ~olo~s. TURTLEGRAPHICS also employs DRAWLINE, an externally assembled procedurei to draw the lines and the tu~tle.
A prog~am that uses TURTLEGRAPHICS has no need for DRAWLINE, and, conse~uentlyj DRAWLINE is private to that UNIT.
Page 167
PROGRAM DRAWPOLYGON;
USES TURTLEGRAPHICS;
VAR I: INTEGER;
SIZE/NUMSIDES: INTEGER;
BEGIN
INITTURTLEi <* Initialize the UNIT's variables
*>
WRITE{'What size pclygon~/)j
READf_N(SIZE) i
WRITE(~How many sides?i)j
READLNCNUMSIDES);
FOR 1:=1 TO NUMSIDES DO
Bf:~rN
END.
MOVE ( S J Z E ) j
TURf\! (360 D I \/ hP')MS I DES);
ENDj
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.
Paoe 168
UN I T rUPTLJ:':~CRAPHT. CSi I ~.rn::·? F !\ ~ F
PRoc!:~n! . .InE IN I TTI.IRTLEi
PHOCEDURE TURN ( HFLANGLE.. In t P.g e 1" ) ;
PROCEDURE MDVE( REL.DISTANCE: !nt~gE~' )i
PRDCEDURi-: MDV~.TO( X, 'y" Integer ) i
PROCEDURE TURNTO( ANGLE, Intege'r' )i
PROCEDlJRE PENGOL.OR ( PCOLOR, TGCOLOR ) i
! ~1PLEMEN T'A r ION
TER xsr ZF = 319:
"fER'y'S:: 7E - 2,39;
TYPE
SCREEN
=
Pi.=:!C ~ed,";T'T'dY TERXSIZE, O .. TERVSIZEJ of Boolean;
VAR
<*
Private Y~riables *) TGXPOB: Integer;TGYPClS: Integer;
TGHEADING: !nteger~
TGPEN: TGCDLOR;
1; d: Int.eger-j S: SCREEN;
(* Externally clssembled ~rocedure *)
P~OCED1)RE DRAlfJL,INE( Var RADI~R. Integer; Val'S: SCREENi
ROW, XO, VOl DX, DY, PEN: Integer );
EXTERNALi
<*
External declaration * )PROCEDURE INITTURTLEi
BE(~ IN
Fillchar-( SCREEN_, SilHOf(SCREEN), 0 ) ;
UnitwTite( 3, SCREEN, 63 );
HEADING : = 0;
TGXPOS .-- 0;
TGVPOS 0;
ENDi
PROCEDURE MOVEi (* Public procedu~el pa~ameters declared above
*>
BFGr,lN
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.