12.07.2015 Views

ATARI PASCAL LANGUAGE SYSTEM - Strotmann.de

ATARI PASCAL LANGUAGE SYSTEM - Strotmann.de

ATARI PASCAL LANGUAGE SYSTEM - Strotmann.de

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

W <strong>ATARI</strong>' PROGRAM EXCHANGE<strong>ATARI</strong> <strong>PASCAL</strong><strong>LANGUAGE</strong> <strong>SYSTEM</strong>lSO Pascal with many enhancementsDiskette: 48K (APX-20 l02)User-Written Software for <strong>ATARI</strong> Home Computers


A T A R X P A B C A L I A N G U A G ' K R Y ' & T E NP r o g r a m an d Nenue l Co n t e n t s © 19'8 2 AT4RX > Xn c .software)~ ATAK~ Znci grants yau a nonexdusive Bcense to ezecute the enclosed softwareiThis software is copyrightedi You are prohibited from reproducing> translating f ordist ributing t his software in any unauthorized manner.


Distributed ByThe <strong>ATARI</strong> Program ExchangeP.O. Box 3705Santa Clara. CA 95055To request an APX Product Catalog, write to the address above. or call toll-free:800/538-1882 (outsi<strong>de</strong> California)800/872-i850 (within California)Or call our Sales number. 408/727-5603The following are tra<strong>de</strong>marks of Atari, inc.<strong>ATARI</strong>e<strong>ATARI</strong> 400 Home Computer<strong>ATARI</strong> 800 Home Computer<strong>ATARI</strong> 410 Program Recor<strong>de</strong>r<strong>ATARI</strong> NO» Oisk Orive<strong>ATARI</strong> 820 ~ lumn Printer<strong>ATARI</strong> 822» Thermal Printer<strong>ATARI</strong> 825 8&Column Printer<strong>ATARI</strong> N O Acoualc Mo<strong>de</strong>m<strong>ATARI</strong> 850 Interface Moduie


~ P O R T 4 N T !D UP L Z C 4 T ET H X SD XSKET TEBKFOREuSXNGTHXSP ROGRAH lThis kPX diskette is unnotched to protect the software againstacci<strong>de</strong>ntal erasures However> this protection also prevents a programfrom storing information on the diskettei The program you' vepurchased involves storing information. Therefore, before you can usethe program, you must duplicate the contents of the diskette onto anotched diskette that doesn't have a writ~ r o tect tab covering thenotch oTo duplicate the diskette> call the Disk Operating System (DOS) menuand select option 3'> Duplicate Diski You can use t hi s option wit h asingle disk drive by manuaQy swapping source (the kPX diskette) and<strong>de</strong>stination (a notched diskette) until the duplication process iscomplete< You can also use this option with multiple disk drivet b . 'nserting source and <strong>de</strong>stination diskettes in two separatedrives and letting the duplication process proceed automatical ' call y. ~(Note. This option copies se* or by se* or, Therefore> when theduplication is complete> any f iles previously st ored on t he<strong>de</strong>stinat ion disket t e wil l have been <strong>de</strong>stroyedi)


NCN-KKCMSXVE p MYALTY-FREE- LICENSE TO QSETHE RU~ M E @TEN ASBDCVLTED WITH THEI. Pug oseIn or<strong>de</strong>r t o peculate wi<strong>de</strong>spread use of the P ascal a cmputer l anguage o n<strong>ATARI</strong>e Bcme ~ t ers , At er i , I nc . ( At ar i ) w i l l grant a ~ x cl usive,royalty- free l iaense t o di st ribut e the Run-Time Systen associated wi t h t heAXARX Pasaal Language System ( Pascal ' ).Subject t o the condi tions st ated herein, At ar i wi l l grant t o the ori ginalpurchaser of P ascal ( ' L icensee ) a m n -exclu sive, r oyalt y -f ree l iaense t odi st ribut e th e Rm-Time System associated wi t h Pascal ( Run-Time Syst ~ ") .Licensee i s only authorised to di st ribute the 1 ' - Time System in an abject ao<strong>de</strong>form which i s i <strong>de</strong>nt i cal t o t he Run- Time System of Pascal ( APX p roductAPX-20102), and onl y in m njunctian with. and on the siane media (e.g. , diskett e)as applicat ion progrens <strong>de</strong>veloped by Licensee which require the RurrTime Systanfor th eir peeper operation. E xcept a s provi<strong>de</strong>d above, L icensee shall n ot u sear purImr t t o authorise any person t o use any of th e c opyrights, t ra<strong>de</strong>marks,service marks, ar t ra<strong>de</strong> nenes of At ar i wi thout At ar i ' s prior wri't ten consent .The Run-Time System consi st s of t he f ol lowi ng f i l es : <strong>PASCAL</strong>, NON,P ASLIB.ERI , FP LI B.ERL, GRSND.ERL. Thi s l i cense conveys r i ght s whi ch r el at es olel y t o these f ive (5) named f i l es . These f i l es are enco<strong>de</strong>d on the diskett ew hich is per t of Pascal .II I . The License TeanThi s l i cense wi l l r un for a t e rm af t h ree ( 3 ) y ears f rcen the d ate o fpurchase of Pascal. T wo ( 2) e xtensions, e ach far a duration of a ne ( 1) y ear,wil l be granted upon receipt of wr i t ten request f ra n Licensee. Requests fo rextension shoul d be submitted two (2 ) senths prior t o the expiration of t hethen current t enn.Li censee wi l l be <strong>de</strong>emed t o have accepted the t erms and condi t i ons ofthi s Agreement when he/she di st ributes t o an y t hir d part y a n appl icationprogram which incorporates the Run-one System licensed hereun<strong>de</strong>r.459(A1) 2/ 24/ 82


G . The val i d i t y , constr uct i o n an d per f ormance o f t h i s Agreement shal lbe governed by t he subst ant i v e l aw o f t h e St at e o f C a l i f or ni a and o f t heUnited St at es o f Amer i ca excl udi ng t hat body o f l aw r el at ed t o choi ce o f l aw.A ny ac t i on or pr oceedi ng brought t o enf or ce t he t erms o f t hi s Agreement shal lb e brought i n t he Count y o f Sant a Cl ar a , St at e o f Cal i f or ni a ( i f un<strong>de</strong>r St at el aw) or t he Nor t her n Di st r i c t o f Cal i f or ni a ( i f un<strong>de</strong>r Fe<strong>de</strong>r al l aw) .H . I n t he event o f any l egal proceeding between t he par t i es ar i si ng f r a nt hi s Agreement , t he pr evai l i ng par t y shal l be ent i t l ed t o r ecover , i n addi t i onto any ot he r r el i e f awar<strong>de</strong>d o r gr ant ed , i t s r easonabl e cost s and expenses ,incl udi ng at t orneys ' f ees , i ncur red i n t he pr oceedi ng .VI . S i f i c Di s k r a t i n S t ern Excl usi onThe l i cense gr ant ed her ei n does no t r el at e i n an y wa y t o t he <strong>ATARI</strong>®Disk Oper at i ng Sy stem, DOS I l . I nqui r i es r el at i ng t o such a l i cense shoul d bes ent t o :A t ar i , I nc .Hcme Ccmputer Di v i si on6 0 East Plumer i a Dr i veSan Jose, CA, 95134At t n : S o ft war e Acqui s i t i on GroupF or At ar i :A t ar i , I nc .1265 Bor regas Avenue Name: B ruc e W. I r v i n eP.o . Box 427 T i t l e : V . P. , HCD .Sof t war eSunnyval e , CA 94086Date:459(A3) 2/ 23/ 82


TABL E O F CONTENTSC H*PTER 1 :ATAR I PASCA L I NTRODUCT I ON AND OVERVI EWM an ua l O v e r v i e wS y s t e m Ov e r v i e w1 , 3 S y s t e m Re q u i r e me n t s1. 4 R u n - T i m e R e q u i r e me n t sA T*Rl Pa s ca l D i s t r i b u t i o n Di s k e t t e I n f or ma t i on43 2CH* PTER 2 : HOURI T O OPERAT E THE <strong>PASCAL</strong> L ANQU* QE <strong>SYSTEM</strong>2 . l C omp i l e . L i n k a n d Ru n a Sa mp l e P r o g r a m2 . 1 . 1 Comp i le S amp le P ro g ra m 772 1 . 2 L i n k Sa mp l e P r o g r a m2. 1, 3 R u n Sa mp I e P r o g r a m 1 12 2 C omp i l e r Op e r a t i o n2 , 2 , 1 I n v o c a t i o n a n d F i l e na me s 122 . 2 . 1. 1 D OS a n d QU I T O p t i o n s 122. 2 . l . 2 C omp i l e 122, 2 . 2 C omp i l a t i o n D a t a 132. 2 . 3 Comp x 1er Tog g les 142 . 2 . 3 . 1 E n t r g P o i n t R e c o r d Ge n e r a t i o n ( E ) 142 2 3 2 I n c l u d e F i l e s ( I ) 142 . 2 . 3 . 3 . St r i c t T y p e a n d P o r t a b i l i t y C h e c k i n g ( T i W) 142. 2 , 3 . 4 R un- Ti me Range Checki ng ( R) 1 52 . 2 , 3 . 5 R un - T i m e E x c e p t i o n C h e c k i n g ( X ) 1 52. 2 . 3 . 6 Li s t i n g C o n t r o l s ( L . P ) 1 52. 2 . 3 . 7 Summar y o f Comp i l er Tag g l es 162. 2 . 4 S u i I t - i n R o u t i n e s a n d I n c l u d e F i l e s 172 . 2 . 5 K r r o r M e s s a g e s 182. 2. 6 L i n e Nu mb e r s 182. 3 L i n k e r Op e r a t i o n 192 . 3 . 1 I n v o c a t i o n a n d Comma n d s 193 L i n k e r O p t i o n S w i t c h e s 192 . 3 . 2 . 1 R un - T i m e L i b r a r y S e a r c h ( / S ) 192. 3 . 2 . 2 M emor y Ma p ( / M) 192 , 3 2 3 L o a d Ma p ( / L ) a n d E x t e n d e d L o a d Ma p ( / E ) 192. 3 . 2 . 4 P r o g r a m ( / P ) a n d Da t a ( / D ) O r i g i n 2 05 C o n t i n u a t i o n L i n e s ( / C ) 2 02, 3 . 2 , 6 Li n k e r I n p u t Comman d F i l e ( / F ) 2 02. 3 . 2 . 7 L 1 n k er Sw i t c h Summa r g 2 12, 3 . 2 . 8 R e l o c a t a b l e F i l e Re q u i r e me n t s 2 12. 3 . 2 . 9 L i n k e r K r r o r Me s s a g e s 2 12, 3 . 2 . 10 At t r ib ut e s o 0 L i n ka b le M odule s 2 22. 4 O b j e c t P r o g r a m E x e c u t i o n 2 32 . 5 A T AR l P r o g r a m - T e x t E d i t o r ( M E D I T ) 2 42 . 5 . 1 R u n n i n g t h e A T AR I P r o g r a m - T e x t K d i t o r 2 4C HAPTER 3 :ATAR I <strong>PASCAL</strong> L ANGUAGE <strong>SYSTEM</strong> E XTENS I ONS


3 . 1 Nod u l a r Camp i 1 a t i on 2 63 , 2 D a t a A l l o c a t i o n a n d P a r a me t e r P a s s i n g2 93 , 2 1 Da t a Al 1 oca t i a n 2 9P a r a me t e r P a s s i n g 3 13. 3 P r o gr am Segmen t a t i on — Cha i n i n g 323 , 4 B u i l t - i n P r o c e d u r e s a n d P a r a me t e r s 3 43. 4 .' 1 N OVEi HOVER I GHT i NOVEL EF T 3 53. 4 . 2 EXI T 3 73. 4 . 3 TST B I T i SETB IT i CLR B I T 3 83. 4 . 4 SHR i SHL 3 93. 4 . 5 H I i L O i S W A P ­ 4 03. 4 . 6 ADDR 4 13. 4 . 7 S I ZEOF 4 23. 4 . 8 F I LLCHAR 433. 4 . 9 LENGTH 4 43. 4 . 10 CONCAT 4 53 . 4 . 1 1 COP Y 463. 4 . 12 POS 473. 4 . 13 DELETE 483. 4 . 14 INSERT 4 93. 4 . 15 ASSI GN 503. 4 . 16 WNBi QNB 5 13, 4 . 17 BLOCKRE*D. BLOCKWRITE 523. 4 . 18 OPEN 533. 4 . 19 CLOSE > CL OSEDEL 543 . 4 . 2 0 PURGE 5 53 , 4, 2 1 IORESUL T S63. 4. 22 H EHAVA I L . HA XAVA I L 573. 4 . 2 3 O u i c k R e f e r e n c e G u i d e t o B u i l t - i n s 583 . 5 N on- St andar d Da t a Ac c es s 5 93 . S. 1 ,Absol ut e Var i abl es 593. 6 INL I NE 6 03 . 6 . 1 S gn a x 6 03. 6 , 2 * pp 1i c a t i a n s 6 03 . 7 G r a p h i c s a n d S o un d Do c ume n t a t i o n 6 23 . 7 1 Scr ee n Ty pes 633. 7 . 2 Var i ab les 6 33. 7. 3 G r a p h i c P r o c e d u r e s a n d F u n c t i o n s 6 43 . 7 . 3 . 1 In i t i a 1 i ze P r o c e d u r e 6 43. 7 . 3 . 2 G r a p h i c P r o c e d u r e 6 43. 7 . 3 . 3 T e x t mo d e P r o c e d u r e 6 43. 7, 3. 4 S e t c o l o r P r o c e d u r e 6 43 . 7 . 3 . 5 C o l o r P r o c e d u r e 6 53. 7. 3. 6 P l o t P r o c e d u r e 6 53. 7 . 3 . 7 Loca t e Pr ace dur e 6 53. 7 . 3 . 8 P o s i t i o n P r o c e d u r e 6 53. 7 . 3 . 9 D r a ~ t a P r o c e d u r e 6 53. 7 , 3 . 10 F i l l P r o c e d u r e 6*3. 7 . 4 S o u n d P r o c e d u r e s a n d F u n c t i o n s 6 63 . 7 . 4 . 1 S o un d P r o c e d u r e 6 63. 7 . 4 . 2 S a u n d o f f P r o c e d u r e 6 63 . 7 . 5 C o n t r o l l e r F u n c t i o n s 6 63 . 7 . S. 1 Paddi es 6 73 . 7 . S. 1. 1 P addi e s F u n c t i on 6 7


3 7 5 1 2 T r i g g e r F u n c t i o n 6 73. 7 . 5 . 2 J o g s t i c k s 6 73 . 7 . 5 . 2 . 1 S t i c k F u n c t i o n 6 7CHAPTER 4 :RUN- T I M E ERROR HANDL I NQ4 . 1 R ange Ch ec k i n g 6 84. 2 E xc e p t i a n Ch ec k i n g 68U s e r S u pp l i e d Ha n d l e r s 6 94. 4 F a t a l E r r o r s 69CHAPTER 5 : STRUCTURE/ FORMAT OF A <strong>PASCAL</strong> PROGRAM 7 05 . 1 Data Tripes 7 0S , l . 1 CHAR 7 05 . 1 . 2 BOOLEAN 7 0$ . 1 . 3 INTEGER 7 15 . l . 4 REAL 7 1S. 1. 5 B y t e 7 15. 1. 6 W or d 7 15 , l . 7 S t r i n g 7 15 . 1. 7 . 1 Def i n i t i on 7 1S. l . 7 . 2 Ass i gnment 7 25. 1. 7 . 3 C omp a r i s o n s 7 45. 1. 7 . 4 Read ing an d Wr i ti ng Str i n gs 7 55 , 1 . 8 Set 7 5C GMPAT I 8 I L I T Y 7 66 . 1 I n c omp a t i b i l i t i e s w i t h UCSD P a s c a l 7 76. 2 Add i t i anal F e a t ur e s Av a i I ab 1 e Wi th * T ARI P ascal 7 8CHAPTER 7 :L ANGUAGE DEF I N I T 1GN7. 1 I n t r a d u c t i a n 8 07 S umma r y o f t h e A T AR I P a s c a l L a n g u a g e 8 17. 3 Natation, Termino lag g and Vocabulary 8 37 4 Id e n t i f i e r si N um be r s . a n d S t r i n g s 8 47 . 5 C o n s t a n t De f i n i t i o n s 8 57. 6 D a t a T g p e De f i n i t i a n s 8 67 . 6 . 1 Simpl e Types 8 67 . 6 . 1. 1 S c a l a r T y p e s 8 67. 6 . l . 2 St an dar d Ty pes 8 67 . 6 . 1 . 3 Subr a ng e Ty pes 8 67. 6 . 2 St r u c t ur e d Ty pes 8 67 . 6 , 2 . 1 Ar r a y T y pes 8 77. 6 . 2 . 2 R e c o r d T y p e s 8 87. 6 . 2 . 3 S e t T y p e s 8 87 . 6 . 2 4 Fi l e T y pes 8 97. 6 . 3 P a i n t e r T y p e s 8'97. 6 . 4 T ripes a n d As s i gnmen t Compa t i b i l i t y 9 0


7. 7 D e c l a r a t i o n a n d D e n o t a t i o n a 0 V a r i a b l e s 9 17 . 7 . 1 En t i r e Va r i ab l es 927. 7 . 2 C omp a n en t V a r i a b l e s 9 27 . 7 . 2 . 1 I n d e x e d V a r i a b l e s7. 7 . 2 . 2 F i e l d De s i g n a t a r s 9 27. 7 . 2 . 3 Fi l e S uff e rs 9 27. 7 . 3 R e f e r e n c e d V a r i a b l e s 9 27. 8 E x p r e s s i o n s 9 37 . B. 1 O per a t o r s 9 47 . 8 . l . 1 Th e Gp e r a t a r NGT 9 47 . 8 . 1 . 2 Mu I t i p 1 g i n g Op er a t o r s 9 47 . B. 1 . 3 A d d i n g Op e r a t a r s 9 47. 8 . 1. 4 R e l a t i o n a l Op e r a t o r s 9 47. B. 2 F u n c t i o n D e s i g n a t o r s 947. 9 S t a t e me n t s 9 57 . 9 . 1 S i m p l e S t a t e me n t s 9 57 . 9 . l . 1 A s s i g n me n t S t a t e me n t s 9 57. 9 . 1. 2 P r o c e d u r e S t a t eme n t s 9 67. 9 . 1. 3 Q GTO S t a t e me n t s 967. 9. 2 S t r u c t u r e d S t a t e me n t s 9 67 . 9 . 2 . 1 C amp o u n d S t a t e me n t s 967, 9. 2, 2 C on d i t i ona l S t a t eme n t s 9 67 . 9 . 2 . 2 . 1 I f S t a t emen t s 967. 9 . 2 . 2 , 2 C as e S t a t eme n t s 9 67. 9 . 2 . 3 R e p e t i t i v e S t a t eme n t s 9 77 . 9 . 2 . 3 1 W hi l e S t a t eme n t ­ 9 77. 9 , 2 . 3 . 2 R e p ea t S t a t e me n t s 977, 9 . 2 . 3 . 3 F OR St a t emen t s 9 77. 9 . 2 . 4 W i t h S t a t e me n t s 9 77. 10 P r o c e d u r e De c l a r a t i o n s 987 . 10 . 1 S t a n d a r d P r o c e d u r e s . 10 07 , 1 0 , 1 . 1 F i l e H a n d l i n g P r o c e d u r e s 1 0 07. 10 . 1. 2 D y n a mi c A l l o c a t i o n P r o c e d u r e s 1 0 17 . 10 . l . 3 D a t a T r a n s f e r P r o c e d u r e s 1 0 17. 10 . 2 FORWARD 1 0 17. 10 . 3 CGNFGRMANT ARRAYS 10 27 . 1 1 Functi on Decl ar at i ons 1 0 47 . 1 1 . 1 S t a n d a r d F u n c t i o n s 1047 . 1 1 . 1. 1 A r i t h m e t i c F u n c t i o n s 1 0 47 , 1 1. 1 . 2 P r e d i c a t e s 10 47. 1 1 . 1. 3 T r a n s f e r F u n c t i a n s 1 0 47 , i l . 1 . 4 F u r t h e r S t a n d a r d F u n c t i o n s 1 0 47. 12 INPVT AND OUTPUT 1 0 67 , 1 2 . 1 Th e P r o c e d u r e READ 1067. 12 . 2 Th e P r o c e d u r e READLN 10 67. 12 . 3 T h e P r o c e d u r e W R I T E 10 67 , 1 2 . 4 T h e P r o c e d u r e W R I T EL N 1 0 67 . 12 . 5 A d d i t i o n a l P r o c e d u r e s 1 0 67. 13 Pr o g r a ms 1 0 8


APPENDI X A :APPENDI X B :APPENDI X C. 'A PPEND I X D :APPENDI X E :APPEMDI X F :APPENDI X G :L ANGUAGE SYNTA X DESCRI P T I ONRESERVED NQRDSERROR MESSAGESA TAR l <strong>PASCAL</strong> F I L E I t OB I BLIQGRAPHYP L AYERt MI S S I L E DEMO PROGRAMH ELPFUL H I NT SINDEXTABt E OF F I GURESFi guv e 1- 1 S c he ma t i c D i a g' am o f * T A RI P a s r a l O pe r a t i o nF i g ur e D- iFi g u v e D -2 TF i g uv e D- 3F i l e I n pu t a n d Ou t pu te x t F i l e sLlv i t i n g t o a p v in t e v a n d n u m be r F o x mat t i n g


PREFACEP ASCA! — WHAT I S I T . "P a s c a l wa s c r e a t e d b g N i k l a u s W i r t h t o f a c i l i t a t e t e a c h i n g as y s t e m a t i c a p p r oa c h Co comp u t e r p r o g r ammi n g a n d p r o b l e m s o l v i n g . T h i sh i g h - l e v e l s t r u c t u r e d p r o g rammi n g l a n g ua g e i s s u i t e d f o r p r o f e s s i o n a ls o f t wa r e d e v e l o p e r s i m a k i n g i t a n e x c e l l e n t t o o l f o r d e v e l o p i n p a n dmai nt a i n i n g pr ograms.PURPOSE GF T H I S MANUALT h i s r e f e r e n c e a n d o p e r a t i on s ma n ua l d e f i n e s t h e l a n g ua g e f e a t u r e s o fA TAR I P a s c a l a n d c a n h e l p y o u C o u n d e r s t a n d ho w t o u s e t h e s e f e a t u r e s ,T h i s ma n ua l a s sume s f a m i l i a r i t y w i t h t h e J e n s e n a n d Wi r t h ' s " P a s c a lU se r M a n ua l a n d R e p o r t " a n d t o r I n t e r n a t i o n a l S t a n d a r d s Gr ga n z a t i o n( I SG ) d r a f t s t a n da r d ( DPS / 7 18 5 ) . T h e s t a n d a r d P a s c a l f e a t u r e s t h a td i f f e r i n * T* R I Pa s ca l f r om t hos e i n t h e s t andar d an d i n J ensen a n dW i r t h ' s " Rep or t " a r e d e s c r i b e d h e r e . T h i s ma n ua l a l s o c o n t a i n sin f or m a t i o n o n ho w t o o p e r a t e Ch e co mp i l e r a n d l i n k e r ) a d e s c r i p t i o no f t h e i m p lemen t a t i on o f <strong>ATARI</strong> Pa sca l da t a t y pes ; an d a summary ofb u i l t - i n f e a t u r e s a n d e xa mp l e s o f t h e i r u s a g e .AUDI ENCET h i s m a n u a l i s s p ec i f i c a l l q d e s i g n e d f o r a d v a n c e d p r o g rammer s wh oar e f a m i l i a r w i t h P a s c a l a n d wi t h t h e f e a t u r e s o f t h e ATAR I 8 0 0 HomeC omput e r S y s t em , T h i s ma n ua l i s n o t s u i t e d f o r l e a r n i n g Pa s c a l o r t h eA T*RI 80 0 Home Comput er .HGW TG US E T H I S MANUALW e r e commen d s t a r t i n g w i t h t h e I n t r o d u c t i o n a n d Ov e r v i e w


C HAP TER 1 :A TAR I <strong>PASCAL</strong> I NTRODVCT I ON AN D OVERVI EWT h i s m a n u a l d e s c r i b e s Ch e A T * R I P a s c a l L a n g u a g e S y s t e m b e i n g o f f e r e dth r o u g h t h e AT AR I P r o g r a m E x c h a n g e as a s o f t w ar e d e v e l o p ment t o o l f o rp r o f e s s i o n a l d e v e l o p e r s . A T AR I P a s c a l i s a p s e u d o - c o d e c o mp i l e r w h i c hs upp o r t s t h e I n t e r n a t i o na l St an da r d s Or ga n i z a t i o n ( I SO) d r a f t s t an da r d( DPS/ 7 18 5 a s o f I G / I / BO ) i n c l u d i n g v a r i an t r e c or ds > s e t s . t y pe d a n dte x t f i l e s . p a s s i n g p r o c e d u r e s a n d f u n c t i o n s as p a r a m et e r s . ( 'O TO o u to f a p r o c e d u re > . c o n f or ma n t a r r a y s a n d p r o g r a m p a r a me t e r s . A d d i t i o n st o t h e s t a n d a r d a v a i l a b l e i n * T AR I P a s c a l i n c l u d e :Ad d i t i o n a l p r e d e f i n e d s c a l a r s : BYTE. W ORD> S T R IN ('.O p e r a t o r s o n i n t e g e r s 0 ( a n d ) ~ ! ~ / ( o r ) > ~ ' ? ( NOT )E l s e o n CAS E s t a t e me n tNu 1 1 S t r i n g s*b so luCe Var i ab l esE x t e r na l p r o c ed ur e sA d d i t i o n a l b u i l t - i n p r o c e d u r e s a n d f u n c t i o n s :gr a p h i c s o u n d . a n d c o n t r o l l e r d e f i n i t i o n sr e a l a n d t r a n c e n d e n t a l d e f i n i t i o n sm ov e a n d f i l l p r o c e d u r e sb i t a n d b y t e m a n i p u l a t i o nf i l e m a n i p u l a t i o n p r o c e d u r e sh ea p ma n a geme n t a i d ss t r i n g ma n i p u l a t i ona d d r e s s a n d s i z e o f f u n c t i o n sfhodul a r comp i l a t i on f a c i l i t i e sI n a d d i t i o n > r u n - t i m e e r r o r h a n d l i n g p r o v i d e s f o r d i v i d e b g z e r oc h e ck ~ h e a p o v e r f l o w c h e c k > s t r i n g o v e r f l o w c h e c k > r a n g e c h e c k a n du s e r - s u pp l i e d e r r o r r o u t i n e s .A TAR I P a s c a l h a s b e e n d e s i g n e d f o r d a t a p r o c e s s i n g a p p l i c a t i o n sc o n s i s t i n g o f c o mp i l e r s > e d i t o r s > l i n k e r s . b u s i n e s s ~ a n d e n t e r t a i n me n tp a c k a g e s . I t i s d e s i g n e d t o o p e r a t e w i t h t h e AT AR I D i s k Op e r a t i n gS y s t e m 2 . ()S a n d i s c o mp a t i b l e w i t h t h e A T AR I P r o g r a m T e x t - K d i t o r C T N 3 .T h i s c h a p t e r p r e s e n t s a n o v e r v i e w o f t h i s m a n u a l > t h e s g s t e m a n dc o mp i l a t i o n a n d r u n - t i m e s g s t e m r e q u i r e me n t s > a n d i t d e s c r i b e s t h ef i l e s o n t h e d i s t r i b u t i o n d i s k e t t e s .B e c a u s e o f t h e a v a i l a b i l i t y o f m a n y t e x t b o o k s o n t h e P a s c a lp r o g r a m mi n g l a n g u a g e > t h i s d o c umen t i s n o t a t u t o r i a l b u t r a t h e r ar e f e r en c e man ua l a n d a d e t a i l e d d e s c r i p t i o n o f t h e e x t en s i on s a n da d d i t i o n s t h a t m a k e A T * R I P a s c a l u n i q u e . R e f e r t o t h e b i b l i o g r a p h y f o ra d d i t i o n a l r e f e r e n c e m a t e r i a l s .


I . 1 ma n u a l Ov e r v i e wT h e f o l l o w i n g p r o v i d e s a b r i e f o v e r v i e w o f e a c h c h a p t e r c o n t a i n e d i nth i s m anua l.C ha p t e v 1 : T h i s c h a p t e r i n t r o d u c e s a n d o u t l i n e s t h e f e a t u r e s o f AT AR IP a s c a l . p r o v i d e s a n o v e r v i e w o f t h e s y s t e m a n d i d e n t i f i e st ' h e s y s t e m r eq,u i r e me n t s ,C haptev' 2 : T h i s c ha pt e r g e t s y o u s t a r t ed . I t d e s c r i be s t h eo p t i o n s o f t h e c omp i l e v a n d l i n k e r a n d i t pv e s e n t ss t ep- bg- s t ep i n s t r uc t i on s t o compil er s l i nks and vun asample pv ogv'am.C ha p t e r 3 : T h i s c h a p t e r d e s c v i b e s t h e e x t e n s i o n s t o ATAR I P a s c a l . I tp r e s e n t s s u c h f e a t u v e s a s mo d u l a v c o mp i l a t i o n i b u i l t - i npv'oceduv es i g v'ap hie s an d s o u nd e x te ns i ons,Cha p t e r 0 ; T h i s c h a p t e r b r i e f l g s umma r i z e s o fh a n d l i n g r o u t i n e s .t h e r u n - t i m e e r r o v'Cha p t e v 5 : T h i s c h a p t e r d e s c r i b e s t h e s t v u c t u r e o f a p v og r a m g e n e r a t e db g t h e c o mp i l e v . D a t a s t ov a g e i s a l s o d i s c u s s e d i n t h i sc h ap t e r .C ha p t e v 6 : T h i s c ha p t e r b r i e f l y compar e s AT* R I Pa s ca l a n d UCSD Pa s c a lC ha p t ev ' 7 : T h i s c h a p t e r d e f i n e s t h e l a n g u a g e f e a t u r e s o f AT AR I P a s c a l .A ppen d i x * : A comp l e t e d e s c r i p t i o n o f t h e l a n g ua g e s y n t a xA p p e n d i x 8 : T h e v e s ev v e d w o r d s l i s tA ppen d i x C : * comp l e t e d e s c v i p t i o n o f ea c h comp i l a t i o n e v v ormessageA p p e n d i x D : AT AR I P a s c a l F i l e I / OA p p e n d i x E : A b i b l i o g r a p h y o f a d d i t i o n a l r e a d i n g s u g g e s t i o n sAppend i x F : P l a g er/ Mi ss i le Demo P ro g v amA ppendi x 0 : Hel p f ul Hi n t s


I. 2 S y s t e m O ve r v i e wThe <strong>ATARI</strong> Pa s c a l L a nguag e Sy s t em c on t a i n s t h e Pa s ca l moni t or edcompi l er s l i n k e r i r u n - t i m e s u b ro u t i n e l i b r a r y a nd i n t e r p r e t e r. F i g u r eI - I shows a d i a gr am of t he r el at i onshi p among t hese pr oduc t s .R e f e r e n c e t o t h e * T AR I P r o g r a m- T e x t E d i t o r ( AP X- 2 0 0 7 S ) h a s b e e ni n c l u<strong>de</strong>d t o s how i t s r e l a t i on s h i p t o AT* R I Pa s c a l .e ~TEXT E D I T OR ~i+ +VS our c eP r o g r amf i l eIIV+ > t emp or ar y wo r k f i l eCOMP ILERI e r r o r m e s s a g e f i l e+ +II tV + - — - - - - > r e l o c a t a b l e f i l e r u n - t i m e l i b r a r yl i s t i n g f i l eIIIVL I NKERIIVVe xec u t a b l e p r o g r amtVINTERPRETERF i g u r e l - lS c he ma t i c D i a g r a m o f AT AR I P a s c a l Op e r a t i o nT h e <strong>ATARI</strong> Pr o gra m- Te x t E d i t o r ma y b e u s e d t o c r e a t e an d mo di f y t h eP a s c a l s o u r c e p r o g r a m. T h e c o mp i l e r i s u s e d t o t r a n s l a t e t h e s o u r c ep r o g r a m i n t o r e l o c a t a b l e m a c h i n e c o d e . T h e u s e r t h e n l i n k s t h i sm ach i n e c od e wi t h t h e r u n - t i m e s u br o u t i n e l i b r a r y t o p r o d uc e a nex e c u t a b l e o b j e c t p r o g r a m.l . 3S y s t e m Re q u i r e me n t sT h e * T * R I P a s c a l L a n g u a g e S y s t e m r e q u i r e s t h e ATAR I 8 0 0 w i t h 4 8 K o fR AN a n d t w o A T * R I 8 1 0 D i s k D r i v e s . T h e AT AR I 8 2 5 8 0 - C o l um n P r i n t e r a n dt h e * T AR I 8 5 0 I n t e r f a c e N o d u l e a r e o p t i o n a l , A T AR I P a s c a l a l s o


e q u i r e s t h e * TARI Pr o g ra m- Te x t E d i t or . When us i n g A T*R I P as c al i n oc a r t r i d g e s h o u l d b e i n s e r t e d i n t h e c a r t r i d g e s l o t .1 . 4 Run- Ti me Requ i r emen t sThe <strong>ATARI</strong> Pa s ca l Language Sys t e m g ene ra t e s p r o g r ams t h at u s e a v a r i e t yo f r u n - t i m e s u p p o r t s u b r o u t i n e s t h a t a r e e x t r a c t e d f r o m PASL I B i t h er u n - t i m e l i b r a r g i a n d o t h e r r e l o c a t a b l e mo d u l e s , T h e s e r u n - t i mero u t i ne s ha n d l e s uc h n e ed- as "m u l t i p l y " a n d " d i v i d e" a n d f i l e i n p utan d o u t p u t i n t e r f a c e t o t h e Op e r a t i n g S y s t e m.1. 5 <strong>ATARI</strong> Pa s c a l D i s t r i b u t i o n D i s k e t t e I n f o rm a t i o nT h e AT AR I P a s c a l L a n g u a g e S y s t e m i s d i s t r i b u t e d o n d i s k e t t e sc omp a t i b l e w i t h t h e AT AR I S i O D i s k D r i v e . T h e s y s t e m c o n s i s t s o f t w od i s k e t t e s c o n t a i n i n g o b g e c t i s o u r c e a n d r e l o c a t a b l e f i l e s . L i s t e dh e l o t a r » t h e n a me s o f e a c h f i l e a n d a b r i e f d e s c r i p t i o n o f t h e i rc o n t e n t s .D i s k e t t e 1<strong>PASCAL</strong>/ LI NKERF i l e Co n t e n t sDOS. SYSDUP. SYS* TARI D i s k Op er a t i n g Sy s t emAT*R I Dis k Gp erat i n g Sg st em<strong>PASCAL</strong> i n t e r p r e t e r u s e d t o e x e c u t e a l 1 P a s c a l a b ge c t p r o g r a ms .P a s c a l mo n i t o r l o a d e d b g t h e <strong>PASCAL</strong> f i l e i p r o v i d i n g t h em en u t o s p e c i f y t h e d e s i r e d o p e r a t i o n : c o mp i l e l i n k e d i to r r u 'n .L i NK P a s c a l l i n k e r u s e d t o t a k e r e l o c a t a b l e f i l e s ( . E RL ) a n dr u n - t i m e l i b r a r y f i l e s a s i n p u t t o c r e a t e o b j e c t f i l e s( . CON ) ,Pa s c a l l i n k e r p a r t t a o .P ASLI B. ERLRu n - t i m e s u br o u t i n e 1 i b r ar g i n r e l ocat abl e f or m . Sh o u l da luau s b e 1 in k ed l a s t .FPL I B. ERl R u n - t i m e s u p p o r t r o u t i n e s f o r f l o a t i n g p o i n t a r i t h m e t i ca n d t r a n s c e n d e n t a l f u n c t i o n s .QRSND. ERL R u n - t i m e s u p p o r t r o u t i n e s f o r g r a p h i c s o u n d a n dco n t r o l l e r f unc t i o n s .CALC. PAS Th i s i s t h e s o u r c e f i l e f o r t h e P a s c a l d emo p r o g r a m.


D i s k e t t e 2P a s c a 1 Comp i l e rF i l e C o n t e n t sPHO P h a s e 0 o f t h e P a s c a l c o mp i l e r u s e d f o r s y n t a x s c a n a n dc r e a t i o n o f t o ke n f i l e ,PH1 P h a s e 1 o f t h e P a s c a l c o m p i l e r u s e d t o c r e a t e t h ep er ma n e n t s y mb o l t a b l e s a n d b u i l d t h e u s e r s y mb o l s .P has e 2 o f t h e Pa s ca l comp i l e r c o n t a i n i n g c od e g en er a t i oni n i t i a l i za t i on .P h a s e 3 o f t h e P a s c a l c o mp i l e r u s e d t o c r e a t e t h er e l o c a t a b l e o b gee t c o d e f i l e .P h a s e 4 o f t h e P a s c a l c o mp i l e r u s e d t o c d mp l e t e t h e o b j e c tc od e gener a t i o nE RRORS. TX T F i l e c on t a i n i n g ATASC I l t e x t f o r e r r o r me s s ag e s .GSPROCSFL TPROCSMQYEST h i s f i l e i s t h e i n c l ud e f i l e c o n t a i n i n g g r a p h i c ~ s o un da n d c o n t r o l l e r <strong>de</strong> f i n i t i on s .T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g r e a l n u mb e r a n dtr a n sc end en t a 1 f u n c t i o n <strong>de</strong>c 1 ar a t i o n s .T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g d e c l a r a t i o n s f o rc h a r a c t e r a r r a y s .9 I TPROCS T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g d e c l a r a t i o n s f o rb i t m a n i p u l a t i o n r o u t i n e s .HEAPSTVFDSKPROCSSTDPROCSISQPROCSSTRPRQCST h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g d e c l a r a t i o n s f o rh ea p p r o c ed ur e s ,T h i s f i l e i s t h e i n c l ud e f i l e c o n t a i n i n g f i l e ma n i p u l a t i onp r o c e d ur e s .T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g s t a n d a r d P a s c a lr o u t i n e s i n c l u d i n g t h e f l o a t i n g p o i n t r o u t i n e s ,T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g I S O s t a n d a r dP a s c a l r o u t i n e s e x c l u d i n g f l o a t i n g p o i n t r o u t i n e s .T h i s f i l e i s t h e i n c l u d e f i l e c o n t a i n i n g s t r i n g p r o c e s s i n gp r oced ur e s a n d f unc t i on s .


CHAPTER 2 : HOW TQ OPERAT E THE P* SCA I L ANGVAGE <strong>SYSTEM</strong>T h i s c h a p t e r d e s c r i b e s h o w t o u s e t h e A T * B I P a s c a l L a n g u a g e S y s t e mc o n t a i n e d o n t h e <strong>PASCAL</strong> / L I NKER a n d P a s c a l Comp i l e r d i s k e t t e s .c over s t h e f o 1 lo vin g i n f orm at i o n:Sec t i o n 1 p r o v i <strong>de</strong> s s t e p- b g - s t e p i n s t r u c t i on s o n how to c ompi l e >l i n k an d r u n a sa mp l e pr o gr amS e c t i o n 2 d e s c r i be s t h e comp i l e r an d i t s o p t i o n s .S e c t i o n 3 d e s c r i b e s t h e l i n k e r a n d i t s o p t i o n s .Se c t i o n 4 d e s cr i be s hour t o r u n a n o b j ec t pr ogr am.S ec t i o n 5 d e s c r i be s t h e AT* RI Pr o g r am T e x t - E d i t o r .


2 . 1 Comp i l e L i n k an d Ru n a Sampl e Pr o gr amBe f o r e c o m pi l i n g a n d r u n n i n g t h e s a m pl e p r o g r a m d e s c r i b e d i n t h i ss e c t i on ~ ma k e a ba c ku p c op y o f al l d i s k e t t e s i n c l u <strong>de</strong> d i n t h i spac ka ge .2. l . 1 Comp i l e Samp l e Pr ogr amSt e p On eP l a c e t h e <strong>PASCAL</strong> / L I NKER d i s k e t t e i n t o d i s k d r i v e 1 a n d b o o t t h e D i s kO per a t i n g Sy s t em 2 . QS. Then us e o p t i o n C t o c op y t h e samp l ec a l c u l a t i o n p r o g r a m " CAt C. PAS " t o a b l a n k d i s k e t t e o n d i s k d r i v e 2 .A t t h i s t i m e u s e t h e L o p t i o n t o l o a d t h e F i l e n a me d " PASC* L " f r o md i s k d1 i v e 1 T h e P a s c a l me n u w i l l t h e n a p p e a r .<strong>ATARI</strong> P a s c a lV e r s i o n 1 . ( ) : I - M a r - 8 2( c ) 198 2 b y * T*R IE ) d i tL ) i n kD ) o sC ) ompi l eR ) u n( l ) u i tSt e p TwoEnt e r l et t e r a n d CRETURN3:Respon d t o t h e Pa s ca l men u d i s p l aye d o n t h e s c r ee n w i t h t h e command"C " CRETURN3 t o beg i n comp i l a t i on .4lhe n p r o mp t e d f o r y o u r s o u r c e f i l e n a me s t y p e " D2 : CALC. PAS " CRETURN3Th e mo n i t o r w i l l t h e n p r o mp t y o u fo r a t o k e n a n d c o d e f i l e n a m e.R e s p on d w i t h f RETURN 3 f o r e a c h .A me s s a g e w i l l t h e n b e d i s p l a y e d " Ch a n g e D l t o c o m p i l e r d i s k . " * t t h i sti m e p l a c e t h e P a s c a l Co mp i l e r ( d i s k e t t e 2) i n t o d i s k d r i v e i m a k es u r e t h e s a mp l e p r o g r a m " CALC. PAS " i s i n d i s k d r i v e 2 a n d t h e n p r e s sC RETURN 3 .Th e c o mp i l e r w i l l b e l o a d e d i n t o memor y a n d p r o mp t y o u t o c h o o s e ali s t i n g d e v i c e . R e s p on d " P : " ( p r i n t e r ) ~ "E : " (s c r e e n ) i o l C RETURN3(n o l i s t i .n g )T h e c o mp i l e r w i l l p r o c e e d t o d i s p l a y t h e f o l l o w i n g c o mp i l a t i o ns t a t i s t i c s .Loa d i n g Comp l i erA TAR I P a s c a lV e r s i o n 1 . 0 — I - K a r - 8 2( c ) 19 8 2 b y A TAR I


Syn t a x Sc anCr ea t i ng : D2 ; CALC. TOKL i s t i n g f i l e s P ; o r E :% ret ur n > f a r n oneF i l e d o e s n o t c o n t a i n l i n e n u mb e r s0 > . . . . . . . , . . . . .In c l u d i n g T e x t f r a m F i l e : D l : STDPRQCS14>3 2 )64>96>128>E n d o f P h a s e 0S our c e l i n e s p r a c e s s ed : 1 3 2( s gn t a x f t o ke n f i l e g en er a t i o n )L a a d i n g P h a s eOpen as in p u t : D 2: CAl C. TOKOpen as ou t p u t : D 2: C*L C. ERLAva i l ab I e M emor g; 4 3 8 7 - ( t o t a l sy mbo l t a b l e s pa c e )U ser Ta bl e Spa ce : 3 2 6 4 ( a f t e r p r e d e f i n e d s y mb o l s )V er s i o n i . 0 Phas e 14 8 8 4 8 (a n e 8 f o r e a c h r o u t i n e b o d y )R ema i n i n g Memor g 2 10 0 ( a f t e r u s e r s y mb o l s )V e r s i o n i . Oi P h a s e 2S UBREA L 1 8A DDREA L 4 3T F 6 4 (d e c i ma l o f f s e t f r o m b e g i n n i n g )C AL C 1 1 9M ENU9 1 SCALCULATE x t e r n a l :TRVNCE xternal : SQRTE xternal : S I NE x t e r n a l : ROUNDE x t e r n a l :OUTPUTE xternal : L Nx t er n a l :I NPVTE xternal : EXPE x t e r n a l :COSE x t e r n a l :ARCTANL i n e s 130Er r o r s .' 0C o d e 1 7 3 7D at a 6 4REPLACE D i THEN ( p l a c e d i s k e t t e 1 PASCA L / t I NKER )T yp e ~ r e t ur n > t o c o n t i n ue (i n d i s k d r i v e i i t h e n p r e s s CRETVRN3M i n u t e s l a t e r .


T h e s y s t e m w i l 1 p r o mp t y o u t o " REPLACE D i T HEN T y p e TRETVRN I t oco n t i n u e . " A t t h i s t i m e r e mov e t h e P a s c a l Co mp i l e r f r o m d i s k dr i v e 1an d i n s er t t h e <strong>PASCAL</strong> / L i NKER i n d i s k d r i v e 1 t h e n p r e s s 1 'R ETVRNIT h e c o m p i l a t i o n p r o c e s s w i l l t h e n b e c o mp l e t e d a n d t h e P a s c a l me n uw i l l d i s p l a y ,N OTE ; I f t h e c o mp i l e r f a i l s t o c o m p l e t e c o mp i l a t i o n . c h e c k t o s e e i fth e d i s k e t t e s a r e i n t h e p r oper d r i v es . I f t h e y a r e t r y , I f b o t h o f t h e s e a t t e mp t s f a i l i t h e o n l y r e c o u r s e i s t o t u r no f f y o u r c o mp u t e r a n d t u r n i t o n a g a i n .2 . 1. 2 L i n k Sa mp l e P r o g r a mS t e p On eT o c r e a t e t h e r e l o c a t a b l e o b g e c t f i l e , r e s p o n d t o t h e P a s c a l me n u w i t ht h e comma n d " t " CRETVRN I t o b e g i n t h e l i n k i n g p r o c e s s . * t t h i s t i methe f ol lowi ng wi l l be displayed.L o a d i n g L i n k e rwhen L I NKER pr ompt s w i t h " + " e n t ery o u r . ERL f i l e na me s s e p a r a t e d b gc omma s e n d i n g w i t h PAS L I B / STh e n t y p e CRETURNILI NKER V 1 . ()4lhen p r omp t e d f o r y o u r f i l e n ame b g a n a s t e r i s k ( + ) i y o u d o n ' t n e e d t ou s e a n e x t e n s i o n ( . ERL ) b u t y o u mu s t u s e t h e d e v i c e p r e f i x " D2 : " .Th e P a s c a l li b r a r y r o u t i n e s m us t t h e n b e l i n k e d a l o n g w i t h y o u rpr o gram.A t t h i s t i m e r e s p o n d t o t h e f i l e n ame p r o mp t w i t h t h e f o l l o w i n g :D2 : CA( Cs FPLI B r PASLI B / S C RETURNIN OTE : T h i s p r o g r a m ma y b e u s e d a s a n e xa mp l e o f u s i n g t h e F l o a t i n gP o i n t L i b r a r y ( F P L I B ) r o u t i n e s .T h e l i n k e r w i l l t h e n d i s p l a y t h e f o l l o w i n g s t a t i s t i c s a n d p r i n t" L I NK COMPL ET E TYP E CRETURNI " .D2: C*LC. ERL D1: FPL I 8 , ERL Di : P* SL I H. ERL -C IF5GH>U n<strong>de</strong>f i ned Symbol s— N o V n <strong>de</strong> f i n e d Sq mb o 1 s


ii 4 0 5 b y t e s mv i t t e n t o D2 : CALC. CONT o t a l Da t aT o t a l C o d eR emai n i n gO OBEH by t es2 8CEH b y t e s1 4 42 H b y t e sLi n k comp 1 et c t yp e CRETVRN3A t t h i s t i m e pv' es s CRETVRN3 an d t h e <strong>PASCAL</strong> men u e i 1 1 d i s p l a y .


2 . 1. 3 R u n Sa mp l e P r o g r a mT o r u n t h e s a mp l e p r o g r a m r e s p o n d t o t h e P a s c a l m e n u w i t h t h e comma n d"R " t h e n CRETURN 1 t o r u n t h e o b j e c t p r o g r a m.Y o u w i l lf o l lowing:D2 : CALC. CONt h e n b e p r o mp t e d f o r t h e f i l e n ame a n d s h o u l d ~ e s p on d w i t h t h eT h e c a l c u l a t i o n p r o g r a m w i l l b e g i n e x e c u t i o n d i s p l a y i n g t h e me s s a g e"ENTER FI RST OPERAND> " Tr y t h i s exampl e Fo r a d d i n g 5. 5 t o 9 9. 25 6.F i r s t r e s p on d w i t h " 5 . 5 " t h e n CRETURN1 . T h e me s s a g e " R 1 = 5 . 5 0 0 E+ 0 0 "s h o u l d b e d i s p l a g e d f o l l o we d b g " ENTER SECOND OPERAND'7" . R e s p on d w i t h" 9 9 . 2 5 6 " t h e n CRETURN1 . T h e me s s a g e " R 2 = 9 . 9 2 5 6 0 E + 1 " s h o u l d b edi s p l aye d f o l l owe d b g "ENTER OPERATOR; " f o l l owe d b g a l i s t o fo p e r a t o r s . R e s p o n d w i t h t h e o p e r a t o r " + " t h e n CRETURN1 . T h e r e s u l t"104. 756 " s h ou l d t he n b e d i s p l ay ed . Yo u s h o u l d now p r es s t h e CESCAPE3ke g t o r et ur n t o t h e DOS menu .Y o u h a v e n o w c o mp l e t e d t h e c omp i l a t i on e l i n k i n g a n d r u n n i n g o f g o u t'f i r s t <strong>ATARI</strong> Pa s ca l p r o g r am!


2 . 2 Comp i l e r Op er a t i on2. 2 . 1 I n v o c a t i o n a n d Fi 1e n am esT h e A TAR I P a s c a l L a n g u a g e S y s t e m i s e x e c u t e d u n d e r t h e A TAR I D i s kO p e r a t i n g S y s t e m ( DQS 2 . 0 8 ) . T o e x e c u t e t h e c o mp i l e r s p l a c e t h eP ASCAL / t I NKK R ( d i s k e t t e 1 ) i n d i s k d r i v e 1 a n d L OA D t h e f i l e c a l l e d<strong>PASCAL</strong> f r am t h e D QS m en u . T h i s f i l e i s t h e P a s c a l in t e r p r e t e r a n d w i l 1a utoma t i c a l l y c a l 1 t h e Pa s ca l m a n i t o r w i t h a f i l ename a f NON. T h em on i t o r t h e n d i s p l a y s t h e f o l l o w i n g me n u .* TARI Pa s ca lV e r s i o n 1 . 0 : 1- Ma r - 8 2(c ) 198 2 b y <strong>ATARI</strong>K) d 1't C ) omp i l eL ) i n kR) unD ) a sG ) u i tE n t e r l e t t e r a n d CRETURN3 :S e l e c t t h e f i r s t c h a r a c t e r o f t h e d e s i r e d f u n c t i o n a n d e n t e rc h a r a c t e r f a l l o we d b y a CRETURN ] ,t h i s2 . 2 . 1. 1 DQ S a n d G U I T Qp t i o n sT h e "DOS " a n d " GU17 " op e r a t i o n a l l ow s y a u t a e x i t t h e Pa s ca l men u a n dret ur n t o t h e *TARI Di s k Oper at i ng Sy stem.2 , 2, 1. 2 Comp i l eW he n y a u s e l e c t " C " f o r " Comp i l e . " t h e ma n i t o r w i l l r e q u e s t y a ut a e n t e r t h r e e f i l e n a me s a n d t h e n l o a d t h e c amp l i e r . T h e f i r s tr e q u e s t i s f o r t h e s o u r c e f i l e n a me . Y o u ma y t h e n r e s p a n d w i t h t h ef i l e n ame p r e f i x ( D2 : ) t a i d e n t i f y t h e d e v i c e . t h e i n p u t f i l e n a me i a n dth e e x t e n s i o n . PAS. Th e Comp i l e f u n c t i o n t he n r e ques t s t h e name f art h e t o k e n a n d c o d e f i l e s , l f t h e r e i s s u f f i c i e n t r o o m o n t h e d i s k e t t ec on t a i n i n g t h e s o ur c e f i l e y a u ma y r e s pon d b y s i m p l y d e p r e s s i n gCRKTURN3 i n r e s p ons e t o t h e s e r e que s t s . I f . t h er e i s n o t s u f f i c i entr o a m y a u ma y s p e c i f y t h a t t h e s e f i l e s b e p l a c e d o n s e p a r a t e d i s k e t t e sb y s p e c i f y i n g t h e F UL L f i l e n a me a s d e s i r e d . NOTE : N o n e o f t h eC amp i l e r f il e s may b e c a s s e t t e b as e d.A me s s a g e w i l l t h e n b e d i s p l a y e d " C h a n g e D 1 ,t o c omp i l e r d i s k , " A t t h i st i m e p l a c e t h e P a s c a l Co mp i l e r ( d i s k e t t e 2 ) i n d i s k d r i v e l i p l a c e t h edi s k e t t e c a n t a i n i n g y o u r s o u r c e p r o g r a m i n d i s k dr i v e 2 t h e n p r e s sCRETURN3. AT* R I Pa s c a l t he n c r e a t e s a r el ocat ab l e f i l e "'"name>. ERLw h i c h mu s t b e l i n k e d w i t h t h e P a s c a l l i n k e r t o t h e r o u t i n e s i n t h er u n - t i m e l i b l a r y ( PASt I B ) .


2 . 2 . 2 Co mp i l a t i o n Da t aT h e AT* R i Pa s c a l comp i l e r w i l l p e r i o d i c a l l y d i sp l a g c ha r a c t er s d u r i n gt h e f i r s t t w o p h a s e s o f t h e c o mp i l a t i o n ( P h a s e 0 a n d P h a s e i ) .* p e r i o d ( . ) w i l l b e d i s p l a y e d o n t h e c o n s o l e f o r e v e r g s o u r c e c o d el i n e s y n t a x s c a n n e d d u r i n g P h a s e 0 . A t t h e b e g i n n i n g o f P h a s e l i t h ea v a i l a b l e me mo r g s p a c e i s d i s p l a y e d . T h i s i s t h e nu mb e r o f b y t e s ( i nd e c i m a l ) o f memo r y b e f o r e g e n e r a t i o n o f t h e s y mb o l t a b l e ,A ppr o xi ma t e l g l K o f t h e symbo l t a b l e s pa c e i s c o nsumed b g pr e - d e f i n e did e n t i f i e r s . W h e n a p r o c e d u r e o r F u n c t i o n i s f o u n d i a p o u n d s i g n ( 0 )w i l l b e d i s p l a y e d o n t h e c o n s o l e . A t t h e c o mp l e t i o n o f P h a s e 1 ~ t h en umber o f b y t e s rema i n i n g i n memor y i s d i s p l aye d i n d e ci m a l ,P h a s e 2 g e n e r a t e s o b j e c t c o d e . N h e n t h e b o d y o f e a c h p r o c e d u r e i se n c o u n t e r e d t h e n a me o f t h e p r o c e d u r e i s d i s p l a y e d s o t h a t y o uc a n s e e w h e r e t h e c o mp i l e r i s i n t h e c o mp i l a t i o n o f t h e p r o g r a m , T h el i n k e r t N


2. 2. 3 Comp i l e r Tog g l es4 c o mp i l e r t o g g l e ma y b e i n c l u d e d i n t h e s o u r c e p r o g r a m t o s i g n a l t h ec o mp i l e r t h a t y o u w i s h t o e n a b l e o r d i s a b l e c e r t a i n o p t i o n s . T h ef or ma t o f t h i s t o g g l e i s ( + e e ) wh e r e th e b l a n k s ar e f i l l e d i nw i t h t h e t o g g l e . Th e comp i l e r d oe s n o t a c c ep t b l a n k s b e f or e t h e kegl e t t e r o r t r a i l i n g o r i mb e d d e d b l a n k s i n na me s b u t w i l l s k i p o v e rle a d i n g b l a n k s ) e. g. ~ ( ~ 4 E + e ) i s t h e s a m e a s ( a@Ewe ) i b u t t h e ( e % E+ + ) w i l l b e i g n o r e d .Examp l e s:(a 4 E+%)( ~ 4 P « )( e 4 I D: USERF I L E . L I S e )2 . 2 . 3 . 1 E n t r y P o i n t R e c o r d Ge n e r a t i o n ( E )% E+ a n d SE - c o n t r o l t h e g e n e r a t i o n o f e n t r y p o i n t r e c o r d s i n t h er e l o c a t a b l e f i l e . 4 E + c a u s e s t h e g l o b a l v a r i a b l e s a n d a l l p r o c e d u r e sa n d f u n c t i o n s t o b e a v a i l a b l e a s e n t r y p o i n t s ( i . e. i a v a i l a b l e t o b er e f e r en c e d b g EXTERNAL d e c l a r a t i on s i n o t he r mo d u l e s ) , 4E - s upt es s e st h e g e n e r a t i o n o f t h e s e r e c o r d s t h u s c a u s i n g t h e v a r i a b l e s ip r o c e d u r e s . a n d f u n c t i o n s t o b e l o g i c a l l y p r i v a t e . T h e d e f a u l t s t a t ei s SE+ an d t h e t ogg l e ma g b e t u r n e d o n an d of f a t w i l l .2 . 2 . 3 2 I n c l u d e F i l e s ( I )% I< f i l ename> c a us e s t h e comp i l e r t o i n c l ud e t h e name d f i l e i n t h es e q u e n c e o f P a s c a l s o u r c e s t a t e me n t s . F i l e na me s p e c i f i c a t i o n i n c l u d e sd r i v e n a me a n d e x t e n s i o n i n s t a n d a r d f o r m a t .T h e f or ma ti s a s f o 1 1 ows:( a S I Dn : XXXXXXX' )o r(e S I Dn : XXXXXXX. PAS» )wh e r e n i s t h e d i s k d r i v e n u mb erwh e r e XXXXXXX i s t h e I n c l u d e f i l e n a meU s i n g t h e s e s t a n d a r d I n c l ud e f i l e p r o c e d u r e s a s e xa mp1 es i y o u ma yc r e a t e I n c l u d e f i l e s t o b e u s e d d u r i n g t h e c o m p i l a t i o n p r o c e s s .2 . 2 . 3 . 3 S t r i c t T y p e a n d P o r t a b i l i t y C h e c k i n g ( T . 4 )fT + . ST - . 4 41 +. a n d %14- c o n t r o l t h e s t r i c t t y p e c h e c k i n g / n o n - p o r t a b l ewa r n i n g f a c i l i t y . T h e s e f e a t u r e s a r e t i g h t l g c o u p l e d < i . e. s t r i c t t y p ec h e c k i n g i m p l i e s w a r n i n g n o n - p o r t a b l e u s a g e a n d v i c e v e r s a ) . T h ed e f a u l t s t a t e i s %T - (% W- ) i n w h i c h t y p e c h e c k i n g i s r e l a x e d a n dwa r n i n g me s s a g ~ s a r e n o t g e n e r a t e d . T h i s m ag b e t u r n e d o n a n d o f ft h r o u g h o u t t h e s o u r c e c o d e a s d e s i r e d . 4 u s e o f n o n - s t a n d a r d l o g i can d / o r b u i l t - i n r o u t i n e s wi 1 1 c a u s e e r r o r 5 0 0 t o b e . g e n e r a t e d , T h i ser r o r i s n o t f a t a l b u t s e r v e s a s a w a r n i n g t o t h e p r o g r a mmer . C o d e


g e n er a t e d w i t h e r r a r 5 0 0 d u r ' i n g t h e c o mp i l a t i o n w i l lp r' o p e r' 1 g .s t i l 1 e x e c u t e2 . 2. 3. 4 Ru n - t i m e Ra ng e Ch ec k i n g ( R )C R+ an d 4R - c o n t r.o l t h e compi l e r ' s g ener'a t i on o f r.u n- t i m e c ad e wh i c hw i l l p e r f o r m r a n g e c h e c k i n g a n a r r a y s u b s c r i p t i n g a n d s t o r i n g i n t as ubr'ang e v a r' i a b l es . Th e d e f a u l t s t a t e i s 4R - < o f f ) an d t h i s t o g g l e ma ybe t u r n e d a n a n d o f f t h r o u g h o u t t h e s a u r c e c a d e as d e s i r e d .2 . 2. 3. 5 Ru n - t i m e E xce p t i o n Check i n g


2 . 2 . 3 . 7 Summa r y o f Co mp i l e r T o g g l e sL i s t e d b e l ow i s a summar y o f av a i l a bl e comp i l e r t o gg l e s :Comp i l e r Tog g lesDefaul t%E + / ­ C o n t r o l s e n t r y p o i n t g e n e r a t i o n4I < name>I n c l u <strong>de</strong> s a n o t he r s o u r c e f i l e i n t o t h ein p u t s t r e a m (e . g . < »4 1 X XX. L I B » )C on t r o l s r a ng e c h e c k i n g c o d e% T + / ­% W + / ­ C o n t r o l s s t r i c t t y p e c h e c k i n g a n d g e n e r a t i o no f w a r n i n g me s s a g e sC on t r o l s e x c e p t i o n c h e c k i n g c o d eE n t e r a f o r m f e e d i n t h e . PRN f i l eCon t r o l s t h e l i s t i n g o f s o u r c e c o<strong>de</strong>


2 . 2 . 4 B u i l t - i n R o u t i n e s a n d I n c l u d e F i l e sT h e * T* R I Pa s ca l compi l e r c o n t a i n s o n l y t h e l o g i c n e c e s s a r y f ord e f i n i n g " m a g i c " p r e - d e f i n e d p r o c e d u r e s i f u n c t i o n s a n d v a r i a b l e s .T h e s e a r e s u c h r o u t i n e s a s REA D W R I TE i ADDR i S I ZEQF i e t c . w h i c hre q u i r e i n - l i n e c o d e g e n e r a t i o n b g t h e c o mp i l e r or r e q u i r e s u p p o r t f o ra v a r i a b l e n u mbe r o f p a r a m e t e r s .Al 1 o t he r r o u t i n e s a r e <strong>de</strong> f i n e d us i n g a s p e c i a l k e g ~o rd " PREDEFIN ED"a n d t ~ o s pec i a l t y pe s * NYTVPE an d * NYF I LE , Yo u mus t i n c l ud e i nt h e s o u r c e p r o g r a m d e c l a r a t i o n s f o r t h e s e r o u t i n e s . T h i s i s n o r m a l l yd o n e u s i n g t h e S I t o g g l e t o i n c l u d e ST DPROCS a n d o t h e r s i m i l a r f i l e s .STDPRQCS con t a i n s '<strong>de</strong>c l ar a t i ons fo r p r o c e du re s a n d f u n c t i o ns d ef i n ed b gt h e I SQ s t a n d a r d f o r P a s c a l . A d d i t i o n a l f i l e s c o n t a i n d e c l a r a t i o n s f o rpr o c e d u r e s a n d f u n c t i o n s w h i c h a r e e x t e n s i o n s t o t h e I S O s t a n d a r d s u c has s t r i n g r o u t i n e s i AS S I G N. I Q RESVLT e t c . Y ou m ay e d i t S TDPRQCSan d t h e s e f i l e s t o c o n t a i n o n l y t h e r o u t i n e s n e c e s s a r y f o r a g i v e npr o gram,T h i s m e t h o d o f d e f i n i n g b u i l t - i n r o u t i n e s i s p r e s e n t b e c a u s e t h e ATAR I8 0 0 Home Co mp u t e r h a s l i m i t e d me mo r y f o r a l l . t h e d e c l a r a t i o n s a n d u s e rsymb o l s u s e d i n comp i l i n g l a r g e pr o g r ams ,


2 , 2 . 5 E r r o r M e s s a g e sGamp i l a t i on er r o rs a r e n umbere d i n t h e s ame s e quence a n d m ean i n g a st h o s e i n J e n s e n a n d W i r t h ' s " U s e r M a n u a l a n d R e p o r t " T h e e r r o rm es s a g e s i b r i e f e x p l a n a t i o n s a n d s o m e c a u s e s o f t h e e r r o r a r e f o u n di n Ap pen d i x C.Er r or 40 7 ~ S ymbol T ab le O ve r f l o w: O c c u rs i n P hase I w hen n o t e n o u ghs ymbo l t a b l e s pa c e rema i n s f o r t h e c u r r en t sy mb o l . T h i s ma y b ea ) l e v i a t e d b g b r e a k i n g t h e p r o g r a m i n t o mo d u l e s .2 . 2. 6 L i n e Number sATAR I P a s c a l a l l ow s l i n e n u mber s. W h e n l i n e n u m be r s a r e d e s i r e d t h ef i r s t l i n e o f t h e p r o g r a m s our c e f i l e mus t c o n t a i n a nume r i c v a l u e .t h e n a s s u me s a l l l i n e s c o n t a i n l i n e n u mb e r s a n d t h e l i n e n u mb e r mu s ts t a r t i n c o l umn on e . L i n e number s ma y b e o f a n y l e n g t h an d i t s h o u l db e n o t e d t h a t t h e y a r e i g n o r e d b g t h e c omp i l e r .


2 . 3 L i n k e r Op e r a t i o n2 . 3 . i I n v o c a t i o n a n d Command sLI NK i s u s e d b g e x e c u t i n g t h e l i n k e r f r om t h e Mo n i t o r , E n t e r ' L ' f v ' omt h e P a s c a l men u f a l l owe d b g CRETURN 3 a n d t h e l i n k e r w i l l l o a d . T h eli n ke r w i l l t he n pv amp t t h e usev. f a r t h e name a f t h e ma i n pv ogr am andm odu l e s t a b e l i n k e d . s e pa v a t e d b g comma s . T h e o u t pu t i s d i r e c t e d t oth e same di s ke t t e a s t h e ma i n pr ogvam un l es s ga u speci f y a n out putf i l e name f o l l awed bg a n eaua l s i gn bef or e t h e ma i n pv agvam name.Example:C ALC. FPL I 8 / S . PASL I B/ SD 2 : CALC=CALC. FPL IB ~ PASL I B/ S ( CALC. CON i s wv i t t e n t a D2 ; )Th e a b av e comman d w i l l li n k a n e o f t h e d emo p v ag ra ms w i t h t h e r u n - t i m epa c ka ge . T h e i t e m s t o b e l i n ke d ma y b e pv e c e <strong>de</strong> d b g a d i s k dv iv e d e v i c eprefix:'D 2 : CALCi Df : FPL I B D l : PASL I B / S2, 3. 2 L i n ke r Op t i on Swi t c hesT h e l i n ke r l e t s e a u t o p l a c e a numbe r o f " s w i t c h e s " f a l l o w i n g t h e f i l en a me s i n t h e l i s t , E a c h s w i t c h i s p r e c e <strong>de</strong> d b g a s l a s h ( / ) a n d i s as i n g l e l e t t e v . T h e r e i s a p a r a m e t e v a n t h e / P a n d / D s ~ i t c h e s .2 . 3 . 2 i R u n - t i m e L i bv a r g S e a r c h ( / S )T h e e xamp l e s a b a v e s how t h e u s e a f t h e / S s w i t c h wh i c h ' comma nd s t h el i n ke r t a s e a r c h t h e p r e v i o u s l y na me d r e l o c a t a b l e fi l e t s PAS L I B . a s al i b r a r y a n d e x t r a c t o n l y t h e n e c e s s a r y mo d u l e s . T h e / S s w i t c he x t r a c t s mo d u l e s o n l y f r o m l i b r a v i e s a n d d o e s n o t e x t v a c t pv oc e d u r e sa n d ' f u n c t i on s f v om s e pa r a t e l g comp i l e d ma d u l e s . I t i s p o s i t i ond e p en d en t i n t ha t i t m u s t f a 1 ) ow t h e na me o f t h e r u n - t i m e 1 i bv a r g i nt h e l i nk ev' comman d l i n e a s i n t h e e xamp l e s a b o v e . P * S L I B i s as pe c i a l 1() c o n s t u c t e d , s e a r c ha b l e l i b r a r y . O t he r . ERL f i l e s s u pp l i,e dw i t h t h e sy st e m un l es s ex p l ie i t l g s pe c i f i ed , av e no t s e ar chabl e .U s e r - c r e a t e d mo d u l e s a v' e n o t s eav c ha b l e . T h e a r <strong>de</strong> v o r " ma d u l e s w i t h i na l i b r a r y i s i mpov t a n t .E a c h s eav c ha b l e 1 i bv av g mus t c o n t a i n r o u t i n e s i n t h e c o r r e c t o r <strong>de</strong> r a n db e f o l l owe d b g / S f o r s e av c h i n g t o o c cuv' . l f / 8 i s n o t s p ec i f i e d t h ee n t i r e c o n t e n t s o f t h e l i b r a r y i s l o a d e d.2 . 3 . 2 . 2 Me mar () Ma p ( / M >A / M f o l l o w i n g t h e l a s t f i l e n am ed i n t h e p av am et e r l i s t g e n e r a t e s am ap t o t he; s c r e e n .2 . 3 . 2 , 3 L oa d Ma p ( / L > a n d E x t e n <strong>de</strong> d L oa d Ma p ( / E )


A / L f o l l o w i n g t h e l a s t mo d u l e n a me d c a u s e s t h e l i n k e v t a d i s p l a ym od u l e c a d e a n d d a t a l o c a t i o n s a s t h e y a r e b e i n g l i n k e d , A / Efa l l o w i n g t h e l a s t m o d u l e wo v' k s as a m ad i f i e v C a / N a n d / L a n d c a u s e st h e l i n k e r t o d i s p l a y a l l r o u t i n e s i n c l u d i n g t h o s e b e g i n n i n g w i t hor 8. w h i c h a r e v es e r v e d f o r r u n - t i m e 1 i b v ar y r o u t i n e n a m es .2 . 3 . 2 . 4 P r o gv a m ( / P ) a n d Da t a ( / D ) Or i g i nT a s u p p o r t r e l o c a t i o n o f a b j e c t c o d e a n d d a t a a r e a s i t h e l i n k e vs u p p av t s t h e / P a n d / D s w i t c h e s . T h e / P s w i t c h c o n t v a l s t h e l o c a t i a na f t h e o b g ec t a r e a (RON ) a n d t h e / D s w i t c h c o n t r o l s . t h e l o c a t i o n a ft h e d a t a a r e a ( RA N ) . T h e s y n Ca x i s ; / P : n n n n o v / D : n n n n ~ h e r e " n n n n " i sa h e x a d e c i ma l n u mb e r i n t h e r a n g e 0 . . . FF F F .In a d d i t i o n i i f y o u s p e c i f y /D i t h e l i n k ev' w i l 1 n o t s a v e a n y o f t h »d a t a av e a i n t h e . CON f i l e . T h i s i s a g a o d wa y f o v r e d u c i n g t h e d a t as t o v a g e a n d i s k e t t e f o v p v o g r a ms . s i n c e o n l y t h e c o d e w i l l b e l o a d e dfv am d i s k e t t e a n d n o t u n i n i t i a l i z e d d a t a a v eas . N a t e t h a t l o c a l f i l ea per'a t i on s a v' e na t g uav an t ee d i f t h i s i s u s e d b e c a us e t h e s y s t em<strong>de</strong> p e n d s o n t h e l i n k e r z e r o i n g t h e d a t a a r e a t o ma k e C h i - f a c i l i t y wo v kpv oper 1 y.A l s o i f / D i s u s e d i m a r e s p a c e i s g a i n e d i n t h e l i n k i n g pv o c e s sbe c a u s e t h e d a t a i s n o t i n t e r mi x e d w i t h t h e c o d e as i t i s b e i n gl i n k e d . U s i n g t h i s s w i t c h i s t h e f i r s t ' wa y t a s o l v e a n d " a u t o fmemo r y " me s s a g e s d i s p l a y e d by t h e l i n k e r ,U s i n g t h e / P s w i t c h a n d / D s w i t c h d o e s n a t c a u s e t h e l i n k e v t o l e a v ee mpt y s pa c e a t t h e b e g i n n i n g a f t h e . CON f i l e . T h e p h i l a s aph y o f t h el i n k e r i s t h a t i f Ch e / P s w i t c h i s u s e d i y o u r e a l l y w a n t t a mo v e t h ep v' ag v'a m t o a n a t h e v s y s t e m f o v ' e x e c u t i a n . T h i s me a n s t h a t i f y o us p e c i f y / P: 8000 . t h e f i r s t b y t e o f t h e . CON f i l e w i l l b e p l a c e d a tlo c a t i o n 8 0 0 0 H a n d n o t 3 2 K a f z e r o s b e f o v e t h e f i v ' s t b y t e . I na d d i t i on . i f y o u s p e c i f y / D t h e l i n ke r w i l l n o t s a v e an y a f t h e d a t aav ea i n t h e . CON f i l e . T h i s i s a g o a d w ay f a v r e d u c i n g t h e d a t ast o r a g e o n d i s k e t t e f o r pv agrams s i n c e o n l y t h e c ad e w i l l b e l o a d edfr o m a di s k e t t e a n d n o t u n i n i t i a l i z e d d a t a a r e a s .Th e s w i t c h e s / P an d / D a v e s p e c i f i e d a f t e r tl o a d e d a n d ma y b e i n a n y o v ' d e r .h e l a s t r o u t i n e t o , be2 . 3 . 2 . 5 C a n t i n u a t i a n L i n e s ( / C )a l i n e n e e d s t a b e c o n t i n u e d e n t e r / C a f t e v t h e l a s t c ha v' a e t e r o nt h e l i n e be f or e pv es s i n g t h e CRETURN3 k e y .2 . 3 . 2 . 6 L i n k e v I n p u t Comman d F i l e ( / F )Th e l i n k e r l e t s y o u e n t e v d a t a i n t o a f i l e a n d h a v e t h e 1 i n k e v p v a c e s st h e f i l e n a me s f r a m t' h e f i l e . Yo u s p e c i f y a f i l e w i t h a n e x t e n s i o n o f. CND a n d f o l l a w t h i s f i l e n a me w i t h a /F ( e , g . i C F I L E S / F ) . T h e l i n k e rw i l l r e a d i n p u t f r a m t h i s f i l e a n d p v ' ac e s s t h e n a me s g u s t a s i f t h e yw ev' e t y p e d f v ' o m t h e c o mp u t e r k e y b o a r d . I f t h e f i l e c o n t a i n s mav e t h a no n e l i n e . y o u mu s t u s e / C a f t e r e a c h 1i n c , I f y o u w i s h t o v e t u r n t o2 0


C h e c o mp u t e r c o n s o l e f o r m o r e i n p u t y o u ma y p l a c e / C o n Ch e l a s t l i n ei n t h e f i l e , D a t a o n t h e command l i n e f o l l o wi n g t h e / F i s i g n o r ed . A. CND f i l e ma y n o t c o n t a i n a l i n e c o n t a i n i n g / F .2 . 3 . 2 . 7 L i n k e r S w i t c h Summa r ySe a r c h p r e c e e d i n g n a me as a li b r a r y e x t r a c t i n g o n l y t h er e q u i r e d r o u t i n e s ./ L L i s t mo d u l e s a s t he y a r e b e i n g l i n k ed .Li s t al l e n t r g p o i n t s i n t a b u l a r f or m.Li s t e n t r y p o i n t s b e g i n n i n g w i t h S i 7 o r 0 i n a d d i t i o n t oo t h e r e n t r y p o i n t s ./ P : n n nn Re l o c a t e o b j e c t c o d e t o n n n n H./ D; n n n n Re l o c a t e d a t a a r e a t o n n n n H.Ta k e pr ec ee d i n g f i l e name as a , CND f i l e c o n t a i n i n g f i l en ame s ( s e e a b ov e f o r s y n t a x ) .C o n t i n u a t i o n L i n e s2 . 3. 2. 8 Re 1 oca t ab l e F i l e Requ i r emen t sT h e d i s t r i b u t i o n d i s k e t t e s c o n t a i n s e v e r a l . ERL f i l e s t h a t mu s t b el i n ke d i n t o t h e p r o gr a m T h e pa r t i c u l a r f i l e s d epen d o n wha t g r ou p ofr o u t i n e s t h e c o mp i l e r m u s t r e f e r e n c e i b a s e d o n t h e c o n t e n t s o f y o u rpr o g r am. B e l ow is a l i s t o f e a c h f i l e a n d t h e r o u t i n e s i t c o n t a i n s . I fgo u h a v e a n y o f t h e s e r o u t i n e s as a n u n d e f i n e d r e f e r e n c e i t h e n l i n kt h e a p p r o p r i a t e r e l o c a t a b l e f i l e t o r e s o l v e t h e u n d e f i n e d r e f e r e n c e .FPL I B F l o a t i n g p o i n t r eal numbers 8 X GP. A RRL. 8 NRL < sca r c hah 1 e )P * SL I B Compa r i s ons i I / O , a r i t hm e t i c s u pp o r t s e t c ,Q RSND Q r a p h i c s i s o u n d . a n d c o n t r o l l e r s s u p p o r t2 . 3 . 2 . 9 L i n k e r E r r o r Me s s a g e sT h e l i n k e r a l l ow s u p Co f o r t g n a me s o n t h e c omma n d l i n e ( o r c omma n df i l e i n p u t ) f o r f i l e s t o b e l i n k e d .E r r o r s e n c o u n t e r e d i n t h e l i n k i n g p r o c e s s a r e u s u a l l ys e l f - e x p l a n a t o r g . s u c h a s " u n a b l e Co o p e n i n p u t f i l e : x x x x x x x x " a n d" Du p l i c a t e s y mb o l - x x x x x x x . " D u p l i c a t e s y mb o l me a n s t h a t a r u n - t i mer o u t i n e o r v a r i a b l e a n d u s e r r o u t i n e o r v a r i a b l e h a v e t h e s a me na me .V n d e f i n e d r e f e r e n c e i n d i c a t e s t h e a p p r o p r i a t e r e l o c a t a b l e f i l e h a s n o tb e e n i n c l u d e d . R e f e r t o Ch e p r e c e e d i n g p a r a g r a p h o n R e l o c a t a b l e F i l eR e q u i r e me n t s .


I f g o u r u n o u t o f me mo r y w h i l e l i n k i n g y o u ma y r e mo v e t h e d a t a f r o mt h e c o d e s p a c e w i t h t h e / D s w i t c h Y o u ma y n e e d t o r u n a t e s t l i n kw i t h t h e / D s w i t c h s e t v e r y h i g h t o f i n d o u t w h a t t h e c o d e s i z e i s it h e n r e l i n k w i t h t h e / D s w i t c h s e t g u s t a b o v e t h e l a s t c o d e a d d r e s si t h s ome r o o m f o r c o d e e x p a n s i o n ) .2 , 3. 2, l O A t t r i b u t e s o f s i nk abl e Nodul esT h e l i n k e r w i l l . b i n d t o g e t h e r A T AR I P a s c a l m a i n p r o g r a ms . A t a r i P a s c a lm odul es i a n d as sembl y l a n guag e mo d u l e s c r e a t e d b g a n a p pr o p r i a t ea ssembler .


2. 4 Ob g ec t P ro g ra m E x ec ut io nO nc e t h e s o u r c e p r o g r a m ha s b e e n s u c c e s s f u l l y c o mp i l e d a n d l i n k e d w i t ht h e a p p r o p r i a t e r u n - t i m e l i b r a r i e s y o u ma y e x e c u t e o r " R u n " t h epr o gram.l 4he n y o u s e l e c t " R " f o r Ru n f r o m t h e P a s c a l m e n u i y o u w i l l t h e n b ea s ke d f o r t h e o b j ec t f i l ename t o r un .E xamp l e :D2 : CALC. CGAT h e o b j e c t p r o g r a m w i l l t h e n b e l o a d e d i n t o memo r y a n d e x e c u t e d .


2 . S A T * R I P r o g r a m - T e x t E d i t o r ( MED I T >T h e AT AR I Pv agv'a m T e x t K d i t o v i s a v ev s a t i l e t o o l t h a t c a n b e u s e d t ac v' c a t e a n d mo d i f y s ou v' c e p r o g r a m s wv i t t e n i n AT AR I P a s c a l . T h i sp r o d u c t ma y b e o r d e r e d t h r o u g h t h e AT AR I P r o g r a m K x c h a n g e ( AP X- 2 0 0 7 5 )o v ma y b e p u v c h a s e d w i t h t h e AT AR I M a c r o * s s e mb l e r ( C XB i 2 i )2 . 5 . i R u n n i n g t h e A T * R I P r o g r a m - T e x t E d i t o rT h e P a s c a l me n u p r o v i d e s a n o p t i o n o f c a l l i n g t h e * T AR I Pv a g va m- T e x tE d i t o v . T h e d e f a u l t v a l u e a f t h i s o p t i o n i s d i s k d v i v e 2 . Pv i o r t ou s i n g t h i s o p t i o n y o u mus t f i r s t m a k e t h e f a l l o w i n g mo d i f i c a t i o n s .I > Co p y ME DI T f v ' o m t h e d i s t r i b u t i o n d i s k e t t e t a a b l an kd i s k d r i v e 2 .d i s k e t t e o n2 ) 4 a a d D2 : MEDI T f r a m t h e DOS me n u u s i n g t h e " / N " o p t i o n t o p v' e v e n t i tfv om r u n n i n g ( t h i s w i l l v eq u i r e t h e t emp or av y pr e s enc e a f MEM. SAVw hi c h ca n b e d e l e t e d a f t ev war d s ) .3) Sav e i t b a c k f r am DOS as f o l l o w s: D 2: MEDIT /A > 2 * 0 0' 2 6 0 i .T h i s a p p e n d o p e r a t i o n t e l l s t h e " P a s c a l " p r a gv am p o i n t e r t o b e g i ne xec u t i o n a t t h e MEDI T en t r y p o i n t .N o t e : T h e a p p en d o p e r a t i o n ma y a l s o b e u s e d t o r u n a n y a s s e mb l yl a ng uag e f i l e f r om Pa s c a l . Th e f i l e mus t b e a p pen <strong>de</strong> d w i t h t h e s t a r tad d v ess a n d s t a r t a d d r e s s p l u s a n e . I f t h e f i l e c o n s i s t s o f m a n yd i s c a n n e c t e d mo d u l e s s c a t t e r e d t h r a u g h o u t t h e p r o g r a ms ma k e su v' et h e a ppen <strong>de</strong> d s t a r t a d dr es s u s e d i s t h e r u n - t i m e e n t r y p o i n t .


CHAPTER 3 :A T * R I <strong>PASCAL</strong> L ANQVAQE <strong>SYSTEM</strong> E XTENS I ONST h i s c ha p t e r d e s c r i be s t h e f u n c t i o n en d us e a f <strong>ATARI</strong> Pa s c a le xt en s i on s ,I t c ov er s t h e f a l l ow i n g a r ea s :3. 1 Na d u l e r Camp i l et i on3 . 2 D a t a * l l a c e t i o n e n d Pe r+met e r Pe s s i n g3 . 3 P r o g r e m Segmen t e t i a n — Cha i n i n g3 . 4 B u i l t - i n P r o c e d u r e s3 . S Na n - S t en <strong>de</strong>r d Da t a Ac c es s3. 6 I m bed<strong>de</strong>d Assembl y Ca<strong>de</strong>3 . 7 Q r a p h i c s en d So un d E x t e n s i on s


3 , 1 M o d u l a r (:omp i l a t i onAT4RI Pa s ca l s u pp o r t s a fl e x i b l e m od u l a r c ompi l a t i o n s y s t e m.Pr o y r ams ma y b e d e v e l o pe d i n a mono l i t h i c f a s h i o n u n t i l t he y ' b e c omet o o l a r g e t o ma nag e ( o r comp i l e ) an d t he n s p l i t i n t o mo d u l e s a t t h a tti me . Th e AT* RI Pas c al mod u l a r c ompi l a t i o n s y s t e m a l l o ws f u l 1 ac cesst o pr o c ed ur e s a n d v a r i a b l e s i n a n y mo d u l e f r om an y o t he r mo d u l e . 4comp i l e r t o g g l e i s pr o v i d ed to a l l o w y o u t o " h i d e " ( i . e. ma k e p r i v a t e )an y gr ou p o f v a r i a b l e s o r p r o c ed ur es . See s e c t i o n 2 . 2. 3. 1 f o r adi s c u s s i o n o f t h e 4E t o g g l e .The s t r u c t ur e of a mod u l e i s s i m i l a r t o t h at o f a pr o g r a m. I t b e g i n swi t h t h e r' es er v ed word MODULE> f o l l o wed b g a n i d e n t i f ie r' a n dsemi - c o l o n


modul ~ / pro g ra m. E x t e rn a l s m ay o n l y b e d e c l a r e d a t t h e g l o b a l(o u t er mo s t ) l e v e l o0 a p r o g ra m o r m od u l e .Jus t as i n v a r i a b l e d e c l a r a t i o ns i t h e * T ARI P as c a l ' l a n g uage r e q u i r e s()ou -t o. make s ur e -t h'e numba r -an d t y pe o0 p ar amet e r s., m atc h e x ac t l y a n dth e r e t ur ne d t y p e ma t c he s e xa c t l y fo r f u n c t i o n s i b e c a u se t h e c omp il e ran d l i n ke r d o n o t ha v e t h'» a b i l i t y t o t ((p e c h ec k ac r o ss m odu l e s .Ext er na l r o u t i n e s ma y NOT hav e pr o c edur e s an d f u n c t i on s as p a r a m ete r s .Not e t ha t i n <strong>ATARI</strong> Pa s ca l e x t er na l na me s a r e s i g n i f i c a n t o n l y t o s e v enc ha r a c t er s an d n o t e i g h t . Whe n i n t e r f a c i n g t o a s semb l y - l a ngua ge s l i m i tt he l en gt h o0 i <strong>de</strong>n t i f i er s access i b l e b g assembl y l anguage t o si xc ha r a c t e r s .Li s t e d b e l o w a r e a ma i n p ro g r a m s k ~ l eto n a nd a m odul e s k e l e t o n. T hemai n pr o g r am r e f e r enc es . va r i a b l e s a n d s ub pr o g r ams i n t h e mo d u l e. . andth e mod u l e r e f e r en ce s v a r i a b l e s an d s ub pr o grams i n t h e ma i n p r o gr am.Th e on l y di d ' f e r en ce s b e t ween a ma i n p ro g r a m a nd a m od u l e a r » t h at a tth e b e g i n n i n g oW a ma i n p r o g ra m t h er ~ ar e 1 6 b y t e s o f . hea<strong>de</strong>r c o d ean d a m ai n p r o g ra m b o d() f o l l o wi n g t h » p r o c e du re s a n d 0 u n c t i o n s .M ai n Pr o g r am Kxamp l e :PROGRAM KXTKRNAL DEMO'VARIi 4 : I NTEQER~ ( + AVAI LABLE I N OTHER MODVLES + )K . L : KXTERNAL I NTEQERi ( + LOCATED ELSEWHERE + )K XTKRNAL PROCEDURE SORT (VAR 8: L I ST ) LEN: I NTKQER) 'EXTKRNAL FUNCTI ONI QTEST: I NTEGER)P ROCEDURE PROC I >BEGINIF I OTKST I THEN( » CALL AN EXTERNAL FVNC NORMALLY + )END>BEGI NS ORT ( . . . . ) (( + CAL L A N E XTERNAL PROC NORMALL Y + )END.MODULE MODUS E DEMOlM odul e E xamp l e : (Not e t h es e a r e s epar a t e W i l e s )


l a b e l s c on s t ~ t y p e d e c l a r a t i on s >I ~ J : E XTERNAL I NTKCER i ( » USE THOSE FROM t1AI N PROORAN » )Kr L: I N TKQKRJ ( » DEFI NE THESK HERE » 3EXTERNAL PROCEDURE PROC1) ( » USK THK ONE FROM THK HA I N PROC » )P ROCEDURE SORT ( . . . ) ) ( » DEFI NE SORT HKRK + )FUNCTION I OTEST: I NTEGERS ( » DEFI NE I OTKST HERE » )< maybe o t he r p r oc ed ur e i a n d f un c t i on s h er e>NODEND.


3 . 2 D a t a A l l o c a t i o n an d Pa ramet e~ Pa s s i n g3 . 2. 1 D a t a A l l o c a t i o nIn add i t i on t o ac c ess ing v ar i a b les b y name> you m ust k no lv hornv a r i a b l e s a r e a l l o c a t e d i n memor y . Se c t i o n 5 . 1 d i s c u s se s t h e s t o r a gea l l o c a t i o n an d f or ma t o f ea c h b u i l t - i n s c a l a r d a t a t y pe . V a r i a b l e sal l o c a t e d i n t h ~ QLOBAL d at a. ,a re a a r ~ al l o c at e d e s s e n t i a l l y s h e enher e. However> va r i a b l e s i n a n i d entd f i e r l i s t b efo re a ty pe (e . g. ~ 4 >8 > C : IN TKQKR) ar e al l o c a t e d i n r e ve rs e o r d er ( i . e. > C F i r s t .f o l l owi n g . b y B . F o l l owe d b y 4 ) .K xamp l e :* INTEQER>8 CH*R >'I ~ J> K BYTE>L INTEQKR >STORAQE LAYOVT:+0 A LSB+1 A MSB+ 2 B+ 3 K+4 J+5 I+6 L L SB+7 L NSBS t r u c t u r e d d a t a t y p es : ARRAYs RECORDs an d SET s r e q u i r e a d d i t i o n a le x p l a n a t i on . * R R* Ys a r e s t or e d i n RQQ ma yo r o r d er . Fo r e xamp l e4; ARRAY Cl . . 3> 1.. 3] Q F C HAR i .s s t o r e d a s :+ 0 A C l > 1 3+1 AC1. 2 )+ 2 * Cl> 3 3+3 A C2> 13w 4 A C2 . 2 3+5 * C2> 33+6 A C3> 1 )+7 AC 3> 23+8 A C3 > 33Th i s is lo g i c a l l y a o ne -d im ens i o nal a r r a y o f v e c t o r s . I n * T ARI P as c a la l l a r r a y s a r e l o g i c a l l y o n e d i me n s i ona l a r r a y s o f some o t he r t y p e .RECORDs ar e s t o r e d i n t h e same ma nner as g lo b al v a r i a b le s.


SKTs a r e a l wa y s s t o r ed as 3 2 b g t e i t e ms. E ac h e l e ment o f t h e s e t i sst or ed' es one b i t . S KTs ar e b y t e - o r i e n t e d a nd t h e l o w o r d er b i t o feac h b y t e i s t h e f i r s t b i t i n t ha t b y t e o f t h e s e t . Shown b e l our is t h es e t ' O ' . . ' Z ' :Byt e number00 0 1 0 2 0 3 O e 0 5 0 6 0 7 OS OV o a OS OC OD OE OF 10 . . . 1F00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FK FF FF 0 7 0 0 0 0 0 0 0 0 0 0 . . . 00T he f i r s t b i t i s b i t 6 5 ( % 4 1 ) a n d i s f o un d i n b y t e S < b i t 1 . Th e l a s tb i t i s b i t 9 0 an d i s f o un d i n b y t e 11 . b i t 2 . l n t h i s d i c u s s i o n b i t 0is t h e l e a st s i g n i f i c a nt b i t i n t h e b y t e .3 0


3 . 2. 2 Pa r amet e r Pa s s i n gW hen c a l l i n g a n. a s semb l y , l a ng uag e r a u t i n e f r om <strong>ATARI</strong> .Pas ca l o r c a l l i n ya n <strong>ATARI</strong> Pa s da l r a u t i n e f r'om a s semb l y l a n g uage s p a r ame t e r s a r e p a s s edon 't h e s t a c'k . Th e pa r amet e r p a s s i n g . s t a c k i n <strong>ATARI</strong> , Pascal i s . d i f f e r e nttha n t h e 6 50 2 h a r dwar e s t a c k . T h i s so f t w ar e it a c k is at . l o c a t i o ns 4 600thr ough 46FF i n memory . Th e hardwar e X r egi s t e r mus t b e saved andre s t o r e d d u r i n g e x ec u t i o n o f a s semb l y l a nguag e r o u t i n e s an d i s u s edt h e p o i n t er - t o t h e s o f t w a r e s t a c k . Ya u ma y l oa d t h e t o p o f t h e s t a c kus i n g " LDA 0600 ~,X i e t c . U pon e n t r y t o t h e r o u t i n ei t h e t o p o f t h eh a r dwar e s t a c k c o n t a i n s t h e r e t ur n a d dr e s s . O n t h e s o f t war e s t a c k sin r e v e r s e or d er ) h e . <strong>de</strong>c la r e s ia ni ( Ac,.B: IN TEGERS C: CHAR) ~ w ou l d r e s u l ti n C on t o p 'a f B o n t o p a f A . Ea c h pa ramet e r r e q u i r e s- a t l e a s t o n e16- b i t WORD i 0 s t a c k s p a r e . A c ha r a c t e r o r b o o l ea n i s pa s sed a s a16 bi t wo r d w i t h a h i g h o r d er b y t e o f 0 0. V AR p a r a met e rs a r e p a s s e d b ya d dr e ss., Th e a d dr e i s r e p r es en t s t h e b y t e a f t h e v a r i a b l e w i t h t h el owest ' memor y a d dr e s s .N on- s c a l a r p a r ame t er s ( e x c l u d i n g SETs ) a r e a l wa y s pa s s e d b y a d dr e s s .If t h e p a r ame t e r i s a v a L ue p ar amet e r t h en c o <strong>de</strong> i s g e ne ra t e d b y t h ecomp i l e r i n a' P as cal r a u t i n e t o m ove t h e d a t a . S KT p ar amet e rs a r epa s s e d ' b y v a l u e a n t h » s t a c k an d t he n t h e i n t er p r e t er is u s e d t o s t o r ethem.Th e e xamp l e ' b e l o w s hows a ty p i c a l p a r a mete r l i s t a t e n t r y t o aprocedure:PROCEDURE DEMO ( I i J : I NTEGER) V * R 8 : ST RI NOi C. D: CHAR) iA T ENTRY STACK' ( 4600 i X) :+0 DB YTK OF 0 0+2 C+3 B YTK OF 0 0+a ADDRESS OF ACTUAL STRI NC+$ *DDRESS OF ACTUAL STRI NG+6 J ( LSB )+7 J ( NSB )+ 8 I ( L SB )+9 (NSB )T h e a s semb l y l a n guag e p r o gr a m mus t r emov e al l p a r ame t er s f r o m t h ee v a l u a t i o n s t a c k b e f a r e r e t u r n i n g t a t h e c a l l i n g r o u t i n e .SETs a r e s t o r e d a n t h e s t a c k wi t h t h ~ l e a s t s i g n i f i c a nt b y t e o nb o t t o m ( h i g h a d dr e s s ) .F un c t i o n v a l ue s a r e r e t ur n e d o n t h e s t a c k . T he y a r e p l a c e d " l o g i c a l l y "u nd er n ea t h t h e r e t ur n a d dr es s b e f or e t h e r e t ur n i s e x e c u t ed . T h e yth e r e f or e re mai n o n t h e t o p a f t h e s t a c k a f t e r t h e c a l l i n g pr o g r a m i sr e- e n t e r e d f o l l o wi n g t h e r e t u r n . A s semb1y l a n guag e f u n c t i on s ma y o n l yre t u r n t h e s c a l a r t y p e s I NTEGER. RE AL i BOOL EAN a n d CHAR.


3 . 3 P r o g r am Segmen t a t i on — Ch a i n i n gTh er e a r e t i me s when pr o grams e x c ee d t he memorg a v a i l a b l e a n d . al s om any t i me s when s egmen ta'Ci on i f p r o g r ams f o r comp i l a t i o n a n dmai n t enanc e pui pose s i i d e s i r ed. <strong>ATARI</strong> Pas c al p r o v i d es a " c h a i n i n g "mecha n i s m i n wh i c h on e p r o gr am ma y t r a n s f e r c o n t r o l t o a n o t h erpr o gram.You must <strong>de</strong>c l ar e a n untapped f i l e ( FI LE> ) an d use' t he .ASSION and. RESETpr ocedur e s t o in i t i a l i x e t h e f i l e . Y ou m ay t h en e x e c u t e a c a l l t o C heCHAIN pr o c e du re s pas s i n g t h e n ame o f ' t h e f i l e v a r i a b l e ' ai a s i n g l eparameter, . T hi "'r un-- t i m e l i br ar y r ou t i n e wi l l Che n per'Worm 't heappr opr i a t e f un c t i on s t o l oa d i n t h e f i l e yo u opened. us i n g t h e RESETst a tement . Pr ogram' s i se does no t m a t t er . A s mal l p ro gra m mag c hai n t oa l a r ge on i ,a nd a l a r g e pr ogr am mi j c ha i n Co a sm al l one . I f y oud es i r e ' t o comiivn i c a t e bet ween t h e c ha i ne d pr ogr am you ma y choos e t ocommuni ca t e i n t wo wa ys : sha r e d g l oba l v a r i a b l e s an d ABSOLUTEvar ice 1 es.I f you us e Che -shar e d g l oba l v a r i a b l e me t hods yo u mus t guar a n t e e t ha tat l ea s t t h e f i r s t s e c t i on o f g l oba l v a r i a b l e s i s Che ' same i n t h e t wopl ograms wi s h i ng ' t o communi ca t e . Th e rema i n<strong>de</strong> r o f t h e gl oba l v a r i ab 1esn ee d no t b e t h e same an d t h e <strong>de</strong> c l a r a t i on o f e x t er na l v a r i a b l e s i n t h eg l oba l s e c Ci on wi l l no t a f f ec t t h i s ma ppi ng . I n a dd i t i on . t o ha v i ngm at ch i n g <strong>de</strong> c l a r a t i ons i yo u mus t us e t h e / 9 op t i on swi t c h a va 'i I a b l e i nth e l i n ke r ( se e se c t i on 2. 3. 2. 4 ) t o p l a c e t he va r i a b l e s a t Che s amel oc a t i on i n a ) 1 pr ograms wi s h i n g t o communi ca t e .T o use t he ABSOLUTE var i a bl e method you woul d typi cal l y <strong>de</strong> f i ne ar ec or d used a s a communi ca t i on a r ea an d t he A <strong>de</strong>f i n e t h i s r ec or d a t a na bs o l ut e l oca t i o n i n ea c h modul e . T h i s me t hod doe s no t r e qu i r e us i n gt h e / b sw i t c h i n t h e l i n ke r bu t doe s r equ i r e knowl edge o f t h e memor yuse d bg Che pr ogr am and sy s tem.Li s t e d be l ow a r e t w o e xampl e pr ograms t ha t communi ca t e wi t h ea c h ot heru si 'n g t h e ABSOLUTE v a r i a b l e me t hod. Th e f i r s t pr ogr am wi l l CHAI N t ot h e s econ d pr ograms wh i c h wi l l pr'i n t t h e r e s u l t s o f t h e f i r s tp r ogr am' s e xec ut i on :


Example:PRQQRAN PROC2'TYPECQNNARKA = RECORDIi Ji K . IEND>N TEGERVAR CLOBALS : * BSOLUTE C$8000 3 CONNAREAFCH*INF I L : F I LEiB EGI N ( + NA I N PRGCR* N $ 2 + )W I TH CL QBAL S DQBEGI N3 iJ : ~ 3 iK : ~ I + JKND)ASSIQN 0 THENBEGI NW RITELN


3 . 4 B u i l t - i n Pr o c ed ur e s e n d Pa r ame t e r sT h i s s e c t i o n d e s c r i be s <strong>ATARI</strong> Pascal ' s b u i l t - i n p r o c ed ur e s e n df un c t i o n s . Ec c h r o u t i n e i s d e s c r i be d s g n t e c t i c e l l g i f o l l owe d b g ed es c r i p t i o n o f t h e pa rame t er s en d e n exempl e p r o g r am. us i n g t h ep r o c ed ur e a f t h e f un c t i o n . Se c t i o n 3 . 4 . 2. 5 i s e q u i c k r e f e r e n c eo f e i l b u i l t - i n p r o c ed ur e s an d f un c t i o n s .3 4


3. 4 . I NOVE i MOVER I QHT i NOVELEFTPROCEDURE HOVE (SOURCE> DESTI NATI ON' NUM BYTES)PROCEDURE NOVELEFT (SOURCE DESTI NATI O N NUM BYTES )PROCEDURE MOVER IQMT(SOURCES DESTINATI ON' NUM SYTES)Thes e pr o c ed ur e s mov e t h e number af b y t e s c a n t a i n ed i n N UN- SYTKS f r o mth e l o c a t i a n na me d i n SOURCE t o t he lo c a t i o n nam ed i n - XIKSTINATIQ N.NOVE is a s y n o nym f o r N OVELEFT-. N OVELEFT m aves f r o m t h e l e f t e nd a ft h e s a uy c e: t a t he . l e f t en d a f t he- <strong>de</strong> s t i n a t i on . NOVKRIOHT mov e s f r om' Che r i gh t en d o f t h e s o ur c e Co t h e r i gh t en d o f Ch e d e s t i na'Ci o n f t hep a rame t er s p a s se d Co NOVERIQMT s p e c i f y t h e l e f t ha n d en d o f t h es o ur c e an d d e s t i n a t i o n ) .Us e MOVELEFT -an d NQVERIOHT t a t r ans f er a b g t e f r ' am a ne d a t ast r u c t ur e t o a n o t he r o r t o move;- da t a - a r o un d w i t h i n a s i n g l 'e d a t ast r u c t ur e . T h e. move is . dane o n, a" b yt e l e v e l s o t h e : d a t a s t r u c t u r ety p e i s i gn o r ed . NOVKRIOHT is . usefu l f a r t r a n s f e r r i n g b y t e s f r a m C helo w en d o f a n a r r a y t o t h e h i g h en d . 4 l i t h ou t t h i s p r a c ed ur et a FORloo p wo u l d b» re q u i r e d ta p i c k u p ea c h ch a r a c t e r a n d p ut i t d own a t ahi gher ad d r e s s . N OVERIQ HT i,s al s o m uch. m uch fa s t e r . NOVKRIOHT i sid ea l t a us e in an i n s e r t c h a r a c t e r r o u t i n e w hose p u r p o se i s t o m ak eroo m f o r c h a r a c t er s in a b u f f e r .N OVELKFT i s u s e f u l f o r t r a n s f e r r i n g b y t e s f r om on e a r r a y t o an o t h e r '<strong>de</strong> l e t i n g c ha r a c t e r s f r om a b u f f e r ' o r m a v i n g t h e v a l ues in o ne d a t as t r u c t u r e Co a n o t h e r .T he s o ur c e an d zl e s t i n a t i o n ma y b e an y t y p e a f v a r i a b l e a n d b o t h n e e dno C be of t h e s ame t y p e. T h e se m ay a l s o b e p a i n t e r s t o v a r i a b l e s o rin t eg er s u s ed as p o i n t e r s . T h ey m ay n ot b e n amed- or l i t e r a l c o n s t a n t s .T h e number a f b y t e s i s a n i n t ege r e z p r e s s l a n g r ea t e r t ha n z e r o .4 4 t c h ou t f o r t h es e p r ab lems :Si nc e n o c h e c k i n g is pe r f o rm ed as t o w he th er t h e n umber o f b y t e s i sgr e a t e r t ha n t he si z e o f t h e d e s t i n a t i o ni s p i l l i n g o ver i n t o t h ed at a s t a r a g e a d j a c en t t a t h e d e s t i n a t i a n w i l l o c cu r i f t h ed e s t i n a t i o n i s n o t l a r g e en oug h t o h a l d t h e number a f b y t e s ,2 . No v i n g z er a b y t e s mov e s n o t h i n g ,3 . N a t y p e c h e c k i n g i s d one.


K xamp l e :PROCEDURE MOVE DEMO>CONSTSTRINQSZ ~ BOs.VARBUFF ER : STR I NCf STR INQSZ 7'LI N E : ' STR I NGsPROCEDURE INSRT ( VAR DKST ': STR INQs I NDEX ~: I NTEGER 3 VAR SOURCESTR I NQ3 lBKQ INIF LENGTH(SOURCE) < STRINCSZ — LENGTH(DEST ) THENBEQI NMOVER IQHT (DESTC:-: INDEX '3i DEST C INDEX+LENQ TH (SOURCE 3 3 iLENQTH(DEST ) I NDEX+1 ) 'MOVELEFT(%3VRCEC 1 l~'' DESTO''INDEX' r LKNQTH(SOURCE) ) sD ESTCG i : ~CHR(ORD(DESTC0 3 ) + LENGTH(SOURCE) )ENDsBEQ INMR I TKLN ( 'MOVE DKMO. . . . . . ' ) sB UFFER : ~ ' J udg J . Sm i t h / 33 5 Dr i v e / L ov e l g i Ca . 9 56 66 ' sMR ITKLN,( BUFFER ) sL I NE : ~ " Rol-'and- ' sINSRT (BUFFER' POS ( '5 ' ~ BUFFER )+2i LI NE) sMR ITELN (BUFFER 3'ENDsTHK: OVTPUT FROM" THI S PROCEDUREM OVE DEMO. . . . . .Judg J . Sm i t h / 3 5 5 Dr i v e / L ov e l g . Ca . 9 56 66Judg J . Sm i t h / 3 5 5 Ro l an d Di ve / L ov e l gi ' Ca . 'P5666


3 . 4. 2 K X I TP ROCEDURE EXI T >EXI T i s t h e e v v i v a ) en t o f t he.. RETURN s t a t eme n t , i n FORTRAN or . BASI C.It ei l l l e a ve t h e c u r r e nt p r o c e du re l f u nc t i o n o r m a i n p ro g r a m. E XITm i l l . a l s o l oa d .t h » r e g i s t e r s .an d r e- en a b l e i n t e r r u p t s be'f or e e x i t i n gi f EXI T i s , use d i n a n I NTKRRUPT. pr oc ed ur e . I t i s us ual l y e x ec u t e d a sa s t a t emen t f o l lQQl i n g a t e s t .K xamp l ePROCEDURE EX.I TTEST.'(+EXI T THE CURRENT FUNCTl ON OR M* I N PROGRAM. +)P ROCEDURE EXI TPROC;EX IT'E N D iMRI T KL N ( ' S T I L L I N E X I TPROC i * BOUT T O L EAVE NORMAL L Y ' ) lEND>BEOI NMRITELN( ' EXI TTEST . . . . . . . ' ) iKX ITPROC (TRUE) lN RITKLN( ' I N K XI TTKST * FTER 1ST CAL L TO EXI TPROC ' ) ;K XI TPROC(FALSE ) i4fRITELN< ' I N EXI TTEST AFTER 2ND CALL TO EXITPROC ' ) JEXI T'M RITELN< ' THI S L I NE MI L L NEVER BE PRI NTED ' ) JK N D iO ut p u t :K X I TTEST. . . . . . .KXI TI NO EX ITPROCIN KXI TTEST AFTER 1ST CALL TO EXI TPROCSTI L L I N KXI TPROCi *BOUT TO LEAVE NORMALLYIN EXI TTEST AFTER 2ND CALL TO EXI TPROC


3 . 4 . 3 T STB I T r SK T B I T r CL RB I TFUNCTION TSTB I T ( BA SI C VAR BI T NU M) : BOOLEAN'PROCEDURE SKTBI T (VAR BASI C VAR. BI T NUM) iPROCEDURE CLRB I T (VAR BASI C VAR. B I T NUM»' TSTBI T r e t u r n s TRUE i 4 t h e d e s i gn a t e d b i t i n t h e b a s i c v a r i s on e a n d' '- r et ur n s FALSE i 4 t h e b i t i s o 44 . SETBI T s e t s t h e d e s i g n k t e d b i t i n t h epa rame t er . C LR Bl T c l e a r s t h e d e s i g n a t e d b i t i n t h e p a r a met e r .BASI C VAR is ang 8 o r 1 6 b i t v a r i a b l e s u ch as i n t e ge ri c h a r . b y t e sc o r d i o r b o o l ea n . B I T NUM i s G. . 15 w i t h b i t 0 o n t h e r i g h t . A t t emp t i n gto s e t b i t 1G o 4 an S b i t v a r i a b l e d o e s n o t c a u se a n e r r o r b ut h as n oe 44ec t o n t h e en d r e s u l t ,T hes e pr o c ed ur e s a r e u s e f u l f o r g en er a t i n g me i t l o op s o r a l t e r i n gin comi n g d a t a b g f l i p p i ng a bi t where n e e <strong>de</strong> d. A no t h er a p p l i c a t i o n i sin ma n i p u l a t i n g a bi t ma p ped s c r e e n.PROCEDURE TST 'SET' CLR- BITSYVARI: I NTKQER'BEQ INW RITELN ( ' TST SET CL R B l TS . . . .I: ~ GsSET B I T ( I i 5 ) iIF I ~ 3 2 THENIF TSTBI T ( l i 5) THENWRI TEL N ( ' I ~ ' i I ) aCLRB I T ( l i 5 ) eIF I ~ 0 THENIF NQ T ( TSTB I T ( I. S) ) T HENWRI TK LN ( ' I ~ ' i I ) iOutput:T ST SET CL R BI T S. .I~32I ~ G


3. 4 . 4 S HR i SHLFUNCTION SHR (BASI C VA R NUN > : I NTE()ER'FUNCTI ON SHL (BASI C VARi NU N ) : I NTEGERSS HR ,s h i f t s t h e -BASIC. VAR by NUN b i t s t o t h e r i g h t i i n s e r t i n g 0 b i t s .SHi s h i f t s t h e BASI C VAR b y NUN b i t s t o t he le f t i i n s e r t i n g 0 b i t s .B ASIC VAR i s an -,S or 1 6 bi t v a r i a bl e . NL N i s a n i nt eger expressi on .The use s o f SHR; an d SH I a r e -gene r a l l y obv i ous . F or - e xamp 1 ei s u ppose a10 bit v a l v e i s C o b ~ o bt a i n ed f r o m C eo s ep ar a t e i n p uC p orC s. Y ou c anus e SHL t o r ea d Chem i n :VARPQRT i : ABSOLUTE CO90 00 3 BYTE'PQRT2 : ABSOLUTE COD232 3 BYTE;SHL(PQRT 1 8c $1 Fi 3) ! ( PORT2 L 0 1 F) 'The a b ov e e xamp l e r e ad s f r o m p o r t i i m a s k s o ut t h e t h r e e h i g h b i t sr eCur ne d f r om t h e I N P a r r a y i a n d s h i f t s t h e r e s u l t l e f t . Ne x t t h i sr e s u l t i s l o g i ca l l y OR ' d w i t h t h e i n pu t f r om por t 2 i wh i c h ha s a l s obeen ma s ked.The f o l l owi n g pl ocedur e <strong>de</strong>mons t r a t e s t h e e xpecCe d r e s u l t o f e xe cuCi ngt hes e t w o f un c t i on s .E xamp l e :PROCEDURE SHI F T DENOiVAR I : I NTEOER;BEQ IN4IRITELN ( 'SHI F T DEMO4 iNR I TENLN ( ' I ~ ' ~ I ) il 4RI TELN ( ' S HR ( I r 2 ) ~ ' i SHR ( I i 2 ) ) )MRI TELN ( ' S H L ( 1. 4 ) ~ ' i SHL ( I i 4 ) ).;ENDiO ut pu t :SHI FT DEMO, .I ~ 4S HR( I ; 2) ~ 1S HL ( I i 4 ) = 6 4


S. 4. 5 H l ~ LO . SWAPFUNCTI O N H I ( 8 AS I C VAR > : I NTEQKR 'iFUNCTIO N L O(BASI C VAR > : I NTKOER>FUNCT I ON SWAP (BAS I C VAR ) ; I NTEQERiHI r e t u'm s t h e upp'ev' 8 b i t s o f BASI C VAR ( an .8 o r 1 6 b ' i t v a v ia b l e ) i nt h e Lower 8 b i t s o f - t h e v e s u l t . L O r e t u r n s t h e l owe r 8 b i t s w i t h Ch euppe r 8 b i t s f o r c e d t o z e v o. SWAP r e t u v nf-' t h e u p p er' 8 ' bi t s o fBASI C VAR in t h e l o wer 8 b i t s a f t h e r e s u l t a n d t h e l o wer 8 b i t s o fBASI C VAR i n t h e u p pe r 8 b i t s o f t h e r e s u l t . P a s s i n'g a n 8 b i t v a r i a b l et o H I c a u s e s t h e v e s u l t C o b e 0 a n d pa s s i n g 8 b i t s t o L O d oe s n o t h i n g .Th ese f u n c t i o ns e n h an c e A TARI P as c a l ' s a b i l i t i e s t o r e ad a n d w r i t e t aII O p o r t s . If a d a t a i t e m h as 1 6 b i t s o f i n f o vm at i o n t a s e nd t o " a p ov CC ha t c a n h a n d l e 8 b i t s a t a t i m e u s e L O a vi d H I t a -sen d t h e l a w b y t ef o l l owe d b g t h e h i g h b y t e . S i mi l a r l g i r e a d i n g 16 b i t s o f d a t a f v om ap av' t t ha t s e n d s 8 b i t s a t a t i m e ma y b e pev f ov me d b g SWAPp i n g t h ef i v s t 8 b i t s i n t o Ch e h i g h b y t e :VAR PORT6 : ABSOLUTE (:00234 7 BYTESP GRT6 '. ~ L O(S.) iPORT6 : ~ HI ( B) iB : ~ SMAP)IF SWAP( HL ) ~ 4 0 40 1 THENW RITKLN ( 'SWAP


3. 4. h ADDRFUNCTI ON ADDR(VARI ABLE REFERENCE) : I NTKQERADDR.-r e t u r n s t h e a dd r e s s o f t h e v a r i a b l e r e f e r e n c ed. Var i a b l e ";,; ,r ef e r e n c e i n c l u <strong>de</strong> s p r o c e d u r e / f u n c t i on names'; . sub sc r i p t e d v a r i a b l e s a n dr e c or d f i e l d s . I t d o e s n o t i n c l u d e na me d c on s t a n t s ' u s e r d e f i n e dty p es ' or . a n y i,tern th at d o e s n o t o c c u py c o d e o r d a t a s p ac e.Th i s f u n c t i on is u s e d t o r e t u rn t h e a d d re ss o f a n y t h i n g : c ompi l e t i m et a b l e s y e n e r a t e d b g I NL I NK i t h e a d d r e s s o f a d a t a s t r u c t ur e t o b eus e d i n e m ove s t a t e ment . a n d s o o n.K xamp l e :P ROCEDURE ADDR DKNQ(PARA' : I NTKQER) 'VARRKC : RKCORDJ : I NT ECERiBOOL : BOOLEANiENDSADDRESS '. ! NTKOER'R: REAL >Si : ARRAYC l . . ! 0 3 OF CHAR'B EQI NMRITELN( '*DDR J)KHO. . . . . ' )'MRITELN( '4DDR(ADDR DEPIQ) ~ ' i ADDR(ADDR DKI% ) ) 3MR ITELN( 'ADDR (PAR* 8) ~ ' i ADDR (PARA' ) ) ~M RITKLN ( ' ADDR(REC ) ~ ' i ADDR(RKC) ) tM RITELN ( ' ADDR(RKC. 4 ) ' i 4DDR(REC. J ) ) rW RITKLN ( ' ADDR(ADDRKSS ) ~ ' i ADDR(ADDRKSS ) ) iWR I TELN ( 'ADDR (R ) ~ '. 4DDR ( R 3 ] iW Rl'TELN( 'ADDR ( S ? ) ~ ' . ADR( S l ) ) iEND)O ut pu t i s s y s t em d epen <strong>de</strong> n t .


3. 4. 7 S I ZEOFFUNCTI ON S I ZEOF (VARI ABLE OR TYPE NAMK 7 : I NTEGERSSI ZEOF r e t u r n s t h e si t e of : t h e p a r a m et e r i n b y t e s. ' l t x s u s e d x n m ov es t a'teme n t s f o r t h e numbe r o f b y t e s t o b e move'd; -" Wi t h S I ZKOF y o u ' n e e dn o t k ee p c h a n g i n g o o n s t a n t s : a s t h' e p r o g r a m ev o l v e s . P a r a me t e r ma y b ean y v a r i a b l e : c ha r a c t er i ar r a y s r e c o r d . et c i o r a n y u s e r - d e f i n e d t g p ~ .Kxamp 1 ~PROCEDURE S I ZE OKMOiVAR8 : ARRAY( 1 . . 10 3 OF CHAR)A: ARRAYC1. . 15 7 OF CHARiBEC INWRITELN( ' SI ZE I)EMO. . . . . . . ' ) t; m ~»»»»»»»e»» »»» »» ~>8 : ~ ' 0 12 34 567 8 9 ' IWRITKLN( ' S I ZEQF ( 4 ) ~ ' i S I ZEOF ( A ) , ' S I ZEOF ( B ) = ' , S I ZEQF ( B ) ) iMOVE(8e A SIZEQF ( 8 ) 7 tWRI TEl N ( ' A ~ ' i A ) iENI) iO ut p u t :SI ZEOF ( A) ~1 5 SI ZEQF (8) ~10A~ 0 12 34 56 789'»»»»»


3. 4, 8 F I LLCHARPRQCKDVRK F I LLCHAR ( DESTI NATI ON ' LKNQTHr CHARACTKR ). .. Thi s p r o c ed ur e f i l l s t h e DESTI NATXQN ( a p a c ked -a r r a y o f : c ha r a c t e r s )w i t h t h e numbe r o f CHAR* CTKRs s pec i f i e d b g LENCTH. DESTI NATI ON i sp a c ke d a r r a y o f c ha r a c t e r s . l t ma y b e s u b s c r i p t e d . LKNOTH i s a ni n t e ge r e x p r e s s i o n . I f LKNCTH i s g r e a t e r t ha n t h e l e n g t h o fDESTI NATI ON. a d j a c en t c o d e o r d a t a i s ov e rw ri t t e n . A l s o ' i f i t i sn ega t i v e . a d j a c en t memor y c a n b e ov er w r i t t en . CHARACTKR i s a l i t e r a lo r v a r i a b l e o f t y p e c h a r .T h e p u r p o s e o f F I LLCH* R i s t o p r o v i d e a f a s t m e t ho d o f f i l l i n g -i nl a r g e d a t a s t r u c t u r e s w i t h -t h e same da t a . F o r i n s t a n c e i b l a n k i n g o u tbu f f e r s i s d on e m i t h F I LI CHAR.K xamp l e :PROCEDURE F I L L DENOiVARBUFFER : PACKED ARRAYCI . . 2 56 3 OF CHARiB K(' I NF I LLCH*R (BUFFERi 2 56 ' ' ' ) i C + BLANK THE SUFFERS + 3ENDt


3. 4. 9 LENGTHFUNCTI ON LENGTH ( STRI N G ): I NTEGERST h i s f u n c t i o n r e t v r n s t h e i n t e ge r v a l v e o f t h e l e n g t h o f t h e s t r i n g .E xamp l e :PROCKI)URE LENQTH I)KMQ>VAR81 : ST RI NG E4()3eSEQ XW ~S1 ' ~ ' T h i s s t r i n g ii ' 3 3 ch'ar'ac-te rs l o n g iWRITELN( ' LKNQTH OF ' i S i ~ i L ENGTH(SI ) )'WR I TKLN ( ' LENGTH OF EMP TY STR I NG ~ ' e LENQTH ( ' ' ) ) )KNI) iO ut p u t :LENGTH OF T h i s s t r i n g i s 33 c h a r a c t e r s l o n g ~33L ENGTH QF EMPTY STRI NG ~ 0


3. 4 . 10 CONCATFUNCT ION CONC AT ( SOURCK 1) SOURCE 2> SOURCE ) : S TR I NQi, Thi s f un c t i on, r e t ur ns .. a st r i n g , .in w hi .ch a l l . so urc es i n t h e p ar y ye t e rli,s t ' a r e conc y t ena bqd . , T he ., sour ce s ma y be . str $ ng va r i a b l e@i s t r i n g :li t e r a l s i .,or , c ha r a c t e r s . A ,SOURCE..o f . x er o le n g th ca n . b e c oncat e nat e dwi t h n o p r o b l em.. .. I f . t he to t a l - :le ng th of a l l -=SOURCES' e x ceeds 5 6 . byt e sth e s t r i n g i s t r un ca t ed e t 250 by t e s . .See t he note un<strong>de</strong>r" COPY in t h ene x t s e c t i o n c o n c e r n i n g r e i t r i c t i on s s h en us i n g bo t h CONCAT an d COPY.Kxamp l e :PROCEDURE CONCAT GENOAVARSir 82 : S TR IN C)BKQ INSi : ~ ' l e f t li n k . ri .ght l i n k 'r82 : ~ ' r oo t r oo t r o o t ' >HR I TKLN (81. ' / ' i S2) FSi : ~ CONCAT( 8 i r ' ' i 8 2' ' ! ! ! ! ! ! ' ) iWRITKLN( S i ) >ENDiO ut p u t :' l ; ~l e f t .. l i n ks . r i g h t f i n k / r o o t r o o t .r o o tlef t l ank ! r i gh t l i n k ro ot r o ot r o ot ! ! ! ! ! !


3. 4. 1 1 COP YFVNCTI ON COPY ( SOURCES LOCATI ONS NUM BYTE ) : STRI NQsC op'g r e t vr rl s a i t r i n g co n t a i n i n g t h e number 'o f c ha r a c t er s s pec i f i e d i nNOW BYTES' f r am'-SOURCE be gi n n i n g a t t h e ' i n <strong>de</strong> x sp e t i f i i d i n LOCATI ON.SGVRCK sius t he :a ' s t r i Ag . LOCATI ON a n d NUM BYTES ' a r e . i n t egere xpr e s s i ons . ' -'I f LOCATI ON ' i s ov't ' of bounds o r i s -neya t i v e i n o e r r oroccur s . l' f NUM BYTES fs -'nega t i v e or NUM BYTES pi us LOCATlON exceedsthe l engt h of t he SOURCES t runcat i on occvr s.PROCEDURE COPY DEMO'BKGI NL ONG STR : ~ ' H i f r om Ca r d i f f - b g - t h e s e a ' ;MRITELN (COPY (LONG STRs fr LENGTH(LONG S TR ) 9 + 1 ) ) sENDsO ut pu t sCar d i f f - b g- t h e- s eaC OPY an d CONCAT a r e " pseudo " s t r i n g r e t ur n i n g f v n c t i on s an d ha v e on l yone st a t i ca l l g a l l ocat ed buf f et f o' r t he r et Ui'n va l oe.'-: Ther ef ()re~'thes e f un c t i on s a r e use d mor e t ha n onc e esi't h i n ' t h e same e xpr e s s i on it h e v a l u e o f e a c h occ ur r e nc e o f t h es e f un c t i on s be come s t h e v a l u e ofth e l a s t oc c v r r ence . Fo r i n s t an ce i " I F (CONCAT (Ai STRI NQ1 )( CONCAT ( * . STRING2 ) ) " wi l l a l wa y s b e t r u e be ca us e t h e c on ca t en a t i o n ofA an d STRI NG1 i s r e p l a ce d b g t ha t o f A an d ST RINGS. A l so ' " M RI TELN(COPY(STRI NG1. 1 ~ 4) ~ COPY(STRI NG1i Si 4 ) ) " w r i t e s t h e s e cond s e t o f f ourc ha r a c t e r s i n STRI NG1 t w i c e .


3. 4. f.R P OSFUNCTI ON POS ( PATTERNS SOVRCE ): I NTEQER>T h i s f u n c t i o n r e t u r n s t h e i n t e ge r v a l u e o f t h e po s i t i o n of ' t h e f i r s tocc u r r e'ne o o f ' PATTKRN i n SGVRCK. I f t h e p a t t e r n i s n o t f o u n d ' a z e r ois r e t u r n e d . SOURCE i s a st r i n g a n d P ATTERN i s a st r i n g , a c h a r a c t e r .er a l i t e r a l .Kxamp le:PROCEDURE POS DEMO;VARSTRi PATTERN ; STR INCACH : CHAR r'SEC INSTR : ~ ' ABCDEFQHI JKLMNO ''P ATTERN : = ' FQHI J ' lC H : ~ ' B ' iM RITELN ( ' p o s o f ' , PATTKRN. ' i n ' . STRi ' i s a POS( P ATTERNS STR) )iMRITKLN( ' po s o f ' i CH. ' i n ' i STR ' i s ' ' ~ POS(CH< STR) 3IHRITEL N ( ' po s p f ' ' z ' ' i n 'i STRi ' is ' . POS( ' z ' . STR) 3~END>O ut p u t :pos o f F QHI J i n * BCDKFQHI J KLMNO i s 6p o s o f B i n * BCDKFQHI JKLMNO i s 2p o s o f ' z ' i n ABCDEFQHI J KLMNO i s 04 7


3. 4 , l 3 DELETEP ROCKDuRK DKLKTK ( TARGET , I NDEX, S I ZE ) ;Th i s p r o c e d ur e is us e d t o r e move S / Z K c h a r a c t e r s f r o m T ARCKTbe g i n n i n g a t t h e b y t e na me d i n I NDEX. TARGET i s ' a s t r i n g . I N DKX a n dSI ZK a r e i n t e ge r e x p r e s s i o'ns . 'I f S I ZE is ze r o '. ' no a c t i o n i s t a k e n. I Fit i s n e g a t i v e . s e r i o u s e r r o r s r e s u l t . I F t h e IN DEX p l u s t h e S I Z K i sgr e a t e r t ha n t h e TARQKT or i f t h e T ARGET i s e mp t y ' t h e d a t a a n ds u r r o u n d i n g memor y c a n b e d e s t r a g e d .Kxamp 1 e:P ROCEDURE DELETE D E R 'VARLONG ST R : STR INCABEGINL QNO ST R : ' g e t r i d o f t h e l e a d i n g b l a n k s 'WR I TKLN,< LONO~ TR ) )DKLKTK(LONG 8 ' . I ( POS ( ' g ' . LONG STR )- 1 ) 'WRITELN


3. 4 . 14 I NSERTPROCEDURE I NSERT ( SOURCES D ESTIN ATION~ I N DEX) )Th i s p r o c e d ur e is . used to i n s e rt t h .e S OURCE i n t o t h e D KSTIN ATIO N- atth e' , l o ci % j an-.s pe c i f i e d i n I NDE X. : .' DESTI NATI ON is a !t r .i n g . S OURCE i s achar a c t er o r s t r i,hag i l i t e r a l . qr . var i a b l e . INDKX i s a n i n t egereipr essi on..,, $6URpK can be -empty . I f INDKX .is out o f b ounds o rDESTINATI ON i i em pt y ' d e s t r u c t i on o f da t a oc c ur s . I f i n s e r t i n g SOURCEint o DKSTlNATION causes DKSTINATION t o be l onger t han all ott edD ESTlNATI ON i s t r unca t e d.Examp I ePROCEDURE I NSERT DEMOSVARLONQ . STR ;., STR INC)81 : , STRI NQ t 10 3)BEQ INL ONQ STR : ~ ' Remember N a yS 1 : ~ ' Not her ' s Day i ' )INSERT ( S 1 i LONQ S TRe 10 ) iW RITKLN(l ONQ STR) ;INSERT ( ' t o c e l e br a t e ' . LONQ STRi 10 ) iWRlTELN(LONQ STR ) iKND'OutputRemember N o t h er ' s D ay i H ay 9Remember t o c e l ebr a t e Nother ' s Day ~ Nay


3. 4. 15 ASSI QMPROCEDURE * SSI QM ( FILETS NAME) )Us'e t h i s p r o c e d ur e t o a s s i g n a n e x t e r na l f i l e name t o a f i l e v a r i a b l epr i or t o i RESET o r R EWRITE. F I L E i s a fi l e n amei - NAME i t a li t e r a l o ra v a r i a b l e ' s t r i n g c o n t a i n i n g t h e n ame o f t h e f i l e t o b e c r e a t e d . F l L Emus t b e o f t y p e TEXT t o u s e t h e s p e c i a l d e v i c e na me s be 1,om.Not e t h'a t s t a n da r d Pa s c a l d e f i n e s a " l o c a l " f i l e . A T* R I P as c a li mp l emen t s t h i s f a c i l i t y u s i n g t emp or a r y f i l e name s i n t h e f o r mP ASTMPxx wh er e " x x " i s s e quen t i a l l y a s s i g n ed . s t a r t i n g a t x e r o a t t h eb eg i nn i n g o f eac h pr ogram. I f a n e xt er na l f i l e RE&)RITE is notpr e c e e<strong>de</strong> d b y a n ASSI QN i t h en a t e m po ra r y f i l e n ame m il l a l s o b ea s s i gne d t o t h i s f i l » b e f o r e c r e a t i o n .NAME i s n or m a l l y a d i s k e t t e f i l e n ame i n t h e s t a n d a r d f o rm a t :dn : f i l e na me. ex t b u t c a n a l s o be a s p e c i a l d e v i c e n am e,Dev i c e NamesE: C on s o l e s c r ee n e d i t o r d e v i c eS : C on s o l e s c r ee n o u t pu t d e v i c eC on s o l » k e y boa r d i n pu t d e v i c eP r i n t e r o u t pu t d e v i c eMOTE: Ca s s e t t e ( C: ) f i l e s ar e n o t s u p p o r t e d b y A TARI P as c a l .E xamp l e s o f ASSI QN u s a g e :ASS I CN ( PR INTF ILES ' P : ' );ABSI QN ( F i ' D2 : MT280. OVL ' ) iASSI QN(KEYBOARD ' K : ' ) lA SSI QN(CRT ' ' S : ' ) ;No t e : A f t e r * S SI QN(CRT . ' S : ' ) y o u mus t u s e REL4RITEi as t h e a s s i g nd oe s n o t o pe n t h e f i l e .


3. 4. 16 W N B~ G N SF UNC't IQN 'ONB f FXLKVAR: FI L,K OF .PAOC ): CHAR' .FUNCTION WNBt'F I LKVA'R: F I L E OF CHARi CH: CHAR ): BOOLEAN'i .Th es e f un'c t i on s a l l ou i y o u ,t o h av e BYTE- l e v e l a'ccess C o: a f i l e i nhi j h 'sp'eed' e'an'nor .— PAOC' is "a'n'j C'ape . th a't is fu n'damen'ta ll y a PackedAr > a g''Of Char '. ' Th' e' s'i'ie of 'Che" 'p'ack ed ' a' rr a g ii o p t i c a l 1g i n t h e r a n g e128 . . 4O9'5.ONB" wi l l l e t j o u re'a d a f i 'l e a b y t e a' t ' a t i me . I t r e t ur n s a v a l ue. oft yp e CHAR. T h e EDF f un c t i o n wi l l b e v a l 'i d when 't h'e phy s i c a le nd- o f - f i l e i s r ca che d bu t no t ba se d upon an y da Ca i n t h e f i l e.W NB v i l l l e t you wr i t e a f i l e a b y t e a C a t i me . I C r e q u i r e s a f i l e a n da c ha r a c t e r t o w r i t e . I t r e t ur n s a bo o l ea n v a l u e Cha t i s t r u e i f t h e r ew as a n e r r o r wh i l e w r i t i n g ,t ha t b y t e Co t h e f i l e . N o i n t er pr e t a t i o n i sd one on t h e by t e s Cha t a r e w r i t t e n .QNB an d WNB a r e use d ( a s oppose d t o F i GE T / PVT combi na t i on s ) b e ca us eCheg are signi ficantl y faster ,5 1


3. 4 . 1 7 Bl OCKREAD. BLGCKWR ITKBLOCKRK* D ( F: F I L KVARi BUF: ANYi VA R I QR: IH TEGKRi SZi.RB: Ih lTEOKR) iBLQCKWR ITK (F: F I LEUARi BUF: A'NYi VAR l O R: IH TEQKRl S Zi RB: IH TKCER 3 iThes e p r o c e d y r e s a r e u s e d f o r d i r e c t d i s k e t t e ac c e s s .. F I L EVAR is a nuntapped .f i l i ' (F ILETS ). B VF i s a ny, vari a b le l a rg e e nough t o h old t h eda t a . I O R i s' an" i n t e ge r t ha t r ' e c ei 'v e s t h e r e t ur ne d v a l u e f r om t h e DOS.S 1 i s th ~ numbe r o f b y t e s t o t r a n s f e r a n d RB shou l d a l wa y s b e 0 .The da t a i s t r a n s f e r r e d e i t he r t o o r f r om t h e user ' s BVF v a r i a b l e f ort he "spe c i f i e d number o f b' gt e s .


3. 4 . i 8 QPKNPROCEDURE QPKN ( F I LE . T I TLE . RESULT) JThe OPEN pr oc edur e .i n c r e a se s t h e f ] e x i b i l i t g of AT*R I P a s c a l . F I L E i sany f i l e t gye, very.jabl e. -..TITLE is a st r i n g c onta i n ing- the 'f i l e name.RESULT i s, a ' VAR ,.lt47EQER-..paramet e r a n d upon r e t ur n. fr o m O PEN h as t h esame v a l u e as , IQRESVLT. T he max im um n umber o f f i l e s t h at m ay b e o penedat . an y on e t i me is t h r e e - not . i n c l u d i n g C onso l e ( E : i S : i o r ) (,:.) f i l e s .1T h» OPKN pr oc edur e i s t h e same a s e x ec ut i n g a n ASSI QN ( F I LE.. T l TL E ) iRESET ( F I LE ) a n d RESULT : = I QRESVLT s equence .Examp l es:OPKN ( I NF I L K ' D: FNANE. DAT ' RESULT) l


3. 4 . 1'V CLOSEi CLOSEDELPROCEDURE CLOSE ( FILETS RESUL T ) 'P ROCEDURE CLQSEDEL ( F I LE . RESULT ) iThe Ct QSE' an d CLQSEDEL pr ocedur es- ar e us e d f o r c l o s i n g an d c l os i ngmi t h- <strong>de</strong>'l e t e r e spec t i ve l g . Th » CLOSE pr oc edur'e adus t b e c a l l e d t og uar a nt e e t ha t d a t a un i t t e n t o a f i l e u s i n g a ny' met hod 'i s pr op@r i gp ur ge d f r om t h e f i l e b u f f e r t o t h e d i s k e t t e . Th e CLQSEDEL i s n or ma l l yu sed on tempor ar y f i l es t o <strong>de</strong>l et e t hem af t er use . F I LE and RESULT ar et h e same a s u s e d i n' OPEN ( s i e s e c t i on 3 . 4 . 18 ) .Fi l e s ar e i m p l i c i t l y c l ose d s he n a n open f i l e i s RESET.T he CLOSE pr ocedur e i s use d i n t h e f i l e s e c t i on o f t h e a ppen d i x.


3. 4. 2() PURGEPROCEDURE PURGE ( F I L E ) 'T h e PURGE p r o c ed ur e i s u s e d t o d e l e t e a f i l e wh os e name i s s t o r e d i n ast r i n g . Yo u mu s t f i r s t ASSIG N t h e n ame t o t h e f i l e a n d t h en e x e c u t ePURGE.E xamp l e :A SSI GN (F i ' D2 : BADFI LE. BAD ' ) ;P URGE(F ) ' ( » DELETE D2 : BADFKLE. BAD « )


3. 4. 2 i I GRKSULTFUNCTI ON I ORKSVL T : I NTEGERA f t e r e a c h I / O o p e r a t i o n t h e v a l u e r e t u r n e d b g t h' i I ORESVL T f u n c t i oni s s e t b g t h e r u n - t i m e l i b r a r y r o u t i n e s . O n t h e ATAR I Home Comp u t e r st h e g en e r a l r u l e i s t ha t a n o n - z e r o v a l u e me an s a n e r r o r a n d z e t o i s ag oo d r e s u l t .E xamp l e :ASSI QN ( F i ' D2 : HELLO' ) 'RESET ( F ) lIF I ORKSULT Ca 0 THENWRITELN( ' C: HELLO I S NOT PRESENT ' ) i


3.. 4. 22 . M KH* V* I L i MAXAVA I LFUNCT I ON ' MKMAVA I L : I N TKQKRiFUNCTION M A X4 VA I L : I NTKQKRiTh e f u n c t i on s MKMAVAI L a n d MAXAVAI L a r e u s e d i n c o n j u n c t i o n w i t h NKMa n d DI SPQSK"-t o. manag e t h e HEAP- memor y.-.ar e a :i n 4 TARI Pa s c a l . T h eM KM4VAI L f un c t i on,. r et ur n i Ch e l a r ge s t : t o t a l a v a i l a b l m memor y a t a n ygi ve n t i m» ir r e s pe ct i v e o f f r a gmenta t i o n. T h e . MAXAVAIL . fu nct i o n w i l lfi r s t ga r ba g e c o l l e c t a n d Chen re p o rt t h e l a r g est b l o ck a v a i l a b l e .The M4XAVAI L fu nc t i o n c an b e u sed .Co f o rc e a g ar b age c o l l e c t i o n b e f o rea ti me - sensi t i v e se ct i on of pr ogramming.The 474RI Pascal--.syst em f ul l y suppor t s t h e NKM and- DISPQSK mechani smd ef i ne d b g Ch e Pa s ca l S t andar d . Th e HEAP a r e a gr ows f r om t h e en d ofC he da t a a r e a a n d Ch e s t ac.k f ram e


3 . 4. 2 3 Q u i c k Re f e r e n c e Gu i d e t o B u i l t - i n Pr o c e d ur e s a n d Pa r a me t e r s( A l p ha b e t i c a l »» »i t h i n e a c h g r o up ; )C ha r a c t e r a r r a y ma n i p u l a t i o n r o u t i n e sPROCEDURE F'l LL'CHAR ( BEST I N*T I ON LENGTH " CHARACTKR )PROCKDVRE 'MGUELKFT < SOURCEi DESTI NATI ON i NUM BYTES) iPROCEDVRE MO4KRI QHT ( SGURCE, DESTI NATI ON , NUM BYTES) iB i t a n d b y t e ma n i p u l a t i o n r o u t i n e sP RQCEDURK CLRB I T ( BAS I C VAR i B I T NVM) iF UNCT TON H I BASI ( C ' VARINTEQERiF UNCTION L Q B ASI C VAR ) INTEGER'P RQCKDVRE SETB I T ( B'ASI C VARi' B I T NUM) iF UNCTION SH L BASI ( C V* Ri NUM) INTEQER»F VNC T 1 ON SH R 8* ( SI C V* R» NUM) INTKQER'F VNCT lON SNAP (B AS I C VAR ) INTEGERFUNCTI ON TSTB IT ( BASI C V* R. B I T NUM) BOOLEANiSt r i ng handl i ng r out i nesFVNCTI QN CONC47 ( SOURCE1 i SQURCK2 i . . . i SOURCE n ) : S TR I NQiFUNCTI ON COPY ( SQURCEi LQC* TI ONi NUM BYTE S ) : STR INQiPROCKDURK DKLETK ( T 4 RQET i I NDKX i S I 2 K ) iPROCEDURK INSKRT ( SQURCEi DESTI NATI ON , I NDEX ) iFUNCTI ON LKNQTH ( STR INQ ) INTKQKR iFUNCT I QN PQS ( PATTERN, SGVRCE ) INTEGER»F i l e h and l i n y r o u t i n e sPROCEDVRK ASS! QN F ILK. NAME ) iPROCEDURK B LGCKREAD ( F I L E i BVF i I QR i NUMB YTKS i RE L BL K ) iPROCEDURE BLOCKER ITE ( F ILE. B UF i I QR i NVMBYTES i RE L B L N ) iPROCEDURE C LOSE F I L(K i R ESULT ) iPROCEDURE CLQSKDEL F I L K i R ESUL T ) iFUNCTI ON Q N B F ILK ( ) CHARPROCEDURK IORKSVLT INTEQERiPRQCEDURK O PEN F I LE(Tl T L E i RE SUL T 3 iPROCEDURE PURGE F I LE ) iFUNCTI ON 4 /NB F I L K i ( CH* R ) : BOGL E* NiM i s c e l l a n e ou s r o u t i n e sF UNCTI ON ADDR ( VAR I * BL E RKFERKNCE ) INTEGERiP ROCEDURE EXI T iFUNCTI ON MAXAVA I L ; I NTEQKRiFUNCT I O N MEMAVA I L : I NTEGER iFUNCTI ON S I ZEGF < VARI ABLE GR TYPE NAME ) : I NTEGER>


3 . 5 N o n - S t a n d a r d Da t e A c c e s s3 . 5. 1 Ab s o l u t e Va r i a b l e s< a b s o l u t e v a r > : : ~ ABSOLUTE E < c on s t a n t ) 1 < v a r >A BSOLUTE v a r i a b l e s ma y b e d e c l a r e d i f e a u kn e e t h e a d d r e s s a tc omp i l e t i me , Yo u d e c l a r e v a r i a b l e ( s ) t o b e a b s o l u t e u s i n gs p e c i a l s y n t a x i n a VAR d e c l a r a t i on . ABSOLUTE v a r i a b l e s a r e n a ta l l o c a t e d a n y s pa c e i n g au r d a t a s egmen t b g t h e comp i l e r a n d g a u a r er e s pon s i b l e f o r m a k i n g s u r e t h a t n a ca mp i l e r - a l l o c a t e d v a r i a b l e sco n f l i c t w i t h t h e a b s o l u t e v a r i a b l e s . NOTE : STRI NC VARI ABLES NAY NOTEXI ST b e I otu C4 100 7 i n memor g.E xamp l e s :I: ABSOLUTE C48000 7 I NTECERiSCREEN: ABSOLUTE CSCO00 7 ARRAYCO. . 15 1 OF ARRAYCO. . 63 7 OF CHAR'


3, 6 I N L I NE<strong>ATARI</strong> Pa s c a l ha s a v e v g u s e f u l b u i 1 t - i n f e a t u v 'e c a l l e d I N L I N K. T h i sfe a t u r e l e t s y o u i n s er t d a t a i n t h e mi d d l e a f a n <strong>ATARI</strong>P asc'a l pv oc ed ur e a v f u n c t i o n . I n t h i s wa g s m a l l m a c h i n e c od e o v P- c o d es e quen ce s a n d c o n s t a n t t a b l e s ma y b e i n s ev t e d i n t a a n AT* R I Pa s c a lpr ogram.3 . 6. 1 S y n t a xTh e s a n t a x f o v t h e 1NL I NK f ea Cure i s v e r g s im i l a r t a t h at o f apr ocedur e c a l l i n Pasca l . The wor d I N LI NE is used f a ll owed b g a le f tp av en t h e s i s " ( " f o l l awe d b g a n y numbev o f av gumen t s s e pav a t e d b g t h esl a s h " / " c h a v a c t e v a n d Cer mi n a t e d b g a r i g h t p a r e n t h e s i s " ) " . T h ea r gumen t s b e t wee n Ch e s l a s he s mu s t b e c o n s t a n t s o v v a v i a b l e v e f e r en c e st ha t e v a l u a t e t o c o ns Ca n t s . T h es e c o n s t a n t s c a n b e o f a n y o f t h ef al lowi ng t yp es : CHAR. BTRINCi BOOLEAN. I NTEQER ov REAL . N o t e Chat aS TRI NC i n q u o t e s d o e s n o t g e n er a t e a l e n g t h b y t e b u t s i m p l y t h e d a t afar t h e s t r i n g .L i t ev a l c o n s t a n t s o f t y p e i n t e ge r w i l l b e a l l o c a t e d on e b y t e i f Ch eva l u e f a l l s i n Ch e v ang e 0 C a 2 5 5. N am edi d ec l av 'ed ~ i n t e g er c one Cant sw h i c h w i l l a l wa y s b e a l l o c a t e d t w o b y t e s .3, 6. 2 Ap pl i cationsT h » I N L I NE f a c i l i t y c a n b e u s e d t o i n s er t c od ~ o r t o b u i l dc omp i l e t i m e t a b l e s . T h e f a l l a w i n g t w a s e c t i o n s g i v e e xamp l e s o f e a c ho f t h es e u s e s .


T h e pr o g r a m f r agmen t b e l o w <strong>de</strong>mon s t r a t e s ho w t h e XNLXNE f a c i l i t y c a n b euse d t o c o n s t r u c t a c ompi l e t i m e t a b l e ,E xamp l e :PROQR*M DEMO I NL I NE)TYPEXDFIEL D = ARRAY L' i . . 4 3 QF ARRAY C1. , 10 3 OF CHAR'VARTPTR :I DF I ELDtPROCEDURE TABLElB EQI N1 NL INE ( ' ATAR I I /'HONE /'COMPUTER t /' <strong>SYSTEM</strong>S. . . I )END)8EQ I N ( + HAI N P ROQRANT PT R : ~ ADDR ( TABL E ) ~ 5 i (+ + 5 fo r P - c o <strong>de</strong> o n l g + 3END,MR XTELN ( T PT R C3 1 ) i ( + SHOUL D NR XT E ' CQNPVTK R ' : )


3 . 7 G r a p h i c s an d So un d Do cumen t a t i onT h e g r a p h i c s i s o u nd . a n d c o n t r o l l e r p a c ka g e c o n s i s t s o f a n i n c l u d ef i l e i QSPROCS i a n d a P a s c a l m o d u l e QRSND. ERL . T h e i n c i ud e f i l ed ef i n e s t h e e n t r y p o i n t s a v a i l a b l e i n t h e Pa s c a l mo d u l e . T h e Pa s c a lmodu l e mu s t b e l i n ke d wi t h y ou r p r o gr am.T o us e t h e pa c kag ~ t y p e (« %I D: GSPROCS« ) f o) l owi n g t h e g l o b a lv ar xab l e s o f y ou r p r o g r ams a n d e x e c u t e I NI TQRAPHI CS a s t h e f i r s tst a tement i n your m a i n pr ogram.E xamp l e :PROGRAM QRSND;LABELCONSTTYPEVAR( » I NCLUDE THE GRAPHI CS AND SOUND DEF I NI TI ONS « )(» %I D: QSPROCS» )L OCAL PROCEDURES « )PROCEDURE XXXX'B EGI NEND)PROCEDURE YYYYtBEGI NEND i( » MA I N PROGRAM « )BEGI NINITQRAPHI CS ( 5 3' ( « I N I T I AL I ZE GRAPHI CS PACKAGE WI TH A MAXIMUMG RAPH I CS MODE O F S « )


T he f o l l owi n g s e c t i on s <strong>de</strong>scr i b e ea c h o f t h e i tems av a i l a bl e i n t h egraphi cs and sound package.3. 7. 1 S c r ee n T ype sTYPEs:S CRN TYPE = {SPL I T SCREENS FULL SCREEN) 'CLEAR TYPE ~ ( CLEAR SCRKENi DG NGT CLEAR SCREKN) 'T hes e s c r ee n t y pe s a r e use d bg t h e QRAPHI CS pr oc edur e t o d e f i n e t hetyp e o f s c r ee n an d wh e t he r o r no t t h e s c r een wi l l b e c l e a r e d d ur i n gt h e QR* PHl CS pr ocedur e .3. 7. 2 Variabl esVAR s:SCRNF I LE : EXTKRNAL TEXTSQRRESULT : EXTERNAL I NTKQKR>S CRNFILE ma y b e use d t o d o s t an da r d Pa s ca l I / O t o t h e s c r ee n s uc h a s :4IRITK


3 . 7. 3 Q r ap hi c Pr o c ed ur e s an d F un c t i o n s3 . 7. 3. 1 I n i t i a l i z e Pr o c ed ur ePROCEDURE I NITQRAPHI CS ( MAX MODE: I NTEGER )'I NITQR* PHI CS mus t b e t h e f i r s t s t a t emen t o f a pr o g r a m t ha t u s e s t h eg r a p h i c s a n d s o un d mo d u l e . T h er e i s o n e p a r a me t e r :M AX MODEM a x i mum mod e u s e d b g t h i s p r o g r a m s h o u l d b e a v a l u ef r a m 0 t a 9 .I f a n e r r a r o c c u r s . t h e QRRESULT = 2 5 5 ) o t h e r w i s e ' QRRESULT ~ 0 .3 . 7. 3. 2 G r a p hi c s Pr ocedur eP ROCEDURE GRAPHI CS(MODE: I NTEGERS SCREEN: SCRN TYPES ' CL EAR: CLEAR TYPE ) 'GRAPHICS p e r f or m s t h e same f u n c t i o n a s t h e GRAPHICS s t a t emen t i n <strong>ATARI</strong>B ASI CS e x c ep t i t ha s t h r e e p a r a me t e r s i n s t ea d o f a n e .MOD ESCREENCLEART h e d e s i r e d g r a p h i c s mo<strong>de</strong> 0 t o MAX MODEF UL L SCREEN a r SPL I T SCREENC L EAR SCREEN or DO NOT C LEAR S CREENI f a n e r r o r accursed t hen QRRESULT ~ 2 5 5 ) o t h e r w i s e ' GRRESULT ~ 0 .3 . 7. 3. 3 T e xt mod e Pr o c ed ur ePROCEDURE TEXTMGDEiTEXTMODE c l o s e s " S : " a n d r e o p en s " E : " . QRRESUL T i s u n c ha n ged.3 7 . 3 4 S e t c a l a r Pr o c ed ur eP ROCEDURE S ETCOLOR ( RE GI STERS HUE. L UMI NANCE : 1'NTEQER ) ;SETCOLOR per f or ms t h e same f u n c t i o n a s t h e SETCOt OR s t a t emen t i n * TARIBASI C . GRRESVL T i s unc hang ed .REGISTERA v a l u e f r om 0 t a 4 . Re f e r t o s e c t i o n 9 o f t h e <strong>ATARI</strong>40 0 / 80 0 BASI C Re f e r enc e Ma n ua l u n <strong>de</strong> r SETCGLOR.A v a l u e f r om 0 t a 15 . Re f e r t a s e c t i o n 9 o f t h e <strong>ATARI</strong>40 0 / 8 0 0 B A S I C R e f e r e n c e Ma n u a l u n d e r SETCOLOR.LUMI NANCEA ev e n v a l u e f r o m 0 t a 14 . R e f e r t o s e c t i o 9 o f t h e<strong>ATARI</strong> 4 0 0 / 80 0 BASI C Re f e r en c e Man ua l u n <strong>de</strong> r SETCOLOR.


3 . 7. 3. 5 C o l o r Pr o c ed u r ePROCEDURE COLOR (COLOR VALUE: I NTEGER ) iCO( OR per f or ms t h e same f u n c t i o n a s t h e COt OR s t a t emen t i n BASI C.COLOR VALUE * v a l u e f r a m 0 t o 2 55 . Re f e r t a s e c t i o n 9 o f t h e <strong>ATARI</strong>40 0 / 80 0 BASI C Re f e r e n c e ma n ua l u n <strong>de</strong> r COLOR.3 . 7. 3. 6 P l o t Pr o c ed ur ePROCEDURE PL OT( Xe Y: I NTEGER ) )PLOT p e r f or ms t h e same f u n c t i o n a s t h e PLOT s t a t emen t i n AT4R I B4 S l C.It p l o t s a p o i n t i n t h e c u r r en t c o l o r a t t h e s c r ee n p o s i t i o n X. Y.t h e h o r i z o n t a l c o o r d i n a t e o n t h e s c r e en .t h e v e r t i c a l c o o r d i n a t e o n t h e s c r e e n .G RRESULT = v a l u e o f a n X I O PUT c h a r a c t e r c a l l .3 . 7, 3. 7 L o c a t e Pr a c ed u r eFUNCTION LOCATE ( X> Y: I NTEGER) : I NTEGERSLOCATE p e r f or ms t h e same f u n c t i o n a s t h e LOCATE s t a t ement i n 4 T *R IBASI C. I t r e t u r n s t h e p i xe l v a l u e a t t h e s c r ee n p o s i t i on Xi Y.t h e h o r i z o n t a l c o o r d i n a t e o n t h e s c r e en .t h e v e r t i c a l c o or d i n a t e o n t h e s c r e e n .G RRESULT ~ v a l u e a f a n X I O GET c h a r a c t e r c a l l .3 . 7. 3, 8 P o s i t i o n Pr o c ed u r ePROCEDURE 'POSI TI ON ( Xi Y: l NTEGER) lPOSI TI ON per f or ms t h e same f u n c t i o n a s t h e POSI TI ON s t a t emen t i n * TARIBASI C. I t m o v e s t h e i n v i s i b l e g r a p h i c s cu r s o r t o p o s i t i a n X i Y. N ot eth e c ur s o r i s n o t m o v e d u n t i l t h e n e x t I / O f u n c t i o n i s p er f or me d.X th e hor i z on t a l c o o r d i n a t e a n t h e s c r e e n.Y t h e v e r t i c a l c o o r d i n a t e a n t h e s c r e e n .3. 7. 3. 9 D r a wt o Pr a c edur'eP ROCEDURE DRAWTO ( X, Y : I NTEGER ) ;DR4WTO pe r f or'ms t h e sam ~ f u n c t i o n a s t h e DRAWTQ s t a t emen t i n * TARIB 4SI C . I t d r aws a l i n e f r o m t h e c u r r en t g r a p h i c s p a s i t i o n t o p o s i t i o nX i Y i n t h e c u r r e n t c o l o r .


t h e h o r i z o n t a l c o or d i n a t e o n t h e s c r e en .t h e v e r t i c a l c o o r d i n a t e o n t h e s c r e e n .G RRESULT v a l u e o f a n XI O DR* @TO c a l l .3 . 7. 3 . 10 F i l l Pr o c e d ur eP ROCEDURE F I L L ( X. Y: .I NTEGER) JF I L L p e r f or m s t h e 'same f u n c t i o n a s t h e XI O 18 c a l l i n ATAR I BAS I Cex c ep t i t p e r f or ms a p l o t a t p o s i t i on Xi Y t o m ove t h e c u r s o r t o Xi Y a tt h e en d o f t h e F I L L .X t h e h o r i z o n t a l c o or d i n a t e o n t h e s c r e e n ,Y th ~ ve r t i c a l c o o r d i n a t e o n t h e s c r e e n.GGRESULT = v a l u e o f a n X I O F I L L ca 1 l .S oun d Pr o c e d u r e s an d F u n c t i o n s3. 7. 4. 1 S ou nd P ro c e d u r ePROCEDURE SOUND(VOICED' PITCHY DI STORTI ONS VOLUME: INTEGER 3 3SOUND p er f or m s t h e same f u n c t i o n a s t h e SOUND s t a t emen t i n <strong>ATARI</strong>8 * S I C . I t t u r n s o n t h e s o un d c ha n n e l i n d i c a t e d b g VOI CE a t t h ein d i c a t e d P ITCHY DI STQRTI ON i a n d VOLVO%.VOI CE O ne o f t h e f ou r s o un d c hann e l s a t 0 t o 3 .P ITCHDI STORT I QNVOLUNEA v a l u e b e t wee n 0 a n d 2 5 5 . R e f e r t o s e c t i o n 10 o f t h e*TAR I 9 * S I C man ua l u n <strong>de</strong> r SOUND.A ev e n v a l u e f r om 0 t o 14 . Re f e r t o s e c t i o n 10 o f t h e*TARI BASIC m anu al u n d er S OUND.A v a l u e fr o m 0 to 1 5. 0 i s o f f 3 1 5 i s m a x i m um v o l u me.3 , 7. 4. 2 S o un d o f f Pr o c ed ur ePROCEDURE SOUNDOFF3S OUNDQFF t u r n s o f f t h e s o un d t o a l l t h e s o un d c han n e l s .3 . 7. 5 Co n t r a l l e r F u n c t i o n s3. 7. 5. 1 Paddi es


3 . 7. 5. I . 1 Pa d d l e F un c t i onFUNCTI ON P ADDLE ( P DLNVN: I N TEQER ): I NTEQER )PADDLE p e r f or ms t h e same f u n c t i a n a s t h e PADDLE s t a t emen t i n <strong>ATARI</strong>B ASI C. I t r e t u r n s t h e c u r r en t v a l u e o f a n e a f t h e e i g h t p a d d i e s .PDLNVNIs t h e pa d d l e numbe r t o r e t u r n s mu s t b e a v a l u e b e t we en0 a n d 7 .3 . 7. 5. 1. 2 T r i gger Func t i onFUNCTION PTR I Q(PDLNUN: INTEQER ) : I NTEQERsPTRI Q per f or ms t h e same f u n c t i o n a s t h e PT RI Q s t a t emen t i n AT* RIB ASIC. I t r e t u r n s t h e c u r r en t t r i g ge r v a l u e o f an e o f t h e e i g h tpad d les.PDLNVNIs t h e pa d d l e numbers t o r e t u r n > mu s t b e a v a l u e b e t ween0 a n d 7 .3 . 7, 5, 2 do @s t i c k s3 . 7. 5. 2. 1 S t i c k F u n c t i o nFUNCTION STI CK (STKNVN: I NTEQER ); I NTEQER)STI CK p e r f or m s t h e same f u n c t i a n a s t h e ST I CK s t a t emen t i n * TARIB ASI C. I t r e t u r n s t h e c u r r en t v a l u e o f ' on e o f t h e f o u r J o g s t i c k s .STKNVMI s t h e y o g s t i c k numbe r t o r e t u r n ) mus t b e a v a l u eb et wee n 0 a n d 3 .


CHAPTER 4 :RU N- T I NE ERROR HANDLI NQThe <strong>ATARI</strong> Pa sca l s y st em suppar t s t w o t y pes o f r un- t i m e chec k i n g:ra n g e a n d e x c e p t i o n ,R ang e c h e c k i n g i s p e r f or me d o n a r r a g s u b s c r i p t s an d o n s u b r a n g ea s s i gnmen t s . Th e d e f a u l t c o n d i t i o n o f t h e s y s t em i s t h a t t h es e c h e c ksa r e d i s a b l e d . Yo v ma y en a b l e t hem a r o v n d a n y s e c t i o n a f c o d i n g d e s i r e dv s i n g t h e OR an d OX t o g g l e s ( s e e s e c t i on s 2 . 2. 3. 4 a n d 2 . 2. 3 . 5 ) . T h e s es e c t i on s d e s c r i b e t h e i m p l emen t a t i o n o f t h i s mec ha n i s m an d ho w ea u ma yt a k e a dv a n t a g e o f t h i s me c ha n i s m t o ha n d l e r u n - t i m e e r r o r s i n an on - s t a n d a r d ma nn e r .T h e g en e r a l p h i l o s o ph y i s t ha t e r r o r c h e c k s a n d e r r o r r o u t i n e s w i l ls e t B o o l ea n f l a gs . T h es e Bo o l ea n f l a g s a l o n g w i t h a n e r r o r c o d e w i l lb e l oa <strong>de</strong> d a n t o t h e s t a c k a n d t h e b u i l t - i n r o u t i n e (kERR i s c a l l e d w i t ht h es e t w o p a r ame t e r s . T h e (sERR r a v t i n e w i l l t h e n t e s t t h e Bo o l ea npa r ame t e r . I f i t i s f a l s e t h e n n o e r r o r ha s o c c u r r e d a n d t h e LsERRr o u t i n e w i l l e x i t b a c k t o t h e comp i l e d c od e a n d e x e c u t i o n c o n t i n u e s .l f i t i s t r u e t h e % ERR r o v t i n e w i l l p r i n t a n e r r o r m e s s a g e a n d l e t sy o u c o n t i n u e a r a b a r t .L i s t e d b e l a w a r e t h e e r r o r numb er s p a s s e d t o t h e QERR r o v t i n e :Va 1ueM ean i n g1 )i v i d e- b g- 0 c h e c kH ea p ov er f l o w c h e c kSt r i ng over f l ow checkR ang e c h e c k4 . 1 R a ng e Ch e c k i n gWhen r a n g e c h e c k i n g i s e n a b l e d t h e comp i l e r g e n e r a t e s c a l l s t o 8CHKf o r ea c h a r r a y s u b s c r i p t a n d s u b r a n g e a s s i gnme n t . T h e LsCHK r o u t i n ele a v e s a Ba o l ea n v a l u e o n t h e st a c k a n d t h e c ampi l e r g e ne ra t e s c a l l st o 8ERR a f t e r t h e (kCHK c a l l . I f r a n g e c h e c k i n g i s d i s a b l e d an d as u b s c r i p t f a l l s o u t s i d e t h e v a l i d r a n ge i u n p r e d i c t a b l e r e s u l t s w i l lo c c ur . F a r s u b r a n g e a s s i gnmen t s , t h e v a l u e w i l l b e t r v n c a t e d a t t h eb g t e l e v e l ,4 . 2 E x c e p t i o n Ch e c k i n gW he n e x c e p t i o n c h e c k i n g i s e n a b l e d i t h e c o m p i l e r w i l l l o a d t h e e r r o rf1a gs (t e r a d i v i d e. s t r i n g o ve r f l o w a n d h e ap o v e rf l a w) a s n e e d ed a n dca l l t h e RERR r o u t i n e af t e r e a c h o p e r a t i o n t h at c a n s e t t h e f l a g s . I fe xc e p t i o n c h e c k i n g i s d i s a b l e d t h e r u n - t i m e r o y t i n e s a t t empt s t op r o v i d e a f r i e n d l g a c t i o n i f p o s s i b l e : d i v i d e b g z e r o r e s u l t s i n a


m axi mum v a l u e b e i n g r e t u r n ed . h ea p ov e r f l o w d oe s n o t h i n g . a n d s t r i n go v e r f l o w t r u n c a t e s .4 , 3 Us e r S u p p l i e d Ha n d l e r sY o u c a n wr i t e y ou r ow n @ERR r o u t i n e t o b e u s e d i n s t ea d o f t h e s y s t emr o u t i n e . Yo u s h o u l d d e c l a r e t h e r o u t i n e a s ;PROCEDURE %ERR(ERROR:BOOLEAN' ERRNUN: I NTEQER3lT h e r o u t i n e w i l l b e c a l l e d i a s me n t i o n e d a b av e > ea c h t i m e a n e r r o rc h ec k i s n e e <strong>de</strong> d a n d t h i s r o u t i n e s h o u l d c h ec k t h e ERROR v a r i a b l e a n <strong>de</strong> x i t i f i t i s FALSE. Yo u ma y d e c i d e t h e a p p r o p r i a t e a c t i o n i fth e v a l u e i s t r u e . Th ~ v a l ue s o f ERRNUN a r e a s s hown i n s e c t i o n 'P, 0 .4 . 4 F a t a l E r r o r s" F a t a l E r r o r s " me s sa g e ca n b e d e c i,ph er e d f o r d e bugg i n g p u r p o s e s b u tm ay b e c o n f u s i n g . Th e e r r o r c a n b e t r a n s l a t e d t o t h e Pa s c a l e r r ormessag e a n d t o t h e <strong>ATARI</strong> s t a n d ar d er r o r m es s ag e. T h e f o l l o w i n g e x ampl ewi l l i l l u s t r a t e t h e t r a n s l a t i o n p r o c e s s :F a t a l E r r o r 6 4 . 8 8 — > Pa s ca l E r r o r . * TAR I E r r orUsing bas e 16 ( non- st andards 6 4 — 10 0 an d 8 8 — 1361 6 1 0 1 6 i QA Pa s c a l i 0 0 e r r o r f o r ou r s y s t em r e f e r s t o a n o p e r a t i n g s y s t e m e r r o r .I n t h i s e xamp l e we wo u l d t h e n l o o k a t t h e ATAR I Kr r o r 13 6 me s s a g e t os e e t ha t ou r e r r o r r e l a t e s t o a n "EGF " .T h e f o l l o w i n g a r e p r e <strong>de</strong>f i n e d Pa s ca l f a t a l e r r o r s .6 4 : E r r o r w h i l e c h a i n i n g .6 $ : Ba d p s e ud o c o d e .6 6 : Ba d p s e ud o c o d e .67 : Un <strong>de</strong>f i n e d p s e ud o o p c od e.68 ; St ac k over f l ow ( pr ogr am t oo comp lex >,


CHAPTER 5 : , STRUCTUREl'FORMAT OF A PASC* L PROQRAMT h i s c h a p t e v d e sc v' i b e s t h e d a t a t y pe s a n d ho w t h e y a r e s t ot ed , I t a l s od i s c u s s e s t h e us e o f s t r i n g s .A <strong>de</strong>s cv ip ti an o f t h e l a yout o f a . CGM f i le i n m emory u nd er D OS 2 . 0S i sp v ese n t e d .5. 1 D at a TypesTh i s s e c t i o n d e s c r i b e s h ow t h e s t a n dav d Pa s c a l d a t a t y pe s a v eimplement ed i n <strong>ATARI</strong> Pascal . Ta bl e - summar i ze s t h e dat a t y pes.Dat a Tgp e Si ze Rang eCHAR 1 8 - b i t - b g t e 0. . 2 55BOGLE*N 1 8 - b 1 t - bg t e fa l s e . . t v' ueINTEQER 1 8 - b i t - b y t e 0. . 2 55INTEQER 2 8 - b i t -b g t es - 3 2 7 6 8 . . 32 76 7BYTE 1 8 - b i t - b y t e 0. . 2 55WORD 2 8 - b i t - b y t e s 0 , . 6553 5FLOATI NQ REAL 4 8 - b i t - b y t e s 10E- 9 8 . . 10E+98STR I NQ1.. 256 bytesSET 3 2 8 - b i t - b y t e s 0 . . 2 5 55. 1. 1 CHARThe dat a ty pe C HAR i s i m p lemente d u si n g a ne 8 -b it b yte f or e ac hcha r a c t e r . T h e r e s e r v e d wav d PACKED is as s umed o n a r r a y s o f C HAR, C HARva r i a b l e s ma y h a v e t h e r a n g e o f C HR


5. l. 3 I N TEGERT h e da t a Cgp e I NTEGER i s i m p l eme n t e d u s i n g Cwo 8 - bi t b y t e s f o r e a c hI NTEGER v a r i a b l e , NA XI NT = 3 276 7 a n d I NTEQERS ca n b e i n t h e r a n g e. - 32 7 6 8 . . 32767 . A n i n t e ge r s u br a n g e d e c l a r e d t o b e w i t h i n t h e 0 . . 2 55ra ng e o c c u p i e s o n l y on e b y t e o f memor y i n s t ea d o f t w o b y t e s . I n t e g erc on s t a n t s ma y b e h e xa d e ci ma l numb er s b g p r e c e e d i n g t h ~ h e x numbe r w i t ha d o l l a r s i g n ( e . g . SQF3 B ) .5. l . 4 REALTh e i m p l emen t a t i o n o f t h e d a t a Cgp e REAL i n ATARl Pa s ca l i s t h e sa mea s Cha t u s e d b g <strong>ATARI</strong> BASI C. S i x b y t e s o f d a t a a r e r e q u i r e d t oi mp l emen t a f l o a t i n g p o i n t numb er . T h e f i r s t b y t e c o n t a i n s Ch eman t i s s a s i gn i t h e e x p on en t i n ex ce ss 6 4 . T he b a s e o f C he e x p o ne nt i si 0 0 . T h e r e ma i n i n g f i v e b y t e s c o n t a i n t h e ma n t i s s a i n b inarch c o d e dd e ci m a l . T h e p r e c i s i o n i s a p p r o xi m a t e l g 8 d i g i t s ./ / / +I E Ilow mern l manC i. ssa s i gn/ exponent excessI64 l ms lIl l s t h i g h mern// / — — +m s ~ mo s t s i g n i f i c a n t b i t sl s ~ l e a s t s i g n i f i c a n t b i t s5 . l . 5 B yt eThe BYTE dat a Cgpe occupie s a s i n g l e b yt e . I t i s c ompat i b l e w it h b o t hINTEGER an d CHAR t y p es . T h i s compa t i b i l i t y c a n b e v e r y u s e f u l wh enm ani p u l a t i n g c o n t r o l c h a r ac t e r s e ha n d l i n g c h a r a ct 'e r a r i t hm e t i c ~ e t c .Char a c t e r s a n d i n t e g er s ma y b e a s s i gn e d t o a BYTE.5 . i . 6 W ' o r dW ORD i s a n u n s i gn ed . n a t i v e ma c h i n e wo r d . Al l a r i t hme t i c a n dcompa r i s on s p e r f or me d o n e x pr e s s i on s o f Cg p e WORD a r e u n s i gn ed.5. l . 7 S t r i n g5 . 1. 7. 1 De f i n i t i onTh e p r e - d e c l a r e d t y p e STRI NG is li k e a p acked a r r a y o f c h a r a c t e r s i nw h i c h t h e b y t e 0 c o n t a i n s t h e d y na mi c l e n g t h o f t h e s t r i n g . a n d b y t e st h r o ug h n c on t a i n t h e c ha r a c t e r s . S t r i n g s ma y b e u p t o 2 5 5c h a r a c t e r s i n l e n g t h . T h e d e f a u l t l e n g t h i s 8 0 c h a r a c t e r s t h a t m a y b eal t e r e d when a va r i a b l e o f C gpe S TRIN G i s d e c l a r e d (s ee e x ampl eb e l o w ) .


Th e s t r i n g " T h i s i s a W o t t l e " i s I 6 ch a r a c t e rs l o n g . T he f o l l o wi n gd i a g r a m s hows he w t h es e c h a r a c t e r s a r e s t o r e d i n a s t r i n g d e c l a r e d t ob e 2 0 c h a r a c t er s l o n g .lo w mer n ' h 1g h mernt h e numbe r o f c ha r a c t er s i n t h e s t r i n g i s l e s s t ha n t h e d e c l a r e dl engthen t h e bgt e s o n t h e en d ar e no t d e f i ned . Not e t ha t t h e l en gt hi s s t o r e d i n t h e f i r s t b y t e an d t h e t o t a l numbe r o f b


Th e i n d i v i d ua l c hav'a c t er s i n a st v in g v a v ia b l e a v 'e a c c e s s e d as i f t h est r i n g v e r e a n av r a g o f c h a r a c t ev s. T h u s, n o v mal a r r a y s u b cv ip t i n g v i acon s t a n t s . v a r i a b l es . a n d e xpv es s i on s a l l ows a s s i gnmen t a n d ac c e ss t oi n d i v i d ua l b y t e s sv i t h i n t h e s t r i n g . A c c es s t o t h e s t v i n g ov e r i t sen t i v e <strong>de</strong> c l a r e d l e n g t h is le g al a n d d o es n o t c a u se a r u n - t i m » e v ' r o rev e n i f a n ac c e ss is m ad e t o a p o r t i o n o f t h e s t r i n g b e y o nd t h ecuv r en t d y na mi c l e n g t h . I f t h e s t r i n g is ac t u a l l y 2( ) c h a r a c t e r s l o n gan d t h e d e c l a r e d l e n g t h is 3 0 t h en S TRlN G C 25 3 i s a c c e s s i b l e .Example:P RO(:EDVRE AC(:ESS iVARI : I NTEGER>B EGI Ni 5 >L ONQ ST R : = ' i 2 3 4 5 6 7 8 9 a b c d e f ' )4fR I TKLN (LONG STR ) 'M RITELN(LONG STRC63 i LONG STRC i - 5 3 ) )L ONG STRCi 6 3NR I TELN (LONG STR C i 6 3 ) iMRITKLN(LONG STR) > ( + m i l l s t i l l o n l g un ' i t e i 5 - c h a r a c t ev sEND vO ut p u t :1 2345678 9 a b c d e f6a1 234 56789a b c d e f


5 . 1. ?. 3 Comp a r i s o n sC ompar i s on s a r e v a l i d b e t wee n t wo v a r i a b l e s o f t y p e STRI NQ ( r e g a r d l e s so f t h e i r l e n g t h ) o r b e t ween a v a r i a b l e a n d a l i t e r a l s t r i n g . L i t e r a ls t r i n g s a r e s e q uence s o f c h a r a c t e r s b e t wee n s i n g l e qu o t a t i o n m a r k s .C ompa r i s on s ma y a l s o b e ma d e b e t ween a s t r i n g a n d a c h a r a c t e r . T h ecomp i l e r " f o r c e s " t h e c h a r a c t e r t o b e come a s t r i n g b g u s i n g t h e CDNCATb u f f e r i t h e r e f o r e ~ compa r i s o n o f t h e r e s u l t o f t h e CONCAT f u n c t i o n a n da c h a r a c t e r i s n o t me a n i n g f u l b e c a us e t h i s compa r i s o n wo u l d a l wa y s b ee qua 1,E xamp l e :PROCEDURE CORP AREiV AR Sii S2CH 1: S T R I NQC10 l i: C H* RiB EQI NS i : = ' 0 1 2 3 4 5 6 7 8 ' 'S 2 : = ' 2 2 2 3 4 5 6 7 8 ' iIF S i " S2 THENM RI T E L N ( S i i ' i s l e s s t h a n ' , 8 2 ) iS i : = ' a l p h a b e t a ' iIF 8 1 = ' a l ph a b e t a ' THENM RITEt N( ' t r a i l i n g b l a n k s d o n ' ' t m a t t e r ' )ELSEMRITELN( ' t r a i l i n g b l a n k s c o un t ' ) 'IF S i = ' a l ph a b e t a ' THENM RITELN< ' b l a n k s i n f r on t d o n ' ' t m a t t e r ' )ELSE'M RITELN( 'b l a nk s i n f r o n t d o m a t t e r ' ) >lF S i = ' a l ph a b e t a ' THENMRI T E L N


5 . 1. 7. 4 Re a d i n g a n d Wr i t i n g S t r i n g sSt r i n g s ma y b e w r i t t e n t o a t e x t f i l e u s i n g t h e WRI TE o r M RI TKLNp r o c ed ur e . W R I TELN w i l l c a u s e a c a r r i a g e r e t ur n a n d l i n e f e e dfo l l o wi n g t h e s t r i n g . Rea d i n g a s t r i n g i s a l wa y s d on e v i a t h e READLNs t a t emen t b e c a us e s t r i n g s a r e t er mi n a t e d w i t h a c a r r i a g e r e t ur n a n dl i n e f e ed . U s i n g READ w i l l n o t wo r k s b e c a us e t h e en d- o f - l i n ec ha r a c t e r s a r e i n c o r r e c t l y p r oc e s s ed . T a b s a r e e x pa n <strong>de</strong> d whe n t h e y a r er ea d i n t o a v a r i a b l e o f t h e STRI NG t y p e .S . l . 8S e tT h e SET d a t a t y p e i s a l wa y s s t o r e d a s a 3 2 b y t e i t em . K a c h e l emen t o ft h e s e t i s s t ol e d a s on e b i t . Th e l o w o r <strong>de</strong> r b i t o f e a c h b y t e i s t h ef i r s t b i t i n t ha t b y t e o f t h e s e t . S hown b e l o w i s t h e s e t " A " . . " 2 "( b i t s b 5 . . 12 2 )By t e numbe r0 0 0 1 0 2 0 3 0 4 0 5 O h 0 7 0 8 0 9 OA OB OC . . . 1FCon t e n t s 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FE F F FF 0 7 0 0 . . . 00


CHAPTER 6 :CQNP* T IB I L I TYP a s c a l i s c o n s i d e r a b l y mor » s t a n d a r d i z e d Cha n BASI C. Ne a r l y e v e r yv e r s i o n o f P a s c a l i s ba s e d o n a d e f i n i t i o n o f t h e l a n g ua g e c o n t a i n e di n " Pa s c a l Us e r M a n ua l a n d Rep o r t " b g Ka t h l ee n J e n s e n a n d N i k l a u sM i r t h . S p r i n g e r - V e r l a g 19 74 . Th e Pa s c a l L a n g uag e Sy s t em i s asup er s e t o f t h e Pa s c a l d e s c r i b e d i n t h i s b o o k . I n a d d i t i on i <strong>ATARI</strong>P as ca l me et s a m o r e r e c en t s t a n d a r d , na me l y t h e I SO s t a n d a r d< I n t e r n a t i o n a l S t a n d a r d s Gr g a n i z a t i o n i s i m i l a r t o AN S I ) . I t i sexpe c t e d t ha t a n y Pa s c a l s d e v e l o p ed fr om n o w on w i l l c e r t a i n l g b ecompa r e d t o t h i s s t a n dar di a n d w i 1 1 s t r i v e C o m ee t' i t . A T*R I h a slear ned t h e i mpor t anc e o f compat i b i l i t y f r om i t s exper i enc e wi t h * TARIB ASI C. 4 Pa s c a l t ha t meeCs t h e n e wl y d e v e l o pe d I SO s t a n d a r d i s a v e r yp o s i t i v e s t e p t owa r d compa t i b i l i t y .A p o s s i b l e compa t i b i l i t y p r o b l e m i s t ha t Ch e <strong>ATARI</strong> Pa s c a l L a n g ua geS y s t e m i s n o t e n t i r e l g comp a t i b l e w i t h UCSD Pa s c a l . UCSD Pa s c a l h a sa t t a i n e d c o n s i d e r a b l e p o p u l a r i t g o n s m a l l compu t e r s . W h i l e i t i s t r u eC ha t * TAR I Pa s c a l i s n o t comp l e t e l g comp a t i b l e w i t h UCSD Pa s ca l ~ i tsh o u l d b e r emember e d t ha t b o t h v e r s i on s a r e w r i t t e n a r o un d a commonc ore — Pa s c a l a s d e f i n e d b g J e n s e n a n d W i r t h . T h e d i f f e r e n c es i t h o ug hp r e s en t a r e n o t a s s i g n i f i c an t a s , f o r e xa mp l e s t h e d i f f e r e n ce s i nv a r i ou s BASI Cs . I n a d d i t i o n t h e s u p e r i o r i t g o f t h e Pa s c a l L a n gua g eS y s t e m J u s t i f i e s t h e i n compa t i b i l i t i e s i n v o l v e d.A b r i e f compa r i s o n o f t h e f e a t u r e s Cha t d i f f e r b e t ween t h e t wo Pa s c a l sf o l l o ws , Pa r t s o f t h i s compa r i s o n i s n e c es s a r i l g somewha t t e c h n i c a l .as mo s C o f t h e d i f f e r e n c e s a r e d e e p i n t h e d e t a i l s o f Ch e l a n g ua g e.


6 , 1 I n compa t a b i l i t i e s N i t h UCBD Pa s c a l1 . Th e p r e d e f i n e d t g p e I NTERACTI VE i s a v a i l a b l e o n l g i n UCSD Pa s c a l .O n t h e ATAR I Comp u t e r s a n g f i l e a s s o c i a t e d w i t h t h e comp u t e r c o n s o l eis a u toma t i c a l l g i n t e r a c t i v e i a n d t h e r e f or ~ t h i s t g p e i s n o t n e e <strong>de</strong>da n d wo u l d o n l g c l u t t e r t h e l a n g ua g e u n n e c e s s a r i l g .T h e p r e d e f i n e d p r o c e d ur e SEEK i s a v a i l a b l e o n l g i n UCSD Pa s c a l .3 . VCSD Pa s ca l u s e s UNI T S t o i m p l emen t mo d u l a r co mp i l a t i on . T he g a r ee a s g t o u n d e r s t a n d s b u t a r e muc h mor e r e s t r i c t i v e t ha n AT* R I Pa s ca l ' simplement at i on of modular compi l at i.on.4 . UCSD Pa s ca l p r o v i <strong>de</strong> s SEQHENT p r o c ed ur e s t a a l l o w ov e r l a g s f r omd i s k e t t e . * TARI Pa s c a l w i l l u s e t h e s t a n d a r d DOS me t h od s f o r i n v o k i n go v e r l a g s .5 . S e t s c a n b e c o n s i d e r a b l g l a r ge r i n UCSD Pa s c a l . T he g a r ec on s i d e r a b l g f a s t e r i n ATAR I Pa s c a l . T h e <strong>ATARI</strong> Pa s c a l i m p l emen t a t i oni s m o r e i n k e e p i n g w i t h t h e s p i r i t o f t h e J e n sen a n d Q i r t h s t a n d a r d .6 . UCSD Pa s c a l i n c l u <strong>de</strong> s b i t - l e v e l p a c k i n g o n PACKED s t r u c t u r e s .B i t - l e v e l p a c k i n g c o s t s i n b o t h t h e s i t e o f t h e i n t e r p r e t e r a n d t h es p ee d of- e x ec u t i o n o f t h e p r o g r a m ( p a r t i c u l a r l g o n a ma c h i n e b a s e d ont h e 6 50 2 mi c r o p r o c e s s o r w h i c h d oe s n o t c o n t a i n mu l t i p l g a n d d i v i d e ) .7 . UCSD Pa s ca l ha s a c o n s t r uc t K X I T < p r o c e d ur e. name> t ha t i s n o tin c l u <strong>de</strong> d i n ATAR I Pa s c a l i a l t h o ug h <strong>ATARI</strong> Pas c a l p e rm it s K X IT w i t h o u tt h e p r o c ed ur e na me . Ha n g Pa s ca l p u r i s t s f e e l t ha t t h e c o n s t r u c t a si mp l emen t e d b g UCSD i s n o t a s t r u c t u r e d c o n s t r u c t s a n d i s t h e r e f o r ec o u n t e r t o t h e p h i l o s oph g o f t h e l a n g ua ge .8 . UCSD Pa s ca l i n c l u <strong>de</strong> s t h e t g p e LONQ I NTEQER t ha t i s n o t a v a i l a b l ei n ATAR I Pa s c a l .S ev er a l f e a t u r e s i n UCSD Pa s ca l a r e o p e r a t i n g s g s t e m d ep en <strong>de</strong> n t s' e. g . , l on g f i l e na mes . a n d u n i t I / O ( s i m i l a r t o XI O) . T h e s e h a v e n o tb ee n i m p l emen t e d i n <strong>ATARI</strong> Pa s c a l ,7 7


6. 2 * d d i t i o n a l F e a t u r es *v ail a b l e wi t h t h e A T*R I P as c a l L a n g u ag eS y s t em1 . Th e ATAR I Pa s ca l L a n g uag e Sy s t em i s a comp l e t e I SO s t a n d a r dP a s c a l . Some o f t h e I SO f e a t u r e s n o t i n c l u <strong>de</strong> d i n UCSD Pa s c a l a r eco n f or man t a r r a y ha n d l i n g i p r o c ed u r e s a n d f u n c t i on s as p a r a m et e r s ilo c a l f i l e s . PACK a n d UNPACK pr o c e d u re si R EAD a nd W RlT E f o r n o n - t e x tfi l e s W R I T E an d WR I TEL k o f B o o l ea n e x p r e s s i o n s i a n d QOTO ou t o f apr o c ed ur e i n t o a s u r r o u n d i n g p r o c e d u re .2 . T h e Ps e ud o c od e i m p l emen t e d i n <strong>ATARI</strong> Pa s c a l wa s o p t i mi z e d f o r t h e6 50 2 mi c r o p r o c e s s o r .3. ATAR I Pa s c a l u s e s t h e same o p e r a t i n g s y s t em as al l o t h e r A TARIpr o gr ams , <strong>ATARI</strong> Pa s c a l a n d *T ARI B* S I C f i l e s ar e t h e s ame f o rm a t s a n dd a t a f i l e s c a n b e r ea d b y e i t he r l a n g ua ge . Yo u d o n o t h a v e t h ei n c onv e n i e n c e o f l e a r n i n g t w o d i f f e r en t a n d i n compa t i b l e o p er a t i n gsy s t e ms . as yo u d o w i t h V CSD P as c a l . I n ad d i t i o ns A TARI P as c a l a l l o wsac cess to I / O i n a m an ne~ v e r y s i m i l a r t o A TARI B ASI C , X IO i g r a p h i c s .s o und s game c o n t r o l l e r s ' a n d name d d e v i c e s a r e a l l i m p l emen t e d .4 , VCSD s egmen t p r o c e d ur e s a r e l i m i t e d t o s i x pe r p r o g r a m wh i c h l i m i t st h e d e v e l opmen t o f l a r g e a p p l i c a t i o n s , ATAR I Pa s ca l s h o u l d a l l o w t h ed ev e l opmen t o f m o r e comp l e x a p p l i c a t i o n s .5. * TAR I Pa s ca l ha s n i n e or t e n d i g i t s o f p r e c i s i o n o n r e a l n umbe rs .V CSD Pa s c a l ha s o n l y 6 . 5 d i g i t s o f p r e c i s i o n .b . AT* R I Pa s c a l . p er mi t s t h e p r o g r amme r t o t r a p 'e r r o r s i a n d p r ev en tp rograms f r om abor t i ng .7. <strong>ATARI</strong> P as c al p r o v i d e s p r o t e c t i o n w hen r e ad i n g i n a s t r i n g . I f t h es t r i n g i s t o o l on g f o r t h e r e c e i v i n g v a r i a b l e s ATAR I Pa s ca l w i l lt r u n c a t e t h e s t r i n g . UCSD Pa s ca l w i l l o v er w r i t e t h e b y t e s f o l l o w i n gth e s t r i n g i n memory . r « s u i t i n g i n u n d e f i n e d p r o g r a m e r r o r s .8. ATAR I Pa s ca l ha s e x t e n <strong>de</strong> d t h e CASE s t a t emen t b y a d d i n g a n EL SEcl a u s e , I f t h e ca s e s e l e c t i n g e x p r e s s i o n w ou l d n o t r e s u l t i n t h eex ec u t i o n o f a s t a t e ment w i t h t h e C ASEi t h e E LSE c l a u s e i s e x e c u t e d .ELSE s i mp l i f i e s e r r o r c h e c k i n g . E x ec u t i o n o f a s i m i l a r u nm at c h e dC*SE in V CSD P as c al c a u s e s a n u nd ef i n e d r e s u l t .9. Mo d u l a r co mp i l a t i o n i s mu c h mor e f l ~ x ib l e i n A TARI P as c a l , L o c a ls t a t i c v a r i a b l e s , e x t e r na l p r o c e d ur e s a n d f u n c t i on s l o c a t e d i n t h em ai n p r o g r am . a n d e x t e r na l g 1o ba l v a r i a b l e u s a g e a r e a l l m i s s i n g f r omV CSD Pa s c a l .10 . ATAR I Pa s c a l ha s a bu i 1 t in B YTE d at a t y p e . T h i s d a t a t y p ee 1 imin a t e s t h e u s» o f c o n f u s i n g C *S E v a r i a n t r ec or d s w h en m an i p u1 at i' ngch a r a c t er s as i n t e g e r s .1 1 . * TART Pa s ca l ha s a b u i l t - i n WORD d a t a t y p e . A n u n s i g n e d 16 - b i td a t a t y p e i s v e r y u s e f u l f o r a d d r e s s a r i t h m e t i c a n d ma c h i n e - l e v e lp r o g rammi n g ,7 8


12. UCSD Pasca l daes na t f u 11g i mp1ement compat i b i l i t y b et meen s t r i ngsa n d c hav'ac t er s . S t r i ng s an d c hara c te v's ar e t a t a 1 1 g c ampa t ib 1 e i nA T* RI Pa s c a l .1 3 . Fo r s y s t em <strong>de</strong> pen d en t a p p l i c a t i o n s i * TAR l Pa s ca l a l l am s r e l a x a t i ana f t y p e ch'ee k i n g v u 1es . T h i s v ' e l a x a t i a n a l l ams ma c h i n e I / O an d memor ym an i p u l a t i o n t o b e d an e mi t h o u t c l u t t ev i n g t h e p r o g va m mi t h c o n f u s i n gC *SE vav i a n t r e c ov ds .i 4 . <strong>ATARI</strong> Pa s c a l ha s Ch e b u i l t - i n b i t - m a n i p u l a t i o n v a u t i n e s TSTBI T.S ETBI T . CL RB I T i SHL i a n d SHR. B i t m a n i p u l a t i o n i n VCSD Pa s ca l mu s t b ed on e m i t h CASE v a r i a n t v ec ar d s i m h i c h av e c o n f u s i n g an d ma c h i n ed ep en <strong>de</strong> n t .1 5 . I n b a t h AT* R I Pa s ca l a n d VCSD Pa s c a l i t h e GET / PVT f i l e I / O i squ i t e s l am . * TAR I Pa s c a l a l s o c o n t a i n s GNB an d WNB i m h i c h a r e h i g h­spee d 1/ 0 r ou Ci n e s Wo v by Ce I / O.l b . AT* R I Pa s ca l f u l l y i m p l eme n t s t h e NEW an d DI SPOSE p r a c e d u r e s iin c l u d i n g f r agmen t a t i o n ma na gemen t a n d r e - us e a f d i s p a s e d av ea s . VCSDP as ca l i m p l emen t s a mu c h mov e v e s t v i c t e d v e r s i o n o f t h e s e pv.ac ed ur e s .T h i s f e a t ur e i s v i t a l t a a n y pv agr a m d o i n g d y na mi c d a t a ma na gemen t .i 7 . <strong>ATARI</strong> Pa s c a l a l l am s f u l l u s e o f W i l e s . VCSD Pa s c a l d a e s n a t a l l o ml o c a l f i l es . W i l e s i n r e c o r d s ' o v a r r a y s o f f i l e s .1 8 . ATAR I Pa s c a l i n c l u <strong>de</strong> s Ch e ADDR f u n c t i on . T h i s r e Cuv n s t h e a ddv es sof a v a r i a b l e i p v acedu re i or f u n c t i o n. T h i s f u n c t i o n i s u s e f u l m he ndo i n g ma c h i n e d epen<strong>de</strong>n t p r agv'ammi n g.1 9 . ATAR I Pa s c a l ha s a b u i l t - i n I N L I NE f e a t uv e t ha t c a n b e u s e d t ag enev' a t e comp i l e - t i m e c o n s t an t d a t a . T h i s f e a t u r e e l i mi n a t e s r u n - t i mei n i t i a l i z a t i o n a f c a n s t a n t t a b l e s i i n c r ea s i n g e x e c u t i o n s p ee d a n dd e c r e a s i n g c od e s i z e .20 . * TAR I Pa s c a l a l l am s o u t pu t i n a n y numbe r b a s e f r am Cma t h r o u g hs i x t e en . 12 1 . * TARI Pa s c a l a 1 lams i n p u t o f e i t he r d ec i ma l o v he x numb er s .22 . <strong>ATARI</strong> Pa s ca 1 ha s n a t e x t en <strong>de</strong> d t h e pa v'ame t e r l i s t o n a n y 1SQs t a n d ar d r o u t i n e ( s p e c i f i c a I l g RESET an d REWRITE ) , Fa v a c e s s i n gex t er n a l f i l e s a n e m pr o c eduv e ha s b e e n a d d e d.


CHAPTER 7 :L ANGUAGE DEF I NI TI ON7 . 1 I n t r o d u c t i onC ha pt e r 7 d e f i n e s t h e 1a n guag e f e a t u r e s o f ATAR I Pa s ca l t ha t a r ecommon t o eac h i m plement at i on of t h e c ompil e r. I t i s a ssumed h ere t h atg o u a r e f a m i l i a ~ w i t h J e n se n an d M i r t h ' s " Rep o r t " a n d / o r t h e I SO d r a f ts t a n d a r d ( DPS/ 7 18 $ ) . T h e * TARI Pa s ca l f ea t u r e s t h a t d i f e'er f r o m t h o s ein t h e I SO s t a n da r d a n d i n J e n se n a n d Mi r t h ' s " Rep o r t " i a r e d e s c r i b e db g s e c t i on . I n e a c h s e c t i on s BN F


7 S ummav'y a f t h e AT* R I Pa s ca l L a n g ua g eFe a t u r e s o f t h e I SQ Pas c a l in c l u <strong>de</strong> t h e d a t a t y p e s R K*L > I N TEGER> C HAR.BOOLEAN, m u l t i d i men s i o n a l ARRAYS> us e v - d e f i n e d RECORDS> POI NTERSty p es > f i l e v av i ab l es > u s ev - <strong>de</strong> f i n e d TYPES an d CONSTANTS> an d SETS< implemented i n th is vev's i o n a ri t h a b ase t y pe o f 2 56 a ne b y t ee l emen t s ) . ENVMER* TED t y p es > a n d SUBRANGE t y p e s .Al s o i n c l u <strong>de</strong> d i n I SO Pa s ca l a r e PRQCEDVRES FUNCTI ONS> an d PROGRAMS.Pa s s i n g p r o c ed u r e s a n d f u n c t i on s as p a r a met e rs t o a P as c a l v ' o u t i n e a v 'epar t a f t h e I SO s t a n d a r d > a s m e l l as ca n f a rm an t a r r a y s . Arv ays o f t h esame i n d e x t y p e a n d e l emen t t y p e bu t d i f f e r en t si z es m ay b e p a s s e d t at h e same pv oc ed ur e . E x t e r n a l pa r a me t e r s w i t h t h e PROGRAM s t a t emen tar e s u p pov te d a t t h e s y n t a x l e v e l .TYPED an d TEXT f i l e s a r e s u ppov t ed as d e f i n e d i n t h e s t a n d ar d u s i n gth e P a s c a l r o u t i n e s RESET . REWR I TE > GKT P U T> R EA D> W R I T E > R EADLN> a n dW RITELN. Th e d e f a u l t 1/ 0 f i l e s I NPUT an d OUTPUT a r e d e f i n e d .Al l I SO s t a t emen t s a r e s u p p o r t e d i n c l u d i n g WI TH> REPEAT . . . UNT I L > CASK.WHILE l a o ps > FOR 1 oaps > I F , , THEN. . KLSK> an d GOTO.P ACK an d UNPACK a v' e s u pp o r t e d > bu t d o n o t a f f e c t t h e o u t come o f t h epr ogv'am ( dat a s tv uctuv'es ar e al way s packed a t Che by t e l evel >. N EWand DISPOSE ar e i m plement ed ' t hey a l l oc at e an d <strong>de</strong>a l l oc a t e HEAP space,M odu l a r co mp i l a t i o n i s a n e x t e n s i o n a f t h e ATAR I comp i l e r . V a r i a b l e sa n d v' o u t i n e s ma y b e ma d e p u b l i c a n d / a v pr i v a t e a n d ma y b e c a l l e d f r aman y o t he r mo d u l e ar fr o m t h e m ai n p r o gv'am.T h e e x t en <strong>de</strong> d d a t a t y pe s ST RI NG> BYTE> an d WORD a r e i m p l emen t e d i n t h e*TARI Pa s ca l camp i l e v . T h e STRI NG t y p e i n c l u <strong>de</strong>s a le n g t h b y t e f o l l o w edb y t h e ma xi mum numbe r o f b y t e s p o s s i b l e . Ra u t i n e s a r e s u p p l i e d t aINSERT a ch a r a c t e r o r a s t r i n g , D ELETK f r o m a s t v in g > f i n d t h ePQSi t i a n af a ch a r a c t e r i n a st v in g C OPY a p ov't i a n o f a ne s t ~ i n g t oa n o t h er > a n d CONCATen a t e Ce o o r m o r e s t r i n g s a n d / o r c h a r a c t e r sto g e t h ev . BYTE i s a o ne -b y t e d at a i t e m f o v' v ep re s e n t i n g n umbe rs f v om Gto 2 5 5 . WORD i s tsvo b y t e s f o r t h e 8 - b i t CPV.Ad d i t i o n a l p r o c ed u r e s t o ma na g e f i l e s o n d i s k e t t e a v e i m p l e ment e d . Af i 1» o n d i s k e t t e i s a s s o c i a t e d ari t h a n i n t e v nal f i l e a n d m ay b e c l o s e dov d e l e Ced.Man i p u l a t i n g B I T S a n d B YTE S i s d o n e u s i n g r o u t i n e s t o T E S T> S E T >CL K * R > S H I F T R I GHT > a n d L E F T > r e t uv n H I o r L QW o f a va r i a b le > an d S WAPC he h i g h a n d l o u b y t e s o f a v av i a b l e .Mi s c e l l a n e ou s r o u t i n e s t o ac c ess it e ms i n a pr o g r a m a v e t o v etu r n t h ead dr es s o f a va v iab le ov v ou t i n e > r e t u rn t h e s i z e o f a v a v ia b le o rty p e . m ov e a gi v e n n umbev of b y t e s f v am o ne m emav y l o c a t i o n t oan a t h e r a n d f i l 1 a d a t a i t e m v si t h a c e r t a i n c h a r a c t e r . A l s o . t h ea mauvvt a f HE* P s p a c e a v a i l ab l e a t a n y g i v e n t i m e i s a c c e s s i b l e .G ar bag e c o l l e c t i o n o n t h e HE* P i s s u p pov t e d.


Lo g i c a l op e r a t o r s f o r n o n - B oo l e ans a r e i m p l e ment e d .H EX l i t e r a l number s ma y b e u s e d w i t h a d o l l a r s i g n ( 4 ) .I n c l u d e f i l e s a r e s u pp o r t e d .A n ELSE c l a u s e o n t h e CASE s t a t emen t i s p r o v i d e d .P r o gr am CHAI NI NG i s s u p p o r t ed . Ch a i n i n g i s s u c h t ha t t h e c o d e f o r o n epr o gr a m i s t o t a l l y r e p l a c e d b g c od e f o r t h e n e xt pr o g r a ms b u t h e a pspac e ma y b e m a i n t a i n e d a c r o s s a CHAI N,


7 . 3 N o t a t i o n s T e r m i n a l o g y i a n d V o c a b u l a r yB I C I 9 I E I F C I H I I JL M N I 0 I P 6 I R 8 ' TW I X I Y I Zc ' dt I l m I nU I v w I xp z I< d i g i t > : : ~ 0 I l I 2 I 3 I 4 I 5 I 6 I 7 I S IA I B I C I 9 I E I F I ( o n l y a l l owed in H EX n u m be r s )< spec ial symbol > (reserved word s a r e l i s t e d i n t h e a p pen d i x )+ I ~ p II c > I III ( I ) I EII ~ I EI I I J I I(t h e f o l l o w i n g ar e a d d i t i o n al o r s u b s t i t u t i o n s : )( . I . ) I X I '? I ! I I I S I h( . i s s y n ony m f o r) i s a s y n onym .f o l j' ? a n d ar e sy 'nonyms!i a n d I ar e s y n onymsE x t e n s i o n s :The symbo l " 8 " i s a l e g al l e t t e r i n a d d i t i o n t o t h o s e l i s t e d i n t h e" Repo r t " . T h i s sy mbo l h a s b e e n a d <strong>de</strong> d b e ca us e t h e r u n - t i m e l i b r a r yro u t i n e s a r e w r i t t e n u s i n g t h i s s p e c i a l c h a r a c t er as t h e f i r s t l e t t e ro f t h e i r na me . B y a d d i n g " 8 " c o n f l i c t w i t h u s e r na me s i s a v o i d e d b u tus er s a r e a l l owe d t o c a l l t h es e r o u t i n e s , Se e s e c t i o n 7 . 4 f o r f u r t h eri n f or m a t i o n .A commen t b e g i n n i n g w i t h " ( + " mu s t en d w i t h< comment > . : = ( + < a n y c ha r a c t e r s83


7 . 4 I d e n t i f i e r s Numb er s . a n d S t r i n g s i" i d e n t i f i e r > :: = .=. l e t t e r > % < l e t t e r o r d i g i t o r u n d e r s c o r e>3.< l e t t e r o r d i g i t > : : = < l e t t e r > l < d i g i t > (< d i g i t sequenc e> : : ~ ( d i g i t > R 'di g i t >)-"un s i gne d i n t e g er > : : = 5 < d i g i t s e quen c e>< d i g i t s e q u en c e "< un s i gn e d r e a l > . " " . d i g i t s e q uenc e>«u n s 1 gn e d i n t eg er > . < d i g i t s e q uen c e>E r« s c a l e a c t or > E " :un s i g n e d number > < u'ns i 9 n ed i n t e ge r l < u n s i g n e d r e a l >< s c a l e f a c t o r > l « s i gn >«s t r i n g> '


7 . S Co n s t a n t De f i n i t i o n s : : ~ :. i d ent i f i er >< c on s t a n t > : : = < u n s i g n e d numb er >".si gn>~ .cons t a n t i d en t i f i er >- s i gn>%c on s t a n t i d e n t i f i e r >d ist r i n g >< c o n s t a n t <strong>de</strong> f i n a t i o n > : : = < i d e n t i f i e r > = .. c on s t a n t >In a d d i t i o n t o al l c o n s t an t <strong>de</strong>'c l a r a t i on s a v a i l a b l e i n s t a n d a r d Pa s c a l ~ATARi Pa s c a l s u pp o r t s d e c l a r a t i o n o f a n u l l s t r i n g c o n s t a n t :Examp le:n u l l s t r


7, 6 D a t a T y pe Def i n i t i o n ssi m p l e t y p e> : : ~ < i d e n t i f i e r > = < t y p e>7 . 6. 1 S i mp l e T y p es :: ~ < t ype i <strong>de</strong>n t i f i er >< t y p e i d e n t i f i e r > : : = < i d e n t i f i e r >7 . 6 . 1. 1 S c a l a r T y pe s< s c a l a r t y p e > : : = ( < i d e n t i f i e r 4 i < i d e n t i f i e r > > )7 . 6 . 1. 2 S t a n d a r d T y p e sT h e f o l l o w i n g t y p e s a r e s t a n d ar d i n <strong>ATARI</strong> Pa s c a l .INTEGERREALBOOLEANCHARBYTEWORDST R I NGT hr e e a d d i t i o n a l s t a n d a r d t y p e s e x i s t i n ATAR I Pa s c a l . Re f e r t o t h eAppen d i x fo r i n f o rm at i o n o n r e p r e s e n t a t i o n a n d u s a g e o f a l l s t a n d a r da n d s t r u c t u r e d t y p e s .S TRI NG : Pa c lte d a r r a y C 0 . . n l o f c h a rb y t e 0 i s d y na mi c l e n g t h b y t eb y t e s 1 . . n a r e c ha l a c t e r sS ubr a ng e 0 . . 25 5 w i t h s p e c i a l a t t r i b u t e t h a t i t is c ompa t i b l ea l s o w i t h CHAR t y p e .U ns i gn e d n a t i v e ma c h i n e wo r d7. 6. 1. 3 S u br a n g e Tg pes< s u br a n g e t y pe> : ; = < c on s t a n t > . . < c on s t a n t >7 . 6. 2 S t r u c t u r e d T y pe s86


'" s t r u c t u r e d t y p e> «un pa c ke d s t r u c t u r e d t y p e>PACKED =un pa c ke d s t r u c t u r e d t y p e>«unpa c ke d s t r u c t u r e d t y p e> ~«ar r a y t y p e>T h e r e s e t v e d w o r d PACKE D i s d e t e c t e d a n d h a n d l e d b y t h e A T AR I P a s c a lcompil er as f ol laws:Al l s t r u c t ur e s ar e pa c k ed a t t h e B YTE l e v e l e v e n i f t h e P ACKEDr e s e r v e d wor d i s n o t f o un d .7 . 6. 2 . 1 A r r a y T y p e s < normal ar r ay > I STRINQ C ]~ emp t y>« xnc on s t > < uns i gned i n t eger >i n t c on s t i d>« l n t c o n s t i d > A RRAY C < i n d e x t y p e > C i < i n d e x t y p e>] ] OFVa r i a b l e s a f t y p e ST RI NG hav e a d e f a u l t l e n g t h o f 8 1 b y t e s ( 8 0 d at ac ha r a c t e r s ) . A d i f f e r en t l e n g t h c a n b e s p e c i f i e d i n s q u a r e b r a c k e t sf a l l o wi n g t h e wor d STRI NQ. Th e l e n g t h mu s t b e a c o n s t a n t ( e i t h er?i t e r a l a r d e c l a r e d e. g, i STR IN Q(:5] ar STR IN QCxyz ] ( w he re x y z i s ac an s t an t ( xy x= 10 3 3 . I t r e p r es e n t s t h e l e n g t h o f t h e DAT* p o r t i on(i . ei o n e m are b y t e i s a c t u a l l y a l l o c a t e d f a r t h e l e n g t h ) .87


7 , 6, 2. 2 . Rec or d T y p e s ~ RKCORD < f i e l d l i s t > END< f i e l d l i s t > < f i xe d p a r t >< f i xe d par t > t < v ar i a n t p a r t >< var i an t pa r t >< f i xe d p a r t > : = < r ec or d s e c t i an > 4' < r e c or d s e c t i o n>3.< r e c or d s e c t i o n . : = Ci 3 . f < va r i a n t pa r t > : < CASK < t a g f i e l d > < t y p e i d e n t i f i er > QF ) : = < case L ab el L i s t > :-".emp tg>( < f i e l d L i s t > ) : = < cas e l a b e l ) ( < c a se L ab e l > ) : ~ : = < i d e n t i f i e r >7 , 6. 2. 3 S e t T y p e s : : = SKT Q F b a s e t y p e> : : = < s i m p l e t y p e>Th ~ max im um r a n g e a f a ba s e t y p e i s 0 . . 25 5. F o r e x ampl e a s e t a fLO. . 10000 3 i s n a t l e g a l . T h e s e t a f CHAR a r s e t o f 0 , . 255 is L eg alb u t s e t a f 0 . , 25 6 i s n a t .


7 . h. 2. 4 F i l e T y p e s' ".f i l e t y p e > : : = f i l e >U nt y pe d f i l e s a r e a l l owed . T he y a r e u s e d f a r CHAI NI NQ an d a r e a l s oused wi t h BLOCKRE*D and BLOCKWRITE pr ocedur es . Be e x Creme ly c a re fu lw hen u s i n g u n t y pe d f i l e s .When y o u w i s h t o r ea d a f i l e a f A SCI I c h a r a c t e r s a n d u se i m p li e dc on v e r s i an s f a r i n t e g e r s an d r ea l numb er s u s e Ch e p r e - d e f i n e d t y p eTEXT. TEXT i s NO T t h e same es F I L E O F C HAR. I C h as c o n v e r s i o n i m p l i e di n READ an d WRI T E p r a c ed ur e c a l l s a n d a l s o ma y b e u s e d w i t h RE* DL N a n dWRITELN. A f i l e o f t y p e TEXT i s d e c l a r e d i n t h e f' a l l o wi n g ma nn er : " VARF: TEXT" . Th e INCORRECT syn t a x f ar <strong>de</strong> cl ar i n g a TEXT f i l e is " VAR FF ILE- OF TEXT " . Se e t h e a p pendi x o n Pa s ca l f i l e ha n d l i n g .7 . 6. 3 P a i n t e r T y p e s. ".pai n t e r t y p e > : : = < t y p e i d e n t i f i e r >P a i n Ce r Cy pe s a r e i d e n t i c a l t o t h e s t a n d a r d e x c ep t t ha t wea k t y p echec ki n g e x i s t s when Che RELAXED t ype chec k i n g f ea t ur e a f t h e compi l eris e n a b l e d . I n t h i s c a s ei p o i n t e r s a n d W ORDS u s e d a spa i n t e r s a r e compa t i b l e i n a l l c a s es.


7 . 6, 4 Types and Assi gnment Compati bi l i t yT he mos t common s t a n d a r d Pa s ca l q u e s t i o n c o n c e r n s t y p e c o n f l i c te r r o r s me s s a ge s f r o m t h e comp i l e r . T y pe s mus t b e i d e n t i c a l i f Ch eva r i a b l e i s pa s s e d Ca a V AR p a r a met e r. T y p es m us t b e c ompat i b l e f o rexpr e s s i ons a n d a s s i g nment s t a t ement s . T o u nd ers t a nd t h e d i f f e r e nc eb et ween campa t i b l e a n d i <strong>de</strong> n t i ca l t y pes > Ch i n k o f t y pe s a s p o i n t er s t oc omp i l e - t i m e r ec or ds . I f yo u <strong>de</strong> c l a r e a t y p e ( suc h a s T=ARRAY E i . . 10 3O F I NTEGER) > t he n a n y t h i n g <strong>de</strong> c l a r e d a s t y p e T r e a l l y p o i n t s t a t here c or d <strong>de</strong> scr i b i n g t yp e T . I f > on t h e o t he r ha nd > yo u <strong>de</strong> c l a r e t wovar i ab l es a s f ol 1 ows:VARAi : ARRAY E1, . 10 3 OF I NTEGERA2 : ARRAY E i . . 10 3 OF I NTEGER't he y a r e n a t i d e n t i c a l , Th e comp i l e r c r e a t e d a ne w r e c ar d f o r e a c ht yp e an d t h e r e f or e A i a n d A2 d o na t p a i n t t o t h e same r e c or d i n memor yat comp i l e - t i me. Th e gener al r u l e is C hat i f y o u c an nat f i n d y our w a yba c k t o a t y p e d e f i n i t i o n . C hen t h e t y p es a r e n o t i d e n t i c a l .CHR ORD> an d WRD ar e t y p e conver san op er a t or s t ha t gener a t e n o ca <strong>de</strong>b u t t e l l Ch e comp i l e r t ha t t h e f o l l owi n g 8 - b i t da t a i t em i s Cab e c on s i d e r e d t yp e CHAR> I NTEQER> or WORD r e s pe c t i v e l y .Thes e oper a t or s ma y b e v se d i n e x pr e s s i on s a n d wi t h par am et e r s ex ce ptVAR p ar'amete r s .B el ow i s a s e c t i on f r om t h e I SO dr a f t s t an da r d ( DPS- 7 18 5 ) wh i c h i sav a i l a b l e f r om t h e Ame r i ca n Na t i a na l S t a nda r d s I n s t i t u t e . T h e I SOst andar d d e f i n i t i on a f compa t i b l e t y pe s i s a s f o l l ows :Type s T i an d T2 shal l b e <strong>de</strong> s i gn a t e d compa t i b l e i f a n y a f t h e f ovr'st a tement s t ha t f a l l aw i s t r ue.(a ) T i a n d T 2 a r e t h e same t y pe .( b ) T i i s a svbr ang e o f T2 o r T 2 i s a su br a ng e o f T i ~ or b o t h T i a n dT 2 a r e su br ange s a f t h e same hos t t y pe .(c ) T 1 an d T2 ar e <strong>de</strong> s i g nat e d p ac k ed o r n e i t h er T i nor T 2 i s<strong>de</strong>s i gn a t e d pa c ked.< d ) T i a n d T 2 a r e s t r i n g- t y pes+ wi t h Ch e same number o f componen t s ... . Assignment c ompatib il i t y . A v al u e o f t y pe T 2 s hall b e d esig nate da s s i gnment - compa t i b l e w i t h a t yp e T 1 i f a n y o f t h e f i v e s t a teme n t st ha t f ol l ow i s t r u e ,(a ) T l a n d T 2 a r e t h e same t y pe > t ha t i s n e i t he r a f i l e - t y p e nora s t r u c t ur e d- t yp e wi t h f i l e componen t ( t h i s r u l e i s t o bei n t e r pr e t e d r ec ur s i v e l y ) .( b ) T i i s t h e r e a l - t ype an d T 2 i s t h e i n t e g e r - t y pe .(c ) T i a n d T2 a r e compa t i b l e o r d i n a l - t y pes~ + an d t h e v a l v e o f t y peT 2 i s i n t h e c l ose d i n t er va l s p e c i f i e d b y t h e t y p e T i .(d ) T i a n d T 2 a r e compa t i b l e s e t - t y pe s a n d al l t he member s a f t h ev a l u e a f t yp e T 2 a r e i n t h e c l ose d i n t er va l s pec i f i e d b y t heb a s e - t y p e o f T i ,( e ) T i an d T2 a r e compa t i b l e s t r i n g- t y pe s+ .


* t a n y p l a c e wh er e t h e r u l e o f a s s i gnmen t - compa t i b i l i t y i s u s ed :(a ) It s h a l l b e a n e r r o r i f T l a nd T 2 a r e c ompat i b l e o r d i n a l - t y p e s ++an d t h e v a l u e o f t y p e T2 is n o t i n t h e c l o s e d i n t e r v a l s p e c i f i e db y t h e t y p e T l .( b ) I t s h a l l b e a n e r r'o r i f T l a n d T 2 ar e compa t i b l e s e t - t y p e s a n da n y membe r o f t h e v a l u e o f t y p e T 2 i s n o t i n t h e c l o s e d i n t e r v a lsp ~ c if i e d b y t h e b a s e - t y p e o f t h e t y p e T l .S t r i n g - t y p e s i n I SO Pa s c a l s a r e a r r a y s o f c ha~a c t e~ s ,Or d i n a l t y p e s a r e n am ed s u b ra n g es o f n umbe rs o r e n umer a t i o n s .7 . 7 l )e c l a r a t i o n a n d I)en o t a t i on s o f Va r i a b l e s%var/< e x t e r n a l v a r )< a b s o l u t e v a r >< e x t e r na l v a r > : : = < a b s o l u t e v a r > ; = ABSOLUTE [ < c on s t a n t > 1 < v a r >ovary : = < e n t i r e v a r i a b l e > tA BSOLUTE v a r i a b l e s ma y b e d e c l a r e d i f y o u kn ow t h ~ a d d r e s s a t comp i l et i me . Yo u d e c l a r e v a r i a b l e ( s ) t o b e a b s o l u t e u s i n g s p e c i a l s y n t a x i n aV AR d e c l a r a t i on . ABSOLUTE v a r i a b l e s a r e n o t a l l o c a t e d a n y s p a c e i ny ou r d a t a s egmen t b y t h e comp i l e r a n d y o u a r e r es p on s i b l e f o r m a k i n gs ur e t ha t n o comp i l e r - a l l o c a t e d v a r i a b l e s c o n f l i c t w i t h t h e a b s o l u t ev a r i a b l e s . NOTE ; STRI NG VARI ABLES M* V NOT EXI ST A T LOCATI ONS < ~ OI 0 0 . .T h i s i s d on e s o t h a t t h e r u n - t i m e r o u t i n e s c a n d e t e c t t h e d i f f e r e n c eb e t ween a s t r i n g a d dr es s a n d a c h a r a c t e r o n t h e t o p o f t h e s t a c k .C ha r a c t e r s h a v e t h e h i g h b y t e o f 0 whe n p r e s en t o n t h e s t a c k . A f t e rth e c o l o n ( : ) a n d b e f o r e t h e t y p e of v a r ' i a b l e ( s ) i y o u p l a c e t h ek eywor d ABSOLUTE f o l l owe d b y t h e a d d r e s s o f t h e v a r i a b l e i n b r a c k e t s( C. . 3 ) :Examples:I: A BSOL UT E CSS 0 0 3 I NTEGERSSCREEN: ABSOLUTE CSC000 3 ARRAYCO. . 15 3 OF ARRAYCO. . 63 3 OF CHAR'


7 . 7 , 1 E n t i r e Va r i a b l e sen t i r e v a r i a b l e> : : ~ < v a r i a b l e i d e n t i f i e r >< v a r i a b l e i d e n t i f i e r > : ; = < i d e n t i f i e r >7 . 7, 2 Compon en t Va r i ab l e s< componen t v a r i a b l e > : : = « i n d e xe d v a r i a b l e>< f i e l d d e s i gn a t o r >< f i l e b u f f e r >7, 7, 2. i I n <strong>de</strong>xed Var i abl es< i n d e xe d v a r i a b l e > : : = < a r r a y v a r i a b l e > C< e x p r e s s i on > Ci < e x pr e s s i on > > 3< a r r a y v a r i a b l e > : : = < v a r i a b l e >STRI NG v a r i a b l e s a r e t o b e t r e a t e d as a P *C KKD a r r a y o f C HAR f o rs u b s c r i p t i n g p u r p o s e s , T h e v a l i d r a n g e i s 0 . . ma x l en g t h i wh er em ax l e n g t h i s 8 0 f o r a d e f a u l t l e n g t h .7 . 7. 2. 2 . F i e l d De s i g n a t o r s< f i e l d d e s i g n a t o r > : : = < r e c or d v a r i a b l e > . < f i e l d i d e n t i f i e r >< r e c or d v a r i a b l e > : : ~ < v a r i a b l e >< f i e l d i d e n t i f i e r > : : ~ < i d e n t i f i e r >7 . 7. 2. 3 F i l e Suf f er s< f i l e bu f f er > : : ~ < f i -l e v a r i a b l e>< f i l e v a r i ab l e> :: ~ 7. 7. 3 R ef er enced Var i abl es< r e f e r en c e d v a r i a b l e > : : ~ < p o i n t e r v a r i a b l e> : . = < v a r i a b l e>


7 . 8 E x p r e s s i on s< un s i g ne d c on s t a n t > < uns i gne d numb e r >«.5 t r i 'ng >N I L' .c on s t a n t i d e n t i f i e r >f a c t o r > < un s i gne d c o n s t a n t >< f unc t i on d e s i gn a t o r >« expr e s s i on > )< l o g i c a l NO T o p er a t or > < f a c t o r >:set >s et > C « ~el emen t l i s t > < .elemen t > ( , < e l eme n t > )< .empt y>< element > < e x pr ess i an > . . < f act or > < s i m p l e e x p r e s s i o n . < s i m p l e e x pr e s s i on > < t er < t er m>< e x pr e s s i on =- i mp l e e xpr e s s i on. .si mp l e e x p r e s s i on > 9 e l a t i o na l o p e r a t o r >«~simp le expression>4 n a d d i t i o n a l c a t e g o r y o f o p e r a t o r s o n 1 6 - b i t v a r i a b l e s a r e h i(a l s o < ) i < a l s o 4 a n d 7 ) d e n o t i n g * ND. O R an d ONE ' s comp l emen t NOT.r e s pe c t i v e l y , T h es e h a v e t h e same p r e c e<strong>de</strong>n c e a s t h e i r e q u i v a l e n tb o o l ea n op er a t o r s a n d a c c ep t a n y t y p e o f o p er an d w i t h a s i z e < ~ 2b y t e s .


7 . 8 . 1 O per a t o r s7. 8 . 1. 1 T h e Op e r a t o r NOT< ) o g i c a ) NO T op er a t o r > : : =NOT I X I ?an d ? a r e NOT o p er a t o r s fo r no n - B oo l e an o p e r a t o r s .7 , 8. 1, 2 Nu) t i p ) gi ng Oper a t or s : : = + I / I- DI V I MO D I * N D I 4~i s a n AND op e r a t o r o n n o n - Bo o l ea n o p e r a t o r s .7 . 8 . 1. 3 * d d i n g Op er a t o r s< a d d i n g o per a t o r > : : ~ + I I O R I I< syn on y m I } i s a n OR o p er a t o r o n n o n - Bo o l ea n o p e r a t o r s .7 . 8 . 1. 4 Re ) a t i o n a ) Op er a t o r s< r e l a t i o n a l o p e r a t o r s > : : = = I < > I < I ~ = I > = I I N7 . 8. 2 F u n c t i o n De s i g n a t o r s< f u n c t i o n d e s i g n a t o r > : : = ~ f u n c t i o n i d e n t i f i e r >I < ':par m> 4i 3.< f unct i on i <strong>de</strong>n t i 0 i e r > ; ; =


7 . 9 S t a t emen t s: s t a t emen t > < l a b e l > : = u n l a b e1 l ed s t a t emen t >" u n l a b e l l e d s t a t emen t >u n l a be l l e d s t a t emen t > < s t r u c t u r e d s t a t emen t >< 3,abel > < u n s i gne d i n t e g er >7 . 9 . 1 S i m p l e S t a t emen t s: :si mp l e s t a t eme n t > ' .a s s i gne d s t a t emen t >: :pr oc ed ur e s t a t emen t > I- :got o s t a t emen t >< empt y s t a t emen t >- .emp t g s t a t emen t .' '~empt gp7 . 9 . 1, 1 A s s i gnmen t S t a t emen t s< a s s i gnmen t s t a t emen t > : : = : = < e x pr e s s i on >< f u n c t i o n i d e n t i f i e r . = < e x p r e s s i o n )T o t h e l i s t o f e x c e p t i on s t o a s s i gnmen t compa t i b i l i t y a d d :1 . I n t e ge r e x pr e s s i on s ma y b e a s s i g n e d t o v a r i a b l e s o f t g p e -p o i n t e r .F o r e xamp l e :TYPE X ~ RECORD( + f i e l d d e c l a r a t i on s + )E N D iVA R P : "' XiI; I NTEGER>P : = I + 1 )2 . E xpr e s s i on s o f t y p e CHAR ma y b e a s s i g n e d t o v a r i a b l e s o f t g p eSTR ING.3 . V a r i a b l e s o f t y p e CHA R a n d l i t e r a l c h a r a c t e r s ma y b e a s s i g n e d t ovar i ab l e s o f t y p e BYTE.4 . E x p r e s s i o n s e v a l u t i n g t o t h e t y p e WORD ma y b e a s s i g n e d t o p o i n t e rva r i a b l e s.5 . E x pr e s s i on s e v a l u a t i n g t o t h e t y p e I NTEGER ma g b e a s s i g n e d t ovar i ab l e s o f t y p e NORD.


7 . 9 . l . 2 P v ' o c e du v' e S t a t e me n t s'" pv oceduv e s t a t emen t . : : = 3 )< pv aced ur e id en t i f i ev >< pr oc ed ur e i d e n t i f i e v > : : ~ < i d en t i f i er > < pv ac eduv e i d e n t i f i e r >< f u n c t i on i d e n t i f i e r< e xpv es s i on>Th ~ max im um n umbev o f p av amete rs f o r a p r a c e duv.e a r f u n c t i o n i s f i f t y( 5 0 ) .7. 9 . 1. 3 G OTO S ta t e men t s< g a t a s t a t e men t > : : = g a t o < l a b e l >7 . 9 2 S t r u c t u v'e d S t a t emen t s< s t v u c t u r e d s t a t emen t > : : = < r e p e t i t i v e s t a t emen t >: c an d i t i a n a l s t a t emen t >< compoun d s t a t emen t >< e i t h s t a t emen t >7 . 9. 2. 1 Compoun d S t a t eme n t s : : = BEGI N < s t a t emen t > 4i < s t a t emen t > 3 END7 . 9. 2. 2 Co n d i t i o n a l S t a t emen t s< c on d i t i o n a l s t a t emen t > : . ~ c a s e s t a t emen t >< i f s t a t emen t >7 . 9 2 . 2. 1 I f S t a t eme n t s< i f s t a t eme n t ) : ; = I F < e x p r e s s i on > THEN < s t a t emen t > ELSE < s t a t emen t >1 F < e x pr e s s i on > THEN -".s t a t emen t >7 . 9. 2. 2. 2 Ca s e S t a t emen t s< ca s e s t a t emen t > C ASE ' e xpv es s i an > GFca s e l i s t > ~i < case l i s t > )% ELSE 3END < l abe l l i s t > : s t a t eme n t >< l a be l l i s t > C " c a s e l a b e l l »< c a s e l a b e l > < n an- v eel s h or t s c a l a r c o n s t a n t >* T* R I Pa s ca l i m p l emen t s a n ELSE c l a u s e a n t h e CASE s t a t eme n t . I naddi t i ons i f t h e s el ec t i n g ex pr essi on does na t m a t c h an y of ' t h e ca se


s e l e c t o r s . t h e p r o g r a m f l o w w i l l " d r o p t h r o u gh " t h e CASE s t a t emen t .T h e s t a n d a r d s a g e t h i s c o n d i t i o n i s a n e r r o r .Examp le:CASE CH OF' A ' : WR I TELN ( ' * ' ) ;' O ' : M R I T E L N ( ' 6 ' ) iELSEM RITELN( 'NOT * O R 6 ' )END7 . 9. 2. 3 Re p e t i t i v e S t a t eme n t s' r e p e t i t i v e s t a t emen t > : : = < r e p ea t s t a t eme n t )< wh i l e s t a t emen t >< f o r s t a t emen t >7 . 9, 2. 3. 1 Mh i l e S t a t emen t s. "wh i l e s t a t emen t > : ; = WH I L E < e x p r e s s i on > DO < s t a t eme n t >7 . 9. 2. 3. 2 Re pea t S t a t emen t s< r e p ea t s t a t emen t > : : = REPEAT < s t a t ement > 4 , < s t a t eme n t > ) UNT I L7 . 9. 2. 3. 3 F o r S t a t emen t s< f o r s t a t emen t > : : = FOR < c t r l v a r > ; = < f o r l i s t > DO < s t a t eme n t > ; : = DOMNTO TO < c t r l v a r > :: = 7. 9 . 2. 4 M it h S t a t e men t s< w i t h s t a t emen t ) : : = METH < r e c o r d v a r i a b l e l i s t > DO < s t a t emen t >C r ec or d v a r i a b l e 1 i s ' t > : ; = < r e c o r d v a r i able. '


7 . 10 P r o c eduv e De c l a r a t i o n s" .pr o c ed ur e <strong>de</strong>c l av a t i o n > E XTERNAL < pv oc ed ur e h e a d i n g.. pv'oc ed ur e h e a d i n g > < bl o c k > < l a b e l d e c l a r a t i o n p a r t >" ' cons t an t <strong>de</strong>f i ni t i on par t >< t y p e <strong>de</strong> f i n i t i o n p a r t >.Yar i ab l e d ec l av at i on p av t>< pr o c f un c d e c l a r a t i o n p a r t >< s t a t emen t p a r t > P ROCEDURE < i d e n t i f i e v > < pa r ml i s t >P ROCEDURE < i d e n t i f i e v > .< par ml i s t > ( < f pav m> 4i .- f pav m>3 VAR < pa r m g v' oup>


v a r i a b l e d e c l a r a t i o n p a r t . = . : = YAR< var i ab l e d e c l a r a t i on>4 i ~ v a r i a b l e d e c l a r a t i o n > 3. p r o c f un c p a r t > ( < p r o c o r f u n c > ~ -~pr o c ed ur e <strong>de</strong>c l a r a t i o n >< f un c t i o n d e c l a r a t i on>< s t a t emen t p a r t > - .compoun d s t a t eme n t >


7. 10 . 1 S t a n dav d Pv.oc eduv' esTh e f o l l o w i n g i s a l i s t o f A TARI P as c al b u i l t - i n p r o c e du re s. S eeCha p tev' 3 f o v pa va me t ev s an d u s a g e. T h e se p v'o ce duv'es a r e p v 'e -d e c l a v edin a s c o p e s u r r o u n d i n g t h e p v ' ogv am. T h e v ef o " ei a n y u s ev ' v ou t i n e s o ft h e same name w i l 1 t a k e pv ece<strong>de</strong>n c e .NEW DI SPOSE E X I T INSERTDELETE COPY CONC AT F ILLC H*RMOVELEFT HOVER I QHT CLRB I T H IL O S ETB I T SHL SHRS4IAP T STB I T LENGTH POSADDR NOVE NAXA VAI L HENAVA ILS I ZEOF7. 10 , 1. 1 F i l e Ha n d l i n g Pv' o c eduv esAl l s t a n d a r d f i l e ha n d l i n g pv oc eduv es av e i n c l u d e d. I n a d d i t i o n t h epv o c e d u r e A S S I GN ( F i s t r i n g ) i s a d d e d v h e r e " F " i s a f i l e a n d " s t v i n g "is a li t e v'al o v v a r i a b l e s t r i n g . A SSIG N a ss i g ns t h e e x t e v nal f i l e n ameco n t a i n e d i n t h e s t v ' i n g t o f i l e F . I t i - u s e d pv ec e d i n g a R ESET o vREWRITE. Se e Se c t i o n 3 , 4 . 15 f o r mov e d e t a i l s .Li s t e d h e l o t a v' e t h e n a me s o f t h e f i l e h a n d l i n g p r o c e d u v e s :QET PUT RESET REWR ITKASSI GN CLOSE CLOSEDE PURGEOPEN BL OCKREAD BLOC KWR I TK READCHAI N PAQK IORKSULTQNB 4INB WR ITELNWRITEREADL N


7 . 10 . 1. 2 D y na mi c A l l o c a t i o n Pr o c ed ur esNE WD I SP OSEI n a d d i t i o n t o NE W a n d DI SPOSED 'in c l u d ed.NENAVA I L a n d NA XAVA I L a r e a l s o7 . 10 . 1. 3 D a t a Tr a n s f e r Pr o c e d ur e sPACK ( A i I i 2 3 U NPACK ( Zi Ai I 37. 1Q. 2 FORWARDF or wa r d p r o c ed ur e d e c l a r a t i on s a r e i m p l emen t e d i n AT* R I Pa s c a l . l t i sr e commen<strong>de</strong> d t ha t t h i s f e a t ur e n o t b e u s e d u n l es s s t r i c t Pa s c a lco n f or m a n c e i s r e q u i r e d , T h e t h r e e p a s s c o m pi l e r s m a k e s f o r w ar dd e c l a r a t i o n s u n n e c e s s a r y .


7. 10 . 3 CQNFORMANT ARRAYSNo t e t h a t t h e I S Q s t a n d a v d h a s a d d e d t h e COMFQRMANT ARRA Y SCHEMA f o v'pa s s i n g a v ' r a g s o f s i mi l a v s t r u c t uv e < i. e. i s am e n umber o f d i m en s i o n s .c omp a t i b l e i n <strong>de</strong> x t g p e a n d same e l emen t t g p e ) , bu t d i f f e r en t u p pe v a n dlo we r b o u n d s . Y o u ma g n o + p a s s i f a r e x a mp l e . a n a r r a g d i me n s i a n e d a s1 . . 10 a n d a n a r r a g 2 . . 5 0 t a a pv oc ed ur e e x p e c t i n g a n av r ag . Y o u<strong>de</strong> f i n e t h e a r r a g as a V AR p a v a m et e r a n d i n t h e p r o c e s s a f d e c l a r i n gt h e a r v a g i go u a l s o d e f i n e v a r i a b l e s t o h a l d t h e u p pe r a n d l o v e r b o un dof t h e a r r a g . T h es e u ppe r a n d l ame r b o un d i t ems ave f i l l e d i n a tRVN- TI ME b g t h e g en er a t e d c o <strong>de</strong> ; T o pa s s av r ag s i n t h i s man ne v i t h ei n <strong>de</strong> x t gp e mus t b e compa t i b l e ari t h t h e t g p e o f t h e c o n f or ma n t a v r a gb o u n d s .B e l o w i s a n e xamp l e a f p a s s i n g t wo a r r a g s t o a p r o c eduv e t h a td i s p l a g s t h e c o n t e n t s .a f t h e .av r a g s o n t h e f i l e OUTPUT :PRO('RAM DEMOCON;TYPEN ATURA L = 0 . . MA X I NT i ( « F OR US E I N CONFORM* NT ARRA Y DECLA RA T l QN « )VARAlA2: ARRAY C l . , 10 1 OF I NTE


D I SPLAY I T ( A2 )(+ CAL L DISPEL A Y I T AN D PAS S A 2 E XPL I C I T L Y AND2 AND 2 0 I NPL I C I TL Y + )


7. 1 1 Func t i o n Dec l ar a t i ans.f u n c t i a n d e c l .: = EXTERNAL < f u n c t i a n h ea d i n g > t< f un c t i o n h e a d i n g > b l o c k>" parm l is t > :.".r e s u l t t y p e >'FUNCTI ON < i d e n t i f i e r > : < r e s u l t t y p e>< r e s u l t t y p e > = < t y p e i d e n t i f i e r >7 . 11. 1 S t a n da r d F u n c t i o n sL i s t e d b e l o w a r e t h e na me s o f t h e s t a n d a r d f u n c t i a n s s u p p o r t e d ;ASS SSR S I N CQSEXP L N SGRT ARCTANODD TRUNC ROUND ORDWRD CHR SUCC PREDEQLN EOF I ORESUL T MEM*VA ILM AXA VAI L ADDR SI ZEOF POSLENQTH7 . 1 1 . 1 . 1 A r i t h m e t i c F u n c t i o n s7 . 11. 1. 2 P r e d i c a t e s7 . 11. 1, 3 T r a n s f e r F u n c t i a n sWRD< x ) : Th e v a l u e x (a va r i a b l e o r e x p r e s s i o n ) i s t r e a t e d as th e W ORD< un s i gn e d i n t e g er ) v a l u e o f x , I n t e ge r l i t e r a l c o n s t a n t s a r e n o t o ft y p e WORD. T h er e f o r e i f W i s a f t y p e wa r d , W: =3 i s i l l egal ' a n d e a um us t u s e W : = WRD ( 3 ) .7 . 1 1 . l . 4 F u r t h e r S t a n d a r d F u n c t i a n sFi l e ha n d l i n g : ( F i s a fi l e v a r i a b l e . S ee f i l e s i n a p p e nd i x , )P UT(F ) QET ( F ) RESET ( F ) REWRITE N EW(P ) NE W( Ps T l u T2 z . . . ~ T n) D I S POSE( P ) D I S POSE( P s Tl i T 2 i . . . > Tn)Da t a T r a n s f e r P r o c e d u r e s :( S e e p a g e 10 6 o f J e n s e n a n d M i r t h f o r a m o r ec o mp l e t e d e s c r i p t i o n . 3PACK (* s I i Z ) U NPACK ( Ze A i I )A r i t h me t i c f un c t i o n s :


4 3 S ( X ) Q R A BS< I ) — s p e c i a l r e t u r n s t h e t y p e o f i t s a r g u me n tS GR(X ) QR SGR< I ) — i f p a s s e d i n t e ge r r e t u r n s i n t e ger" e t c .T r a n s f e r f un c t i o n s :


7. 1 2 I NPUT AND OUTPUT* TARI Pa s c a l s u pp o r t s a l l s t a n da r d Pa s c a l I / O f a c i l i t i e s .7. 12 . 1 THE PROCEDURE READRea d i n g i n t o s u bvange s i s i m p l emen t e d bu t n o r a n g e c h e c k i n g i sp e r f o r me d . e v e n w i t h v a n g e c h e c k i n g t u r n e d o n .7. 12. 2 TH E PROCEDURE RE* Dl N~~r ead ca11> Rea d o r v' ead l n C ( i 3 % > ) 3. : : = READ l READLN< f i l e v a r > . var i ab 1 e>~ var l i s t > = 4i 3­7. 12. 3 TH E PROCEDURE WRI TE7. 12. 4 TH E PROCEDURE WR ITELN : =" wr i t e o r wv ' i t e l n > ( ( 4< f i l ev a r > ~ 3 f e xpr l i s t 3 ) 3. : : < WR I T E l W R I TELN< e xpr l i s t > 4: 4 : ~i<strong>de</strong> e e x p r>3-3 < e x p r e s s i o n>


n ew pr o c ed ur e s a l l o + He x I / O o n v a r i a b l e s o % an y on e- , t wo- . o rf o u r - b y t e t y p e s u c h a s i n t e g e r s c h a r i b y t e s u b r a n g e . e n ume r a t e d i c o r d ia n d l o n g i n t e g e r . S e e t h e s e c t i o n i n C h a p t e r 3 . 4 o n A T AR I P a s c a le x t e n s i o n s .


7. l 3 PROGRAMS"..pr o gra m>"=pr og r a m h ea d i ng > ~ 'labe l <strong>de</strong>cl ar at i o n pa r t >..con s t a n t d e f i n i t i on p a r t >" '.t ype <strong>de</strong>f i n i t i on par t >" "var i ah 1 e d ec l ara t i on par t >~ ~proc f un c d ec l a r a t i o n p a r t >MODEND: :pr o g r a m h ea d i n g > : : ~ PROGRAM "':i <strong>de</strong> n t i f i e r > ( ~ p r o g p ar ms > )mo d u l e h e a d i n g: : = MODUL E < i d e n t i f i e l "'< pr o g par ms > .i d e n t i f i e r > Ci < i d e n t i f i e r > )T h e a b a v e i s i d e n t i c a lR ef er t o Cha p t e r 3 .t o t h e s t a n d a r d w i t h t h e a d d i t i o n o f mo d u l e s i


A PPENDI X 4 :<strong>LANGUAGE</strong> SYNTAX DESCR I P T I ON< l e t t er > . : = * I B IC l D F I G I . I J IK I Q I P l 6 SIIXN1Rb HV UZ t a c tI F g l h k m toIrxnu YI' d i g i t > - : = 0 ! I ! 2 j 3 i 4 I 5 ' r 6 l 7 ' r 9 s* l B l C l D l E . l F


c on s t a n t i d e n t i f i e r >"'.si gn "":s t r i n g>« c on s t a n t <strong>de</strong> f i n i t i o n > : : = -" . i d e n t i f i er > = ~. c on s t a n t >'Cty p ep «s i m p l e t y p e>< s t r ue t ur e d t y pe > I : : = « i d e n t i f i er > = < t y pe>.:simple t ype>< t y p e i d e n t i f i e r >«t y p e i d e n t i 0 i e r > : . = -. i d e n t i f i ev >« s c a l a r t y p e > : : = < « i d e n t i f i e r > 4 i « i d e n t i f i e r > 3 )" s u br a n g e t y p e > : : = c on s t a n t > , . < c on s t a n t "ARRAY C -. i nd e x type.' 4, " i n<strong>de</strong> x t ype>>3 OF< compon en t t y pe«i n d e x t y p e= RECORD « f i e l d l i s t = E ND< .f i e l d l i s t >


v a r i a n t p a r t >«'f i x ed par t > < r e c o r d s e c t i on > Ci - .re co rd s e c t i o n . )< r e c or d s e c t i o n > : : = f i e l d i d e n t i f i e r > 4. < f i e l d i d e n t i f i e r > ) : < t y p e > l< v a r i a n t p a r t > C ASE < t a g f i e l d > < t y p e i d e n t i f i e r > OF< var i a n t > 4' >< v a r i a n t > = < c a s e l a be l l i s t . : ( < f i e l d 3 . i s t > ) : : = < c a s e l a b e l > 4. < c as e l a b e l> 3.< c as e l a b e l < c on s t a n t >< t a g f i e l d> = < i d e n t i f i e r >SET OF < bas e t y pe>'-:bas e t y p e>< simple type> f i l e i of > < e x t e r na l v a r »< ab s o l u t e v a r >< ext er na l v ar > E XTERNAL ( v a r >< ab so l u t e v a r > A BSOLUTE C < c on s t a n t » 3 < v a r >« va r > = < e n t i r e v a r i a b l e>< compon en t v a r i a b l e>< r e f e r en ce d v a r i a b l e :Dec l a r a t i o n o f v a r i a b l e o f t y p e STRI NG:< i d e n t i f i er > ( . < i d e n t i f i e r > > : ST RI NG ( C< c on s t a n t > l >- ';ent i r e v a r i a b l e> = < v a r i a b l e i d e n t i f i e r >v a r i a b l e i d e n t i f i e r > : : ~ < i d e n t i f i e r >c omponen t v a r i a b l e > : : = ' i n d e xe d v a r i a b l e>« f i e l d d e s i g n a t o r >


f i el d d e s i gn a t o r > : : = < r e c or d v a r i a b l e > . "".f i e l d i d e n t i F i e r >< r e c o r d v a r i a b l e . : : = : v a r i a b l e>< f i e l d i d e n t i f i e r > : : = "". i d e n t i f i e r >< f i l e b u f f e r > < f i l e var i abl e > < r e f e r e n c e d v a r i a b l e > : : -".poi nt er v a r i abl e .," .po i n t e r v a r i a b l e> ~ ;var i a b l e>. un s i gn e d c o n s t a n t > " "un s i g n e d numb er >~'str in g >N1L< c on s t an t i d e n t i f i e r >< f a c t or > < un s i gn e d c o n s t a n t >'-:f un c t i o n d es i gna to r>( < e x pr e s s i on > ) I< l o g i c a l n o t o p e r a t o r > "wf ac to r >- s et >< set > < e l emen t l i s t >< e l emen t l i s t > ~~e lement> E'i < element> ) ~ expl es s l on >.expr es s i on > . . ~t er m> = < f a c t or > < f a c t or >"s i m p l e e x p r e s s i on . : : = < t er m>~ si m p l e e x p r e s s i on > < a d d i n g o p er a t o r > < t er m> l < t er m> : : = NO T l X ta n d - . i s a r e NQT o p e r a t o r s f o r n o n - B o o l s a n s .~mul t i p l y i n g o p er a t o r . ; : = + l / l D I V l NQ D t ANDZ » i s a n AN D o p e r a t o r o n n o n - B o o l e a n s ,' .:ad d i n g o p e r a t o r ~ : : = +l — l QR1 12


! ( s y n o n y m l ) i s a n O R o p e r a t o v o n n o n - B oo l e a n s , ( < p ar m. (i < p arm > )" f un c t i on i <strong>de</strong>n'Cif i e v > ; : = "- i<strong>de</strong>nti f i e v >< s t a t emen t > = < l a b e l > ; < u n l a b e l l e d s t a t ement ."< .vnl a be 1 led s t a t emen t >< u n l a b e l l e d s t a t emen t > ; ; = < s i m p l e s t a t emen t :< s t r u c t uv e d s t a t emen t >" . l a b e l > < un s i gne d i n t e g e r >< s i m p l e s t a t eme n t > < a s s i gnmen t s t a t emen t >< pr oc ed ur e s t a t eme n t >< g o t o s t a t emen t >< empt y s t a t emen t >" empt y s t a t emen t > mptg>< a s s i gnmen t s t a t emen t > : : = < v a r i a b l e > : = ( :.par m> 4 i 3 ) l< pr o c ed ur e i d e n t i f i e r >' '.pr ocedur e i <strong>de</strong>n t i f i ev >: : ~ . .expr e s s i on >< v a r i a b l e>< g o t o s t a t eme n t > g ot o < l a b e l >»~st r u c t u r e d s t a t e me n t > : : = < r e p e t i t i v e s t a t emen t >< c on d i t i o n a l s t a t emen t >


::casest a t emen t > : : = CASE < e x p r e s s i on > OF: .cas e l i s t : 4 i ~ ca s e 1 i s t > 3( ELBE < s t a t emen t > 3END< .cas e l i s t > < l a be l l i s t: -. ; '" . s t a t emen t >i empt g>< .l a be l l i s t > = 4 i < ca s e l a b e l > 3< r e p e t i t i v e s t a t eme n t > : : = < r ep ea t s t a t emen t >c h i l e s t a t emen t >< f a r s t a t emen t >< wh i l e s t a t emen t > : ; = WH I L E < e xp r e s s i an"- DO < s t a t emen t >< r epeat s t a tement > : : = REPEAT E. 3 UNTI L" f o r s t a t emen t > : : ~ FOR < c t r 1 var > : = < f o r 1 i s t > D O . s ta te men t>< f o r l i s t > : : ~ < ex pr e s s i an > DOWNTQ l T O < ct r l v a r > ~ < v a r i a b l e> : : = 4II TH DO < s t a t e men t >< r e c or d v a r i a b l e l i s t > : : ~ < r e c or d v a r i a b l e > 4 i 3p r o c ed ur e <strong>de</strong>c l a r a t i a n > = EXTERNAL " p r o c e d ur e h e a d i n g> < bl ock ' < l a b e l d ec l a r a t i a n pa r t 3< c on s t an t d e f i n i t i o n p a r t >< t y p e <strong>de</strong> f i n i t i o n p a r t >< vari abl e <strong>de</strong>cl ar at i on par t >< pr oc f un c d e c l a r a t i o n p a r t >< s t a t emen t par t >p r o c ed ur e h e a d i n g> PROCEDURE ": i <strong>de</strong> n t i f i er > p a rm 1 i s t>P ROCEDURE P ROCEDURE I NTERRUPT C ( . f par m> 4. > ) 3.< .t yp e i d e n t i f i e r >l 1 4


i d e n t i f i e r > 4 . i d e n t i f i e r . » ARRAY C < i n d x t yp.: C! < i nd xt y p 3 3 OF< c ona r r a y 2> < t y p e i d e n t i f i e r "< c on f or man t a r r a y > : = < i d e n t i f i er > . , < i d e n t i f i e r > : < o r d t y p i d> = < s c a l a r t y p e i d e n t i f i e r .< su br a n g e t y p e i d e n t i f i e r >< l a be l d e c l a r a t i o n p a r t > .empt y>LABEL 4. TYPE< t y p e <strong>de</strong> f i n i t i o n .4! < t y p e d ef i n i t i o n > > : : = VAR< var iab le <strong>de</strong>cl ar at i on > : < or d t y p i d> < sca l a r t y p e i <strong>de</strong> n t i f i e r .< subrange t ype 'i <strong>de</strong>nt i f i e r .' . l a be l <strong>de</strong>c l a r a t i on pa r t >


- :pr o c f un c p a r t > ( < s t a temen t p a r t ." < compound s t a temen t >< f u n c t i o n d e c l > : = EXTERNAL < f u n c t i o n h e a d i n g>< f u n c t i o n h e a d i n g > < b l o c k>< f u n c t i a n h e a d i n g > : : = FVNCT?ON < i d e n t i f i e r >< par m l i s t > : ) IFUNCTION < i d e n t i f i e r > : < r e s u l t t y p e> < t y p e i d en t i f i e r >< r e a d c a l l > = < r ea d o r r e a d l n > 4 < ) 4 < v a r l i s t > ) ) ) : : = READ I READLN< f i 1 ev ar > = < v a r i a b l e >< var l i s t > v a r i a b l e > 4i ) = < < 4< f i 1ev a r . > ) Xe xpr 1 i s t 3 ) > : : = W RIT E I W RIT ELN< expr l i s t > 4, < wexpr3 < e x pr e s s i on > 4: 4 : ) 3.< wi d t h e x p r > ~ < <strong>de</strong>c expr > 'p r o gram> < b l oc k>< l a be l <strong>de</strong>c l a r a t i a n pa r t >< c on s t a n t d e f i n i t i o n p a r t >< t y p e <strong>de</strong> f i n i t i o n p a r t :< var i abl e <strong>de</strong>c l ar at i on pa r t >


APPENDI X 8 :RESERVED WORDSTh e f a l l o w i n g a z e t h e v es e r v e d u tnv ds i n A TA RI P a s c a lAND DOMNTO QQTO NOT RECORD U NT I LARRAY EL SE I F GF REPEA T VARBEGI N END I N OR SET WHILECONST F I L E LABEL PACKED THEN W I T HCASE FOR NOD PROCEDURE TODO FUNCT1ON N I L PROGRAM TYPE* TAR I Pa s ca l a l s o ha s e x t en <strong>de</strong> d r es er ve d wo r d s ;ABSOL UT E E XTERNA L P R EDEF 1NED


APPENDI X CERROR MESSAGESR ec ur s i o n s t a c k o v e r f l o w : e v a l u t i a n s t a c k c o l l i s i o n e i t h sy mbo l t a b l e ic o r r e c t b y r e d u c i n g symbo l t a b l e s i x e s s i m p l i f y i n g e x p r e s s i o n s .1: E r r o r i s si mpl e t y peS e l f - e x p l a n a t o r y .2 : I d e n t i f i e r e x p e c t e dSe1 f-explanatory.3 : 'PROGRAM' e x p e c t e dSe1 f-explanatory.4 : ' ) ' e x p e c t e dSel f-explanatory,5 : ' : ' e x p e c t e dPos s i b l y a n = u s ed in a V AR d e c l a r a t i o n,6 ; I l l e ga l sy mbo l ( p o s s i b l y mi s s i n g " ' o n l i n e a b o v e )S ymba l e n c o u n t e r e d i s n a t a l l o we d i n t h e s y n t a x a t t h i s p o i n t .7 : E r r o r i n p a r a me t e r l i s tSyn t a c t i c er r o r i n p a r a m et e r l i s t d e c l a r a t i o n .8 : ' O F ' e xpe c t e dS e 1 f-e x p l an a t ar y .e xpec t e dS e 1 f-e x p l ana t ar y .1 0 : Er r o r i n t y p eS ynt a c t i c er r o r i n TYPE <strong>de</strong>cl ar at i on .1 1 : 'C ' e x p e c t e dSe 1 f-e x p lana tory.1 2 : ' I ' e x p e c t e dS el f - exp l a n a t o r y .1 3 : ' END ' e x p e c t e dA l l p r o c e d u r e s . f u n c t i o n s i a n d b l o c k s a f s t a t e me n t s m u s t h a v e a n'END ' , Ch ec k f a r m i s m a t c he d BEGI N/ ENDs .1 4: ' ; ' e xpect ed ( possi bl y on l i n e abov e )S t a t emen t s e p a r a t o r r e q u i r e d h e r e .1 5 : I n t e ge r e x p e c t e dS e 1 f - e xp I a n a t a r y .1 6 : ' = ' e x p e c t e dPas s i b l y a : u s e d i n a T YPE o r C ONST d e c l a r a t i o n .


1 7 : ' BEGI N ' e xpe c t e dS e 1 f-e x p 1 ana tory .1 8 : Er r o r i n <strong>de</strong>c l a r a t i an pa r tT y pi c a l l y a n i l l e ga l ba ckwar d r e f er enc e t a a t y p e i n a po i n t erd e c l a r a t i on .19 : Er r o r i n < f 1 e 1 d- 1 1 s t>Synt a c t i c e r r a r i n a re co rd d ec la r at i o n2 0 : ' . ' e xpe c t edS e l f - e xp l a n a t or y .2 1 : ' + ' e x p e c t e dS e 1 f-e x p 1ana t or y.50 : Er r or i n c ans tantS ynt a c t i c e r r o r i n a l i t e r a l c onst an t5 1 : ' : = ' e xpect edS e l f - e xp l ana t a r y .5 2 : ' THEN ' e xpe c t edS el f - e xp l a n a t or y .53 : 'UNT I L ' «x p ec tedC an r e s u l t f r om misma t c he d be g i n / en d s e quences .5 4 : ' DO ' e xpec t e dS ynt a c t i c e r r a r .55 : ' TO ' a r 'DOL4NTO' e xpe c t e d i n FOR s t a tementSelf-explanatory.5 6 : ' I F ' e xpec t e dS el f - e x'p lana t or y .5 7 : ' F I LE ' e xpe c t e dPr oba b l y a n e r r o r i n a TYPE <strong>de</strong> c l a r a t i on .58 : E rr o r i n C fa c t a r. ( b ad e x pre s s i o n)S ynt a c t i.c e r r o r i n e xpr e s s i o n a t f a c t a r l e v e l .5 9 : Er r o r i n v a r i a b l eS y n t a c t i c e r r o r i n e x p r e s s i o n a t v a r i a b l e l e v e l .9 9 : NODEND e xpec t e dEa c h tiODVL E mu s t e n d ed i t h MODEND,1 0 1 : I d e n t i f i e r d e c l a r e d t w i c eN ame a l r e a d y i n v i s i b l e sy mbo l t a b l e .102 : La~ ba un d e xceeds h i gh boundF a r s u b r a n g e t h e l o~ e r b o un d mu s t b e = h i g h b o un d .119


2 0 3 : I d e n t i f i e r i s n o t o f t h e a ppv'opv' i a t e c l a s sA v a r i a b l e name u s ed as a t ypes' o r a t y p e u s e das a v a r i a b l e e t c . c a n c a u s e t h i s e v v or,204 : Un<strong>de</strong>cl ar ed i <strong>de</strong>n t i f i evT h e s p e c i f i e d i d e n t i f i e r i s n o t i n t h e v i s i b l e symbo l t a b l e .1 0 5 : Si g n n o t a l l owedS i gn s a r e n o t a l l o we d o n n o n - i n t e g e r / n o n - r ea l c o n s t a n t s .2 0 k : N umber e x p e c t e dT h i s er v'ov' c a n o f t e n come f r om maki n g t h e comp i t e v t o t a l l ycon f u s e d i n a n e xpv es s i on as i t c h e c k s f o v n umber s a f t e v' a l lot he r possi b i l i t i e s hav e been exhaust ed.107: I ncompati bl e subv ange t ypes(e. g . ' A ' , . ' Z ' i s n o t c ompat i b l e w i t h 0 . . 9 ) .2 08 : F i l e n o t a l l owe d h e r eFi l» c ompa r i s o n a nd a s s i g nment i s n o t a l l o wed.1 09 : T y p e mu s t n o t b e v ea lSe l f - e x p l a n a t ov y .1 10 : < t a g f i e l d > t y p e mu s t b e s c a l a r o v s u b r a n g eSelf-explanatory.121 : I n compa t i b l e w i t h < t a g f i e l d 3 pav tS e l e c t ov ' i n a CASK- v a r i an t v e c or d i s n o t comp a t i b l e w i t h t h e< t a g f i e l d > t y pe .2 22 : I n <strong>de</strong> x t y p e mu s t n o t b e v ea lA n a r v a y ma y n o t b e d e c l av ed w i t h v ea l d i me n s i o n s1 13 : I n <strong>de</strong> x t y p e mu s t b e a s c a l a v o v a s u br a n g eS e 1 f- exp l a n a t ov' y .2 24 : Ba s » t y p e mu s t n o t b e r e a lB as e t y p e o f a s e t ma y b e s c a l av ' o r s ubv'an ge .22S : Ba s e t y p e mus t b e s c a l a v or a s u b va ng eSe l f - e x p l a n a t ov y ,226 : Er v or i n t y p e o f s t a n d ar d p r o c e d ur e p a r a me t erSe l f - e x p l a n a t ov y .1 17 : Un s a t i s i f i e d f or wa r d v ef ev enc eA f or wa r d l y d e c l a r e d p o i n t e r wa s n ev e r d e f i n e d ,2 28 : F ovwav d v ef ev enc e t y p e i d e n t i f i e r i n v a r i a b l e <strong>de</strong>c l av a t i onY ou a t t em p t e d t o d e c l a r e a v a r i a b l e a - a p o i n t ev ' t o a t y p e n o tye t d ec l av ed.2 2 0


119 : R e - s p e c i f i e d p a r a me t e v s n o t G K f o r a f o r w a r d d e c l a v e d pv o c e d u v eSe 1 f-e x p l ana t ov y .1 2 0 : F u n c t i o n v e s u l t t y p e mu s t b e s c a l a v s u b r a n g e o v p o i n t e vA f u n c t i o n ha s bee n d e c l a r e d w i t h a s t r i n g o v o t h er n o n - s c a l a rt y p e a s i t s v a l ue . T h i s i s n o t a l l o ~ e d .121, : F i l e v a l u e pav amet e v n o t a l l o wedF i l e s mus t b e p a s s e d a s VAR p a r amet ev' s .122 : * f ov'wav' d d e c l a r e d f u n c t i o n ' s r e s u l t t y p e can ' t b e -v e -s pec i f i e dS el f - exp l a n a t o r y .1 23 : Hi s s i n g v esu l t t y p e i n f u n c t i o n <strong>de</strong>c l av ' a t i onSelf-explanatory.125 : Er v o r i n t y p e o f s t a n d ar d pv oceduv e p a r a met e vT h i s e r r o v i s o f t e n c a use d b g n o t h a v i n g t h e p a r a me t ev' s i n t h ep v'opev o v <strong>de</strong> r f o r b u i l t - i n pv oc ed ur e s o v b g a t t em p t i n g t ov ead/ wr i t e p o i n t er s i enumev a t ed' t y p es ' e t c .1 26 : Numbev o f pav amet er s d oe s no t a g r e e w i t h <strong>de</strong>c Jav a t i o nS e l f - e xp l a n a t o r g .127 : I l l egal pav arne tev sub s t it u t i onT yp e o f p a vame t e r d oe s n o t e x a c t l y m a t c h t h e c o r r e s p on d i n g f or ma lpar a me t ev' .128 : Re s u l t t y p e d oe s n o t a gv ee w i t h d e c l a v at i o nWhen a s s i g n i n g t y p e s t o a f u n c t i o n r e s u l t s t h e t y p es m us t b ec ompa t i b l e .1 29 ; T y p e c o n f l i c t o f o p er a n d sSe l f - e x p l a n a t or g.130' . Ex pr e s s i on is n o t o f s e t t y p eS e l f - exp 1an a t o r y ,1 3 1 : Te s t s o n e q u a l i t y a l l owe d o n l yO cc ur s when compa r i n g s e t f o v o t hev' t ha n e q ua l i t y .133 : F i l e compav' i s on n o t a l l owedF i l e c o n t r o l b l ock s ma y n o t b e compav' e d b e c a us e t h e y c o n t a i nm ul t i p l e f i e l d s unav a i l a b l e t o t h e u s e r ,1 34 : I l l e ga l t y p » o v o p e r a n d ( s lT h e o p e v a n d s d o n o t m a t c h t h o s e r e q u i v e d f o r t h i s o p e r a t o ~ .1 35 : T y p e o f o p ev an d mu s t b e Bo o l ea nTh e o p ev a n d s t o AND , O R a n d NO T mu s t b e BOOL EAN.1 36 ; Se t e l emen t t y p e mus t b e s c a l a v o r s ubv' an g eSe l f - e x p l a n a t or g.


S e t e l emen t t y p e s mu s t b e compa t i a b l eS e I f - ex p l ana t o r y .f 3 8 : T y p e o f v a r i a b l e i s n o t a r r a g, A s u b s c r i p t ha s bee n s p e c i f i e d on a n o n - a r r a y v a r i a b l e ,In <strong>de</strong> x t y p e is n o t c ompat i b l e w i t h t h e d e c l a r a t i o nO cc ur s whe n i n d e x i n g i n t o a n a r r a y w i t h t h e wr on g Cgp e o fi n d e x i n g e x p r e s s i o n .'14O:T y p e o f v a r i a b 1 e i s n o t r e c o r dAt t em p t i n g to ac c e ss a n o n - r e c o r d d at a s t r u c t u r e w i t h t h e ' d o t 'f or m o r t h e ' w i t h ' s t a t emen t .1 4 1 : T yp e o f v a r i a b l e mus t b e f i l e o r p o i n t e rOcc ur s whe n a n u p a r r o w f o l l ows a v a r i a b l e w hi c h i s n o t o f t y p ep o i n t e r o r f i l e .1 42 : I l l e ga l pa r ame t e r s o l u t i onSel f-exp lanator g.1 4 3 : I l l e ga l Cgp e o f l o o p c o n t r o l v a r i a b l eL oo p c o n t r o l v a r i a b l e s ma g b e o n l y l o c a l n o n - r ea l s c a l a r s .Il l e ga l t y p e o f e x p r e s s i onTh e e x p r e s s i o n u s e d a s a se l e c t i n g e x p r e s s i o n i n a C ASK s t a t e mentmust b e a n on-r e al s ca la r.T ype conf l i c tCas e s e l e c t o r i s n o t t h e same t y p e as t h e s e l e c t i n g e x p r e s s i o n .As s i gnmen t o f f i l e s n o t a l l owedS e l f - e xp l a n a t o r g .i 4 7L a be l Cgp e i n compa t i b l e w i t h s e l e c t i n g e x p r e s s i onC as e s e l e c t o r i s n o t t h e same t y p e a s t h e s e l e c t i n g e x p r e s s i o n .1 4 8 : S u br a n g e b o un d s mus t b e s c a l a rSel f - ex p l a n a t or g.1 4 9 : In <strong>de</strong> x t y p e mus t b e i n t e g erS e l f - exp l a n a t o r g .15G: As s i gnmen t t o s t a n d ar d f u n c t i o n i s n o t a l l owe dSe1 f-exp lanator g.As s i gnmen t C o f or ma l ' f un c t i o n i s n o t a l l o wedS e l f - e xp l a n a t o r g .1 5 2 : N o s u c h f i e l d i n t h i s r e c o r dS e l f - e xp l a n a t o r g .1 53 : T y p e e r r o r i n r e a dS e1 f-e x p lana tory .


1 5 4 : A c t u a l p a r a m e t e r mu s t b e a v a r i a b l eOc c u r s w h e n a t t e m p t i n g t o p a s s a n e x p r e s s i o n a s a V AR p a r a m e t e r .C o n t r o l v a r i a b l e c a n n o t b e f o r ma l o r n o n - l o c a lTh e c o n t r o l v a r i a b l e . i n a FO R l oo p mu s t b e LOCAL.1 56 : M ul t i d e f i n e d c a s e l a b e lSe l f-e x p lana tory.To o ma n g ca s es i n c a s e s t a t e mentO cc ur s whe n pump t a b l e g en er a t e d f o r c a s e o v e r f ) ows i t s b o un d s .1 58 : N o s uc h v a r i an t i n t h i s r e c or dS e l f - exp l a n a t o r g .R e a l o r s t r i n g t a g f i e l d s n o t a l l o w e dS el f - e xp l a n a t o r g .1 60 : Pr ev i ou s <strong>de</strong>cl ar at i o n wa s no t f or war d1 6 1 : A g a i n f or wa r d d ec l a r e d1 62 : Pa r a me t e r s i z e mu s t b e c o n s t a n t1 63 : Mi s s i n g v a r i an t i n <strong>de</strong>cl ar at i onO cc ur s when u s i n g NEW/ DI SPOSE an d a v a r i a n t d o e s n o t e x i s t .164 : Su b s t i t u t i o n o f s t a n d ar d p r o c ed ur e f f u n c t i o n n o t a l l owed1 65 : M u l t i d e f i n e d l a b e lL a be l m o r e t ha n on e s t a t emen t w i t h same l a b e l .1 6 6 : M u l t i d e c l a r e d l a b e lD ec l a r e same l a b e l m o r e t ha n o n c e .1 67 : Un d e c l a r e d l a b e lL a b e l . on s t a t emen t ha s n o t b ee n d e c l a r e d .1 68 : Un d e f i n e d L a b e lA d e c l a r e d l a be l wa s n o t u s e d t o l a b e l a s t a t e men t .1 69 : Er r o r i n ba s e s e t1 ? 0 : V a l u e p a r a m e t e r e x p e c t e d17 1 : S t a n d a r d F i l e wa s re - d ec 1 ared1 72. Un<strong>de</strong>cl ar ed ex t er na l f i l e1 7 4 : P a s c a l F u n c t i o n o r p r o c e d u r e e x p e c t e dSe l f - e x p i an a t or g.1 83 : E x t e r n a l d e c l a r a t i o n n o t a l l owe d a t t h i s n e s t i n g l e v e lS el f - e xp l a n a t o r g .123


1 87 : A t t emp t t a o pe n l i b r a r y u n s u c c e s s f u lS e l f - exp l a n a t a r y .1 91 : No p r i v a t e f i l esF i l e s ma y n o t b e d ec j a r e d o t he r t ha n i n t h e QLOBAL v a r i a b l es e c t i o n o f a p r o gr a m a r mo d u l e b e c a us e t h e y mu s t b e s t a t i c a l l ya l l ocat ed .1 93 : No t e n oug h r oom f o r t h i s o p er a t i anSe 1 f-ex p 1 anat or y.1 94 : Commen t mus t a p pea r a t t o p .o f p r o g r a m2 0 1 : E r r a r i n r ea l numbe r - d i g i t e x p e c t e dSel f-explanatory.2 02 : S t r i n g c o n s t an t mu s t n o t e x c ee d s o u r c e l i n e2 03 : I n t e ge r c o n s t a n t e x c e ed s r a n g eR ang e o n i n t e ge r c o n s t a n t s a r e - 3 2 7 6 8 . . . 3276 72 50 : T o o man y s c a pe s a f n e s t e d i d e n t i f i e r sTher e is a l i m it o f 1 5 n e s t i n g l e v e l s a t c om pi l e - t i m e .T h i s i n c l u <strong>de</strong> s WI TH an d p r a c ed ur e n e s t i n g .2 5 1 : To o ma n y n e s t e d p r o c ed u r e s o r f u n c t i o n sTh er e is a l i m i t a f 1 5 n e s t i n g l e v e l s a t e x e c u t i o n t i m e2 53 : Pr o c ed ur e t o a l o n gA pr ocedur e ha s gener a t ed co<strong>de</strong> t ha t ha s ov er f l owed t h e i n t er na lp r a c ed ur e b u f f e r . Re duc e t h e s i z e a f t h e p r o c ed ur e a n d t r y a g a i n ,259: Expr essi on t oa compli cat edYour e x pr e s s i o n i s t o a camp l i c a t e d ( i . e. t a a m an y r e c u r s i v ec a l l s n e e <strong>de</strong> d t a camp i l e i t ) , Re duc e t h e comp l i c a t i o n u s i n gt emp or a r y v a r i ab l e .3 97 : Ta a man y FO R o r W I T H s t a t emen t s i n a p r o c ed ur eOnl y 16 FOR a n d / o r W I TH s t a t emen t s a r e a l l a ~ e d i n a s i n g l ep r o c ed ur e ( i n r e c u r s i v e mad e o n Ly )4 00 : I l l e ga l c h a r a c t e r i n t e xtA n o n- Pa s ca l s p e c i a l c h a r a c t e r wa s f o un d o u t s i d e a q u o t e d s t r i n g .4 0 1 : U n e xp e c t e d en d o f i n p u t" E n d . " e n c o u n t e r e d b e f o r e r e t u r n i n g t o o u t e r l e v e l .402 : E r r o r i n un ' i t i n g c o d e f i l e . n o t e n o ug h r o omSelf-explanatory.4 0 3 : E r r o r i n r e a d i n g i n c l u d e f i l eS e l f - e x p l a n a t o r y .1 2 4


4 0 4 : E r r o r i n w r i t i n g l i s t f i l e t s n o t e n o u g h r o o mS e l f - e xp l a n a t o r g .4 0 5 : C a l l n o t a l l owe d i n s e pa r a t e p r o c ed ur eS el f - exp l anat or g.4 06 : I n c l u d e f i l e n o t l e ga lSe1 f -exp lane tory.407 : Symbol Ta bl e Over f ) ow4 97 ; Er r o r i n cl osi ng c o<strong>de</strong> f i l e.A n e r r o r o c c u r e d whe n t h e ER E f i l e wa s c l os ed .N a k e m o r e r o o m o n t h e d e s t i n a t i o n d i s L e t t e a n d t r y a g a i n .500 : A n o n - s t andar d f ea t u r e ha s b een u s e d wh en t h e T+ o r 4/+ t og g lesa r e e n a b l e d , T h i s i s a n o n - f a t a l i n f o r m a t i o n - o n l y e r r o r .


A PPENDI X D ;* TAR I PASCA! F I L E I / OT h e s e c t i on s i n t h i s a p p en d i x d e s c r i b e ATAR I Pa s c a l f i l e s a n d how t ou s e t hem, S i n c e wo r k i n g f r om a n e xamp l e w i l l b e t h e mo s t e f f e c t i v ewag o f d e s c r i b i n g t h es e c o n c e p t s i p r o g r a m e xamp l e s h a v e b ee n i n c l u d edf o r ea c h a r e a o f f i l e ha n d l i n g .o T h e f i r s t s e c t i o n d e f i n e s t h e t e r ms u s e d i s u c h as "f i l e s ""wi n dow v a r i a b l es " a n d " TEXT. "oooTh e s e c on d s e c t i o n s h ows ho w t o use a l l t h e f i l e o p e r a t i o npr o c ed ur e s w i t h e xa mp l e s . T h es e i n c l ud e ASSI GNS- RESETS REWRITEsequ e n t i a l f i, l e ac c e ss p r o c e du re si C LOSE~ e t c .T h e t h i r d s e c t i o n d e f i n e s Pa s c a l TEXT f i l e s . Sampl e p r o g r ams<strong>de</strong>mon s t r a t e t h e us e o f b u i l t - i n Bo o l ea n f u n c t i on s EGLN an d EGLF iREADLN. t4R ITELNi fo rm a t t e d I / Q i a n d w r i t i n g t o th e p r i n t e r .T h e f o u r t h s e c t i o n p r e s e n t s some l e s s f r e q u e n t l g u s e d f i l eop erat i ons.


1. DEF I N I T I ONBT h e t e r m s a n d d e f i n i t i o n s i n c l u d e d h e r e a r e a r r a n g e d t o l o g i c a l l ydi s c us s t h e c on c e p t s of- f i l e s a s y o u r ea d t h r a u gh.F I L EA f i l e i s d a t a a r r a n g e d i n l o g i c a l ~ e q u a l - s i z e d e l e me n t s ve r y m uc hli k e a n o p e n - e n d e d a r r a y a c c e s s e d v i a a po i n t e r . T h e si z e a n dar r a n gemen t o f t h e da 't a i s c a n t r a l l e d b g y o ur p r o g r a m. A fi l e i sg en e r a l l y s t o r e d o n a s e c on da r y s t o r a g e me d i um . F a r t h e pur pos e a ft h i s d o cumen t a t i o n . s e c on da r y s t ar'ag e i s a s sume d t a b e a d i s k e t t e . Y a umay wr i t e d a t a t o a f i l e a r r e a d d a t a f r am a f i l e u s i n g t h e f i l eo p er a t i o n p r o c ed ur e s p r a v i d e d wi t h ATAR I Pa s c a l . T h i s d a t a i n t h e f i l em a g b e a c c e s s e d s e q u e n t i a l l y ( r e c o r d 1 a c c e s s e d b e f o r e r e c a r d 2 ire c o r d 2 i s a c c e s s e d b e f o r e r e c o r d 3i e t c ) i a r d i r e c t l g .F ILENANETh e f i l ename i s t h e name o f t h e f i l e a n d i s k e t t e . l t i s t h e na medi spl ayed i n t h e di r ect or y l i s t i n g o f t h e s t or ag e medium. l n <strong>ATARI</strong>P as ca l t h e f i l e name i s r e pr e s e n t e d i n a p r o g r a m b g a STRI NG ( a d y na mi cs e quenc e o f ASCI I c h a r a c t e r s ) . F o r e xa mp l e , " D 2 : TEST. PAS" i. s t h ef i l ename i n l i t er a l s t r i n g f or ma t f o r t h e f i l e l a c a t e d a n dr i v e " D2 "w i t h t h e n a me a f " T EST " a n d t h e e x t e n s i o n a f " . PA B " .TYPETh e t y pe of f 1 1 e d ef i n e s t h e s i z e a nd f o rm at a f t h e i n d i v i d u al f i l ee l e me n t s i t h e s m a l l e s t a c c e s s i b l e u n i t s o f a f i l e , F o r e xa mp l e s a f i l eo f t y p e I NTEGER ( 2 8 - b y t e s ) ma y b e v i s u a l i z e d a s :) 00 00 10 0 0 i 0 0 0000 0 0 l 0 0 100 0 0 1 )0 00 00 00 1 I 0 0000 0 0 1 ) 0 00000 0 0 l+ + + + + +r e c o r d 0 r e c o r d 1 r e c o r d 2T h i s f i l e c o n t a i n s t h e i n t e g e r s B i 3 3 i a n d 1 ( s t o r e d i n v e r t e d i n t h i ss amp l e ) . Th e s m a l l e s t r e t r i e v a b l e e l emen t i " t w o b y t e s . Be e t h ee xpl anat i on s a f untapped f i l e s or b y t e f i l e s i t yo u wan t t a t r ea t t h i sf i l e d i f f e r e n t l q t h a n a f i l e o f i n t e g e r s . F i l e s ma y b e a f t h e s t a n d a r dP as ca l s c a l a r t g p es : 8OO! EAN I NTEGER CHAR a r REAL . F i l e s ma y a l s ob e o f t h e s t r u c t u r e d t y p e s S T R I NG i a r r a g s i a n d r e c o r d s , T h e p r e d e f i n e dty p e TEXT i s u s e d f o r ASCI I f i l es . T e x t f i le s ar e si m i l i a r t o F I L E a fC HAR e x c e p t t h a t t h e y a r e s u b d i v i d e d i n t o l i n e s . a n d n u mb e r s w r i t t e nta t h em ar' e c onv er t e d t o ABC l I ( a n d ma y b e . f or ma t t ed ) i an d n umber'sr e a d f r a m t h e m a r e c o n v e r t e d t o b i n a r y . A l i n e i s a s e q u e n c e o fcha r a c t er s t e rm in a t e d b g a n e nd -o f - l i n e c h a r a c t e r . w h i c h i s u su all y ac a r r i a g e r e t u r n l l i n e f e e d . A l s o , u n l i k e F I L E o f CHAR i T E XT f i l e s w i l la ce ep t PACKED ARRAYS 1.. N3 OF CHAR a r ARRAYC 1.. Nl O F CHAR (wr i t i n g a nUNPACKED ARRAY i s n o t 1'BO s t andar d ) ~ a n d STRINGS as d a t a , A B ool e anv a l u e i s c o n v e r t e d t a t h e AS C I I s e q u e n c e " TRUE " a r " F AL SE " o n w r i t eb u t t h e r e v e r s e i s n o t t r u e . F o r f u r t h e r e x p l a n a t i o n s o n t g p e d a n dt e x t f i . l e s i s e e t h e o p e r a t i o n s s e c t i o n .1 2 7


* n a n - I SO s t a n d ar d c o n c ep t r e ga r d i n g f i l e s i s t h e VNTYPED f i l e . T h i sc on c ep t i s u s e d f a r f a s t b l o c k i n pu t a n d o u t p u t ( e n t i r e s e c t or - a r er ea d ov ' wv i t t en } r e g a r d l e s s o f t h e k i n d o f d a t a c o n t a i n e d i n t h e f i l e .F ILE I NFORMATI ON BLOCK ( FI B )T h e F I B c o n t a i n s i n f or ma t i o n n e c e s s a v g f a r t h » r u n - t i m e r o u t i n e s t apev f o r m f i l e o p e v a t i o n s a n a d i s k f i l e . T h e f i l e name t h e t y p e o f Ch efi l e t h e a c c es s t y p e ( r ea d o v w r i t e) ~ e n d- o f - f i l e a n d en d- of — I i n efl a g s , a n d a d i s k e t t e b u f f e ~ ( t h e s i z e o f o n e d i s k e t t e s e c t o v ) a r ea mo n g t h e k i n d s a f i n f o r m a t i o n k e p t i n Ch e F I B.WINDOW V* RI * BL E OR WI NDOW POI NTERT h e w i n dow va v' i ab l e i s a b u f f e r t h e s i z e o f a f i l e e l emen t a n d i sl o c a t e d gu s t p a s t t h e F I B i n * TARI Pa s c a l . 4 wa g t o Ch i n k o f i t i stha t i t move s a l on g t h e f i l e an d a c t s as a ' w i n d o w' t a C he e l e ment o ft h e f i l e t o b e r ea d o r w r i t t en . F o v t h i' s r ea s on s i t i s c o n s i <strong>de</strong>v e d apo i n t e r t a t h e f i l e e l emen t b e i n g a c c e s s ed . I t i s d e n o t e d a s " F " "wh er e " F " i s t h e name of a f i l e v a r i a b l e . T o r e ad f r a m a f i l e i t h ee l emen t w h i c h i s a c c e s s i b l e i s e a v e d t o t h e w i n do w v a r i a b l e . T o wv i t eta a f i l e t h e d a t a m us t b e t r a n s f e v v ed f r a m t h e w i n d ow v a v ia b l e t ot h e f i l e .F I L E VA R I ABl ETh e f i l e v a r i a b l e c a n s i s t s a f a F I B a n d a w i n d o w v a r i a b l e . I C i s t h ea c t ua l d a t a i t e m a l l o c a t e d b g t h e co mp i l e r a n d v ef e r e n c e d i n a Pa s c a lpr o g r am . An e xa mp l e w i l l c l a r i f y wha t a f i l e v a v ia b l e i s . a s w e l l a sw ha t t h e FI B a n d w i nd aw v a r i ab l e a r e . T h e s t a t emen t " V* R F . F I L EQ F I NTEQERi " c a u s e s t h e comp i l e r t o c r e a t e a f i l e v av i a b l e F w i t h i t sa wn F I B i n t h e d a t a a r e a a n d i t s own w i n do~ v av i a b l e < 2 b y t e s ) t o h a l da 16 - b i t i n t e g er . Th e w i n dow v av i a b l e is d e n o t e d b g F " ', S up p o se " I " i sa n i n t e ge r i n t h e same pv ogv'am an d ha s t h e v a l u e 2 . Su p p os e a l s o t h a tt h e f i l e a l v ea<strong>de</strong>m c a n t a i n s t h e v a l u e i ,i n t h e f i r s t e l emen t a s b e l o w :l 0 0 0 0 0 0 0 i l 0 0 0 0 0 0 0 0 l+ + + +F I B l ) 0 0 0 0 0 0 1 0 t 0 0 0 0 0 0 0 0 l w i n d o w v a v i a b l e+ W+ + +T o wv ' i t e t h e c o n t e n t s o f I t a t h e f i l e . t h e w i n d a w v a r i a b l e mu s tc o n t a i n 2 ( F : = I p u t s t h e c o n t e n t s o f I i n t o t h e w i n d o w v a v i a b l e )a n d b e " p o s i t i o n ed " a v e r t h e s e c on d e l emen t o f t h e f i l e . ( ' i v e n t h ec omma n d P UT ( F ) d e s c v i b e d i n t h e o p e r a t i o n s s e c t i a n . t h e n u mb e r 2 i sw r i t t e n t a Ch e f 1 l e .


2. F UNDA)" EN T* L F I L E OP ER* T I QNSS a mp l e p r o g r a ms a n d e x p l a n a t i o n s d e mo n s t r a t e t h e u s e o f f i l e o p e r a t i o np r o c e d u r e s i n * T AR I P a s c a l . Y o u s i i l l se e h o w t o o p e n c r e a t e r e a d iw r i t e . d e l e t e i a n d c l o s e f i l e s . De mo n s t r a t e d a l s o a r e t h e u s e o f t y p e dan d t e x t f i l e s i t h e f i l e s t a t u s F u n c t i o n s I ORESUL T i EO Fi a n d E O LN i a n dh o w t o a s s i g n t o a w i n d o m v a r i a b l e .Fi g ur e D- i l i s t s a p r o g r a m n amed W RIT E R EAD F I L E D EMO t h at c r e a t e s atyped F i l e on di s k e t t e s wr i t e s d a t a t o t h e f i le i cl o ses t h e f i l e . t h e nr e - o p e n s t h e f i l e t o r e a d t h e d a t a b a c k . T h e p r o c e d u r e s u s e d t op e r f o r m t h e s e a r e A S S I GN r REWR I TE t RESET S I ORESUL T > PU T GE T a n dC LOSE . W R I T E i s u s e d t o d i s p l a g t h e r e s u l t s o n t h e t e r m i n a l . T h eo u t pu t wor k i s d on e i n WRI TEF IL E an d t h e i n pu t w or k i s d on e i nR EADFILE . Cr e a t i n g i o p e n i ng ~ an d c l o s i n g t h e f i l e i s d on e i n t h e m a i nbod y o f t h e p r o g r am.The WRI TEL N s t a t emen t s o n l i n e s 3 7 , 4 3 ' 46 , a n d 4 9' w ri t e t h e s t r i n gp a s se d t o t hem t o t h e d e f a u l t OUTPUT f i.l e ( t h e c o n s o l e ) . T h i spr o c e d u r e a n d READL N a r e d i s c u s s e d l a t e r i n t h i s s e c t i o n u n d e r T E XTf i l e s .F i r s t n o t e t h e f o r m o f t h e d e c l a r a t i o n o f OUTF I LE , I t i s d e c l a r e d t obe o f t y p e CHF I LE . ur h i c h i s d e f i n e d a s a FI L E Q F C HAR i n t h e T YPEd e c l a r a t i o n s e c t i o n ( l i n e s 3 a n d 4 ) . T h i s i s d on e b e c a us e t h e F i l e i spa s s e d as a p a r a m e t e r t o t h e W R I T E F I L E a n d R EADFI L E r o u t i n e s a n d ap a r ame t e r l i s t c a n no t d e c l a r e a n e w t y pe . Fo r e xa mp l e . t h e f o l l o w i n gp a r ame t e r d e c i a r a c t i o n i s i l l e ga l i n Pa s c a l b e c a us e o n l y t y p ei d e n t i f i er s a r e a l lobbied i n a p a r ame t e r l i st :125376PROCEDURE WRITEF I LE ( VAR F : F I L E OF CH * R ) '10 0PROGRAM WRITE READ F I t E DEMO'TYPECHF I L E = F I L E QF CHARiVAROUTF 1'LE : CHF I LE iRESUf T : I NTEGERiFI LENAME: S TRING( 1 6' i9810PROCEDURE WR I TEF I LE ( VA R F : CH F I L E ) i1 1 VAR CH : CH*R i12 B EG I N132 2.F OR CH: = ' O ' T O ' 9 ' DO14 B EG I N15 3 F ' : = CH i ( + CHR ( I + ORD ( ' 0 ' ) ) i + )16 P UT ( F )17 END)18 1233END'1920PROCEDURE READF I LE ( VA R F : CHF I L E )2 1 VAR I : I NTEGER i22 CH : CHAR;


B EGI N2 42 5F OR I ; 0 T O 9 DOBE'GIN2 6 CH : = F" i2 7 13 2Q ET


P ROCEDURE A S S I GN ( VA R F : F I L E VARI * B I E i ST P. : S T R I NG ) >P u i p o s e : A s s o c i a t e t h e f i l e v a r i a b l e F w i t h a n e x t e r n a ldi s k e t t e na me d i n STR.f i l e a nA S S I GN i s t h e f i r s t f i l e o p e r a t i o n t o b e e x e c u t e d i n l i n e 3 4 . T h i spr o c e d u r e a s s o c i a t e s a f i l e v a r i a b l e ( O VTF I L E ) w i t h a n e x t e r n a l f i l ean a d i s k e t t e g i v e n i n F I L E NAME ( i n t h i s c a s e i t i s " T E ST D AT " ) . T h es t r i n g p a s s e d t a ASSI GN i s p l a c e d i n t o t h e F I B a n d t h e name i si n t e r pr e t ed , 4 f t e r e x e c u t i n g t h e ABBI QN p r o c ed u r e . t h e f i l e v a r i a b l ep a s s e d t o t h e AS S I GN p r o c e d u r e i s a l wa y s' a s s o c i a t e d w i t h t h e d i s k e t t ef i l e n a me d i n t h e n a me p a r a m e t e r u n t i l ~ o r u n l e s s . a n o t h e r A S S I G N i sd on e t o t h e f i l e v a r i ab l e .PROCEDURE REWRITE (VAR F : F I L E VARI ABLE >'P ur p o s e : Cr e a t e a f i l e a n d i s k e t t e u s i n g t h e name i n t h e F I B ( e i t h e rf i l i e d i n b g t h e ASSI GN s t a t emen t p r e v i o u s l y a r n u l l ( i f n u l l ~ atemp or a r y f i l e is c r e a t e d. > .T h e REWRITE p r o c ed ur e i s c a l l e d i n l i n e 3 5 o f F i g u r e D - l . E x e c u t i n gt h i s p r o c ed ur e c a u s e s t h e c r e a t i o n a f a f i l e w i t h t h e name c o n t a i n e di n t h e F l' B o f F . An y e x i s t i n g f i l e s b g t ha t name a r e d e l e t e d s aNEVER us e REWRITE on a f i l e w hi c h c o n t a i n s u s a b le d at a . I n t h i se xamp l e s t h e f i l e o n d i s k e t t e w i l l b e na me d " TEST. DAT " a n d i s l o c a t e do n t h e d e f a u l t d i s k e t t e ( b e c a us e n o o t he r d i s k e t t e wa s s p e c i f i e d i nt h e f i l e name s t r i n g pa s s e d t o ASSI GN ) .I f n o p r e v i o u s AS S I GN h a d b e e n p e r f a r me d i t h e n a me f i e l d o f t h e F I B i se mpt y a n d a t emp o r a r y f i l e i s c r e a t e d w i t h t h e name " PABTMPOO. 444 . "T empor a r y f i l e s a r e gener a l l y u s e d f o r s c r a t c h pa d memor y a n d d a t aw h i c h i s n a t n e e <strong>de</strong> d a f t e r e x e c u t i o n a f t h e p r o g r am . Th e d i g i t s a t t h ela s t t w a p a s i t i o n s i n t h e name a r e u s e d t o g i v e ea c h t emp or a r y f i l e aun i q u e na me.T h e EQF f u n c t i o n a n d t h e EQLN f u n c t i o n r e t ur n t r u e b e c a us e OUTF I L E i sa n o u t pu t f i l e . OVTF I L E i s o pe n o n l y f a r w r i t i n g s e qu e n t i a l l y a n d i sr ea d y t a r e c e i v e d a t a i n t o i t s f i r s t e l eme n t . I f t h e o p e r a t i o n i s n o tsu c c e s s f u l ' t h e I QRESUL T f u n c t i o n r e t u r n s a n o n z e r o i n t h i s c a s e ( s e e1 i n e 3 6 ) ,FUNCTION I QREBU! T ; I NTEGER 'P u r p o s e ; R e t u r n t h e i n t e g e r v a l u e i n d i c a t i n g s t a t u s ' a f f i l ea per a t i o n .T h e v a l u e o f t h i s f u n c t i o n i s s e t a f t e r a n y i n p u t a r o u t p u t o p e r a t i o na n d ma y b e c h e c k e d a t a n y t i me . N a t e i n F i g u r e D- l i t i s c a l l e d a f t e re a c h f i l e o p e r a t i o n i n l i n e s 3 6 , 4 2 ' a n d 4 b . I t i s u s e d h e r e t o s t o pt h e p r o g r a m i f a f i l e o p e r a t i o n d i d n o t w a r k a s p l a n n e d , N o t e t h a t e a uc a n n o t " W R I T E ( I ORESV L T ) " b e c a u s e I QRESUL T i s r e s e t t a 0 a f t e r e a c h I / Oo p e r a t i o n . T h e me a n i n g o f t h e v a l u e s r e t u r n e d b g I QREBVL T i s p r e s e n t e di n Chap t e r 3 .1 3 1


P ROCEDURE P U T ( VAP. F : F I L F VARIABL E ) iP ur p o s e : T r a n s f e v t h e c o n t e n t s o f t h e w i n dow v a r i a b l e a s s o c i a t e d w i t hF t a t h e n e x t a v a i l a b l e r e c o v d i n t h e f i l e ,P r o c e d uv e W R I T E F I L E i b e g i n n i n g o n l i n e 9 o f F i g uv e D - l i wv i t e s t h ec ha r a c t e r s " 0 " t o " 9 " t o t h e TEST. DAT f i l e . T h e PVT p r o c e d ur e c a u s e sth e d a t a t o b e w r i t t e n t a t h e f i l e , A l wa y s b e f o r e e x e c u t i n g a P V Ti a na s s i gnmen t i s ma d e t a t h e w i n dow v a r i a b l e a s i n l i n e 15 . F a l l owi n g i sa d i a gva m a f wha t i s o c c u r r i n g :) 00110000 ( Wi n dow va r i ab l e a f t e v a s s i gnmen t ( l i ne 15 ) a n d CH i s e q u al+ t a ' 0 ' .+ + + + + +F i l e b e f ov e an y PVT s t a t emen t i s e x e c u t e d .l 0 0 1100 00 l W i n dow v a r i a b l e a f t e r PU T i n i n e 1 6 ,+ + + + + + +) 0 0 1 1 0 0 0 0 ) 4 I IlI+ + — —— — + + ­F i l e a f t e v t h e f i r s t PU T i s ex e c u t e d i n t h e F OR l a o p i n F i g u r e D - 1l i ne s 13 t h r o ug h 17 .PROCEDURE WR I TE r'PRGDEDVRE WRI TE ( e xpv es s i o n . . . i ex pv'e s s i o n ) 'P ROCEDURE WRI TE (VAR F. F I L E VARI ABLE. e x pr e s s i o n . . . e x p r e s s i o n ) 'Pur p a s e : Sh ov t ha n d f a r ' F : = d a t a v PUT


g t h e Op e r a t i n g S y s t e m i n d i c a t i n g w h e t h e r t h e c l o s e i s s u c c e s s f u l . I ti s i n c l u d e d a s a p a r a me t e r t o m a i n t a i n c o mp a t i b i l i t y w i t h p r e v i o u sve r s i o n s o f t h e c o mp i l e r , I n t h i - p r o g r a m a v a 1 u e a f n o n z e r o m ea n s a ne r r o r c l o s i n g t h e f i l e s a n d a n y o t he r v a l u e i n d i c a t e s s u c c e s s .PROCEDURE RESE T ( VA R F: F I L E VAR I AB L E ) iP ur po s e : Open an exi s t i n g f i l e f or r ea di ng . Th e wi ndow var i abl e i sm oved t o t h e b e g i n n i n g a f t h e f i l e .A f t e r c bee k i n g RESULTS t' h e pr o c e d ur e RESET i s ca 1 1 ed i n 1 inc 4 7 .R ESET o p e n s a n e x i s t i n g f i l e f a r r e a d i n g a n d r e s e t s t h e w i n d o wv a r i a b l e t o t h e b e g i n n i n g o f t h e f i l e . F i s a s s i gn e d t h e f i r s te l e me n t o f F . I f F i s a l r e a d y o p e n i RESE T c a l l s CL OSE . EOF a n d E OL Nr e t u r n F ALSE,. I f a RES ET i s d a n e o n a f i l e t h a t d a e s n o t e x i s t iI ORESUL T c a n t a i n s a n o n z e r o . Al l o t h e r v a l u e s o f I ORESUL T i n d i c a t esu c c e s s . I n t h e s a mp l e p r o g r a m , OUT F I L E i s o p e n e d b g t h e RESETp r o c ed ur e s o t h a t i t ma y b e r ea d , B e l o w i s a d i a g r a m o f t h e f i l e a n dw i n dow v a r i a b l e a f t e r t h e RESET i s e x e c u t e d i n l i n e 4 7 . No t e t ha t w i t hno n - c o mp u t e r c o n s o l e t y p e d f i l e - , s u c h as OUTF I L E . t h e p r o c e d u r e R ESETdoe s a n i n i t i a l GETS w hi c h m ove s t h e f i r s t e l e ment o f t h e f i l e ( i nt h i s c a s e t h e A S C I I v a l u e f o r t h e n u mb e r 0 ) i n t a t h e w i n d a w v a r i a b l e .l GG1 10 0 0 0 l W i n d o m v a r i a b l e ( OUT F l L E ". ) a f t e r RESE T ( l i n e 4 7 ) .+ +' + + + + + +l 0 0 1100 0 0 l 0 0 110 00 1 l 0 0 1100 10 l 0 0 110 0 11 ', 0 0 110 l 0 0 l 0 0 1 10 101 ,' .+ + + + — + + +T h e i n i t i a l GET i s n o t p e r f or me d o n c a n s a l e f i l e s o r unt apped f i l e s .Y o u wo u l d a l wa y s h a v e t o t y p e a c h a r a c t e r b e f o r e y ou r p r o g r a m c o u l <strong>de</strong> xec u t e i b e c a us e t h e GET p r o c ed u r e i s ~ a i t i n g f o r a c h a r a c t e r .PROCEDURE GET ( VAR F : F I L E VARI ABLE) 'Pur p a s e : T r a n s f e r t h e c u r r e n t l y a c c e s s i b l e r e c o r d t o t h e w i n d owv a r i a b l e a n d a d v a n c e t h e w i n d o w v a r i a b l e .A f t e r c h e c k i n g t ha t t h e RESET p r o c ed ur e i s s ucces s f ul ' p r o c ed u r eRE*DFILE i s ca 1 led i n l i n e Si , Th i s pr ocedur e r ead s eac h e l ement o ft h e f i l e p a s s e d t a i t ( i n t h i s c a s e t h e e l e me n t i s a c h a r a c t e r ) a n dw r i t e s t h a t e l e me n t t a t h e s c r e e n . READF I L E b e g i n s o n l i n e 2 0 . T h ewo r k i s do n e i n t h e F OR l o o p o f l i n e s 2 4 t h r a u g h 2 9 .T h e GET p r o c ed ur e a dv an ce s t h e wi n do ~ v a r i a b l e b g on e e l emen t a n dm o v e s t h e c o n t e n t s a f t h e f i l e p o i n t e d t o i n t o t h e w i n d o w v a r i a b l e .If n o n e x t e l e me n t e x i s t s i EO F b e c o me s T RUE . S e e S e c t i o n 3 a n T E XTf i l e s f o r m o r e d e t a i l s a n GE T a n d T EXT f i l e s . T h e d i a g r a m b e l o wd e s c r i b e s w h a t i s h a p p e n i n g w i t h i n t h e FOR l o o p o n l i n e s 2 6 a n d 2 7 t h ef i r s t t i m e t h r o ug h t h e l o o p.133


l 0 0 1100 00 l W i n daw va r i ab l e ( QVTF I LE ) a f t e r l i n e 2 6+ + + + +l 0 0 1 1 0 0 0 0 l 0 0 1 10 0 0 1 l 0 0 1 1 0 0 10 l OG1 10 0 1 1 l 0 0 1 1 0 10 0 f 0 0 1 10 1 0 1 l . . .+ - —— + + + — — — — + - +Af t e r e x e c u t i n g l i n e 2 6 C H c o n t a i n s t h e ASC I I F o r 0 ( 0 0 1 1 0 0 0 0 ) .A f t e r e x e c u t i n g l i n e 2 7 ' t h e w i n d o w v a r i a b l e i s a d v a n c e d .l0 0 110001 l W i n dow v a r i a b le a f t e r G ET i n l i n e 2 7 ,++ +l OO l l QOOQ I 0 0 1 10 0 0 1 < 0 0 1 10 0 1 0 l 0 0 1 1 0 0 1 i l 0 0 1 10 1 0 0 < 0 0 1 10 1 0 1 l .+ + + + + + +L i n e 2 8 wr i t e s t h e c o n t e n t s o f CH t a t h e d e f a u l t o v t p u t f i l e wh i c h i st h e comp u t e r c a n s o l e . Pr o c e dvr e READF I L E d i s p l a y s t h e c h a r a c t e r s " 0 "t h r o ug h " W " i n a c o l um n a n t h e co mp u t e r c o ns o l e . Ca 1 l i n g CLOSE a f t er ' aR ESET i s n o t n e c e s s a r y i n t h e s e q u e n t i a l c a s e i b e c a v s e t h e f i l ea l r ea d y e x i s t s o n t h e d i s k e t t e a n d ha s n o t b ee n a l t e r e d i n a n y wa g . I fOVTF I L E i s ac c e s s e d r a n d a m l g i a C LO SE m i g h t b e n e c e s s a r y .P ROCEDURE RE AD ( d a t a ' d a t a . . . i d a t a ) iPROCEDURE RE AD ( VA R F : F I L E VA R I ABL E . da t a ' d a t a . . . i d a t a ) 'P ur p o s e : Whe n v s e d w i t h n o n - camp v t e r c a n s a l e f i l e s e x e c u t e " d a t aF ' Q ET ( F ) ' " f o r e a c h d a t a i t em r e ad . Whe n u s e d w i t h comp v t e r c o n s o l ef i l e s e x e c u t e " GET ( F ) ' d a t a : =F"" " . I f F i s n a t s p e c i f i e d t h e d e f a u l tINPUT f i l e i s u s ed. Se e th e s e c t i o n o n T EXT f i l e s fo r i n f o rm at i o n a nc an v e r s 1 on s.Th e READ pr oc edur'e is th e s ame as an a s s i gnment a n d a c a 1 1 t o G ET. I fREAD i s u s e d r a t he r t ha n QE T i n t h e cu r r e nt e x ampl e s t h e F OR l o op b o d gw ou l d l o o k l i k e t h i s :F OR I : = 0 T O 9 DOB EGI NR EAD ( CH ) iW RI TEL N ( CH )END'Rea d i n g pa s t e n d - o f - f i l e a n comp u t e r c o n s o l e i n pu t r e s u l t s i n a s y s t e mc r a s h .


3 . T E XT F I L E SDEF IN I T I QNA TKXT f i l e i s a f i l e a f A S C I I c h a r a c t e r s s u b d i v i d e d i n t o l i n e s . Ali n e i s a s e q u e n c e a f c h a r a c t e r s t e r m i n a t e d b g a n o n p r i n t a b l een d- o f - l i n e i n d i c a t o r i u s u a l l y a ca r r i a g e r e t u rn a n d a l i n e f e e dc h a r a c t e r . I t i s s i m i l a r t o a f i l e o f CHA R e x c e p t t h a t a u t a m a t i cco n v e r s i o n a f n u mb e r s i s pe r f o r m ed w h e n t h e y ar e r e a d f r a m a n d w r i t t e nt a t h e f i l e . A l s o . v a r i a b l e s o f t gp e STR1NG ma y b e r ea d f r om a t e x tf i l e a n d BOOL EANs i S T R I NGs i a n d P ACKED ARRAY s ma y b e w r i t t e n t a t e x tf i l es . * c c e s s t o a TEXT f i l e i s v i a GE T a n d PUT f o r c h a r a c t e r I / O( w h i c h d o n o t d o c o n v e r s i o n s ) i RE AD a n d W R I T E i w h i c h h a v e b e e n d e f i n e <strong>de</strong> a r l i e r i n t h i s s e c t i o n i a n d READL N a n d W R I T EL N > w h i c h a r e u s e d i nF i g ur e D- 2 a n d <strong>de</strong> f i n e d i n t h i s s e c t i on .Th e f or ma t o f a TEXT f i l e i n m emory i s a FI B a nd a i - b y t e w i n d o wv a r i a b l e . O n d i s k e t t e i t h e f i l e l o o k s l i k e t h e sa mp l e b e l o w i n wh i c h aca r r i a ge r e t u rn i s r e p re s e n t e d b g " : . " i l i n e f e ed b g " / " a n d e nd o f f i l eI l g NT h i s i s a l i n e > / T h i s i s t h e n e x t l i n e > / T h i s i s t h e l a s t l i n e : / 0FUNCT I ON EQL N : BOOL EAN'FUNCTION KOLN(VAR F : TE XT ) BOOLEAN;Pur p o s e : I n d i c a t e t h e s t a t e o f t h e f i l e b e r e t u r n i n g t r u e o n l y wh ent h e w i n dow v a r i a b l e i s o v e r t h e en d- a f - l i n e c h a r a c t e r . W h e n n o f i l e i ssp e c i f i e d t h e d e f a u l t I NPUT f i l e i s a s sumed.T h i s f u n c t i o n r e t u r n s t r u e o n d i s k e t t e t e x t f i l e s whe n t h e l a s t v a l i dch a r a c t e r o n a l i n e i s r e a d u s i n g a R EAD s t a t e m en t . B e c a u s e t h ese quenc e o f s t a t eme n t s f ar a READ (a n n o n - c ompute r c o n s o l e f i l e s )is " C H ; = F l G E T ( F ) i " i t h e w i n d o w v a r i a b l e i s p o s i t i o n e d o v e r t h ee n d- o f - l i n e c h a r a c t e r i m me d i a t e l g a f t e r t h e l a s t c h a r a c t e r i s r e a d .T h u s ' E OL N r e t u r n s TRUK o n NON- COMPUTER CONSOL E T E XT f i l e s w h e n t h el a s t c h a r a c t e r i s r ea d . A l s o . a BLANK c h a r a c t e r i s r e t u r n e d i n s t ea do f t h e e n d - a f - l i n e c h a r a c t e r , T h e a b o v e s e q u e n c e i s r e v e r s e d o nc omp ut e r CONSOLE f i l e s ( RE* D i s a n i n i t i a l c a l l t a GET f o l l owe d b g a nas s i gnmen t f r om t h e w i n dow v a r i a b l e ) , W h e n ga u u s e comp u t e r CONSOLEf i l e s . KOLN wi 1 1 r e t ur n t r u e a f t e r t h e c a r r i ag e r e t u r n / l i n e f e e d i sr e a d i n s t e a d o f a f t e r t h e l a s t c h a r a c t e r a s i n d i s k f i l e s . A b l a n k i sst i l l re t u r n e d i n t h e c h a r a c t e r ,F UNCT I ON E OF iFUNCT I ON E QF ( VA R F : F I L E ) : BGOL KANIP u r p o s e : I n d i c a t e t h e s t a t e o f a f i l e b g r e t u r n i n g t r u e o n l y w h e n t h ew i n d o w v a r i a b l e . i s a v e r a n e n d - a f - f i l e c h a r a c t e r . W h e n n o f i l e i ss p e c i f i e d ' t h e d e f a u l t I NPUT .f i l e i s a s s u me d .1 3 5


E GF i s a f unc t i o n Cha t r e t u r n s t r u e wh en t h e en d- a f - f i 1 e c h a r a c t e r i sr e a d . I t i s s i mi l a r t a EGL N i n t ha t t h e l a s t c har aet e r r e a d w i l l s e tE OF Co t r u e o n NON-COMPUTER CONSOLE f i l e s , G n comp u t e r CGNSOf E f i l e sE QF i s t r u e on l y whe n Ch e en d- o f - f i l e i n d i c a t o r i s e n t e r ed . Re a d i n gpa s t en d - a f - f i l e o n comp u t e r c o n s o l e f i l e s i s n a t s u pp o r t e d . . . e x p r ) 'Pur p o s e : Pu t t h e d a t a i n t o t h e f i l e a s so c' i a t e d w i t h Fi e n d i n g t h eav t pu t w i t h a n e n d- o f - l i ne ch a r a c t e r . If n o f i l e is s p e c i f i e d t h ee x p r e s s i an s a r e wr i t t e n t a t h e QUTPUT f i l e , * W R I TE( N w i t h n oex p r e s s i an s m e r e l g o u t p u t " a c a r r i a g e r e t u r n / l i n e f e e d . Th e WR I TEpr ocedur e i s r e<strong>de</strong>f i ned as a c onve rs i o n r a t h er C han a r e pla cement f o rPUT.T h i s p r o c ed ur e w r i t e s t h e d a t a p a s s e d t a i t t o t h e f i l e na med ~ p l a c i n gan e n d - a f - l i n e c h a r a c t e r a f t e r t h e l a s t i t e m a f d a t a w r i t t e n . I f n af i l e i s n a me d i t h e f i l e i s w r i t t e n t o t h e d e f a u l t OUTPUT f i l e . D a t am a y b e l i t e r a l a n d na me d c o n s t a n t s i i n t e g e r s i r e a l s i s u b r a n g e s .e n u me r a t e d i B o o l e a n s i s t r i n g s a n d p a c k e d a r r a y s o f c h a r a c t e r s b u tmay n o t b e s t r u c t u r e d t y pe s s u c h as r e c o rd s . N umer i c d a t a i s c o n v e r t e dt a ASCI I a n d s t r i n g s a r e C r e a t e d a - a r r a y s o f c h a r a c t e r s


F o r m a t t e d O u t p u tIn F i g v r e D-2 t h r e e l i n e s t h a t m a k e u p t h e b o d y o f W R I T EDAT* ( 9 i i G ia n d 11 ) d o t h e a c t v a l f i l e o u t p u t . L i n e 9 s e nd s t h e c o n t e n t s o f t h ev a r i a b l e s t r i n g S f o l l owe d b g a c a r r i a g e r et ur n / l i n e f e e d t o t h eT EXT f i l e F . L i n e I G f o r m a t s t h e c o n t e n t s o f I i n a f i e l d o f f o u rspa ce s a n d s e n d s t h i s f or ma t t e d o v t p u t t o t h e f i l e F . Th e r e a l numberl i t er @ i i n l i n e i l i s f o r m a t t e d i n t o a f i e l d o f n i n e s p a c e s ' f o u r o fwh i c h mu s t b e Co Ch e r i g h t o f t h e d e ci ma l p l a c e . T h i s f or m a t t e d numberi s t h e n w r i t t e n t o t h e f i l e F . T h e f i e l d f o r ma t ma y b e s p e c i f i e d f o ran y d a t a t y p e . Fo r n o n - r ea l number s o n l g t h e f i e l d w i d t h i s s p e c i f i ed ~n o t t h e number o f p l a c e s a f t e r t h e d e c i ma l p o i n t , T h e d a t a i s r i g h tgv s t i f i e d i n t h e f i e l d . 1 f a number i s l a r ge r t ha n Ch e 6 . 5 s i g n i f i c a n td i g i t s c a n r e p r e s e n t . t h e o u t pv t i s a l wa y s e x p r e s s e d i n e x p on en t a ln o t a t i o n . A l s o i f t h e f i e l d w i d t h i s t o o s m a l l t o e x p r e s s t h e n u mb e ri t i s w r i t t e n i n e x p o n e n t i a l n o t a t i o n . F o r f u r t h e r i n f o r m a t i o n o nf o r m a t t i n g c o n s u l t a P a s c a l t e x t b o o k a n d e x p e r i me n t ,Th e b o d y o f t h e W R I TEDAT A p r o c e d u r e c o u l d h a v e b e e n w r i t t e n as f o l l o w sw i t h t h e s a me r e s u l Cs ,WRITELN im ov i n g t h e w i n dow va r i ab l e t o t h e be g i n n i n g i n p r e pa r a t i o n f or . r ea d i n gd a t a f r o m t h e f i l e F . F o l l o wi n g a s u c c e s s f u l RESETS t h e p r o c e d u r eRE*DD* T* i s c a l l e d t o r ea d b a c k t h e i n f or m a t i o n p l a c e d i n " TEXT. TST"a n d d i s p l a g i t a t t h e comp u t e r c o n s o l e .137


St a t ementS o ur c e S t a t emen tPROGRAM TE XT 10 DENOi2 345 100 V AR F : T E X TiINTEGERiS: STR INGi6PRO


PROCEDURE READ'PROCEDURE READL N;P ROCEDURE READL N ( F ) iP ROCEDURE READLN ( F v a r i ab l e ~ v a r i a b l e . . i va r i a b le ) iPur po se : Rea d f r o m t h e f i l e a s s oc i a t e d w i t h F i n t o t h e v a r i a b le sl i s t e d . I n a l l c a s e s i r e a d u n t i l a n e n d - a t - l i n e c h a r a c t e r i s f o u n d .s k i p p i n g a n y u n r e a d d a t a ' a n d a d v a n c e t o t h e b e g i n n i n g a f t h e n e x tl i n e . REA D i s r e d e f i n e d t o p e r f o r m c o n v e r s i o n o f r e a l s ' S a o l e a n s i a n di n t eg er s .READL N i l i k e M R I T ELN i h a s a s p a r a m e t e r s an o p t i o n a l f i 1 e v a r i a b l e a n dan y numbe r o f v a r i ab l es t a r e c e iv e t h e d a t a f r o m t h e f i l e . I f t h e f i I ev a r i a b l e i s n o t s p e c i f i e d i i n p u t i s t a k e n f r a m t h e d e f a u l t I NPUT t i l e .th e k e y b oa r d . T h e v a r i a b l e s i n t h e p a r a me t e r l i s t a r e t h e same t g pe a st h e d a t a b e i n g r e a d f r o m t h e f i l e . H o w e v e r ~ n o t g p e c h e c k i n g i s d o n e iso i t i s u p t a g a u t a c o n s t r u c t a p a r a m et e r l i s t c o m pa t i b l e w i t h t h ef or ma t o f g ou r f i l e . An y numb er s a r e c o n v e r t e d o n i n p u t b u t t h ef or ma t t i n g i s l o s t . Numb er s mus t b e s e par a t e d f r o m ea c h o t h e r a n dot he r d a t a t y p e s bg a b l a n k o r a c a r r i a g e r e t u r n l i n e f e e d.R E* DL N r ec agn i ze s bu t d oe s n o t t r a ns mi t t h e en d- o f - l i n e c ha r a c t e r . T h ea c t i o n i s t o r ea d da t a u n t i l i t e n c o u n t er s a n e n d- o f - l i n e a n dcha r a c t er , Th e a c t i o n i s t o r ea d d a t a u n t i l i t e n c ou n t er s a ne n d - o f - 1 i n e an d a dv a nc e t h e w i n dow v a r i a b l e t a t h e b eg i n n i n g a f t h en e x t l i n e . T h e d a t a i n " T E XT . TST " l o o k s l i k e t h e f o l l o w i n g :THI S. I S A ST RI NG/3 5 4 5 . 6789 > t 8Af t er ~e a d i n g t h e s t r i n g i n t h e f i r s t l i n e t o r e ad t h » i n t e g er 35 ' y o umus t u s e READ an d n o t READLN. I f a READLN wer e u s ed he r e . t h e 3 5 w ou l db e r ea d p r o p e r l g b e c a us e t h e f i r s t b l a n k t er mi n a t e s t h e numb er .H ow e v e r s t h e w i n d o w v a r i a b l e w o u l d b e a d v a n c e d p a s t t h e r e a l n u mb e r t ot h e en d a f t h e f i l e . T h en ' i f y o u t r y t o r ea d t h e r e a l i a l l on e g e t si s EOF . a n d t h e n y o u bran<strong>de</strong>r wha t h a p p ene d t a t h e r ea l numbe r k n own t ob e o u t t h e r e .ST R I NGS mu s t a l wa y s b e r e a d w i t h a READL N b e c a u s e t h e y a r e te r m in a t e dwi t h e n d - o f - l i n e c h a r a c t e r s. I f t h e d a t a t a t h e f i l e h a d b e e n ' T H I S1 8 A S T R I N(' 3 5 > / ' . t h e v a l u e r e t u r n e d f a r S w o u l d b e t h e e n t i r e l i n e iincl udi ng t he ASCI I 35.Li n e s 2 0 a n d Z l w r i t e t h e d a t a t o t h e c o mp u t e r c a n s a l e i n t h e s a mef o r ma t a s i t i s c a n t a i n e d i n t h e f i l e .A f t e r e x e c u t i n g READDATAi t h e pr agr a m i s f i n i s h ed . A CLOSE i s n o tn e c e s s a r y b e c a u s e t h e d a t a i n " T E XT . TST " i s n o t a l t e r e d i n a n y wa gs i n c e t h e l a s t CL OS E a n t h a t f i l e .


W r i t i n g t o t h e P r i n t erW r i t i n g t o t h e p r i n t e r i - v e r y s i m p l e . a s <strong>de</strong>mon s t r a t e d i n F i g u r e D- 3 .A f i l e v a r i a b l e i s d e c l a r e d t o b e o f t y p e TEXT a s i n l i n e 5 o f F i g u r eD - 3 , T h i s f i l e v a r i a b l e i s A S S I QNe d t o t h e p r i n t e r i n l i n e 1 1 . T h ef i l e n a m e ' P : p a s s e d t o A S S I GN me a n s t h a t F i s t o b e a s s o c i a t e d w i t hth e l i s t d e v i c e s o t h a t a l l d a t a w r i t t e n t o F i s r o u t e d t o t h epr i n t er , REWRI TE is c a l l e d t o o p en t h e l i s t d e v i c e f o r w r i t i n g . N ot etha t a CLOSE is . n ot n e c e s s a r y s i n c e t h e d a t a h as a l r e a d y b e en w ri t t e na n d t h e buf f e r d o e s n o t n e e d t o b e f l ushed . L i n e s 2 3 a n d 2 5 u s es t a n dar d Pa s c a l f or ma t t i n g d i r e c t i v e s . I n l i n e 2 3 . R i s t o b e wr i t t eni n a f i e l d s e v e n c h a r a c t e r s l o ng ~ w i t h t h r e e d i g i t s t o t h e r i g h t o ft h e <strong>de</strong>c i ma 1 p l a c e ,N e s tS o u r c e S t a t e me n t1 PRQGRAN PRI NTERs(+WRI TE DATA AND TEXT TG THE PRI NTER10 054VARF: TEXT sI: I NTEQERi9876S: STR I NGiR: REAL s10 BEGI Ni i*S S l Q N ( F , ' P : ' ) i12 REWR I TE ( F );13 IF I ORESVLT < > 0 THEN14 W RITELN( ' Er r o r r e w r i t i n g f i l e ' )15 1 1ELSE16S EGI N17 2 S : = ' T H I S L I N E l S A STRI NG ' i1S I : = 5 5 i19 2 R; 3 . 14 1563s2 0 WRI T E ( F i S ) i2 1 2 WRI T E ( F i I ) i22 2 WRI TEL N ( F ) i23 2 WRI T E L N ( F i R: 7 : 3 ) s2 4 2 W RI T E ( F i I i R ) s2 5 WRI T E ( F i I : 4 i R: 7 . 3 ) s2 6 2 WRI TEl N ( F ) i2 7 W RITELN


MI SCEL L ANEOUS F I L E ROUT I NE SA s a mp l e p r o g r a m i s n o t p r o v i d e d f o r t h e f o l l o w i n g r o u t i n e s .P ROCEDURE OPE N ( F : F I L E V A R I ABL E T I T L E S TR I NG i VA R RE S UL TI NTEGER) iP ur p o s e ; I d e n t i c a l t o t h e s e quenc e ' ASSI GN (F. T I TL E ) RESET ( F ) ' ' .PROCEDURE CLOSEDEL ( F: F I L E VAR I * BLE i VAR RESUL T : I NTEGER ) lP u r p o s e : C l o s e f i l e F a n d d e l e t e i t . U s e d w i t h t e m po r a r y f i l e s .Ex a c t l y t h e s a me a s CL OS E f o l l o w e d b y PURGE,P ROCEDURE PURGE ( F : F l L E VARI ABt E ) 'P ur p o s e : D e l e t e t h e f i l e a s s o c i a t e d w i t h F f r o m t h e D i s k e t t e . AnA SSI GN mus t b e e x e c u t e d some t i m e bef or e t h e c a l l t o PURGE s o t ha t t h ef i l e c o n t r o l b l a c k f o r F c o n t a i n s t h e name o f t h e f i l e t o b e d e l e t e d ,Qn some o p er a t i n g s y s t e ms , t h e f i l e ma y b e r e q u i r e d t o b e c l os edb e f or e t h i s pr o c ed ur e c a n f u n c t i o n p r o p e r l y . I n t h i s c a s e CLOSEDEL i sa u s e f u l p r o c e d ur e .


*PPENDI X E :B I BL I GQRAPHYQr o g o n o . Pe t e r . P r o r a m m in i n P a s c a l e Ad d i s o n - W e s l e y ~ R e a d i n g ~M assa c h u s e t t s . 19 7 8 .A g o o d i n t r o d u c t i o n f o r s e l f - t e a c h i n g .W i l s o n . I . R i a n d A d dy ma n A . M. * P r a c t i c a l I n t r o d u c t i o n t o P a s c a lSp r i ng e r - V e r l a g ~ Ne w Yo r k e 1 9 7 9 .A n a dv a n c e d t e x t b o o kJ e n s e n p K a t h e l e e n e a n d W i r t h , N i k l a u s , P a s c a l U s e r M a n u a l a n dRapport , Spr t oper- @er i e New York ~ 1474.Fi r s t <strong>de</strong> f i n i t i o n o f Pa s c a l . Bes t u s ed as a r e f e r e n c e d o c ument ." Dr a f t Pr o p o sa l I SO/ DP 7 18 5 ; Pr o g rammi n g L a n g ua g e s - Pa s c a l "N o t d e s i g n e d f o r t h e n o v i c e . A p r e c i s e l a n guag e d e f i n i t i o n .M ay b e o b t a i n e d f r om * me r i c a n Na t i o n a l S t a n d a r d s I n s t i t u t ei n t e r n a t i o n a l S a l e s De pa r t me n t .143 0 Br oadwa yN e w Y o r k e Ne w Y o r k 1 0 0 18F i n d l ege Wi l l i am , an d Wa t t D a v i d * . ~ P*SCAL : An i n t r oduct i o n t oM e t h o d i c a l P r o r a m m i n , Co mp u t e r S c i e n c e P r e s s ~ P o t o ma c ~ Ma r y l a n d e1 978 .Con wag ~ R i c h a r d p G r i e s . Da v i d p Z i m merm an . E . C a r l , A P r i m er o nP a s c a l W i n t h r o p Pu b l i s h er s ~ Camb r i d ge e Ma s s a c h us e t t s e 19 76 .Mi l l e r e A l a n R. r P a s c al P r o g r a ms f o r S c i e n t i s t s a n d E n i n e e r s 'Sgbexp I nc . B erkel ey C * . , 1981.De Re A t a r i " * G u i d e t o Ef f e c t i v e P r o g rammi n g " AP X 9 0 0 08A TAR I 4 0 0 / 8 0 0 D i s k 0 e r a t i n S s t e m I I R e f e r e n c e M a n u a l C0 1 6 3 4 7ATAR l 4 0 0 / 8 0 0 BASI C Re f e r en c e Ma n ua l C 0 1530 7


A PPEND I X F : P l a y e r / M i s s i l e Demo P r o g r a mTh e Pl ay e r / l'l i s s i l e Demo p r o gr am ma y b e e n t e r e d u s i n g t h e * TARIP r o g r am — Text E d i t o r a n d u s e d a s a n e xamp l e f o r mo d u l a r co mp i l a t i o n a n du s e o f t h e b u i l t - i n g r a p h i c s an d s o un d p r o c e d ur es . Comp i l e e a c h of ' t h em o d u l e s s e p a r a t e l g (PMDENOi P N N I S i PEEKPOKE i PNSND ) . T h e n l i n k t h e s em o d u l e s t o g e t h e r a l o n g w i t h t h e Gr a p h i c s a n d S o u n d L i b r a r y ( GRSND ) .W hen t h e l i n ke r r e s p ond s w i t h t h e a s t er i s k r e p on d w i t h t h e f o l l o w i n g :D 2 : PNDENOi D2 : PNN I S i D2 ; PHSND, D2 : PEEKPOKEi GRSND. PAS L I S / SO nc e l i n ks'd t o g e t he r y o u ma g e x ec u t e t h e p r o g r a m u s i n g t h e " Run "c ommand . A go g s t i c k i s r e q u i r e d t o mo v e t h e p l a y e r a n d f i r e t h em i ss i l e.


PROGRAM P L AYER/ MI S S I L E ( I NPUTS OUTPUT ) iT h i s p r o g r ams w r i t t e n i n Pa s c a l , <strong>de</strong>mon s t r a t e s t h e p l a g e r / m i s s i l ec a pab i l i t i e s o f <strong>ATARI</strong> Pa s c a l . I t i s b a s e d o n t h e p l ay e r / mi ss i l e<strong>de</strong>mon s t r a t i o n p r o g r a m wr i t t e n i n BASI C. E r r o r c h e c k i n g ha s b e eni mp l emen t e d s o t ha t t h e p l a ge r d a e s n a t c a us e s y s t e m c r a s he s whe n i tgoe s of f t h e s c r e en . Th e p l a ge r i s h e l d gu s t o f f t h e v i s i b l e s c r e enun t i l t h e i n pu t f r om t h e j o y s t i c k c ha n ge s i t s p o s i t i o n t o a p o i n t o nth e v i sib le sc r e e n. I n a d d i t i a n a v is i b l e m is s i l e @ ti l l b e f i r e d w he nth e b u t t o n o n t h e j o y s t i c k i s p r e s s ed . A l s o i m p l emen t e d ar e s o u n d sa s s oc i a t e d w i t h t h e movemen t a f b o t h t h e p l a y e r a n d t h e mi s s i l e ,F ou r mo d u l e s mu s t b e comp i l e d s e p a r a t e l g a n d t he n l i n k e d t o g e t he r t ofo r m t h e e x ec u t a b l e oh gee t f i l e . T h e s e ma d u l e s i n c l ud e PMSOUND(D2: PMSND. PAS) i P EEKPQKE(D 2; PEEKPOKE, PAB> i P MMIS SI L E a n dpr ogr am pl ay er / m i s s i l e ( D2: PMDEMO. P*S) .T h e e x e c u t ab l e f i l e i s D2 : PMDEMQ. COM an d ca n b e r u n b g t gp i n g " R " i nt h e Pa s c a l mo n i t o r . A j o y s t i c k i s r e q u i r e d f o r p r o g r a m e x e c u t i o n .T h e p l a y e r w i l l r e s p on d t a t h e j o y s t i c k b g mo v i n g v e r t i c a l l g ih o r i z o n t a l l y ~ a n d d i a gon a l l y . Th e mi s " i l e i s f i r e d b g p r e s s i n g t h eb u t t o n o n t h e j o y s t i c k . B a t h t h e p l a y e r a n d t h e mi s s i l e ma g b e mo v i n gs im u1 ta n e ous 1 g.« )TYPESCRN T YPE = ( F UL L SCREENS SPL 1T SCREEN ) iC L EA R T YP E = ( CL EAR SCREEN. DO NOT CL EA R SCREEN ) iVARPMBASEi ( +PLAYER- MI SS I L E BABE ADDRESS+ >Xi ( + Pl AYER AND M IS SI S E HORIZONTAL P OS IT ION+ >Y


E XTERNAL PROCEDURE 8 I GBANG> ( « I N MODUL E PMMI S S I L E « )E XTERNAL PROCEDURE MOVEMI S S I L E ; ( « I N MODUL E PMMI S S I L E « )E XTERN* L PROCEDURE POKEBYT E ( ADDR. VAL : I NTEGER ) ' ( « l N MODUL E PEEKPOKE« )EXTERNAL F UNCT I ON PEEKBYT E ( ADDR I NTEGER ) : I NTEGER 'PEEKPGKE« )< « I N MODUL EPROCEDURE SETPLAYER)


PROCEDURE MOVEUP i< sMQVKUP mov e s t h e p l a ge r u p o n t h e s c r ee n b g mo v i n g t h e p l a ge r u p i nt h e p l a ger ' s memor g a r ea . « )VA R I : l NTEQERiBEGI NIF Y> 1 THEN BE GI N (+ MOVE PL AYER UP ONE U N I T I N MEMORY AND ONS CREENS )F OR I ; = 0 T O 6 DO PQKEBYTE (PMBASE+ 5 1 1~ Y w l ,PEEKBYTE < PMBASE+512+Y+ I ) ) 'Y; = Y- 1 < « PL AYE R HA S MOVED UP ONE UN I T » )E ND ( e E L S E HOL D S T I L L i GUS T OF FSCREEN A T TO P QF SCRKENe )E N D iPROCEDURE MQVEDOWN'


END E L B E I F A = 7 T HEN MOVER I QHTE LSE I F A= 9 T HE N BE G I NMOVEL EFT iMOVEDONNE ND E L S E I F A = i 0 T HEN BE GI NM OVEL EF T iMOVEUPEND ELBE I F A = i i THEN MOVE EFTELBE I F A= i 3 THEN MOVEDOWNELBE I F A= i R THEN MOVEUPEL S E I F A i 5 T HE N BOUND < 0r l 8 2 t 2z 0 ) i


NODUL E P NN I SS I LE i{ + T h e r o u t i n e s i n t h i s mo d u l e h a n d l e t h e f i r i n g a n d f l i g h t o f t h emi s s i l e f o r t h e p l ay e r / m i s s i l e g r a p h i c s <strong>de</strong>mon s t r a t i o n p r o g r am, w)VAR PNBASE i Xi Ys MIS Y: EXTERNAL I N TEGER iFI RED: EXTERNAL BOOLEAN'EXTERNAL F UNCT l GN PE EKBYTE ( ADDR: I NTEGER ) : I NTEGER'EXTERNAL PROCEDURE POKEBYT E ( ADDRi V * L : I NTEGER ) iEXTERNAL PRQCEDURE SOUND ( V OI CE , P I TCH D I STORT I ON VOLUME : I NTEGER) lP ROCEDURE NOVEMI SS I L E i( +Movemi s s i l e i s c a l l e d b g p r o c ed ur e b i g ban g whe n t h e mi s s i l e i sf i r s t f i r e d . a n d l a t e r b g t h e ma i n p r o g r a m a s t h e mi s s i l e c o n t i n u e sit s tr a g e c t o r g . T he m ai n p r o g r a m c a l l s m ovemis s i l e u n t i l t h e m is s i l eha s mov e d o f f t h e t o p e d g e o f t h e sc r e en an d t h e "f i r e d " fl a g h a s b e e nr e s e t , e )VAR I : I NTEGER;BEGI NI F N1SY ' 5 THEN BEGI NFOR I ; = 0 T Q 1 DO POKEBYT E ( PNBASE+ 3 8 3 + MI S Y+ I i P EEKBYTE( P NBASE+3 8 4 +NI SY+ I 3 ) s( +MOVE MI SS I L E UP I N MI SS IS E NEMQRYe )M I SY: ~NI BY- 1 { % MI SS I L E H* S NOVED UP ONEe )END >IF MI BYs


P IOVENI S S I L E i ( + ST ART t" I S S I L E O N I T S TR* VECTORY+ )SOUND ( 3 r 46> I 2> 0 i (+ S TOP T HE F IR IN C S OUNDS' )END;MOBEND.f 4 9


MODUL E PMSOUNDi( + T h i s mo d u l e c o n t a i n s p r o c e d u r e m a i e n o i s e i u ! h i c h c o n t r o l s t h e s o u n dg en er a t i o n f o r t h e play e r ' s movemen t , Th i s p r o c ed ur e wa s p u t i n t o i . t so wn mo d u l e. + )EXTERNAL PROCEDURE SOUND ( V O I CE. P I T CHi D I STORT I ONS VOLUME : I NTEGER ) iP ROCEDURE MAKENOI S E i( eQKNERATE ENGI NE SOUND 4JHKN PLAYER MOVES. + )B EGI NS OUND (G. 18 2 2 , ' 6 )KND)MODEND.


M ODULE PE EKPOKE '(+Thi s modul e cont e i n s pr os edur es ro r per f a rm in g B ASIC sty le PEEKsa n d POK E s . + )P ROCEDURE POKEBYTE ( ADDRi V * L : I NTEGER ) i( %POKEBYTE ' BAS l C STYL E OF MEMORY LOCATI ONSPOKEBYTE PROVI DES * METHODS SIMILAR TG THE 8 4 S I C POKERY FOR THEP 4SC* L USER TQ SET MEMORY LOCATI ONS .E NTRY: PQKEBYTE


*PP END I X 9 : HELPFUL HI NTSTh e f o l l o w i n g av e a s s o r t e d s t a t emen t s t ha t ma y p r ov e t o b e u s e f u l wh enus i n g t h e <strong>ATARI</strong> Pa s c a l L a n g ua g e Sy s t em,1 . Comp i l a t i o n o f Pa s ca l p r ogv ams u s i n g F l o a t i n g P o i n t numb er s ( REALS 3r e q u i r e s t ha t t h e I n c 1ud e f i l e FLTPRDCS o r STDPROCS b e i d e n t i f i e dw i t h i n t h e d e c l a r a t i o n b od y o f t h e s ouv ce . I n a d d i t i o n t h e FPL I Sm us t b e l i n k e d w i t h y ou r comp i l e d s o u r c e a n d PASL I 8 . F a i l u r e t o d os o w i l l c a us e y ou r comp i l a t i o n a n d / o r l i n k i n g t o e r v ov . Re f e v t oth e <strong>de</strong>mo pv o gr a m CAL C f ov a n e xamp l e .2 . I d e n t i f i e r s a r e s i g n i f i c an t t o o n l y e i g h t c h a r a c t e r s .3 . CLGSEDEL ca n b e u s e d w i t h a n y f i l e s o b e c a r e f u l . Yo u ma ya c c i d e n t a l l y d e l e t e some t h i n g t ha t y o u d i d n ' t e x p ec t t o .4. W h i l e s t a n d a r d p v' o c ed ur e s av e b u i l t i n t o t h e comp i l ev i ot h ev sr e q u i r e t h e a p p r o p r i a t e I n c l u d e f i. l e s f o r d e c l av a t i o n p u r p o s e s .C hec k t h e s e f i l e s t o d e t er mi n e i f y o u n ee d t hem, T h es e I n c l u d ef i l e s ma y b e l i s t e d o n t h e p r i n t e r b y u s e o f t h e c o p y o p t i o n u n d erDO5 . Th e v es e r v e d wov d "PREDEFI NED" a l l ows c e r t a i n p r o c e duv.es a n df u n c t i on s t o b e come p a r t o f t h e s c op e s u r r o u n d i n g t h e p r o g r am . l nad d i t i o n an y f i l e pav ame t e r i s p a s s ed as tw o p av amete rs as r e q u i r e db y t h e v un - t i m e r o u t i n e s .1 5 2


INDE XA BSOL UT E v a t i a b l e s 3 2 1 59ADDR 4 1*NDand 16 b i t v a r i abl es 9 4ARCTAN 104*RR* Yas pr o e d u v a 1 p a> 'amet e ws 102s t o t a g e 2 9ASSI GN 5 0 . 1 3 1A ssignment compati bi l i t y 9 0A v a i l a b l e memos g me s s a g e S r 13BCD REAL 7 1B i t a n d b y t e m a n i p u l a t i o n 3 8 . 9 3BL OCKREADBLOCKWR ITE 52BOOLEAN 7 0Bui 1 t-in procedure esADDR 4 1*SS I QN 50B LOCKRE* D 52BLOCKWR I TE 52CLOSE 54CLOSEDEt 54CLRB I T 3 8CONC*T 4 5COPY 4 6DELETE 4 8E X I T 3 7F 1LLC H*R 4 3QNB 5 1H I 4 0INSERTI ORESUL T 5 6LENGTH 4 4LO 4 0P 1AXAVA I L 5 7NENAVA I L 5 7HOVE 3 5M OVELEF T 3 5MOVER IGHT 3 5OPEN 53POS 4 7S ETS I T 3 8SHL 3 9SHR 3 9SI ZEOF 4 2s ummar y o % 58SWAP 4 01 5 3


T STBI 7 3 8H N B 5 1P URGE 5 5B YT E 7 1 i 8 6B y t e ma n i p u l a t i on(s e e B i t a n d b y t e m a n i p u l a t i o n )CAI C. PAS 7C ha i n i n g 1 0 3C ha i n i n gabso l u t e v a r i a b le communi c a t i o n 3 2e xamp l e 3 3g 1 o1 a 1 va r i ah 1 e c ommuna t i on 3 2h ow- t o 3 2m ai n t a i n h ea p 3 2CH*R 7 0CHR 7 0 ' 9 0 . 10 5CLOSE 5 4 . 13 2CLOSEDEL 5 4 . 1 4 1CLRB 1T 3 8C omment ss LJnt a x 83Compa t i b i l i t y w i t h VCSD 77Comp iler cont r o lCog g lese n t r y p a i n t c o n t r o l 4 E 14li s t i n g ca n t r o 1s % P/O L 15r u n - t i m e r a n g e c h e c k i n g c a n t r a l % R 15r u n - t i m e e x c e p t i o n c h e c k i n g c o n t r o l 4 X 1 5sour c e co<strong>de</strong> i ncl u<strong>de</strong> mechani sm 4I 14s t r i c t / r e l a xe d t y p e e hec k i n g c an t r a 1 f T/ S Mi 1 4summer y 16s y n t a x 14Compilera u t p u t 8 . 13o u t p u t . 8 i 13a vai l abl e memor y 8c amp i l e t i m e i n f or m a t i o na l a u t p u 7 i 1 3e x e c u t i o n 7 i 1 2o p er a t i o na l d e s c r i p t i o n 12P H*SE 1 1 3 ' 1 8P HASE 2 13r ema i n i n g memor y 8s amp l e o u t p u t 7s epa r a t e comp i l a t i a n 2 6s t e p - b y - s t e p i n s t r u c t i a n s 7s y s t em r e q u i r emen t s 3u se r t ab l e s p a c e 8CONCAT 4 5C on f r oman t a r r a y s 1 0 2C onst an t da t a a t compi l e - t i me 6 1COP Y 4 61 5 4


D a t a s t o r a g eD a t a t y p e sBOOLEAN 70BYTE 7 1CHAR 70INTEGER 7 1r a n g e 70REAL 7 1SET 7 5s i z e 70STR INQ 7 1WORD 7 1DEl ETE 4 8D i s t r i b u t i o n d i s kc a n t e n t smi n i mum c on f i g u r a t i anE n d o f f i l e 1 28 . 13 4 ' 13 5EOF 1 0 4 ' 1 3 3EOLN 1 04 ' 13 3E r r o r ha n d l i n gr u n - t i meE r r o r me s s a g et y p e c o n f l i c t 9 0E r r o r me s sa g e s 18 > 1 18E xc e p t i a n c h e c k i n g(se e C ompi l e r c o n t r o l t o g g l e s )E XI TE x t e n s i an s t a I SO s t a n d a r d(s e e I S O s t a n d a r d e x t e n s i o n s )E x t en s i o n ssummary 8 1EXTERNAiand ent r y p o in t sgmb o 1 s 14a n d mo d u l a r comp i l a t i on 2 6a n d p r o c e d u r e s / f u n c t i o n s 2 6a n d v a r i a b l e s 27ro u t i n e s as p a r a m et e r s 2 6F I B( s e e F i l e I n f o r m a t i o n B l a c k )Fi l e I n f ormat i o n B l oc k 1 2 8F i l e v a r i a b l e 1 2 8Fi l e v ar i abl e untapped f i l es a r e. a l l owed 9 0Fi l e n a med ef i n i t i on 1 2 7F i l e n a me sa s s o c i a t i n g e x t e r n a l a n d i n t e r n a l 5 0c o mp i l e r i n p u t 7I 1 2l i n k e r i n p u t 19ASC I I t e x t1 5 5


A SSI GN p r o c ed ur ea s s o c i a t i n g f i l e s w i t h e x t e r n a l100b u i l t - i n p r o c e d ur e s 100c h a i n i n g 1 5 1c l os Lng 5 4 . 132c r e a t i n g 1 3 1d e f i n i t i o n 1 2 7d e l e t i n g 5 4 ' 55d e v i c e s E : , S : K : . P : . 50err or handl i ng 5 6e xamp l e 1 3 0f a s t b y t e r o u t i n e s 5 1f or ma t 't e d o u t p u t 137h e x o u t p u t 106i mp l i e d c o nv e r s i on s 9 0l o c a l 5 0l o c a l f i l e s a n d l i n ke r / D s mi t c h 20openi n g ( see a Iso R ESET > 53pr e - <strong>de</strong> f i n e d t y p e TEXT 89p r i m i t i v e f i l e a c c e s s 52p r i n t e r o u t p u t 5 0 ' 14temp or a r g i (s e e l o c a l >t e x t 1 35 ' 138untapped 89w i n d o m v a r i a b l e 1 28 ' 1 3 2 ' 1 3 3 m 13 4u rri t i n g t o p r i n t er 140FI LLCHAR 43Fl o a t i n g P o i n t REAL 7 1F or ma t t e d o u t p u t 1 06 ' 137FORWARD 1 0 1FPL I B. ERL4 i 9. 1 9 . 7 1 ( 1 5 2GET 133GNB 5 1GOTO 9 6GSSND. ERL 4 i 143Hea p ma na gemen tI SO s t a n d a r d 142M EMAVAI L a n d MA X* VA I L 57p a r a me t e r s 1 0 4H e xa d e ci ma l numb er s 1 0 6H I 4 0I / O(s e e F i l e s )I <strong>de</strong>nt i f i e r sa n d8 3 'e x t e r n a l s i g n i f i g a n c e 2 6l e ga l Pa s c a l 8 %


I n c l u d e f i l es 5s 8 t 1 4 ' 1 52INL I NEcod e e xamp l es 6 1s y n t a x 6 0lNSER7 49INTEGER 7 1I GRESUL T 5 6 ' 13 1 i 1 3 8 ' 1 4 0l 'SO s t a n d ar d e x t e n s i on sa bsol ut e v a r i a b l es 9 1a d d i t i on s t o a s s i gnmen t compa t i b i l i t yr u l e s 9 5B NF s y n t a x d e s c r i p t i o n o f AT* R I Pa s c a l 109b u i l t - i n p r o c e d u r e s a n d f u n c t i o n s 3 4c ha i n i n gc on c i s e l i s t o f ATAR I Pa s ca l f a c i l i t i e s 1E LSE c l aus e o n CASE s t a t emen t 9 6e x t e r n a l p r o c e d u r e s 9 8INL,I NE 6 0m odu l a r co mp i l a t i onnul l s t r i n gs 84o p er a t o r s 9 4W RD t y p e t r a n s f e r f u n c t i o n 1 0 4I SG s t a n d a r da s s i gnmen t comp a t i b i l i t g 9 0c h a n g e s f r o m J e n s e n a n d W i r t h f o rF GR l o o p s 97dr a f t u s e d b g <strong>ATARI</strong> 1e x t e n s i on s f o r c o n f or ma n t a r r a y s 1 0 2summar y o f f ea t ur e s 8 1. t gp e compa t i b i l i t y 90LENGTH 4 4L i n e 1 3 5L i n e numb er s 18Li n k er/ D a n d c h a i n i n g 32at t r i b u t e s o f comp a t i b le m od u l e sc ommand f i l e f ac i l i t g s w i t c h / F 2 0d a t a o r i g i n s ~ i t c h / d 19e f f ec t s o f / P a n d / D o n . CON f i l ec o n t e n t s 2 0e f f e c t s o f u s i n g / D o n l o c a l f i l e s 2 0e x t en d i n g ma p s w i t c h / E 19ga i n i n g memory s pace 19i n p u t f i l e n a me s 19i n v o c a t i on 19l i b r a r y s e a r c h s w i t c h / S 19l o a d ma p s w i t c h / L 19p r o g r a m o r i g i n s w i t c h / P 2 0s amp l es amp l e o u t p u t99s a v i n g s p a c e b g u s i n g / D 2 0s w i t c h s umma r g 2 1


s w i t c h e s 19LI NK 4L i.s t i n g 7L Q 40L o ca l f i l e s( s e e F i l e s )MAX*VAILN ENAVAI LN od u l a r comp i l a t i o na nd. 4 E t o g g l e 26an d EXTERNAL 2 6e xamp l e 2 6o v e r v i ew 2 6s y n t a x 2 6HOVE 3 5t1QYELEFT 3 5HOVER IQHT 3 5N OT and 16 b i t v a r i a b l e sODD 7 0 . 1 0 4OPEN 5 3 > 1 3 3 > 1 4 1; . Oper a t o r s- AND 7 0 > 9 4a n d 16 b i t v a r i a b l e s 93NOT 7 0 . 9 4OR 7 0 . 9 4O pt i o n Sw i t c h e sc omp i l er 16li n k er 2 1ORa n d 16 b i t v a r i a b l e s 9 3.ORD 7 0 > 7 1 > 9 0 > 1 0 4O ut pu t0 'or ma t t e d 137PACKED 7 0 > 8 6PASLI 8 9 > 152PASL I B. ERL 4P o i n t e r s 89P or t ab i 1 i t g 14POS 4 7P r i n t era s s i gnmen t 50w r i t i n g e xamp l e 1 4 0w r i t i n g t o 1 4 0P r o g r a m samp l eCHAI N Demo Q 31 5 8


DEMUCUN ( c on f or ma n t a r r a g s > 1 0 2DEMO I NL I NE 6 1Kx ternal Demo (Modul ar comp i la t i on )PR INTER 1 4 0Pr o c e d ur e ACCESS ( s t r i n gs > 73Pr o c ed ur e ADDR DEMO 4 1P r o c e d ur e ASSI GN ( s t r i n g s )7 wP r o c e d ur e COMPARE ( s t r i n g s > 74Pr o c ed ur e CQNCAT DEMO 4 5Pr o c ed ur e COPY DEMO 46Pr o c e d u r e DEL ET E DEMO 48Pr o c ed ur e EXI TTEST 37Pr o c ed ur e F I L ! DEMO 4 3Pr o c ed u r e H I L O SWAP 40Pr o c ed ur e I NSERT DEMO 49Pr o c ed ur e MOVE DEMO 36Pr o c e d ur e POS DEMO 47Pr o c ed ur e SHI F T DEMO 39Pr o c e d ur e S I ZE DEMO 42Pr o c e d ur e TST SET CL R HI TS 38Pr o c ed ur e TEXTI O DEMO 138Pr o c ed ur e WR I TE READ F I L E DEMO 129PVRQEPuT55129R ang e c h e c k i n g(see R un - t i m e )READ 134READLN 139REALHCD 7 1F l oa'ting po1n't 7 1RECORDs t o r a g eRema i n i n g memor y me s sa geR eq u i r emen t sru n - t i mes y s t em34R es e r v e d ~ o r d s 1 17RESET 1 3 3REWRITE 1 3 1Run- t i me Li b r ar gs o u r c eRu n - t i mee r r o r h a n d l i n g 6 8e x c e p t i o n c h e c k i n g 6 8F a t a l e r r o r s 6 9r a n g e c h e c k i n g 6 8S c a l a r ss t o r a g eSET 3 0


SETB IT 38SHL 3 9SHR 3 9SI ZEQF 4 2S p a c e r e d u c t i o na n d l i n ke r / D s w i t c h 20STR I NG 135STR I NC i mp 1 emen t a t i a n d e t a i I s 7 1ST R I NGaccess 7 5a n d READL N 139ass i g nment 7 1c ampa r i s on 74CQNCAT 4 5COPY 46d e f a u l t l e n g t h 87d ef i n i t i a n 71' 86ex p l i c i t 1 eng t h <strong>de</strong>c la r a t i on 8 7nu l l s t r i n g 8 5r u n - t i m e e r r or 68us e as a r r a u s o f c h a r a c t e r s 9 2S t r i n g sDELETE 48INSERT 4 9LENGTHPQS 4 7SWAP 4 0S ymb o l s 83Symbol si d e n t i f i e r s i g n i f i c a n c e 8 4u s e o f 8 i n i d e n t i f i e r s 83u s e o f h e x a d e ci ma l nume r i c l i t e r a l s 8 4us e o f u n d e r s c or e i n i d e n t i f i er s 8 4TEXT f i l esd e f i n i t i o n 1 3 5TSTB I T 38T yp e c h e c k i n g t o g g l e 14T ype conf l i c te r r o r 8 9T gpe sABSOLUTE a t t r i b u t e f o r v a r i a b les 5 9d a t a i m p l eme n t a t i on 7 0e x t e n d e d 8 6f i l e t y p e s 8 9imp l e me n t a t i o n o f P ACKED 8 6p o i n t e r s 89p r e - <strong>de</strong> f i n ed 8 6range a f SET ty pe 8 8re s t r i c t i o n s o n u s e o f ABSQLUTEw i t h s t r i n g s160


U s e rt a b l e s p a c eW i nd o w v a r i a b l e< se e F i l e s )WNH5 lWORD T l i 8 6WRITE } 3 6WR I TEL Na n d t e x t f i l e s


Limited Warranty on Media and Hardware Accessories. Atari, Inc. ("Atari") warrants to the originalconsumer purchaser that the media on which APX Computer Programs are recor<strong>de</strong>d and anyhardware accessories sold by APX shall be free from <strong>de</strong>fects in material or workmanship for aperiod of thirty (30) days from the date of purchase. If you discover such a <strong>de</strong>fect within the 30-dayperiod, call APX for a return authorization number, and then return the product to APX aiong withproof of purchase date. We wiif repair or replace the product at our option. If you ship an APXproduct for in-warranty service, we suggest you package it securely with the probiem indicated inwriting and insure it for value, as Atari assumes no liability for loss or damage incurred duringshipment.This warranty shall not apply if the APX product has been damaged by acci<strong>de</strong>nt, unreasonableuse, use with any non-<strong>ATARI</strong> products, unauthorized service, or by other causes unrelated to<strong>de</strong>fective materials or workmanship.Any applicable impiied warranties, including warranties of merchantability and fitness for aparticular purpose, are also! imited to thirty (30) days from the date of purchase. Consequential orinci<strong>de</strong>ntal damages resulting from a breach of any applicable express or implied warranties arehereby exclu<strong>de</strong>d.The provisions of the foregoing warranty are valid in the U.S. only. This warranty gives youspecific legal rights and you may also have other rights which vary from state to state. Some statesdo not allow limitations on how long an im plied warranty lasts, and/or do not allow the exclusion ofinci<strong>de</strong>ntal or consequential damages, so the above limitations and exclusions may not apply toyou.Disclaimer of Warranty on APX Computer Programs. Most APX Computer Programs have beenwritten by people not employed by Atari. The programs we select for APX offer something of valuethat we want to make avaiiabie to <strong>ATARI</strong> Mome Computer owners, In or<strong>de</strong>r to economically offerthese programs to the wi<strong>de</strong>st number of people, APX Computer Programs are not rigorouslytested by Atari and are sold on an "as is" basis without warranty of any kind. Any statementsconcerning the capabilities or utility of APX Computer Programs are not to be construed asexpress or impiied warranties,Atari shall have no liability or responsibility to the original consumer purchaser or any otherperson or entity with respect to any ciaim, loss, liability, or damage caused or alleged to be causeddirectly or indirectly by APX Computer Programs. This disclaimer inclu<strong>de</strong>s, but is not limited to,any interruption of services, loss of business or anticipatory profits, and/or inci<strong>de</strong>ntal orconsequential damages resulting from the purchase, use, or operation of APX ComputerPrograms.Some states do not allow the limitation or exclusion of implied warranties or of inci<strong>de</strong>ntal orconsequential damages, so the above limitations or exclusions concerning APX ComputerPrograms may not apply to you.For the complete list of currentAPX programs, ask your <strong>ATARI</strong> retailerfor the APX Product Catalog


<strong>ATARI</strong>PROGRAMW EXCHANGEP.O. Box 3705Santo Qae, CA 95055Review FormWe re interested in your experiences with APX programsand documentation, both favorable and unfavorable,Many of our authors are eager to improve their programsif they know what you want. And. of course. we want toknow about any bugs that slipped by us. so that theauthor can fix them. We aiso want to know whether ourinstructions are meeting your needs. You are our bestsource for suggesting improvementsi Please help us bytaking a moment to fill in this review sheet. Fold the sheetin thirds and seal it so that the address on the bottom ofthe back becomes the envelope front. Thank you forhelping us!1. Name and APX number of program,2. If you have probiems using the program, please <strong>de</strong>scribe them here.3, What do you especially like about this program?4. What do you think the program's weaknesses are?5. How can the catalog <strong>de</strong>scription be more accurate or comprehensive' ?6. On a scale of 1 to 10. 1 being "poor" and 10 being "exceHent". please rate the following aspects of this program:Easy to useUser-oriented (e.g., menus. prompts. clear language)EnjoyableSelf-instructiveUseful (non-game programs)Imaginative graphics and souncl


7. Describe any technical errors you found in the user instructions (please give page numbers).8. What did you especially like about the user instructions?9. What revisions or additions would improve these instructions?10. On a scale of 1 to 10, 1 representing "poor" and 10 representing "excellent". how would you rate the userinstructions and why?11. Other comments about the program or user instructions.r omSTAMP<strong>ATARI</strong> Program ExchangeP.O. Box 3705Santa Clara. CA 95055[seai nerei

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!