`L i=L\Ʃx ? N'i  ͭЅ?0ȱ Ѕ?iȱi lԠԠ͠ԠϠŠͮŠ SYSTEM.APPLE   L$J׶'***************************************צ'*OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*'*O###################################O*צ'*O#IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII#O*" LOGO  CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge  TYPESET.CODET UNIVERSAL.TEXT CHASE.TEXTTvg  CHASE.CODE.TEXT" LIST.TEXTEXTvgT LIST.CODEXTTvg۞INTRINSIC.TEXTgUUNITS.DOC.TEXTge TYPESET.TEXTvge UNIVERSAL.TEXT UNIVERSAL.TEXTPSCAL01  TITLE.CODELKvgW $ INTRO.TEXTTEXTgW$6 POLICY.TEXTTEXTW6H BUGS.TEXT.TEXTgTHr DOS3.2A.TEXTXTg*r DOS3.2B.TEXTEXT⠜ DOS3.2C.TEXTXTg  COMBINES.TEXTTg COMBINES.CODEXT&꽌ɪɖ'*&%&,E'зЮ꽌ɪФ`+*xH&x'8*7Ixix&&  ') + &п x) ++`FG8`0($ p,&") (jJJ>L+ "?I>  N `  ` x V Nx .x- z `V0^*^*>` aI꽌ɪVɭ&Y&&Y& 꽌ɪ\8`&'*O#IXvvvvvvvvvvvvvvvvvvvvvvvvvvvvvXI#O*צ'*O#I> APPLE ][ PASCAL DONATED TO THE APPLE COMPUTER NET BY:ALEX M.MASSIMO - Ahe same, except for the  minifloppies used for the Apple, North Star, or TRS-80. So disk software in  source or object form may be freely shared among users of such diverse  machines as a PDP-11 or an 8080.   The Pascal Users Group. %It would sirectly, as their machine language, offering extremely  rapid execution.) In addition, once the P-code interpreter has been  installed, programs written in UCSD Pascal may be run on any microprocessor  without modification. Even the disk formats are t interpretive language available for micros, and has the additional advantage  that P-code occupies approximately one third the space of native machine  language. (Now, however, at least two manufacturers have produced computers  that execute P-code dmulated in software on most  microprocessors. Even though this P-code interpretation system runs three  times slower than assembly language, it is much faster than any other ver, by the time you have  received this disk, several full-standard native-code compilers will have been  released for microprocessors.  %UCSD Pascal compiles its programs to P-code, designed for a hypothetical  16-bit stack machine that must be eto business applications to games, the UCSD system promises  to be the vanguard of an enormous interest in Pascal in the coming decade.  Already a number of other Pascal implementations have appeared for  microprocessors, though none so complete. Howe Introduction. %The UCSD Pascal language system is one of the most sophisticated  microcomputer software systems available today. Because of the ease with  which one can write and maintain high quality programs of most types, from  systems software O^̞F6W BY:ALEX M.MASSIMO - AF6W changes made to the original) and the  other CP/M compatible, so your CP/M-based assemblers and editors can work on  the coage of the interpreter. The modified BIOS accepts  128- byte and 512-byte sectored disks transparently, although you have to  reboot if you change disk density. In addition, the BIOS contains complete  cursor-handling routines for a dumb terminal suc%6. A nifty restructuring of the 8080/Z-80 interpreter and BIOS to  support disks formatted with 512-byte blocks (single or double density), for  a 23% greater disk capacity and a breathtaking increasw in disk access speed,  as well as a slight shrinkd  manuscripts.  %4. An assortment of games, ranging from CHASE to SKYLANES. (As of yet,  no STARTREK.)  %5. Two programs in Pascal to convert UCSD-format disks to the CP/M  format, and vice versa.  hard to modify for other modems. Two  versions of this program have been prepared by different authors.  %3. A file printer offering several options in page headings and page  numbering, as well as single to quad line spacing. Good for programs an80, includes:  %1. The powerful pretty printer and formatting programs, to beautify  Pascal source code, from the Pascal News Vol 13.  %2. A Pascal driver for a D.C. Hayes modem, so your computers can talk  with one another. This should not be  that native code versions are three times larger) and adapted to your system.  We will be happy, though, to accept Pascal software on CP/M disks if it can be  readily adapted to the UCSD system.  %Software already in the hopper as of February 15, 19 from the UCSD  disk format (similar to the PDP-11 RT11 format) to CP/M, all volumes will also  be available on CP/M disks for those using CP/M-compatible Pascal. However,  you will be on your own to get the programs to fit into your memory (remember ng (preventing the program  from crashing if the wrong`types of data are entered), variable declarations,  saving the CRT mask data within the procedure or on the disk as you wished,  etc.  %By the way, since it is relatively trivial to transfer textRT mask directly from the system editor, plus  needed data about the variables to be typed in by the user. The program will  generate Pascal source code for incorporation into your applications programs  and handle automatically things like goof proofilities of transferring programs from one  format to another (e.g., to North Star or Apple disks) or who are willing to  copy the smaller disks for distribution. If we can provide these services,  then other formats could be distributed as well.  %Although programs would be the main emphasis, I hope to have other  features on the disks as well as software. Information on programming tips  would certainly be a useful addition. For example, there are a number of  "hidden gotchas" in the UCSD syional disk to cover air mail) from Jim Gagne, Datamed  Research, 1433 Roscomare Road, Los Angeles CA 90024. Both UCSD Pascal and CP/M-  compatible Pascals are supported, though UCSD programs will require  modification to run under other systems.  %5-re $10  each postpaid (California residents MUST add 6% sales tax; Canadian and  Mexican recipients should add $3 per order for the extra hassle involved;  other out-of-country sales must add $8 for the first disk of an order and  $1.50 per each addit %INTERIM POLICY OF THE UCSD PASCAL USERS' GROUP LIBRARY   Obtaining Library Software.  %Floppy disks full of donated Pascal programs are available from the  Library as follows:  %8-inch, single-sided, single-density UCSD- or CP/M-format disks aO^á 8-inch floppies can be ordered at $10 per volume. Make  sure you specify UCSD or CP/M format. %You can find out more about the present status of the users group by  sending a self-addressed, stamped envelope to the following address: %UCSD Pascal Users Group %DATAMED RESEARCH  1433 Roscomare Road %Los Angeles, CA 90024 %Alternatively, jumping to the upper left of the screen. Is there an easier  way that will always work?  %Finally, we should share algorithms and reviews of commercial Pascal  software.  %  For further information.  screen or  causes a formfeed on the printer. It does nothing in systems that do not  recognize an ASCII formfeed character (12 decimal). One could clear the  screen on ANY UCSD system by jumping to the bottom of the screen, doing 24  WRITELN's, thenstem, as well as features that are inadequately  documented. Also, I don't think it's clear just which programming  techniques are the most portable from system to system. For example,  including a PAGE (OUTPUT) within a program in my system clears my1/4 inch diskettes of UCSD software (2 or 3 are required to hold an 8-  inch volume) are available from Bruce Sherman, SofTech Microsystems, 9494  Black Mountain Road, San Diego CA 92126. Pricing is not yet established, but  will probably exceed $20 per volume due to order processing costs. (We are  looking for volunteers to distribute the various 5-1/4 inch formats so we can  offer them at lower cost.) Software of interest only to users of certain  systems will as a rudergoing development that you eventually  wish to sell, we would be willing to pilot it for you if it is of sufficient  interest to the group at large and works moderately well. I am certain many  members would enjoy writing you with their comments, any from someone else. If you have an especially long program  or one that is for some reason tricky to compile, you may wish to submit  object code as well as source. Certain items may be submitted in object form  only: if you have a quality program un free of bugs, 3) be reasonably clearly written and documented so that it may  be easily modified, 4) come with sufficient instructions so that we can use  it, 5) be capable of being placed in the public domain, and 6) not have been  received previousldevelop the habit of donating particularly useful  tools to the Users' Group, a broad base of software support will quickly  develop which will benefit us all enormously.  %To be accepted, software must: 1) be in source form, 2) be relatively precision integer packages, business math routines, generic input/output  processing, program timers and debuggers, system utilities, and reports of  specific techniques to speed UCSD programs are particularly desired. It is  clear that if we can all are particularly eager  to receive donations of software tools: those procedures and programs you  have developed to make your programming simpler and more productive, and  which may be of broad interest to the Pascal community. Such items as double-  programs obtained from the Users' Group Library will be suitable for your  intended purpose.  %  Submitting Software.  %We are interested in receiving software from anyone who may wish to  contribute. Every type of program is welcomed, and we OT be copied without continuing to carry whatever statements of  authorship it may now contain. Finally, despite hard work to maintain the  highest standards possible, we of course cannot guarantee in any way that be paid to Datamed Research  at the above address, within a month's time of the sale.  %All software is furnished with the understanding that no one may sell it  for profit without the written consent of the author. In addition, the  software MAY Nroup must be reimbursed $2 per disk volume sold. (A  disk volume is the contents of one 8-inch, single-sided, single-density  diskette.) These charges apply no matter how indirectly the seller obtains  Users' Group software. These editing fees should  for nothing. This includes OEM's and retailers. However, if any charge  whatsoever is made to the recipient of the software, then: 1) the maximum  charge is limited to a $5 fee per volume plus the retail cost of each floppy  disk and 2) the Users' Ge disk volume of your choice by donating software to  the group if the software is accepted (see below).  %Any user may copy Users' Group software and give it away to others FREE le because of differences in disk sectoring). In addition, they can  provide Microengine users with software that will enable them to convert UCSD  standard disks on their machines. Contact them directly for more information.  %You can obtain a frele not be distributed to incompatible systems. Contact  Bruce for further information.  %Western Digital has indicated an interest in distributing Users' Group  software on 8-inch disks compatible with the Microengine (these are NOT UCSD  compatibd you should wind up  with a product of much higher quality in a much shorter time than is the rule.  %We are also interested in reports of bugs in the system or user software  (preferably with fixes or kludges to get around them) and documentation of the  more obscure aspects of UCSD Pascal. %  Editors.  %Many people have written to UCSD and SofTech wishing to assist in the  organization of a users group library. We t'^Vpersuasions. So the $1 payment per disk is intended to  reimburse you in part for the very real effort required to create a disk with  truly useful contents.  warning: most of the Pascal disks now floating around have much less work put  into them than we feel is required for them to be generally useful. I, in  particular, am a FANATIC about making our products helpful and/or fun to  programmers of various brary, so we can coordinate our efforts.  (I reserve the right not to send you ALL the Users' Group volumes if this  thing gets too big and you haven't contributed for a while.) A word of as editor of that volume, 2) receive $1 for each disk SOLD  (remember, many will be given to friends), and 3) be placed on the official  UCSD Pascal Users' Group Library Roster of Editors, and receive all past and  future volumes of the Users' Group lirograms if they solve a pressing need. (I would prefer to  put most of the hardware-specific material on a special disk, which users can  ignore if they wish.)  If you submit a disk that is reasonably well put together, you will: 1)  be listed any remaining documentation required for use. Note that we are specifically  committed to full and complete documentation ON THE DISK whenever possible.  Programs should be of general interest, although it is all right to include  hardware-specific phecked out the programs and organized them in some way. You  should have a catalog of the files on the disk, and a separate file  containing: 1) descriptions of each program, 2) what you think of it, and 3) l of  software may submit it to the Users' Group (send them to Datamed Research; 8-  inch diskettes preferred). Fundamentally, the requirements for the acceptance  for the software are those stated previously; in addition, the disk editor  must have chink this is grand. Because it  makes little sense for the collection and distribution of programs to be  scattered all around the country, we plan to set up the following structure  for now and see how it works: Anyone who wishes to collect a disk ful % %This is a list of known PASCAL  problems. Updates and fixes will be  announced.(from application notes of  INTERNATIONAL APPLE CORE MARCH 10  1980).Entered to file by Roger L.  Pennell of the San Diego Apple Core.  %1.The integer vahen the file is  completely full.  %33.the compiler INCLUDE  directive dose not always work as  expected.  %34.Use of the compiler swapping  option causes global declarations to  be ignored.  %35.The manual dose not clearly  state the stin Applestuff, but is not documented.  %31.Overflowing the code file  causes the system to crash in various  ways.  %32.The Editor informs the user  when it is about to run out of space  for the file buffer, but strange  things may happen w%27.documentation for the SCAN  function is incomplete.  %28.The example of MOVERIGHT is  incorrect.  %29.The editor dose not report  assembler errors in the same way that  it reports compiler errors.  %30.The function KEYPRESS exists  se  items to be empty.  %26.Due to the normal inaccuracies  in representing REAL's some equalities  may not test true. For example,  LOG(10) prints as 1.00000 but dose not  yield equality in the comparision  LOG(10)=1.00000.  tions cannot return  STRING values, although this is  implied in the Apple PASCAL Reference  Manual.  %25. Standard PASCAL syntex allows  the field list and in a  RECORD declaration to be null. The  UCSD compiler dose not allow theion accepts REAL  and pointer arguments even though this  is incorrect.  %22.Negation of BOOLEAN variables  do not turn FALSE to TRUE and vice  versa.  %23.The compiler allows  underscores in an identifier, but  ignors them.  %24. Func incorrectly at run-time.  %20.There is no way to tell the  compiler to allocate all available  disk space for the code file, so the  compiler may run out of room for the  code file even if sufficent space is  available.  %21.The ORD funct11.  %17.A run-time stack overflow  crashes the system insted of re-  initializing.  %18.The MEMAVAIL function may  return incorrect results in some  cases.  %19.The .PUBLIC and .PRIVATE  assembler variables may be relocated vice versa.  %14.Intrinsic units cannot contain  references to files.  %15. Long integer constants are  not implemented.  %16 the IN function for set  inclusion dose not always work when  the first argument is negative or  greater than 5r to go  out of control, requiring the user to  delete text in orded to recover.  %12.When compiling using the  (*$L+*) option, the compiler may  damage the contents of the diskette.  %13.Intrinsic units cannot use non-  intrinsic units,and  not included in the APPLE3:CALC  program.  %9.The compiler will allow more  than 9 segment procedures but only 9  will function properly.  %10.Separate units do not work.  %11.Erroneous placment of control  characters may cause the editond Wirth, page  157.  %6.The Editor sometimes ends a  file with 00 insted of the required  0D00. This results in trash on the  screen.  %7. TTLOUT in Applestuff dose NOT  work.  %8.Transcendental functions are legal according to Jensen &  Wirth, page 147.  %4.The BREAK key (ctrl-shift-P)  dose not cause a break during the  execution of some programs.  %5.A variable of type TEXT can be  passed as a VAR parameter. This is ok  according to Jensen alue -32768 prints  as "--2768 and causes a compile error  in the expression I:=-32768 where  I:integer.  %2. A long integer compare causes  the system to crash.  %3. The compiler dose not allow  R:Real; I,J:integer; R:=I/J;which  should bering argument of the  .TITLE pseudo-option must be enclosed  in double quotation marks.  %36.Not all optiona of the Editor  are listed on the prompt line,and the  "?" option to get a list of the  additional options is not supported.  %37.The reference manual dose not  adequately describe how to set up a  program to be executed automatically,  using SYSTEM.STARTUP.  %38.The Editor accepts files with  names of the form .TEXT.  %39.the Editor is insensetive to  certLE3:LINEFEED should be made  available.  %end of bugs for this list!! %59.The code to clear SYSCOM is  incorrect in the procedure BOOT.  %60.The figures given for the  maximum integer value for each  declared length of long intrger are  incorrect in the Apple PASCAL Manual,  page 198.  %61.Source code for  APPontaining the  file to be copied.  %57.The interperter code for  floating point comparisons returns  0.0> (-0.0).  %58.DIV and MOD functions give  incorrect results for certain  combinations of signs for the  arguments.  ler QUIT option (Q+)  does not turn off all output to the  console.  %56.The system will cresh if the  system disk containing the Editor is  not on line when returning from a Copy  File command when the system disk was  replaced for a disk cf the actual  parameter without detection any error  conditions.  %54.Using an unintialized long  integer may cause unpredictable  problems because there may be illegal  bit patterns that are not  representations of digits.  %55.The compi the declared length of STRING  parameters passed by reference.  Therefor, if the declared length of  the actual parameter is less than that  of the formal parameter,assignment of  characters into the formal can clobber  space beyond the end ors  while in graphics mode, the screen  does not switch back to text mode to  desplay the error.  %52.The cross reference program on  APPLE3 dose not close and lock the  output file.  %53.The Compiler does not check out  the differences between the built-in  variable KEYBOARD and the volume  identifier SYSTERM:.  %50 The fact that the Editor  requires text files to have an even  number of 512-byte blocks is not  documented.  %51.If a run-time error occu PROM  appears to be incompatible with BIOS.  th P1-02 PROM is required.  %48.The listing file produced by  the Assembler does not follow the  standard for text files as described  in the Apple PASCAL Manual.  %49.There is some confusion ab that it is already there.  %45.The ATAN function gives an  erroneous result for an argument less  than -1.00.  %46.BIOS does not turn off the  high-order bit of characters handled  by the remote I/O routines.  %47.The P1 parallel printerh a data  segment, the compiler failes to  generate code to unload the data  segment at the end of execution. Thus,  if the program is run again, the data  segment will not be loaded since the  interperter segment table will show mpiler may generate an  error #407 (too many libraries).  %43.The compiler generates code to  always load segments 28-31 if they are  present. This may cause undesired  loading.  %44.When the NOLOAD option is used  for an intrinsic unit witain punctuation conventions during  paragraph reformatting.  %40.The Assembler should translate  all alphabetics to upper-case.  %41.The documentation is  inadequate in the description of  assembly language and various options.  %42.The co LOCATIONS FROM 08FF ON DOWN. A VALUE IS STORED IN A LOCATION ONLY IF THE LOW ORDER BYTE OF THE ADDRESS OF THE LOCATION DOES NOT CONTAIN 2 ADJACENT ZERO BITS. ALSO, AN EXCEPTION IS MADE FOR ADDRESS 08D5, WHICH IS NOT STORED THE SECTION OF CODE FROM C600 TO C61C SETS UP THE AREA IN MEMORY 08AB-08FF. WHAT SEEMS TO BE HAPPENING HERE IS THAT THE 32 VALUES 1F,1E,1D,...,01,00 ARE STORED IN DECREASING (BUT NOT NECES- SARILY CONTIGUOUS) MEMORY THE 256 BYTES OF ROM ON THE DISK II CONTROLLER WHICH IS AVAILABLE TO THE APPLE STARTS AT $C600. THIS ADDRESS IS BRANCHED TO WHENEVER PR#6 IS ISSUED IN BASIC OR 6(CNTL-K) OR 6(CNTL-P) IS DONE IN THE MONITOR. SECTION H: APPLE DOS BOOTING PROCESS BY TED BURNS -----SECTION A --- DISK CONTROLLER ROM----- SECTION D: DISK II DEVICE SELECT ADDRS. SECTION E: DOS 3.2 ERRATA SECTION F: MISC. NOTES & OTHER GOODIES SECTION G: SECTOR SKEW FACTOR PART THREE THE FOLLOWING SECTIONS: PART ONE SECTION A: DISK CONTROLLER CARD ROM SECTION B: MEMORY MAP OF DOS PART TWO SECTION C: DOS MEMORY/DISK CROSS-REF. CONTROLLER CARD ROM START AT LOCATION 'CX00', WHERE 'X' IS THE SLOT NUMBER. THE ADDRESS FOR THE DISK CONTROLLER DEVICE SELECT STARTS AT LOCATION C080+X0, WHERE 'X' IS THE SLOT NUMBER. THIS REPORT IS COMPOSED OF THIS, THE RAM ADDRESSES USED BY DOS ARE $4000 (HEX 4000) LESS THAN THOSE GIVEN FOR A 32K MACHINE AND $8000 LESS FOR A 16K MACHINE. THE ADDRESSES FOR THE DISK ] NOTE: ADDRESSES GIVEN ARE FOR APPLE II DOS ON 48K SYSTEM WITH DISK II CONTROLLER IN SLOT 6, AND LANGUAGE CARD MOD NOT INSTALLED ON DISK CONTROLLER. FOR APPLE II CONFIGURATIONS WHICH ARE DIFFERENT THANoriginally appeared on the Illini Microcomputer Abbs, Naperville, Illinois. Downloaded and edited by Bill Blue. Part three by Ted Burns, from The Apple Orchard, March/April 1980 issue.DOS1 Format for printer (Y/N) ?Y APPLE II DOS INTERNALS ----- -- --- --------- BY MARK PUMP [Parts one and two EVEN THOUGH 'D5' (BINARY 11010101) DOES NOT CONTAIN 2 ADJACENT ZERO BITS. 'D5' IS USED AS THE START OF AN ADDRESS MARKER BEFORE EACH SECTOR ON THE DISK. THE SECTION OF CODE FROM C61E TO C62F CALLS A DUMMY SUBROUTINE IN THE MONITOR TO STORE THE CURRENT ADDRESS IN THE STACK. THEN THE HIGH ORDER BYTE OF THE ADDRESS IS SHIFTED 4 BITS TO OBTAIN THE SLOT USED. EACH BUFFER OCCUPIES 595 ($253) BYTES AND CONSISTS OF 3 SECTIONS. SECTION 1 RESIDES AT 00-FF WITHIN THE BUFFER AND IS THE CONTENTS OF THE CURRENT DATA SECTOR. SECTION 2 RESIDES AT 100- 1FF WITHIN THE BUFFER AND CONTAINS THE# 3 9853-9AA5: USER FILE BUFFER # 2 9AA6-9CF8: USER FILE BUFFER # 1 THE HIGHEST NUMBERED BUFFER IS USED FIRST BY DOS. NOTE THAT IF MAXFILES IS GREATER THAN 3, MEMORY LOCATIONS BELOW 9600 WILL BE BA90-BCFF: DATA AREA: FUNCTION UNKNOWN BD00-BFFF: MAINLINE RWTS CODE 9600-9CFF ARE USED FOR USER FILE BUFFERS (NORMALLY 3), AND ARE ALLOCATED AS FOLLOWS: 9600-9852: USER FILE BUFFER UDING SYSTEM BUFFER B700-B7DE: CODE INCLUDING RWTS ENTRY B7DF-B7FF: DATA AREA INCLUDING IOB, DCT B800-BA8F: CODE 9600-9CFF: USER FILE BUFFERS 9D00-9D83: DOS ADDRESS CONSTANTS 9D84-A883: SYSTEM CODE SECTION A884-AAFC: DATA AREA FOR SYSTEM SECTION AAFD-B396: I/O PACKAGE B397-B6FF: DATA AREA INCLUTINES CURRENTLY IN USE, AND RECONNECT DOS I/O. THE DOS MAINLINE AT 9600-BFFF IS COMPOSED OF SEVERAL SECTIONS. THESE SECTIONS ARE LISTED BELOW AND DESCRIBED SEPARATELY IN DETAIL. 03DC - LOAD Y,A WITH ADDRESS OF THE END OF THE SYSTEM BUFFER. 03E3 - LOAD Y,A WITH ADDRESS OF THE DOS IOB. 03EA - CAUSE DOS TO SAVE THE ADDRESSES OF THE CHARACTER INPUT AND OUTPUT ROGRAM. 03D3 - RESTART DOS, KILLING CURRENT BASIC PROGRAM. 03D6 - ENTER DOS I/O PACKAGE. 03D9 - ENTER RWTS SUBROUTINE. 9600- BFFF ON A 48K APPLE. (SEE SECTION 3) IN ADDITION TO THE MAIN DOS CODE AT 9600-BFFF, THERE ARE 7 DOS ROUTINES THAT HAVE ENTRY POINTS IN PAGE 3. THEY ARE: 03D0 - RESTART DOS, SAVING CURRENT BASIC PROEAD OF DRIVE 1. -----SECTION B --- MEMORY MAP OF DOS----- AT BOOT, DOS IS LOADED TO ADDRESSES 3600-3FFF, FOLLOWED BY ADDRESSES 1D00-35FF. IT THEN RELOCATES ITSELF TO RESIDE AT MESSAGE. HERE IS A METHOD TO BOOT FROM DRIVE 2 IF YOU EVER NEED TO. IN THE MONITOR, *1600 200 DO RNUM:=RNUM-200;  CLEARSCREEN; "WRITELN(' HOW GOOD A PLAYER ARE $WRITELN('THERE ARE 3 ROBOTS TO START FOR A BEGINNER.'); $WRITELN('THE NUMBER WILL INCREASE AS YOU WIN GAMES !'); $WRITELN; $WRITELN(' GOOD LUCK!!!!!') "END;  END; {END OF INSTRUCTIONS}    PROCEDDESTROY THE COMPUTERS.'); $WRITELN('THIS IS DONE BY RUNNING THEM INTO FENCE POSTS,"*",'); $WRITELN('OR BY RUNNING THEM INTO EACH OTHER.'); $WRITELN('THE DIAGRAM BELOW THE MAZE SHOWS HOW YOU CAN MOVE'); $WRITELN('THE ROBOTS WILL TRY TO FOLLOW YOU.'); OR N) '); "READ(M); "IF M='Y' THEN "BEGIN $WRITELN;WRITELN; $WRITELN(' HERE ARE SOME INSTRUCTIONS'); " WRITELN('YOU,"O",ARE IN A HIGH VOLTAGE MAZE.'); " WRITELN('THE ROBOT COMPUTERS,"R",ARE TRYING TO DESTROY YOU.'); $WRITELN('TO WIN, YOU MUST )  END;    PROCEDURE INSTRUCTIONS; {DISPLAY INSTRUCTIONS}  VAR M:CHAR;  BEGIN "CLEARSCREEN; "WRITELN('WELCOME TO THE WONDERFUL EXCITING ');WRITE(' GAME OF CHASE'); "GOTOXY(0,4); "WRITE('WOULD YOU LIKE INSTRUCTIONS ? (Y  GOTOXY(COL,ROW); {POSITION CURSOR}  WRITE(SYMBOL)  END; {END OF DOMOVE PROCEDURE}    PROCEDURE CLEARSCREEN; {FOR AN ADM3-A CHANGE IT FOR OTHER TERMINAL}  BEGIN "WRITE(CHR(CLRSCRN),CHR(0),CHR(0),CHR(0),CHR(0),CHR(0) :INTEGER;  BEGIN "REPEAT $RNUM:=RNUM*21.182813+31.415917; $RNUM:=RNUM-TRUNC(RNUM); $I:=TRUNC(RNUM*HI); "UNTIL I>LO; "RND:=I;  END; $    PROCEDURE DOMOVE(COL,ROW:INTEGER;SYMBOL:CHAR); {DISPLAY SYMBOL AT I,J ON FIELD}  BEGIN D CHARACTERS}  MOVES : INTEGER; {COUNT OF MOVES} (CRASH : INTEGER; {NO OF ROBOTS "CRASHED"}   FUNCTION RND(LO,HI:INTEGER):INTEGER; {RANDOM NUMBER GENERATOR}  VAR Q :REAL;  I ICULTY} (GAMENU : INTEGER; {GAME NUMBER} (M : CHAR; (NROB : INTEGER; {NUMBER OF ROBOTS} (WINS : INTEGER; {NUMBER OF GAMES WON}  GOODCHAR : SET OF CHAR; {GOO(R : INTEGER; {NUMBER OF ROBOTS LEFT} (RI,RJ : ARRAY[1..ROBMAX] OF INTEGER; {ROBOT COORDINATES} (RNUM : REAL; (DIFF : INTEGER; {DIFFICULTY} (IDIFF : 0..10; {INITIAL DIFF {CLEAR SCREEN CODE}    VAR FIELD : PACKED ARRAY[0..XMAX,0..YMAX] OF CHAR; (AGAIN,PLAY : BOOLEAN; (WIN : BOOLEAN; (MI,MJ : INTEGER; {COORDINATES OF THE MAN} AX HORIZONTAL FIELD DIMENSION} (YMAX = 14; {MAX VERTICAL FIELD DIMENSION} ( (TOP = 2; {SPACE ABOVE FIELD} (SIDE = 5; {SPACE TO LEFT OF FIELD} ( (CLRSCRN = 12; {SYMBOL FOR A ROBOT} (BLANK = ' '; {AN ASCII BLANK} ' (DROB = 3; {STARTING NO OF ROBOTS} (ROBMAX = 20; {MAX NO OF ROBOTS ALLOWED} (XMAX = 39; {MELN;  WHILE NOT (SK IN ['B','I','E','P']) DO "BEGIN $GOTOXY(10,10); $WRITE(' WHAT WAS THAT AGAIN PLEASE ? ',CHR(7)); $READ (SK); $WRITELN "END;  CASE SK OF $'B': IDIFF:=0; $'I': IDIFF:=1; $'E': IDIFF:=3; $'P': IDIFF:=5; "END;  END;    PROCEDURE INITIALIZE; {SET UP BLANK FIELD SURROUNDED BY FENCE}  VAR I,J:INTEGER;  BEGIN "FOR I:=0 TO XMAX DO "BEGIN $FOR J:=0 TO YMAX DO $IF((I=0) OR (I=XMAX) OR (J=0) OR (J=YMAX)) THEN FIELD[I,J]:=EDGE &ELSE FIELD[I,J]:=BLANK #END;  ENDGE NO OF ROBOTS} *WRITE(R:8); *RI[L]:=0; *IF R=0 THEN *BEGIN ,GOTOXY(XMAX+16,CRASH+3); ,WRITELN('GOOD WORK!'); ,GOTOXY(XMAX+8,CRASH+4); ,WRITELN('YOU HAVE DESTROYED THEM ALL!!'); ,WIN:=TRUE; ,PLAY:=FALSE *END; (END; &END; &IF FIELD[RI[L],RJ[LFIELD[RI[L],RJ[L]]:=ROBOT; & DOMOVE(I,J,ROBOT) &END &ELSE &BEGIN (IF ((FIELD[I,J]=OBST) OR (FIELD[I,J]=ROBOT)) THEN (BEGIN *GOTOXY(XMAX+12,CRASH+3); *CRASH:=CRASH+1; *WRITELN('CRASH!! YOU GOT ONE!!'); *R:=R-1; *GOTOXY(53,1); {CHAN&FIELD[RI[L],RJ[L]]:=BLANK; &DOMOVE(RI[L],RJ[L],BLANK); &IF MI>RI[L] THEN RI[L]:=RI[L]+1; &IF MIRJ[L] THEN RJ[L]:=RJ[L]+1; &IF MJ0) AND (WIN)) THEN $BEGIN = EDGE THEN $BEGIN &WIN:=FALSE; &PLAY:=FALSE; &WRITELN('OUCH, YOU GOT ELECTROCUTED!') $END ELSE $BEGIN &IF FIELD[MI,MJ] = ROBOT THEN &WRITELN('THWACK! YOU RAN INTO A ROBOT (TURKEY!)') ELSE &WRITELN('ZZAP! YOU RAN INTO AN ELECTIFIED POST'); &WIN:1; "5: ; "6: MI:=MI+1; "7: BEGIN MI:=MI-1; MJ:=MJ+1 END; "8: MJ:=MJ+1; "9: BEGIN MI:=MI+1; MJ:=MJ+1 END %END; "MOVES:=MOVES+1; "IF FIELD[MI,MJ] = BLANK THEN " BEGIN &DOMOVE(MI,MJ,MAN); &FIELD[MI,MJ]:=MAN " END ELSE "BEGIN $IF FIELD[MI,MJ] $ GOTOXY(10,22); $END; "IF C='Q' THEN $BEGIN %PLAY:=FALSE; %WIN:=FALSE $END; "M:=ORD(C)-48; "FIELD[MI,MJ]:=BLANK; "DOMOVE(MI,MJ,BLANK); &CASE M OF "1: BEGIN MI:=MI-1; MJ:=MJ-1 END; "2: MJ:=MJ-1; "3: BEGIN MI:=MI+1; MJ:=MJ-1 END; "4: MI:=MI-$WRITE(' ',CHR(8)); $READ (C); $IF NOT (C IN GOODCHAR) THEN $BEGIN &GOTOXY(4,21); &BAD:=TRUE; &WRITE('BAD MOVE, PLEASE TRY AGAIN ':33,CHR(7)) $END; "UNTIL (C IN GOODCHAR); "IF BAD THEN $BEGIN $ GOTOXY(4,21); &WRITE(' ':40); MOVE => ');  END; {END OF MAP}   PROCEDURE MOVE; {ENTER YOUR MOVE FROM KEYBOARD}  VAR M : INTEGER;  C : CHAR;  BAD : BOOLEAN;  BEGIN "BAD:=FALSE; "REPEAT GAMENU:3,DIFF:5,R:8,WINS:10,MOVES:8); "GOTOXY(0,0); "FOR J:=0 TO YMAX DO "BEGIN $FOR I:=0 TO XMAX DO WRITE(FIELD[I,J]); " WRITELN "END; "WRITELN; "WRITELN('1 2 3 Q = QUIT'); "WRITELN('4 X 6 5 = NO MOVE'); "WRITE('7 8 9  END; {END OF INNERFIELD}    PROCEDURE MAP; {DISPLAY PLAYING FIELD}  VAR I,J:INTEGER;  BEGIN "CLEARSCREEN; "WRITELN('GAME DIFF ROBOTS WINS MOVE':79); "WRITE(' ':44,:=1 TO POSTS DO "BEGIN $REPEAT &IF DIFF>3 THEN &BEGIN (I:=RND(0,XMAX); (J:=RND(0,YMAX) $ END ELSE &BEGIN (I:=RND(1,XMAX-1); (J:=RND(1,YMAX-1) &END; $UNTIL FIELD[I,J]=BLANK; $FIELD[I,J]:=OBST $END; {NOW DO R ROBOTS}  BEGIN $REPEAT &I:=RND(0,XMAX);J:=RND(0,YMAX); $UNTIL FIELD[I,J]=BLANK; $FIELD[I,J]:=ROBOT; " RI[L]:=I; $RJ[L]:=J "END;  POSTS:=RND(25,35); {NOW SET UP 25 TO 35 POSTS} "FOR L; {END OF INITIALIZE}    PROCEDURE INNERFIELD; {SET UP MAN, ROBOTS AND OBSTRUCTIONS}  VAR I,J,L,POSTS:INTEGER;  BEGIN "MI:=RND(0,XMAX); MJ:=RND(0,YMAX); {LOCATE MAN AT ANY RANDOM POSITION} "FIELD[MI,MJ]:=MAN; "R:=NROB; "FOR L:=1 TO R DO ]]=FIELD[MI,MJ] THEN &BEGIN (WRITELN('ZAP! A COMPUTER GOT YOU!'); (WIN:=FALSE; (PLAY:=FALSE &END; " END;  END;  END; {END OF ROBOTMOVE PROCEDURE}     BEGIN {START OF MAIN PROGRAM} "GOODCHAR:=['1'..'9','Q']; "GAMENU:=1; "WINS:=0; "AGAIN:=TRUE; "PLAY:=TRUE; {INITIALIZE QUIT} "INSTRUCTIONS; {DISPLAY INSTRUCTIONS} "STARTGAME; {INPUT STARTING POSITION AND SKILL LEVEL} "DIFF:=IDIFF; {INITIAL DIFFICULTY LEVEL} "NROB:"ENTER A NUMBER FOLLOWED BY RETURN qq qLEAqqq! HOW GOOD A PLAYER ARE YOU ?צ BEGINNER - Bצ "THE ROBOTS WILL TRY TO FOLLOW YOU.+THERE ARE 3 ROBOTS TO START FOR A BEGINNER.צ+THE NUMBER WILL INCREASE AS YOU WIN GAMES ! GOOD LUCK!!!!!Jצ'TO WIN, YOU MUST DESTROY THE COMPUTERS.2THIS IS DONE BY RUNNING THEM INTO FENCE POSTS,"*",#OR BY RUNNING THEM INTO EACH OTHER.צ1THE DIAGRAM BELOW THE MAZE SHOWS HOW YOU CAN MOVE'WOULD YOU LIKE INSTRUCTIONS ? (Y OR N) Yá HERE ARE SOME INSTRUCTIONS#YOU,"O",ARE IN A HIGH VOLTAGE MAZE.צ2THE ROBOT COMPUTERS,"R",ARE TRYING TO DESTROY YOU.qqAfvFASqqqqڊšBJF D"WELCOME TO THE WONDERFUL EXCITING  GAME OF CHASE"*> CHASE (IF WINS>15 THEN DIFF:=IDIFF+6; (IF WINS>20 THEN DIFF:=IDIFF+8; (IF WINS>30 THEN DIFF:=IDIFF+12; (NROB:=DROB+2*DIFF &END; $END; "END;  END.  HEN AGAIN:=FALSE ELSE $BEGIN &PLAY:=TRUE; &GAMENU:=GAMENU+1; &IF WIN THEN &BEGIN (WINS:=WINS+1; (IF WINS>2 THEN DIFF:=IDIFF+1; (IF WINS>5 THEN DIFF:=IDIFF+2; $ IF WINS>8 THEN DIFF:=IDIFF+3; (IF WINS>11 THEN DIFF:=IDIFF+4; RITELN(MOVES:8); (DOMOVE(30,18,BLANK) {INPUT NEXT MOVE} &END; &MOVE; {LETS YOU MOVE} &IF(PLAY) THEN ROBOTMOVE {MOVES THE ROBOTS} $END; $GOTOXY(0,21); $WRITE('WOULD YOU LIKE TO PLAY AGAIN (Y OR N) '); " READ(M); $IF M='N' T=DROB+DIFF*2; {INITIAL NUMBER OF ROBOTS} "WHILE AGAIN DO "BEGIN $MOVES:=1;WIN:=TRUE;CRASH:=0; $INITIALIZE; {CLEARS FIELD[X,Y]} $INNERFIELD; {SETS UP PLAYING FIELD} $WHILE PLAY DO $BEGIN &IF MOVES=1 THEN MAP ELSE &BEGIN (GOTOXY(70,1); (W INTERMEDIATE - Iצ EXPERT - Eצ OLD PRO - Pצ! TYPE IN YOUR SKILL سS$P ! WHAT WAS THAT AGAIN PLEASE ? ع$ tA t8 t/ t&BP, 1-  'ȡHȡ6'ÍÍÍ'I' PG `'GFO^i   C &WOULD YOU LIKE TO PLAY AGAIN (Y OR N) vvNáDCuuE{xxxštsxštsxštsx štsxštsxštsxšt sswr =,vBF 4  Fá4ZAP! A COMPUTER GOT YOU!ECT{}  yuxDCtsswDEC4á F   C &WOULD YOU LIKE TO PLAY AGAIN (Y OR N) vvNáDCuuE{xxxštsxštsxštsx štsxštsxštsxšt ssEC]'IG'Fá4ZAP! A COMPUTER GOT YOU!ECT{}  yuxDCtsswDEC4á F'IRR'*å'RÍ' CRASH!! YOU GOT ONE!!HH5H ]Hám'צ GOOD WORK!'YOU HAVE DESTROYED THEM ALL!!I G]š]]G]ɡ]]FIšIIFIɡII]I' á+]G'FRá<צ&THWACK! YOU RAN INTO A ROBOT (TURKEY!)9צ%ZZAP! YOU RAN INTO AN ELECTIFIED POSTEC_ j wȡ]˩E]'I ]GFFzFFpGGFF^GGTRGGHGGFF6FF,GGFF9 zjbRJJB2*G'F áGFOG'FOG'FIá9ECצOUCH, YOU GOT ELECTROCUTED!צ7 8 9 MOVE =>  V  ٥y9BAD MOVE, PLEASE TRY AGAIN !٥yڡ ( QáCE0G'F GF عrGROBOTS WINS MOVEO ,u s H x  ȡ7'ȡ'1 2 3 Q = QUITצ4 X 6 5 = NO MOVEG'FOwHHȡP'' á'R]ۚIښ#ȡSsš''' á'*[X #GAME DIFF PROGRAM LISTFILE;   CONST linesperpage = 60;  pagewidth = 80; (* columns per line *) &quarterwidth = 20;   VAR printhead, printfname: boolean; %i, pageno, startpage, endpage, LFname, Lmsg: integer; %ioerror: 0..12; %lineno: 0..70; %, ' ':i, 'Page ', pageno); "Writeln (list); "Writeln (list); "Writeln (list);  Lineno := 4  END; "  PROCEDURE PRINTPAGE;   BEGIN "WHILE (NOT EOF(f)) AND (lineno <= linesperpage) $DO BEGIN &READLN (f,s); &WRITE (list,s); &FOR i := 1 TO Spac, CHR (14) (*char to expand title*), filename, ' ':spaceL); "i := SpaceR; (* move 'page' to right if pageno less than 3 digits *) "IF pageno < 10 THEN i :=3i + 1; "IF pageno < 100 THEN i := i + 1; "IF printfname OR (pageno > 1) $THEN WRITE (list, msg(message centered, and the page number flush right, all double width. (2. Otherwise any message is flush left and the pageno flush right, (standard width char. In addition, the page 1 heading is skipped.*)   BEGIN "IF printfname $THEN WRITE (list-> '); (READ (endpage); WRIToLN &END  END (*initialize*);   PROCEDURE HEADING;  (* This procedure prints the following: (1. If printfilename flag is on, then the filename is flush left, the E ('Do you want to print the whole file? '); "READ (ch); WRITELN; "IF (ch in ['Y', 'y']) $THEN &BEGIN (Startpage := 0; (Endpage := MAXINT &END $ELSE &BEGIN (WRITE ('Start with page no. --> '); (READ (startpage); (WRITE ('End after page no. -aceL + Lmsg + 7) *END (ELSE (* no, skip filename and don't expand heading. *) *BEGIN ,Printfname := FALSE; ,SpaceL := 0; ,SpaceR := pagewidth - (Lmsg + 7) *END; &IF spaceR < 1 THEN spaceR := 1 $END $ELSE printhead := FALSE; "Pageno := 1; "WRIT (* Don't forget to change SpaceL and SpaceR here if you're not going to expand !your page heading to double width. *) ,SpaceL := (pagewidth DIV 4) - (LFname + (Lmsg DIV 2)); ,IF spaceL < 1 THEN spaceL := 1; ,SpaceR := (pagewidth DIV 2) - (LFname + Spu want to include the filename in the heading? '); &READ (ch); WRITELN; &IF (ch IN ['Y', 'y']) (THEN (* yes, print it and expand heading as well. *) *BEGIN ,Printfname := TRUE; ; "READ (ch); WRITELN; "Msg := ''; (* empty string *); "IF (ch in ['Y', 'y']) $THEN BEGIN &printhead := TRUE; &WRITELN ('If you wish a date or other heading or title,', .' type it here: '); &READLN (msg); &Lmsg := LENGTH (msg); &WRITE ('Do yoiteln; "IF (ch IN ['Y', 'y']) $THEN Spacing := 1 $ELSE BEGIN &REPEAT (Write ('How many spaces per line (1 - 4)? '); (Read (ch); (Writeln &UNTIL (ch IN ['1'..'4']); &Spacing := ORD (ch) - ORD ('0') $END; "WRITE ('Do you wish a page heading? ')&ELSE BEGIN (Writeln ('Oops, there''s a problem. IORESULT = ', ioerror, '.'); (Writeln ('Try again. To quit just type '); (Writeln &END "UNTIL Successful; "REWRITE (list, 'PRINTER:'); "Write ('Single-space each line? '); "Read (ch); Wr ('Please type name of file to be listed --> '); $READLN (filename); $LFname := LENGTH (filename); $IF LFname = 0 THEN EXIT (Program); $(*$I-*) $RESET (f, filename); $(*$I+*) $ioerror := IORESULT; $IF ioerror = 0 &THEN successful := true name: string [25]; %msg: string; %f, list: text; %  PROCEDURE INITIALIZE;  VAR ch: char;  successful: boolean;   BEGIN "Formfeed := CHR (12); (* this is what my printer wants to start new page *) "Successful := false; "REPEAT $Writespacing: 1..4; %spaceL, spaceR: -15..pagewidth; %formfeed: char;  (* if your system needs nulls or other char to move your printer to the top of  the next page, make formfeed an array and fill it with whatever you need. *) %s: string [135]; %fileing DO (BEGIN *Writeln (list); *Lineno := SUCC (lineno) (END $END; "WRITE (list, formfeed); "Pageno := SUCC (pageno)  END;   PROCEDURE DUMMYPAGE;   BEGIN "IF printhead THEN lineno := 4 ELSE lineno := 1; "WHILE (NOT EOF (f)) AND (lineno <= linesperpage) $DO BEGIN &READLN (f,s); &FOR i := 1 TO Spacing DO Lineno := SUCC (lineno) $END; "Pageno := SUCC (pageno)  END;    {Main program]}   BEGIN  "Initialize; "WHILE (startpage > pageno) ANN^UuLJ ȡF   d1 nF F <Ȅ1LJ ȡF   G bť ĥ F /DjpL @?PU  ɡ dɡ ō0b צPage  F  <ȄDLJ ȡF   d1 nF F <Ȅ1LJ ȡF   G bť ĥ צEnd after page no. -->  @?PU  ɡ dɡ ō0b צPage  F  <ȄD7PPɡ PPPPPPɡ P &Do you want to print the whole file? س eStart with page no. --> bתPس צ-If you wish a date or other heading or title, type it here: bPbצ5Do you want to include the filename in the heading? سW١PRINTER:צSingle-space each line? س; X#How many spaces per line (1 - 4)? س0 Do you wish a page heading?  +Please type name of file to be listed --> UUáU" á%Oops, there's a problem. IORESULT =  .צ&Try again. To quit just type "@ LISTFILE D (NOT EOF(f)) DO Dummypage; "WHILE (endpage >= pageno) AND (NOT EOF(f)) DO $BEGIN &Lineno := 1; &IF printhead THEN Heading; &Printpage $END  END. % 0SOME DOCUMENTATION ABOUT UCSD SEGMENTS AND UNITS %Since the release of version 1.5 in early 1979, UCSD Pascal has supported  several very useful extensions to Standard Pascal (a la Jensen and Wirth) that  assist modular compilation and/or execuO^àITELN('1ST COPY:',SCRATCH); "SCRATCH:=COPY(DEST,NE,LENGTH(DEST)-NE+1); "WRITELN('2ND COPY:',SCRATCH)  END. "WRITELN('AFTER INSERT:',DEST); " "(* CONCATENATE NEW STRING TO END OF DEST *) "SRC:='I WILL DENY IT'; "DEST:=CONCAT(DEST,SRC); "WRITELN('AFTER CONCAT:',DEST); " "(* NOW MAKE COPIES OF BEGINNING AND END OF DEST *) "SCRATCH:=COPY(DEST,1,NE-1); "WR FOR LATTER USE *) "WRITELN('LENGTH OF PATTERN IS:',LP); "WRITELN('BEFOR DELETE:',DEST); " "(* DELETE PATTERN BEFOR INSERTING SUBSTITUTING *) "DELETE(DEST,NB,LP); "WRITELN('AFTER DELETE:',DEST);  INSERT('HEARD',DEST,NB); '; "PAT:='SAW'; "(* FIND POSITION OF PAT IN DEST *) "NB:=POS(PAT,DEST); "WRITELN('POSITION OF ',PAT,'IS:',NB); ((* USED FOR TRACE *) ( "(* NOW DETERMINE NUMBER OF CHARACTERS TO DELETE *) "LP:=LENGTH(PAT); "NE:=NB+LP; &(* SAVE END OF PATTERN IN NECORE *)  (* *)  (*====================================*)   (* ILLUSTRATE BUILT-IN PROCEDURES & FUNCTIONS *)   VAR SRC,DEST,PAT,SCRATCH:STRING; $LP,NB,NE:INTEGER;   BEGIN "DEST:='EVEN IF HE SAW MEPROGRAM INTRINSIC;  (*====================================*)  (* *)  (* PROBLEM SOLVING USING PASCAL *)  (* PAGE 084 *)  (* OK AS IS APPLE ][ BY R.L. PENNELL *)  (* SAN DIEGO APPLE tion of programs. These are:  %1. Programs may declare procedures or functions EXTERNAL in the same way  they may be declared FORWARD (ie, a full 1st procedure/function declaration  line is required). The program may not be run until it has been L(inked; the  linker usually expects to find the missing code in the SYSTEM.LIBRARY.  EXTERNAL procedures are reserved for assembly language procedures; the entire  process is well documented in the UCSD handout.  %One item that is not completely cl then trick the operating system with your phony console input.) However, I'll  bet that someone familiar with the operating system could cook up a way of  feeding data directly to the program execution section; it would require  compiling your routineis no clean way for one program to load another and then  pass execution to it. (You have to have some way of fudging the console  input buffer in the BIOS, then quit the execution of the present program, e) you expect to use rarely,  before the memory fills up. Unlike some other Pascal implementations, all  other code (not explicitly declared a SEGMENT procedure/function) is always  memory resident while the program is running.  %Further, there wn into memory only when required, and are overwritten by  data or code at other times. This approach is essential if you have a  complicated program that uses a lot of memory and has one or more long  procedures (most commonly an initialization routin%3. Finally, it is possible (but within the main program ONLY) to declare  certain procedures or functions SEGMENT procedures/functions. The compilation  process is not changed, but when the program is actually run, the declared  procedures are dra(simply passing initialized  variables to the main program) and was best debugged by itself. 2) I added an  automatic hyphenation routine, which also was quite long and needed to be  debugged separately.  pproach with great success for a complicated text  processing program, for two functions: 1) the program begins with a detailed  menu that reads in user requests for margins, page length, etc. Not only is  this code quite long, it stands by itself am, even if you use them -- you will get an error,  since they are already there. (If this is not clear, try setting up a UNIT  and a main program that uses it, then examine a listing of the main program  after compilation.)  %I have used the UNIT a first thing at the time of compilation of the main program, and these  declarations are copied verbatim into the text of the main program by the  compiler. This means that you should NOT declare the same constants, types,  etc., within the main progrvailable to the linker. The documentation is not clear about how  common variables are actually declared: any constant, type, variable,  procedure, or function declared in the INTERFACE portion of the unit is read tes "USES  , ,...,;" at the second line of the  program (right after the main program declaration). Normally, you should  incorporate the code from the correctly compiled UNIT into the SYSTEM.LIBRARY,  where it is aared parameter is popped off first).  %2. You can construct a separate UNIT, which contains text that performs  some involved but functionally distinct process within your program. This is  then compiled separately, and the calling program merely sta the called routine is a function, two words of zeros, which reserve space for  the result of the function (these two words are skipped if the routine is a  procedure); 3) the parameters being passed to the routine, in reverse order  (ie, the last declear is the way parameters are passed.  The called routine will find the following items on the stack, in descending  (normal "POP xx" order): 1) the return address (this must be saved); 2) IF (usually simply a menu) at the 0th lex level with the  (*$U-*) compiler command. The reason this may be important is that many  business programs use multiple separate procedures driven by a menu, and the  Pascal system at present limits you to 6 procedure segments.  %It is absolutely not mentioned anywhere, but although external UNITS are  given new segment numbers by the compiler, they are ALWAYS resident in memory  at run time. If you want to have the code in a unit work as a SEGMENT  PROC$ IF LINE[I]<>' ' THEN B:=TRUE $END; "IF NSP>0 THEN $BEGIN &JUST:=TRUE; &NEEDSP:=(COLWIDTH-LINELENGTH)*PITCH; &ADDSP:=NEEDSP DIV NSP; &EXTSP:=NEEDSP-ADDSP*NSP; $END ELSE JUST:=FALSE  END;   PROCEDURE VARLINE(LINELENGTH:LINEPOS);  VAR K,L : I&READLN(FILL) $END  END;    PROCEDURE BLANKSCAN(LINELENGTH:LINEPOS);  VAR I,J : INTEGER;  B : BOOLEAN;  BEGIN "B:=FALSE; "NSP:=0; "FOR I:=1 TO LINELENGTH DO  BEGIN &IF ((LINE[I]=' ') AND B) THEN NSP:=NSP+1; 6); "RESET(INPUT); "FILL:=80; "PITCH:=6; "READ(C);  IF C='Y' THEN $BEGIN $ CLEARSCREEN; &WRITELN;WRITELN; $ WRITE('PICA OR ELITE (P/E) ':35); &{EAD(C); &IF C='P' THEN PITCH:=6 ELSE PITCH:=5; &WRITELN; &WRITE('MAXIMUM FILL PERCENT ':35); 6;  GOTOXY(10,12); "WRITELN('THE CURRENT PROGRAM OPTIONS ARE:'); "WRITELN('TYPE PITCH - 5 (ELITE)':40); "WRITELN('MAXIMUM PERCENT FILL - 80%':40); "WRITELN('SINGLE SPACE TEXT':30); "WRITELN;WRITELN;WRITE('WOULD YOU LIKE TO CHANGE THEM (Y/N) ':4"READLN(INFILE); "IF LENGTH(INFILE)=0 THEN INFILE:='SYSTEM.WRK'; "INFILE:=CONCAT(INFILE,'.TEXT'); "GOTOXY(10,7); "WRITE('OUTPUT FILE NAME '); "READLN(OUTFILE); "GOTOXY(10,9); "WRITE('ENTER COLUMN WIDTH '); "READ(COLWIDTH); "SPACING:=1; "PITCH:=SCREEN;  BEGIN "WRITE(CHR(26),CHR(0),CHR(0),CHR(0),CHR(0),CHR(0),CHR(0))  END;   PROCEDURE OPTIONS;  VAR C:CHAR;  BEGIN "CLEARSCREEN; "WRITELN('DARLENE''S SUPER TYPESETTING PROGRAM':52); "GOTOXY(10,6); "WRITE('INPUT FILE NAME '); NSP : INTEGER; {NUMBER OF SPACES IN CURRENT LINE} *P : BOOLEAN; {PARAGRAPH FLAG} &PITCH : 5..6; $SPACING : INTEGER; "JUST,STOP : BOOLEAN; &SPCNT : INTEGER; &NEEDSP: INTEGER; &ADDSP : INTEGER; &EXTSP : INTEGER;   PROCEDURE CLEAR: CHAR; 'LINE : ARRAY[1..MAXCHAR] OF CHAR; {UNJUSTIFIED} &DLINE : ARRAY[1..MAXCHAR] OF CHAR; {JUSTIFIED FOR DISPLAY} % FILL : INTEGER; {MAX % FILL ALLOWED} %INFILE : STRING[15]; $OUTFILE : STRING[15];    PROGRAM TYPESET;   CONST MAXCHAR = 80; {MAXIMUM NUMBER OF CHARACTERS PER LINE}  ESC = 27; {ESCAPE CHARACTER}   TYPE LINEPOS = 1..MAXCHAR;   VAR I,J : INTEGER; #COLWIDTH : INTEGER; 'W,JW : TEXT; (C,D A J R O^۝EDURE or FUNCTION, you MUST include the source within the main file and  declare it a SEGMENT PROCEDURE or FUNCTION.  % %