Digital PDFs
Documents
Guest
Register
Log In
DEC-8E-OCASA-B-D
December 1974
223 pages
Original
4.7MB
view
download
Document:
CAPS8 UG
Order Number:
DEC-8E-OCASA-B-D
Revision:
Pages:
223
Original Filename:
https://svn.so-much-stuff.com/svn/trunk/pdp8/src/dec/dec-8e-ocasa/dec-8e-ocasa-b-d.pdf
OCR Text
users manual digital equipment corporotfon UP S S Sp Sp Sp Sp Sp S Sp Sp Sp Sp Sp Sp ^ DEC- 8E-0CASA-B-D CASSETTE PROGRAMMING SYSTEM USER'S MANUAL from Software For additional copies, order No. DEC-8E-0CASA-B-D Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754 8 8 First Printing, March, 1973 Revised September, 1973 Printed July, 1974 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this manual. The software described in this document is furnished to the purchaser under a license for use on a single computer system and can be copied (with inclusion of DIGITAL'S copyright notice) only for use in such system, except as may otherwise be provided in writing by DIGITAL. Digital Equipment Corporation assumes no responsibility for the use or reliability of its software on equipment that is not supplied by DIGITAL. Copyright (6) 1973, 1974 by Digital Ecjuipment Corporation The HOW TO OBTAIN SOFTWARE INFORMATION page, located at the back of this document, explains the various services available to DIGITAL software users. The postage prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: CDP COMPUTER LAB COMSYST COMTEK DDT DEC DECCOMM DECTAPE DIBOL DIGITAL DNC EDGRIN EDUSYSTEM FLIP CHIP FOCAL GLC-8 ID AC IDACS INDAC KAIO LABLAB-8/e LAB-K OMNIBUS OS/8 PDP PHA PS/8 QUICKPOINT RADRSTS RSX RTM RT-11 SABR TYPESET 8 UNIBUS 1 CONTENTS PAGE CHAPTER 1 THE CASSETTE PROGRAMMING SYSTEM 1.1 1.1.1 1.1.2 INTRODUCTION TO A CASSETTE STORAGE SYSTIM Hardware Components Software Components 1.2 VfflAT 1-2 1-4 1-4 1.3 THE SYSTEM CASSETTE 1-4 1.4 MOUNTING AND DISMOUNTING CASSETTES 1-5 1.5 CONCERNING EXAMPLES 1-6 1.2.1 1.2.2 IS A CAPS-8 CASSETTE? The Format of a Cassette The Sentinel File 1-1 1-2 1-2 CHAPTER 2 GETTING ON-LINE WITH THE CAPS-8 SYSTEM 2.1 SYSTEM PROGRAMS 2-1 2.2 2.2.1 2.2.2 2.2.3 SYSTEM CONVENTIONS File Formats Filenames and Extensions Input/Output Devices 2-1 2-1 2-2 2-2 2.3 LOADING THE KEYBOARD MONITOR 2-3 2.4 2.4.1 2.4.2 2.4.3 USING THE KEYBOARD MONITOR Making Corrections Special Characters I/O Designations and Specification Options 2-3 2-3 2-4 2-5 KEYBOARD MONITOR COMMANDS Run Command Load Command DAte Command Directory Command DElete Command Zero Command REwind Command Version Command 2-5 2-6 2-7 2-7 2-7 2-8 2-9 2-10 2-10 2.6 NOTES ON DEVICE HANDLERS 2-11 2.7 MONITOR ERROR MESSAGES 2-12 5 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 CHAPTER 3 SYMBOLIC EDITOR 3 . INTRODUCTION 3-1 3.2 3.2.1 3.2.2 3.2.3 CALLING AND USING THE EDITOR EDITOR Options Input and Output Specifications Version Numbers 3-1 3-1 3-2 3-3 111 1 ) 3.3 3.3.1 MODES OF OPERATION Transition Between Modes 3-4 3-4 3.4 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3,4.10 3.4.11 3.4.12 3.4.13 SPECIAL CHARACTERS AND FUNCTIONS RETURN Key Erase (CTRL/U) RUBOUT Key Form Feed CCTRL/FORM) The Current Line Counter C. Slash (/) LINE FEED Key ALT MODE Key Right Angle Bracket (>) Left Angle Bracket C<) Equal Sign (=) Colon (:) Tabulation (CTRL/TAB) 3-4 3-5 3-5 3-5 3-5 3-6 3-6 3-6 3-7 3-7 3-7 3-7 3-7 3-7 3.5 COMMAND STRUCTURE 3-8 3.6 3.6.1 3.6.2 3.6.3 COMMAND REPERTOIRE Input Commands Output Coimuands Editing Commands 3-8 3-9 3-10 3-12 3.7 TEXT COT.LF.CTION 3-15 3.8 3.8.1 3.8.2 CHARACTER SEARCHES Single Character Search Character String Search 3-16 3-16 3-17 3.9 EDITOR ERROR MESSAGES 3-21 3.10 EDITOR DEMONSTRATION RUN 3-23 CHAPTER 4 SYSTEM COPY 4 . INTRODUCTION 4-1 4.2 4.2.1 4.2.2 4.2.3 CALLING AND USING SYSTEM COPY System Copy Options Input and Output Specifications System Copy Example 4-1 4-1 4-2 4-3 4.3 SYSTEM COPY ERROR MESSAGES 4-4 CHAPTER 5 PALC ASSEMBLER 5 . 1 INTRODUCTION 5-1 5.2 5.2.1 CALLING AND USING PALC PALC Options 5-1 5-5 5.3 CHARACTER SET 5-5 5.4 STATEMENTS Labels Instructions Operands Comments 5-6 5-6 5-6 5-7 5-7 5.4.1 5.4.2 5.4.3 5.4.4 IV 5.5.1 5.5.2 5.5.3 FORMAT EFFECTORS Form Feed Tabulations Statement Terminators 5-7 5-7 5-7 5-8 5.6 NUMBERS 5-9 5.7 5.7.1 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 SYMBOLS Permanent Symbols User-Defined Symbols Current Location Counter Symbol Table Direct Assignment Statements Symbolic Instructions Symbolic Operands Internal Symbol Representation for PALC 5-9 5-9 5-9 5-10 5-11 5-12 5-13 5-13 5-13 5.8 5.8.1 5.8.2 EXPRESSIONS Operators Special Characters 5-14 5-14 5-17 J INSTRUCTIONS Memory Reference Instructions Indirect Addressing Microinstructions Autoindexing 5-20 5-20 5-20 5-21 5-23 PSEUDO-OPERATORS Indirect and Page Zero Addressing Radix Control Extended Memory 5,,1)3.3 End-of-File 5.,1)3.4 5,,1^.5 Resetting the Location Counter Entering Text Strings 5,,1)3.6 Suppressing the Listing 5,,1)3.7 Reserving Memory 5,.1)3.8 5,.1^.9 Conditional Assembly Pseudo-Operators Controlling Binary Output 5,.1)3.1)3 Controlling Page Format 5,.1)3.11 Altering the Permanent Symbol Table 5,.1)3.12 5-24 5-24 5-24 5-25 5-26 5-26 5-27 5-27 5-27 5-28 5-28 5-29 5-29 5.5 <1 :> 5.,9.1 5.,9.2 5.,9.3 5.,9.4 5..Ij? 5,,1)3.1 5,,1)3.2 5.11 LINK GENERATION AND STOl^AGE 5-30 5.12 CODING PRACTICES 5-31 5.13 5.13.1 PROGRAM PREPARATION AND ASSEMBLER OUTPUT Terminating Assembly 5-32 5-33 5.14 PALC ERROR CONDITIONS 5-33 CHAPTER 6 CASSETTE BASIC 6.1 INTRODUCTION 6-1 6.2 CALLING BASIC 6-1 6.3 NUMBERS 6-2 6.4 VARIABLES 6-3 ARITHMETIC OPERATIONS Priority of Operations Prentheses and Spaces Relational Operators 6-4 6-4 6-5 6-5 6.6.1 6.6.2 6.6.3 IMMEDIATE MODE PRINT Command LET Command Looping PRINT and LET Commands 6-6 6-6 6-7 6-7 6.7 EXAMPLE RUN 6-8 6.8 BASIC STATEMENTS Statement Numbers Commenting the Program Terminating the Program. The Arithmetic Statement Input/Output Statements Creating Run-Time Input Files Loops Subscripted Variables Transfer of Control Statements Program Chaining Subroutines Functions 6-10 6-10 6-10 6-11 6-11 6-12 6-25 6-27 6-29 6-31 6-34 6-35 6-37 6.9.1 6.9.2 6.9.3 6.9.4 6.9.5 IMPLEMENTING A USER-CODED FUNCTION Coding Formats Floating-Point Format Incorporating Subroutines with UUF Writing the Program Examples of User-Coded Functions 6-44 6-44 6-46 6-46 6-47 6-47 6.10 6.10.1 6.10.2 FLOATING-POINT PACKAGE Instruction Set Addressing 6-50 6-50 6-51 6.11 6.11.1 6.11.2 6.11.3 6.11.4 6.11.5 6.11.6 6.11.7 6.11.8 EDITING AND CONTROL COMMANDS Erasing Characters and Lines Listing a Program Running a Program Stopping a Run Loading a User-Coded Function Erasing a Program In Memory Renaming a Program Saving a Program 6-52 6-52 6-53 6-54 6-54 6-55 6-55 6-55 6-56 6.12 CASSETTE BASIC ERROR MES55AGES 6-57 6.13 CASSETTE BASIC SYMBOL TABLE 6-59 6.5 6.5.1 6.5.2 6.5.3 6.6 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.8.6 6.8.7 6.8.8 6.8.9 6.8.10 6.8.11 6.8.12 6.9 CHAPTER 7 USING CAPS-8 CODT 7.1 FEATURES 7-1 7.2 7.2.1 USING CODT Commands 7-2 7-2 7.3 ILLEGAL CHARACTERS ADDITIONAL TECHNIQUES TTY I/O-FLAG Interrupt Program Debugging 7-8 7.4 7.4.1 7.4.2 7-9 7-9 1 Octal Dump Indirect References 7-9 7-9 7.5 ERRORS 7-9 7.6 OPERATION AND STORAGE Storage Requirements - CAPS-8 System Programming Notes Summary COMMAND SUMMARY 7-9 7-10 7-10 7.6. 7.6. 7.7 CHAPTER 8 7-11 CAPS-8 UTILITY PROGRAM 8.1 INTRODUCTION 8-1 8.2 8.2.1 8.2.2 CALLING AND USING THE UTILITY PROGRAM Utility Program Options Input and Output Specifications 8-1 8-1 8-2 8.3 UTILITY PROGRAM ERROR MESSAGES 8-2 CHAPTER 9 BOOT 9.1 OPERATING PROCEDURES 9-1 APPENDICES A ASCII Character Codes A-1 B Error Message and Command Summaries B-1 C PALC Permanent Symbol Table C-1 D CAPS-8 Demonstration Run D-1 E Monitor Services E-1 F Assembly Instructions F-1 TABLES Table 2-1 CAPS-8 Extension Names Table 2-2 Directory Options Table 2-3 Keyboard Monitor Error Messages Table 3-1 EDITOR Options Table 3-2 Command Format Table 3-3 Input Commands Table 3-4 List Commands Table 3-5 Text Transfer Commands Table 3-6 Editing Commands Table 3-7 Search Character Options Table 3-8 Terminating a String Search Table 3-9 EDITOR Error Codes Table 4-1 System Copy Options Table 4-2 System Copy Error Messages Table 5-1 PALC Options Table 5-2 Use of Operators Table 5-3 PALC Error Codes VI 2-2 2-8 2-12 3-1 3-8 3-9 3-10 3-11 3-12 3-16 3-20 3-21 4-1 4-4 5-5 5-15 5-34 Table 6-1 Cassette BASIC Functions Table 6-2 Function Addresses Table 6-3 Floating-Point Accumulator Table 6-4 Floating-Point Instructions Table 6-5 Relative Addresses Table 6-6 Cassette BASIC Error Messages Table 6-7 Cassette BASIC Symbol Table Table E-1 Monitor Memory Map Table E-2 Utility Subroutines and Locations Table E-3 Header Record Structure 6-38 6-45 6-46 6-50 6-51 6-57 6-60 E-1 E-1 E-11 ILLUSTRATIONS Figure Figure Figure Figure Figure 1-1 1-2 1-3 E-1 E-2 Cassette Programming System CAPS-8 Cassette Mounting a Cassette Switch Option Characters Ring Buffers Vlll 1-1 1-3 1-6 E-10 E-10 CHAPTER 1 THE CASSETTE PROGRAMMING SYSTEM 1.1 INTRODUCTION TO A CASSETTE STORAGE SYSTEM The PDP-8 Cassette Programming System (CAPS-8) is a small programming system for the PDP-8/E (8/M or 8/F) computer and is de signed around the use of cassettes for program storage, rather than DE Ctape, paper tape or disk storage. CAPS-8 replaces paper tap a procedures completely. The MI8-E Hardware Bootstrap initially loads the Cassette Keyboard Monitor into memory; with the use of the Mon itor all file transfers and program loading and storage is done v la cassette, Cassettes are more convenient and reliable and much easie r to use than paper tape, and in addition, cut the time involved in loading and storing programs using paper tape by almost one half. CAPS-8 provides the user with a Keyboard Monitor, I/O facilities at the Monitor level, and a library of System Programs, including a machine language assembler, an editor, and a higher-level programming language. Figure 1-1 Cassette Programming System 1-1 ,, 1.1.1 Hardware Components The Cassette Programming System is built around a PDP-8/E, 8/M, or 8/F computer with a minimum of one TU60 dual cassette unit, a console terminal (LA30 DECwriter, LT33 or LT35 Teletype, or VT05 DECterminal) and BK of memory. A line printer is optional. 1.1.2 Software Components A brief description of the software Cassette Programming System follows. greater detail later in the manual. package available with the Each program is discussed in 1. MONITOR - The Keyboard Monitor provides communication between the user and the Cassette System Executive Routines by accepting commands from the console terminal keyboard. The commands allow the user to run system and user programs, save programs on cassette, and obtain directories of cassettes. 2. Symbolic EDITOR - The EDITOR allows the user to modify or create source files for use as input to language processing programs such as BASIC and PALC. The EDITOR contains powerful text manipulation commands for quick and easy editing. 3. PALC Assembler (Program Assembly Language Cassette) PALC accepts source files in the PAL machine language and generates absolute binary files as output. These files can then be loaded cind executed using Monitor commands. 4. BASIC - BASIC provides a higher- level programming language which is easy to learn and use. It includes such language features as user-coded functions, data files on cassette, and program chaining. 5. System Copy (SYSCOP) - SYSCOP allows the user to transfer files from one cassette to another, giving him the ability to make multiple copies of a cassette and "clean up" full cassettes so that they may become available for future use. — 1.2 WHAT IS A CAPS- 8 CASSETTE? A CAPS-8 cassette is a magnetic tape device much like that used in a cassette tape recorder. The tape itself and the reels it is wound on (see Figure are enclosed inside a rectangular plastic case 1-2) making handling, storage, and care of the cassette convenient for the user. 1-2 . On either end of one side of the cassette are two flex ible plastic tabs called write protect tabs (see A in Figure 1-2) There is one tab for each end of the tape; since data should only be w ritten in one direction on the tape, the user will need to be concerne d with only the tab which is specifically marked on the cassette labe 1. Depending upon the position of this tab, the user is able to pro tect his tape against accidental writing and destruction of data. Wh. en the tab is pulled in toward the middle of the cassette so that the hole is uncovered, the tape is write-locked; data cannot be writ ten on it and any attempt to do so will result in an error message. Wh. en the tab is pushed toward the outside of the cassette so that the hoi e is covered, the tape is write-enabled and data can be written onto i t. Data can be read from the cassette with the tab in either positior. The bottom of the cassette (B in Figure 1-2) provides an opening where the magnetic tape is exposed. The cassette is locked into position on a TU60 cassette unit drive so that the tape comes in cont.act with the read/write head through this opening. Both ends of the magnetic tape in a cassette consist of clear plastic leader/trailer tape; this section of the tape is not used for information storage purposes, but as a safeguard in handling and storing the cassette itself. Since cassette tape is susceptible to dust and fingerprints, the leader/trailer tape should be the only part of the tape exposed whenever the cassette is not on a drive. Figure 1-2 CAPS-8 Cassette 1-3 1.2.1 The Format of a Cassette A cassette is formatted so that it consists of a sequence of one or more files. Each file is preceded and followed by a file gap. (A gap in this sense is a set length of specially coded tape.) All cassettes must start with a file gap; any information preceding the initial file gap is unreliable. A file consists of a sequence of one or more records separated from each other by a record gap. The first record information of a file is called the file header record and contains concerning the name of the file, its type, length, and so on. A (Chapter 2 provides more information concerning header records.) 12 8 (decimal) characters of information; record generally contains there are approximately 600 records per cassette tape. Records consist of a sequence of one or more cassette bytes; a byte in turn consists of eight bits each representing a binary zero or one. Characters and numbers are stored in bytes using the standard ASCII character codes (see Appendix A) and binary notation. The number of records of information on a cassette tape may be On the outside of the cassette case is a clear estimated by the user. plastic window (C in Figure 1-2) . Along the bottom, of this window is series of marks; each mark represents abovit 50 inches of magnetic a Knowing that approximately 2 records fit on an inch of tape, tape. the user is able to make a reasonable guess as to the length of tape By simply glancing at the and number of records available for use. width of the tape reel showing in the window, the user can tell Since he is given no advance quickly if he is very close to the end. warning of a full tape condition, the user must visually keep track of Should the tape become full the length of tape he has available. before his file transfer has completed, einother cassette must be substituted, cuid the transfer or output operation must be restarted. . 1.2.2 The Sentinel File This The last file on a cassette tape is called the sentinel file. file consists of only a file header record and represents the logical end-of-tape. A zeroed or blcink cassette tape is one consisting of only the sentinel file. 1.3 THE SYSTEM CASSETTE The software discussed in Section 1.1 is provided to the user on a single cassette called the System Cassette. This is the cassette on which the entire CAPS-8 System resides, and it is utilized for all system functions. The System Cassette must always be mounted on drive serves as the default device when the user fails to specify 0; drive another. 1-4 NOTE Each TU60 dual cassette unit has two drives . The drive on the left is always odd-numbered and the drive on the right even-numbered; thus, drive will be the If the user has more left drive. than one TU60 dual cassette unit, he should pirobably label the drives in consecutive order so that there will be no confusion when he is using the system. The write protect tab on the System Cassette should usucilly be in the write-locked position so that data will not accidently be written on it; it is suggested that the user make a copy of thisi cassette as protection against loss or accidental destruction. 1.4 MOUNTING AND DISMOUNTING A CASSETTE To mount a tape on a drive, hold the tape so that the open part of the cassette is to the left and the full reel is at the top. Set the top write protect tahi to the desired position depending upon whether data is to be written on the tape. Open the locking bar on the cassette drive by pushing it to the right away from the drive (see A in Figure 1-3) . Next hold the tape up to the cassette drive at approximately a 45-degree single and insert the tape into the drive by applying a leftward pressure while simultaneously rotating the cassette over the drive spirockets. This Push the brings the tape into position against the read/write head. tape into the unit so that when the cassette is properly mounted, the (Figure locking bar automatically closes over the cassette back edge. 1-3 illustrates this procedure.) Press the rewind button on the cassette unit (see B in Figure 1-3; there is a rewind button for each drive) . This causes the cassette to (Pressing the rewind to the beginning of its leader/trailer tape. rewind button ci second time causes the cassette to revrind to the end The of the leader/trciiler tape and to the physical end--of-tape. cassette unit will click; this sound is almost inaudibJ.e and the user Normal usage may not hear it unless he is listening carefully. requires that the user press the rewind button only once whenever he wishes to manually rewind a cassette) . Even though tapes which are not actively being used on a drive should already be positioned at the beginning, the user should develop the habit of automatically When the tape has finished winding, the rewinding a cassette. The cassette is now in place; and ready for cassette will stop moving. transfer operations. 1-5 Figure 1-3 Mountincr a Cassette Before removing a cassette f rom a drivei, the tape should always be rewound to its beginning, This can be done by pressing the rewind button on the cassette unit or by issuing the REwind Monitor Command as explained in Chapter 2 Rewinding a tape ensures that the clear leader/trailer tape will be the only tcipe exposed at the open part of the cassette. To remove a cassette from the cassette drive, open the locking bar and the cassette will pop out. When cassettes are not being actively used on a cassette drive, they can be stored in the small plastic boxes provided for this purpose by the manufacturer. NOTE Before using a new cassette, or prior to using a cassette that has just been shipped or accidently dropped, mount the cassette on a drive so that the Digital label faces the inside of the unit and perform a rewind operation. Remove the cassette, turn it ovcir, and perform another rewind operation. This packs neatly in the cassette and the tape places the full tape reel at the proper tension. 1.5 CONCERNING EXAMPLES In the chapters that follow, care has been taken to include acutal machine printout whenever possible. In cases in which there may be some discrepancy as to whether a character was typed by the user or by the system, that typed by the system will be underlined. 1-6 : CHAPTER 2 GETTING ON-LINE WITH THE CAPS-8 SYSTEM 2.1 SYSTEM PROGRAMS The Cassette Programming System is distributed on a single cassette, called the System Cassette, which contains all the programs necessary for loading the Monitor into memory and creating and lunning system The directory of the System Cassette is as user programs. cind follows C2B00T .BIN MONFOrt • BIN sybcop • BIN EDIT .BIN PALC .BIN BASIC .BIN 01/22/73 01/22/73 01/25/73 01/02/73 01/02/73 01/02/73 Ul Ul V2 VI VI VI System files are in binary format (see Section 2.2.1). The first two files on any System Cassette must be C2B0OT.BIN and MONTOR.BIN; these C2B00T.BIN two files comprise a bootstrap cind the Keyboard Monitor. loads the Monitor into memory from the System Cassettes; the Keyboard Monitor links the user and the CAPS-8 System by providing a means of communication between the two. By accepting commands from the console terminal keyboard, the Cassette Keyboard Monitor allows the user to run system and user programs, save eind recall files utilizing cassette storage, and create, assemble, and load programs. 2.2 SYSTEM CONVENTIONS The following procedures and other systems. conventions concern file formats and file naming standard for the CAPS-8 System, as well as for many aire 2.2.1 File Formats The Cassette Programming System makes use of two types of file formats ASCII and Binary. — Files in ASCII format conform to the American National Standard Code Interchange in which alphanumeric characters are for Information represented by a 3-digit code. A table containing ASCII character codes in 7- and 8-bit octal is provided in Appendix A. Binary format files consist of 12-bit binary words representing PDP-8 The standard DEC binary format is used with machine language code. Binary files contain the exception that no checksum is necessary. field addresses and memory instructions and are read directly into 2-1 memory for immediate execution. CAPS- 8 System Programs are in binary format, and programs which the user assembles with PALC are translated into files in binary format. 2.2.2 Filenames and Extensions System and user files are referenced symbolically by a name of as many (A-Z) followed alphabetic characters or digits (0-9) as six optionally by an extension of from 1 to 3 alphabetic characters or (the first character in a filename must be alphabetic) . The digits; extension to a filename is generally used as an aid in remembering the CAPS-8 format of a file. Table 2-1 lists commonly accepted extensions it is the user may or may not conform to this list as he chooses; included here only as a guide: , — Table 2-1 CAPS-8 Extension Names Meaning Extension PAL BIN BAS TXT DOC DAT PALC source file (ASCII) System or user binary format file BASIC source file (ASCII) Text file (ASCII) Documentation file (ASCII) Data file (ASCII or other) Generally the user may call his files by any mnemonic filename and some cases, if he omits specifying an In extension he chooses. extension, the System Program he is running may assume an extension. For example, PALC assumes an extension of .PAL unless the user .BIN unless another indicates another, and the Run command assumes extension is specified. 2.2.3 Input/Output Devices There are three available categories of input/output devices in the Cassette Programming System: console terminal keyboard (including paper tape reader and punch if an LT33 Teletype containing these units the console terminal) , cassette drives 0-7, and a line is used as There are no permanent device names in the CAPS-8 System. printer. Command strings cind I/O designations are entered in such a way that the user specifies the device by a drive nximber and the file by a option characters allow the user to direct listings to the filename; line printer or to otherwise change the normal operating procedure of is the default device if drive The System Cassette a program. For example: no drive number is specified. — .DI/L 2-2 — (DI is a Monitor command instructing the computer to print a directory Since no drive number is specified, drive listing of a cassette. The option character L sends is assiomed. the System Cassette output to the line printer instead of the console teriiinal, which is the normal output device.) — — 2.3 LOADING THE KEYBOARD MONITOR The CAPS-8 hardware bootstrap and C2B00T.BIN on the System Cassette (Both are used to load the Cassette Keyboard Monitor into memory. Loading the Monitor is bootstraps are described in Appendix E.) accomplished as follows: 1. Ensure that the computer and terminal are on-line. 2. Press and raise the HALT key. Make sure that the SINGLE STEP key is in a raised position. 3. Place the System Cassette (write- locked to protect data) onto cassette unit drive 0; 4. Press and raise the SVJ key. At this point the RUN lamp should be on and the System Cassette should begin to move. The hardware bootstrap calls the first program on the System Cassette (C2B00T.BIN) which in turn loads the Keyboard Monitor If an error occurs during the loading into memory. (MONTOR.BIN) process (for example, an error may be caused by the cassette being improperly mounted, by a missing file on the tape, or by the occurrence of an I/O error) no error message will inform the user Instead, the System since the Monitor is not completely in memory. If this Cassette may stop moving and the computer may loop or halt. is the case, steps 2-4 above should be repeated. Once the Monitor has been loaded, the System Cassette stops moving and This dot is typed at the left margin of the console terminal page. a instructs the user that the Monitor is now in memory and ready to accept input commands. 2.4 USING THE KEYBOARD MONITOR Each command to the Keyboard Monitor is typed at the console terminal keyboard in response to the dot at the left margin. A command is entered by pressing the RETURN key. 2.4.1 Making Corrections Corrections may be made to the command line providing they are made before the line is entered (that is, before a carriage return has been typed). The RUBCUT key is used to correct typing errors. Pressing the 2-3 . . RUBOUT key once causes an open bracket to be typed followed by the [) last character entered into memory. After this character is echoed on Successive RUBOUTs the console terminal it is deleted from memory. each cause one more character to be printed and deleted. The first non-RUBOUT character typed (after the last RUBOUT in a sequence) causes a closing bracket (] to be printed, thus enclosing only the deleted portion of text within brackets. For example: ( ) The user types: ,R BACIC (RUBOUT) (RUBOUT) (RUBOUT) SIC The console terminal shows: ^H BACIC CCIC 3SIC The string is entered to the Keyboard Monitor as: .R BASIC 2.4.2 Special Characters (CTRL/C, CTRL/0, and CTRL/U) Control can be returned to the Keyboard Monitor while under any of the System Programs by typing a CTRL/C (produced by holding down the CTRL If the Monitor is not key and simultaneously pressing the C key) . still in memory, a CTRL/C causes a complete rebootstrap by reading the When it is appropriate files from the System Cassette on drive 0. ready to accept input, the Keyboard Monitor types a dot at the left margin of the teleprinter (i.e. console; terminal) page. Teleprinter output can be suppressed by typing a CTRL/0 (produced by holding down the CTRL key and simultaneously pressing the O key) This allows execution of the program to continue, but stops all Typing a second CTRL/0 will resume output again. console printout. Unless output is extremely lengthy, or unless the program is waiting for input from the user, processing of a program after an initial CTRL/0 will usually be completed before the user is able to type a Printout will automeitically resume when control is second CTRL/0. returned to the Keyboard Monitor (indicated by a dot at the left margin) NOTE certain prevent CTRL/0 does not important error messagess from printing on the console terminal. A command line may be deleted completely, before it is entered, by typing a CTRL/U (produced by holding down the CTRL key and pressing This causes the current command line to be ignored and the U key) . returns control to the Keyboard Monitor. The Monitor prints a dot at the left margin to indicate that it is ready to accept another command. 2-4 2.4.3 I/O Designations and Specification Options Whenever the user runs a System Program or performs any I/O operation, he must indicate the file(s) to be accessed, the cassette drive (s) on which they are located, and any desired options associated with the operation. Procedures used in entering this information are explained below. Monitor commands generally require only a single command line which specifies the unit drive number (in the range 0-7), fiLename{s), and option (s) in the following format; .COMMAND DRIVE #: FILENAME:. EXT/OPTION (S) COMMAND represents one of the eight Monitor commands discussed in Section 2.5. The filename should be separated from the drive number by a colon. Options are alphabetic characters and are separated from the rest of the command line by the slash character (/) Successive options follow one another without any separating character. The command line is executed by typing a carriage return. . I/O specifications to System Programs follow a different format. First the System Program is called from the System Cassette using the Monitor Run command. The System Program then asks for the input filename, drive number, and options, jind then the output filename, drive number, and options. This information is usually requested in two separate command lines, but the actual format varies between System Programs. Generally, the command strings appear as follows: .R SYSTEM PROGRAM/OPTIONS INPUT-DRIVE #:FILENAME OUTPUT-DRIVE #:FILENAME The appropriate chapter should be referenced for the accurate format. Options are available in most System Programs and Monitor commands allowing the user to change the order or format of input and output operations from that which would normally be carried out by the program. Again, interpretation of options varies; the user should refer to the appropriate section or chapter to learn which options are available and what actions will result from their use. 2.5 KEYBOARD MONITOR COMMANDS There are eight Keyboard Monitor commands available to the user. Commands are typed in response to the dot printed by the Monitor and are entered when the RETURN key is pressed. Each command consists of one or more alphabetic characters, followed by a space (or any non-alphcibetic character) . Any error made while utilizing these commands will result in a message informing the user (see Section 2.8). After occurrence of an error, control returns to the Keyboard Monitor and the command must be retyped. (Since several of the commands begin with the same letter, the user must be sure to note how much of the command must be entered in order to distinguish it from other commands. While it does not matter if too many characters are entered, too few will cause errors.) 2-5 . ; 2.5.1 Run Command The Run command is of the form: .R Drive #: Filename/Option (s) The Run command instructs the Monitor to load and execute the file specified in the command line. The file should be in self-starting binary format (tihat is, the last location in the source file must be an origin setting which indicates the starting address of the file) as the file is not in self-starting binary format, the program will be loaded but execution will not begin; the user will have to proceed as though he were using the Load command (see Section 2.5.2). The user may omit specifying an extension as the Monitor assumes .BIN. For example: .R CART.BIW .H CART or Regardless of which command string the user types , the Monitor assumes .BIN, searches drive for the file CART. BIN, and executes it. Options allowed in the command line depend upon the program the user is running. Availability of options and results of their use are discussed in Chapters 3, 4, 5 and 6. No error occurs if the user specifies an option not allowed by a program; the option is simply ignored. Patches to Multiple files may be executed using the Run command. programs, BASIC user-coded functions, and programs the user may have created using PALC can be executed as follows: .R Drive #:PR0G1, Drive #:PR0G2 ,. . .PROGn/Option (s) where n represents any number of programs as long as the total number The of characters on the input specification line does not exceed 64. user must enter programs in the command line in the order in which he wants them executed cind must be careful to include appropriate starting, chaining, and return addresses (see Appendix E) For example , assume the user has written a routine which will be used for debugging purposes; each time a certain condition is met during execution, this routine will be accessed, print a message and cause The routine has been created using the CAPS-8 execution to halt. EDITOR, assembled with PALC, and is stored on cassette drive 1 as DBG. BIN; it is loaded into memory with the user's program (TABLE.BIN stored on cassette drive 0) . The programs are loaded as follows: .R TABLE.BIN* :DBU.B I iV 1 2-6 Chapter 6, BASIC, contains an example of running multiple conjunction with the BASIC user-coded function feature. files in 2.5.2 Load Command The Load command is used to load a binary file into memory the form: and takes .L Drive #:Filename.ext/Option(s) This command is similar to the Run command except that the computer halts after loading the file. To start execution, the user sets the correct starting address in the Switch R€>gister, presses ADDR LOAD, the file is in self-starting binary format, the CLEAR and CONT (if user need only press CONT) ; appropriate addresses included in the program (see Appendix E) will return control to the Keyboard Monitor after execution. Multiple files may be loaded in the same manner as in the Run command by simply specifying them in correct execution order on the command line: .L Drive #:PR0G1, Drive # :PR0G2. . . .PROGn/Option(s) Again, n may represent any number of programs as long as the number of characters on the command line does not exceed 64. total 2.5.3 DAte Command The DAte command is of the form; .DA mm/dd/yy where mm, dd, and yy represent the current month, day and year as (One or two-digit numbers in the range 0-99 are entered by the user. allowed in the DAte command. The Keyboard Monitor does not check for errors other than the entry of a number which is outside this range.) This date will then appear in directory listings (see Section 2.5.4), If the the date of creation of all new files will be included. cind DAte command is not used, directory listings will contain only filenames, as illustrated in Section 2.1. 2.5.4 Directory Command The Directory comiuand is of the form: .Dl Drive #/Option(s) and causes a directory listing of the cassette on the drive specified No colon is necessary after the to be output on the console terminal. 2-7 . drive number. There are Directory command: two options availcible for use with the Table 2-2 Directory Options Meaning Option /L Causes the listing to be output on the line printer rather than the console terminal. /F Causes a "fast" listing to be creation produced (omitting dates and version numbers) requested In the following example a directory of cassette drive 2 is output (the version number in the directory listing reflects the and number of times the file has been accessed and CAPS-8 EDITOR; see Chapter 3, Section 3.2.3): changed using the li^/f>9/7!3 FILE .BIN (^3/17/78 ABCDEF.PAL A R .ASC y.T ^22 This same directory using the F option will be reduced to: lH/29/7f> .RIM FILE ABCnEF.PAL A B .ASC 2.5.5 DElete Command The DElete command is of the form: .DE Drive #: Filename. ext and causes the filename on the specified drive number to be deleted The filename is replaced by the name *EMPTY in from the directory. Only the directory listing and the file can no longer be referenced. one file may be specified in the DElete command string at a time. 2-8 : For example, assume the user wishes to delete the from the directory of cassette drive 3. He types: .DE filename MATH. DAT 3:MATH.DAT and then obtains a directory listing of drive appear as follows: 11/17/78 TAPE .BAS *EMPTr. .ASC TOR 3. The directory will 11/02/72 11/07/72 73 where *EMPTY represents the deleted filename MATH. DAT. 2.5.6 Zero Command The Zero command is of the form: .Z Drive #: Filename and specifies that the sentinel file of the indicated cassette is to be moved so that it immediately follows the file indicated in the command line. (See Chapter 1 for a description of the sentinel file.) All files following the sentinel file are deleted from the cassette and that portion of the tape is completely reusable. For example, assume cassette drive LOOK BASE FOfJR .ASC .RAS 'BIM l'^/23/7a 3 contains the following directory: V2 11/17/72 EMPTY. RAC E . E and the user wishes to save only the first three files. Zero command as follows He uses the ^Z 3:F0';R.Bir\J and the sentinel file is placed immediately after the The directory now reads: LOOK. ASC BASE. BAS FO'JH.BIM 1 3/23/72 72 11/17/72 2-9 file FOUR. BIN. ;vhen no filename is specif ed in the command line, for example; .Z 1 the cassette is said to be zeroed, or completely deleted of files; the sentinel file is moved to the beginning of the cassette so that the entire tape is available for use. This method is useful in "cleaning cassettes which may contain several Ef-IPTY files in the directory up" listing but have become full and therefore unavailable for further use. First, any needed files are transfered to another cassette using SYSCOP (see Chapter 4) , then the directory of the old cassette is zeroed. The sentinel file is written at the beginning of the tape making the cassette completely reusable. All new tapes must be zeroed before they are first used. This ensures that a sentinel file is present on the tape and moved to the beginning of the tape. 2.5.7 REwind Command The REwind command is of the form: .RE Drive # and causes the cassette on the drive numiber specified to be rewound to its beginning. (The user can also cause the tape to rewind by pressing the rewind button on the cassette unit.) System Programs and Monitor commands always rewind a cassette before accessing a file, but if the user delevopes the habit of rewinding the cassette himself he performs a timesaving action. A cassette should always be rewound before it is removed from a drive. 2.5.8 Version Command The Version command is used to find out Monitor currently in use. Typing: the version number of the .V instructs the Monitor to respond with example: the appropriate indicates that version 1.2 is currently in use. 2-10 number. For . 2.6 NOTES ON DEVICE HANDLERS Device handlers for the CAPS-8 System are described in Appendix E. few notes of interest concerning their use are included here. A The line printer perforins a form feed operation before beginning an output task. Characters are unpacked from the output buffer and printed. A form feed is also produced following the completion of an output task. The line printer handler is capable of handling only an 80 column printer., If the console terminal is an LT33 Teletype containing reader and punch units, these may be used as input/output devices in conjunction with the Teletype keyboard. To punch a tape, simply place the punch unit to ON; to read a tape, place the reader unit to START. Characters will be printed on the Teletype keyboard as they are read or punched. Binary tapes may not be punched. NOTE The purpose of the Cassette Programming System is the elimination of paper tape procedures Cassettes provide a more convenient, reliable and faster means of program storage than paper tape. Therefore, although paper tapes may be read and punched using the LT33 paper tape units, there is no support for this type of I/O' and its use is not encouraged. If the user's program does not over-write certain areas of memory, the parts of the Monitor which are in these locations are available for use. This allows the user who takes advantage of writing his own programs in the PAL machine language to access system hcindlers and to restart or rebootstrap the Cassette Keyboard Monitor after program execution. Infojrmation concerning Monitor Service Routines, I/O routines, device handlers, and internal descriptions of the Keyboard Monitor are provided in Appendix E. 2-11 2.7 KEYBOARD MONITOR ERROR MESSAGES The following error messages may occur when the used incorrectly: Table 2-3 Keyboard Monitor Keyboard Monitor Error Messages Message Meaning BAD COMMAND The user has failed to follow the correct syntax for Monitor commands. This may be the result of mispelled commands or too many or improper arguments in a command string. FILE NOT FOUND The Monitor could not locate the file (or files) specified. The user should check to be sure that filenames are spelled correctly and that the unit drive number specified is correct. INPUT ERROR ON UNIT n OUTPUT ERROR ON UNIT n An I/O error has occurred on the cassette drive specified. This may be caused by an incorrectly formatted cassette or may be due to a timing The user should try the I/O error. transfer using another cassette. UNIT n NOT READY There is no cassette on the drive specified, or no such drive exists. Ul-ILOCK UNIT n The user tried to write data when the write protect tab of the cassette on the drive specified was write-locked. To write data this tab must be write-enabled. 2-12 is CHAPTER 3 SYMBOLIC EDITOR 3.1 INTRODUCTION The CAPS- 8 Symbolic EDITOR is used to create and modify ASCII source files so that these files may be used as input to other System Programs such as BASIC and PALC. The EDITOR considers a file to be divided into logical units called pages. A page of text is generally 50-60 lines long, and corresponds approximately to a physical page of a pi'ogram listing. (Note that is not the same as a memory page) . The EDITOR reads one page of this text at a time from the input file into its internal buffer where the The Editor contains commands for page becomes available for editing. creating, modifying, or deleting characters, lines, or complete logical pages of text. All commands consist of a single letter or a letter with arguments, and are executed by typing the RETURN key. 3.2 CALLING AND USING THE EDITOR To call the EDITOR from the System Cassette, type: .R EDIT/Options in response to the dot 3.2.1 (.) printed by the Keyboard Monitor. EDITOR Options There are two options available for use with the EDITOiR; these are (Option usage has been previously discussed described in Table 3-1. in Chapter 2, Section 2.4.3). Table 3-1 EDITOR Options Meaning Option TAB when /B Convert two or more spaces reading from input device. /M More than one file will be used for input. (When one of these commands E, F, J, N, R, end-of-file is or Y is issued and an the EDITOR pauses and requests encountered, that the user specify another input file, thus allowing continuation of the command. has not been previously If the /M option specified in the input line, the end-of-file See Section 3.9 condition remains in effect. for an example.) to — — 3-1 . 3.2.2 : Input and Output Specifications After the EDITOR has been called from the System Cassette it asks the input specification as follows for *IN-^JT FILE- The user responds with the input cassette drive number and filename and extension, if any. For example: the input *INP'JT FILE- 1 : ABA . PAL specified, the drive) is If only a filename (and no input cassette assumed; the EDITOR prints the user's is default device drive input specification line, only first it includes the assumed default device before echoing the filename, as illustrated below: — — The user has typed the filename AB, but before this is printed, the If the input file is EDITOR inserts 0: and then goes on to echo AB. not found or if a syntax error occurs, the EDITOR prints a question (*) at the left margin, and waits for types cin asterisk mark (?) , another input designation. Any number of input files is permitted. return only If no input specification is made, (that is, a carriage has been typed in response to the INPUT request) , a new file will be The created using the console terminal keyboard as the input device. EDITOR allows input from the keyboard via the Append command (see Example Using the EDITOR for an illustration of this method of creating a program) If more than one input file is to be entered, the /M option must be specified when the EDITOR is called from the System Cassette. The user responds to the INPUT FILE line with the drive number and filename of the first input file. He enters output information as When the end-of-file is described next, and then edits his file. reached during the editing procedure, the EDITOR again prints the INPUT FILE request cind the user responds with the drive number and filename of the second file. When the user finishes editing his final file and no more input files are available, he responds to the editor's INPUT request by typing a carriage return; the EDITOR continues and closes the output file. All input files are combined under the one filename specified in the output line. The EDITOR initially requests output info:nnation by printing: •O'JTP'JT FILE- 3-2 . The user responds with the output example drive number and filename. For : Again, if no device is designated, drive is assumed and echoed. If the output file is to have the same name as the input file, the user need only type the correct output drive number followed by a carriage return; the EDITOR will echo the assumed name. For example: »IM?'?r FILF.- l sFILJ^.BAS *0 1Ton FILE- ff; FILE.BAS The EDITOR allows only one output file and creates the header for this file on the specified cassette, deleting any file already on that cassette under the same name (and replacing it with "EMPTY in the directory listing) and leaving the cassette correctly postioned for further output. NOTE If no output designation is specified (that is, a carriage return only has besen typed in response to the OUTPUT FILE request) , the only output operations which may be performed are L (list buffer on the console terminal) or V (list buffer on the line printer) Only cassette files in ASCII mode are acceptable for use by the EDITOR. No error message is given if non-ASCII files are input, but the results of editing operations are garbled. Once I/O file designations are entered, the Symbolic EDITOR is ready to accept commands from the keyboard. It signifies this by printing a number sign (#) at the left margin; this symbol occurs whenever the EDITOR is waiting for a command. 3.2.3 Version Numbers Each time a filename is indicated in response to the output file is assigned to it. This number specification line, the number (called the version number) signifies that a new file has been created and that it hcis not been previously edited or referenced under this filename. The user may call a file from a specified cassette, make corrections to it and change it any number of times before he is finally satisfied with it or ready to use it for some other operation. In this case, he may reference the file in the output specification line; by specifying only the output cassette drive number followed by a carriage return, since the filename itself will not be chcinged. Each time he does 3-3 . this, the version number of the file is increased by 1. When the version number of a file has been incremented in this manner so that it is greater than 0, it appears in directory listings on the same line as the filename (see Chapter 2). NOTE Version numbers associated with edited files should not be confused with the V Monitor command, which prints the version of the Monitor currently in use. 3.3 MODES OF OPERATION The EDITOR operates in one of two different text mode. command mode all input In interpreted as commands instructing the operation. In text mode, all typed input replace, be inserted into, or be appended to buffer. 3.3.1 modes: command mode or typed on the keyboard is EDITOR to perform some is interpreted as text to the contents of the text Transition Between Modes Immediately after being loaded into memory and started, the EDITOR is command mode. The special character # is printed at the left margin of the teleprinter page indicating that the EDITOR is waiting for a command. All commands are terminated by pressing the RETURN in key. In text mode, the EDITOR performs I/O operations on text stored within the text buffer. Text is input to the EDITOR buffer until a form feed is encountered. A line of text is terminated by a carriage return. If no carriage return is present, the text entered on the current line is ignored. The buffer has room for approximately 5200 (decimal) When text has been input to the extent that there are characters. only 256 decimal locations available in the buffer, the console terminal rings a warning bell. From this point on, whenever a carriage return is detected during text input, control returns to the EDITOR command mode and the bell is rung. This line-at-a-time input may continue until the absolute end-of-buf fer is encountered. At this point, no more text will be accomodated in the buffer; a "?" is printed and control returns to command mode every time the user attempts to input more text. 3.4 SPECIAL CHARACTERS AND FUNCTIONS A number of the functions, These console terminal keys have special operating keys and their associated functions are described be low 3-4 3.4.1 RETURN Key typing the RETURN key causes a In both command and text modes , carriage return cind line feed operation and signals the EDITOR to process the infoimiation just typed. In command mode, :Lt allows the EDITOR to execute the command just typed, A command will not be executed until it is terminated by the RETURN key (with the exception In text mode, RETURN causes the line of text of =, explained later). which it follows to be entered in the text buffer. A typed line is not actually part of the buffer until terminated by the RETURN key. 3.4.2 Erase (CTRL/U) The erase character (CTRL/U combination) is used for error recoveries It is generated by holding the CTRL in both command and text modes. When used in text mode, key while simultaneously typing the U key. CTRL/U cancels everything to its left back to the beginning of the line; the EDITOR echoes i V and performs a carriage return/line feed (CR/LF) ; the user then continues typing on the next l;.ne. When used in command mode, CTRL/U cancels the entire command; the EDITOR performs a CR/LF and prints a #. The erase character cannot cancel past a CR/LF in either command or text mode. 3.4.3 RUBOUT Key In Rubout is used in error recovery in both command and text modes . text mode typing the RUBOUT key echoes a backslash (\) and deletes the Repeated rubouts delete from right to left up last typed character. to, but not including, the CR/LF which separates the current line from For example: the previous one., THE O'J'JICKWWICK RROW'NJ FOX will be entered in the buffer as: THE O'JICK 3H0\*»:M FOX When used in command mode, RUBOUT is equivalent to the <;TRL/U feature the EDITOR prints a #, performs a and cancels the entire command; CR/LF, and waits for another command to be entered. 3.4.4 Form Feed (CTRL/FORM) A form feed signals the EDITOR to return to command mode. A form feed the CTRL and FORM keys typing generated by character is simultaneously. This combination is typed while in text mode to indicate that the desired text has been entered and that the EDITOR The EDITOR performs a CR/LF and should now return to command mode. 3-5 prints a # in response to a CTRL/FORM to indicate that it is back in command mode. CTRL/G is usually equivalent to CTRL/FORM except in the case of a SEARCH command, as explained in Section 3.8.1. The Current Line Counter 3.4.5 (.) The EDITOR keeps track of the implicit decimal number of the line on The dot (produced by typing the which it is currently operating. period key) stands for this number and may be used as an argument to a command. For example, .L means list the current line; .-1,.+1L means list the line preceding the current line, the current line, and the line following it, then update the dot (current line counter) to the decimal number of the last line printed. The following commands affect the current line counter as indicated: 1. After a Read or Append command, the current line counter is equal to the number of the last line in the buffer. 2. After an Insert or Change command, the current line counter is equal to the number of the last line entered. 3. After a List or Search command, the current line counter is equal to the number of the last line listed. 4. After a Delete commeind, the current line counter is equal to the number of the line immediately after the deletion. 5. After a Kill command, the current line counter is equal to 0. 3.4.6 6. After a Get command, the current line counter to the number of the line printed by the GET. 7. After a Move command, the current line counter is not updated and remains whatever it was before the command was issued. Slash is equal (/) The slash symbol (/) has a value equal to the decimal number of the It may also be used as an highest numbered line in the buffer. argument to a command. For example: 10, /L means list from line 10 to the end of the buffer. 3.4.7 LINE FEED Key Typing the LINE FEED v*iile in command mode is equivalent to typing .+1 and will cause the EDITOR to print the line following the current one and to increment the value of the current line counter by one. 3-6 . 3.4.8 , ALT MODE Key Typing the ALT MODE key while in command mode will cause the line following the current line to be printed and the current line counter to be incremented by one. If the current line is also the last line in the buffer, typing either ALT MODE or LINE FEED will gain a response of ? from the EDITOR indicating that there is no next line. Some console terminals provide an escape key (ESC) in place of the ALT MODE. Their functions are identical. 3.4.9 Right Angle Bracket {>) Typing the right angle bracket (>) while in command mode is equivalent to typing .+1L and will cause the EDITOR to echo > and then print the The value of the current line line following the current line. counter is increased by one so that it refers to the last line printed. 3.4.10 Left Angle Bracket (<) Typing the left angle bracket (<) while in command mode is equivalent to typing .-IL and will cause the EDITOR to echo < and then print the The value of the current line line preceding the current line. counter is decreased by one so that it refers to the last line printed. 3.4.11 Equal Sign (=) or The equal sign is used in conjunction with the pointer's dot (.) IVhen typed in command mode the equal sign causes the slash (/) , In EDITOR to print the decimal value of the argument preceding it. this way the user may determine the number of the current line (.= ) or the number of , or the total number of lines in the buffer (/= some particular line (/-8= ) without counting lines from the beginning No carriage return need be typed following the equal of the buffer. ) sign. 3.4.12 Colon (:) Typing a colon produces the same result as the equal sign 3.4.13 (=) Tabulation (CTRLAAB) The EDITOR is written in such a way as to simulate tab stops at 8-space intervals across the teleprinter page. When the CTRL key is held down cind the TAB key is typed, the EDITOR produces a tabulation. A tabulation consists of from one to eight spaces, depending on the Thus, the number needed to bring the carriage to the next tab stop'. 3-7 : : EDITOR may be used to produce neat colutnns on the teleprinter or line printer page. The tab function is used in conjuction with the /B option (for input and output) to allow the user to produce cind control tabulations in the text buffer during input operations. On input (under a Read command) , the EDITOR will replace a group of two or more spaces with a tabulation if the user has specified the /B option. 3.5 COMMAND STRUCTURE A command directs the EDITOR to perform a desired operation. Each command consists of a single letter, preceded by zero, one, two or three arguments. The commemd letter tells the EDITOR what operation to perform; the arguments usually specify which numbered line or lines of text are affected. Command format is illustrated in Table 3-2, where E represents any command letter. Table 3-2 Command Format Type of Command Command Format No Argument: E Perform operation E One argument nE Perform operation referenced line. Two Arguments m,nE Perform operation E through n, inclusive. Three Arguments: m,n$jE 3.6 Meaning on on the lines m This combination is used by the MOVE command only and is explained in Section 3.6.3. COMMAND REPERTOIRE Commands to the EDITOR are grouped under three general headings: Input Commands Output Commands Editing Commands Explanation of the three types of commands is detailed in the following sections. Each command description will state if the EDITOR returns to command mode after completing the operation specified by the command. All commands are entered when the RETURI^ key is typed. The EDITOR prints an error message consisting of a question mark whenever the user has requested nonexistent information or used inconsistent or incorrect format in typing a command. For example, if command requires two arguments, and only one (or none) is provided, a and the EDITOR will print ?, perform a carriage return/line feed, Similarly, if a nonexistent command ignore the command as typed. character is typed, the2 error message ? will be printed, follov/ed by a However, if carriage return/line feed; the command will be ignored. 3-8 an argument is provided for a commmand that does not require one, the argument will be ignored and the normal function of the commmand For example: performed. Result: User Types: The buffer is empty. The user is asking for nonexistent information. L ? The arguments are in the wrong order. EDITOR cannot list backwards. 7,5L ? ? This command requires two arguments before the $; only one was provided. H The user types a nonexistent command letter. 17$10M 3.6.1 The Input Commands Two commands are available for inputting text, and Table 3-3. are described Table 3-3 Input Commands Command Format #A Action and Explanation Append the incoming text from the console terminal keyboard to the information (if there is no already in the buffer input file the buffer will be empty initially) . The EDITOR will enter text mode upon receiving this command and the user may then type in any number of lines The new text will be appended to of text. if the information already in the buffer, (CTRL/FORM key until a form feed any, typed; control then combination) is returns to comniand mode. By using the Append command with an empty buffer, a symbolic program may effectively the be generated on-line by entering program via the keyboard. Any rubout encountered during execution of delete the last an Append command will Repeated rubouts will typed character. delete from right to left up to but not beyond the beginning of the current line. in . Table 3-3 Input Commands (Cont'd) Command Format R #R Action and Explanation Read a page of text from the input file on the specified unit drive. The EDITOR will read information from the input file until form feed character a (CTRL/FORM key combination) is detected or until the EDITOR senses a text buffer full condition. All incoming text except the form feed is appended to the contents of the text buffer. Information already in the buffer remains there. NOTE In both these commands, the EDITOR ignores ASCII codes 340 through 376. These codes include the codes for the lower case alphabet (ASCII 341-372) The EDITOR returns to command mode only after the detection of a form feed or when a buffer full condition is reached. 3.6.2 Output Commands Output commands are subdivided into list and text transfer commands. List commands will cause the printout of all or any part of the contents of the text buffer to permit examination of the text. Text transfer commands provide for the output of form feeds, corrected text, or for the duplication of pages of an input file. List or text transfer commands do not affect the contents of the buffer. List Commands The commands in Table 3-4 cause part or all of the contents of text buffer to be listed on the console terminal or line printer. Table 3-4 List Commands Command Action and Explanation Format L #L LIST the entire page. This causes the EDITOR to list the entire contents of the text buffer on the console terminal. L #nL LIST line n. followed by feed. 3-10 This line will be printed a carriage return and a line the . Table 3-4 List Commands (Cont'd) Command Action and Explanation Format L #m,nL LIST lines m through n console terminal. V #V V V inclusive on the List the entire text buffer on printer (if one is available) the line #nV List line n of printer. the line #ra,nV List line m through line printer. on the the buffer n on inclusive The EDITOR remains in command mode after a list command, and the value of the current line counter is updated so as to equal the number of the last line printed. Text Transfer Commands The following commands control the output of text and form feeds. The EDITOR is designed to minimize the possibility of illegal or meaningless characters being written into a source file; therefore the illegal (nonexistent) codes 340-376 and 140-177, and most illegal control characters will not be output. Tcible 3-5 Command Text Transfer Commands Action and Explanation Format E #E Output the current buffer to the output file and transfer all input to the output file; close the output file. P #P Transfer the entire contents of buffer to the output buffer. P #nP Transfer line n only to the output buffer. P #m,nP Transfer the text lines m through n inclusive m must be less than n) to the output buffer. When the output buffer becomes full, the text is output to the indicated output file. The P command automatically outputs a FORM character (214) after the last line of output. (where N #N Transfer the contents of the text buffer to the output buffer, delete the text buffer and read in the next logical page of text from the input file. 3-11 . Table 3-5 Command Format Text Transfer Commands (Cont'd) Action and Explanation Execute the above sequence n times If n is greater than the number of pages of input text, the command will proceed in the specified sequence until it reads the end of the input file, then it will return to command mode. #nN . The N command cannot be used with an empty text buffer. A ? is printed if this is attempted. Immediate end-of-file. The Q command causes the entire text buffer to be output. All text written into the output buffer is then written into the output file and the file closed, with control returning to the Cassette Keyboard Monitor. #Q 3.6.3 Editing Commands The following commands permit deletion, alteration, text in the buffer. or expansion Table 3-6 Editing Commands Command Format Action and Explanation #B List the numlber of available memory locations in the text buffer. The EDITOR returns the number of locations on the next line. To estimate the number of characters that can be accomodated in this area, multiply the number of free locations by 1.7. #nC Change line n. Line n is deleted, and the EDITOR enters text mode to accept input. The user may n aw type in as many lines of text as he des ires in place of the deleted line. If more than one line is inserted, all subsequent lines will be automatically renumbered and the line count will be updated app ropriately. A CTRL/FORM terminates the command #m,nC Change lines m through n inclusive (m must be numbered less the n) . Lines m through n are deleted and the EDITOR enters text mode allowing the user to type in any All number of lines in their place. subsequent lines will be automatically 3-12 of . Teible 3-6 Command Format Editing Commands (Cont'd) Action and Explanation renumbered to account for the; change the line count will be updateid. and After any Change operation, a return to command mode is accomplishesd by typing a CTRL/FORM. After a Change, the value of the current line counter is equal to The C the number of the last line input. command utilizes the Text Collector in altering text (see Section 3.7). ( D . ) #nD Line n is removed from the Delete line n. text buffer. The current line counter and the numbers of all succeeding lines are reduced by one. #m,nD Delete lines m through n inc:lusive. The space used by the line to be deleted is reclaimed as part of the Delete function (refer to Section 3.7, Text Collection). #F Find the Used during a string search. next occurrence of the string currently being searched for (see Section 3.8.2, Inter-Buffer Character String Search) #G Get and list the next line which has a label associated with it. (A label in this context is any line OJ: text which does not begin with a space, slash, TAB, The EDITOR begins with the or RETURN) . line following the current l:.ne (line .+1) and tests for a line with a label. This will most often be a line beginning with a tag; it might also be a line containing an origin. For example: TAD nCA (This is line) the current /THIS IS A COMMENT (This line would be printed by the command G) TAD (This line would also be printed if another G were typed) *5P10'1 #nG Get and list the next line which begins with a label; the EDITOR begins at line n and tests it and each succeeding line as described in the preceding example. 3-13 . . . . Table 3-6 Editing Cominaiids (Cont'd) Conunand Format Action and Explanation Both G and nG update the current line counter after liinding the specified line. However, if either version of the GET command reaches the end of the buffer before finding a line beginning with an ASCII character other than a tab, slash, or space, the current line counter retains the value it vras assigned before the GET was issued, and a ? is typed to indicate that no tagged line was found. The EDITOR remains in conunand mode after a GET command I #nl Insert the typed text before line n until a form feed (CTRL/FORM) is encountered. The EDITOR enters text mode to accept input. The first line typed becomes the new line n. Rubouts are recognized. Both the line count and the numbers of all lines following the insertion are increased by the number of lines inserted. The value of the current line counter is equal to the number of the last line inserted. To re-enter command mode, the CTRL/FORM key combination must be typed (terminating text mode) . If this is not all subsequent commands will be done, interpreted erroneonusly as text and entered in the program immediately after the insertion. I #1 Insert text before without an argument) J #J Initiate an inter-buffer string search (See Section 3.8.2, Inter-buffer Character String Search) K #K Kill (delete) the entire page in the buffer. The values of the special characters (/) cind (.) are set to zero. The EDITOR remains in command mode. line 1 (when NOTE The EDITOR ignores the commands nK or m,nK. This prevents the buffer from accident ly being destroyed if the user intended to type a List command (m,nL) 3-14 used ) . Table 3-6 Editing Commands (Cont'd) Command Format M #m,n$jM Action and Explcination Move lines m through n inclusive to before line j (m must be numerically less than n and j may not be in the range between m and n) . Lines m through n are deleted from their current position and are inserted before line j . The lines are renumbered after the move is completed although the value of the current line counter (,) is uinchanged, as moving lines does not use any additional buffer space. (The $ character is produced by typing a SHIFT/4.) A line or group of lines may be moved to the end of the buffer by specifying j as For example, 1,10$/+1M. /+1. Since the MOVE command requires three arcjuments , it must have three arguments in orcier to move even one line. This is done by specifying the same line number twice. For example, 5,5$23M. This will move line to before line 23. The EDITOR remains in command mode after a Move command. :> #nS Search line n for the character specified after typing the S and a carriage return. Allow modification of the line when the character is found. (See Section 3.8.1, Single Character String Search. #nY Skip to a logical page in the input file, without writing any output. For example, This command reads through 4 #5y. logical pages of input, deleting them without producing output. The fifth page read into the text buffer and control is automatically returns to command mode. If there are no more pages of input, the EDITOR issues a ? and returns to command , mode. #$TEXT" #$TEXT' #" Perform a character string search for the string TEXT (see Section 3. 8.. 2, IntraBuffer Character String Search) Following a string search, #" causes a search for the next occurrence of the string. 3.7 TEXT COLLECTION The CAPS-8 EDITOR contains an automatic text collector which reclaims buffer space following the use of a D, S, or C command. If a full 3-15 (using buffer condition is reached, the user may output lines of text and then delete these lines from the for example) the P command, buffer— text collection is automatic and always occurs on the three commands mentioned above. , NOTE If extremely large amounts of text are deleted, the text collection process could take several amounts text, For small of no seconds. appreciable time is lost. 3.8 CHARACTER SEARCHES — Two types of searches were mentioned in Table 3-6 the standard character search and the character string search. Each is explained in turn. 3.8.1 Single Character Search The single character search may take one of the following forms: #S or #nS or #m,nS where m and n represent line numbers (m<n) , and S initiates the search This command searches the entire text buffer (or the line(s) command. The search character is typed by indicated) for the search character. the user after he types the RETURN key which enters the command, aind The EDITOR prints the contents of does not echo on the teleprinter. the entire buffer or the indicated line(s) until the search character When the search character is found, printing stops and the is found. user types a response chosen from the following table: Table 3-7 Search Character Options Result Option Enter text at that point at which the search character was found and printing Sitopped. text CTRL/G (bell rings) Change the; search character to the search typed; character next continues. If the character is not line , the in the contained remainder of the line will be typed and control will be returned to (For example, CTRL/G command mode. CTRL/G would cause the remainder of the line to be listed.) 3-16 ) Table 3-7 Search Character Options (Cont'd) Result Option 3.8.2 CTRL/FORM Continue searching for the occurrence of the character. next RETURN key End line here, deleting subsequent text on that l;.ne. all LINE FEED key Make two lines out of the current line. Typing a line feed actually inserts a carriage return without returning control to command mode. RUB OUT key Delete characters from th«: line. A rubout echoes a backslassh (\) for When all each character deleted. characters have been deleted, echoing of "V stops. Character String Search The character string search can identify a given line in the buffer by the contents of that line or any unique combination of characters. This search returns the line number as a parameter that can be used to There are two types of string search further edit the text. available: intra-buffer search and inter-buffer search. Intra-Buffer Character String Search The intra-buffer search scans all text in the current buffer for a If the string is not found, a ? is specified character string. If the str ing is found, printed and control returns to command mode. the number of the line which contains the string i s put into the current line counter and control waits for the user to issue a searching for a character string in this manner command. Thus, furnishes a line number which can then be used in con junction with other EDITOR commcinds. This provides a useful framework for editing, as it eliminates the need to count lines or search for 1 ine numbers by listing lines. (which An intra-buffer search is signalled by typing the ALT MODE key The user in response to the # printed by the EDITOR. echoes as $) then types the string to be found (as many as 20 characters may be specified any additional characters typed are echoed but not included The search string cannot be broken across line in the search) . (') terminates the character Typing a single quote boundaries. string; when the RETURN key is typed the search is performed beginning Use of the double quote (") causes the line 1 of the text buffer. at and " as command (Use of search to begin at the current line +1. elements prohibits their use in the search string. An incorrect response resets the current line counter to the becfinning of the buffer. — ' 3-17 : For example, assume the text buffer contciins the following text: ABC DEF bJO lAaB3C4D5E6 .STRINtaABCD The user wants to list the line that contains ABC; this could be by typing: done #$ARC'L The search begins with line 1 and continues until the string is found. The current line counter is set equal to the line in which the string ABC occurred, and the L command causes the line to be printed as follows ABC DEF CJJO Control returns to command mode, awaiting further commands. user wanted to find the next reference to ABC, he could type: If the r-L In this case, " is a command which causes the last string searched for to be used again, with the search beginning at the current line +1. It is not necessary to enter the search string again. The command may be used several times in succession. For example, if the user wanted to find the fourth occurrence of a string containing the characters FEWMET he could type: #$ FEWKET"""'L This command lists the line which contains the fourth occurrence of that string. The L (List) command (or amy other command code) can be given following either or ". The L command causes the line to be listed when and if it is found. ' In order to clear the text string buffer, the user can type: The system responds with a question mark and the text string buffer is cleared. and " allow for easy and useful The properties of the commands example illustrates. In order to change CIF editing, as the following 20 to CIF 10, the user can issue the following commands: ' 3-18 : #$D'JM, '$CIF 30"C 1'3 /'MEW FIi;LD (CTRL/FORM) GIF The above set of instructions first causes the EDITOR to start at line and search for a line beginning wi1ji DUM,. A search is then made 1 for GIF 20, starting from the line after the line containing the string DUM, . When this string is found, the line number of the line containing the string GIF 20 becomes the current line number. The G command is given, and the user then changes the line to the correct instruction, GIF 10 /NEW FIELD . Since this search feature produces a line number as a result, any operations which can be done by explicitly specifying a line number can be done by specifying a string instead. For example: will list the fourth line after STRING in the text buffer. the first occurrence the of text £$LABEL1, '^LABELa^-L will list all lines between the two labels, inclusive. will do a character search on the line which contains PFLUG. (The user types the search character after typing the :return key that enters the line.) In cases where both strings and explicit numbers are used, "should be used first. For example, the following commands: strings #l+SnAD! 'L will not list the next line after the string BAD! occurs. syntax is The correct #?V3AD! • +1L Inter-Buffer Gharacter String Search The inter-buffer search scans the current text buffer for a character string. If the string is not found, the current buffer is written to the output file, the buffer is cleared, and the next buffer is read from the input device. The search then resumes at line 1 of the new buffer. This process continues until either the string is found or no If input is exhausted, control returns to command more input is left. mode with all the text having been written to the output file. If the string is found, control returns to command mode with the current line equal to the numlDer of the line containing the first occurrence of the string. For example, a command to find the character string GONZO may 3-19 appear as follows: SliOIVZO' #.=002^ the $ is printed The J conunand initiates an inter-buffer search; automatically by the EDITOR, and the user types in the character string he wishes to search for. The search proceeds, and when the string is found, control returns to cormiand mode. The user types the .= construction to discover the number of the line in the current buffer on which the string is contained. To find further occurrences The F command of the string GONZO, the user can use the F command. uses the last character string entered to search the buffer starting from the current line count +1. #.= 3106 The above example causes a search for the string GONZO starting at the If no output file is specified in the J or F current line +1. commands , the EDITOR reads the next input buffer without attempting to produce any output. This provides an easy way of paging through text for a particular string. After the J or P commands have processed the entire input file, or Q command must be executed to close the output file. The following two commands may be used command, once given: to abort the string an search Table 3-8 Terminating a String Search Explanation Command CTRL/U A CTRL/U will return control to the EDITOR command mode if executed while string search entering text in a command; the string search command is ignored, as in the following example: #J SWORDtfJ the search for inter-buffer The characters W0:RD was aborted by the user typing fU before terminating the string or ". with ' RUB OUT Executing the RUBOUT key while entering text for use in a string search causes the text so far entered to be ignored and allows a new string to be inserted. The EDITOR answers the command by typing 3-20 E Table 3-8 Terminating a String Search (Cont'd) Command Explanation $, as seen in the following example: jfSCHAR (RUBOUT) S An example of the use of the character string search is contained the EDITOR Demonstration Run found at the end of this chapter. 3.9 in EDITOR ERROR MESSAGES Errors made by the user while running the EDITOR may be of two types. Minor errors (such as an EDITOR command string error, an attempt to execute a read or write command without assigning a device, or a search for a nonexistent string) will cause a question mark to be typed at the left margin of the teleprinter paper. The command may be retyped. Major errors force control to return to the Keyboard Monitor and may be due to one of the causes listed in Table 3-9 . These errors cause a message to be typed in the form: ?n+C where n is one of the error codes in Table 3-9 and '^C indicates that control will pass to the Keyboard Monitor when a character is typed. Table 3-9 EDITOR Error Codes Error Code Meaning The EDITOR failed in reading from a An error occurred in the device device. handler; likely most hardware a malfunction. 1 2 The EDITOR failed in generally device; malfunction. writing a onto a hardware A file close error occurred. The output file could not be closed; either the cassette reached an end-of-tape condition, or a sentinel file needs to be written before any new output files can be created on the cassette. 3-21 time the EDITOR encounters a syntax error. In euiy addition, the following error message may be printed by the EDITOR: A ? occurs Meaning Message UNIT HAS OPENED FILE Two files cannot be open on the same device at the same time. During the editing of a file, the output cassette specified in the is command string may become full before the editing process completed. If this is the case and further writing is attempted on that cassette, cin error occurs. The output file is closed and the message: FULLi-OUTPUT FILE- The user must now indicate a new output cassette and file is printed. which will contain the text that would not fit on the first cassette Since the contents of and any further editing the user wishes to do. the text buffer are retained through this procedure, no text will be lost if this error occurs. NOTE If no output file is specified when this occurs, the EDITOR again condition requests an output file; this continues output designation is until the correctly specified. Assuming the new output device is valid, the EDITOR will continue the operation which filled the old file, putting all output into the new output file. After editing is completed, the output files should be The entire process may then appear as combined using the EDITOR. follows: ^R EDIT flNPUT FILE- 0;IN ^OUTPUT FILE- 1; OUT #Y SSTRING' FULL OUTPUT FILE-2 t OUTEWP #.L Device 1: is full. 2: is specified as the new output device and editing continues. TAD STRING #.D #E 3-22 — When At this point the output "file" is 2 files 1:0UT, 2:0UTEMP. output is split like this, the split may have occurred in the middle Therefore, the output files should never be edited of a line. In a case such as separately as the split lines will then be lost. this, the files should be combined with the EDITOR as follows: ^R EDIT/M »INPUT FILE- : OUT OUTPUT FILE- 5;0UT l *E INPUT FILE- 2;0UTEMP INPUT FILEThe new file, OUT, may then be edited. 3-23 3.10 EDITOR DEMONSTRATION RUN The following example illustrates both the use of the EDITOR to create a new file an(a a few of the commands available for editing. Sections of the printout are coded by letters which correspond with the explanations following the example. .R EDIT INPUT FILEOUTPUT FILE-0:PROO.PAL #A CHRPUT ,0 SNA J MP CDF OCA TAD SPC JMP SNA JMP I CHRPUT /ACCEPTS CHAR IN AC AND /PACKS IT INTO OUTPUT BUFFER /IGNORES NULL SHELF WI\HATl PUT#1 CLO PUT#2 CM A OCA WHATl #.-5S SNA CLO\A #.L SNA CLA #P #K #A TAD SHELF AND (360 CLL RTL #E ^R EDIT INPUT FILE- 0;PRQG.PAL OUTPUT FILE-1 : PROG. PAL #R ISSPC'L SPC #•5 SPC\A #E 3-24 A The user calls the EDITOR; the output file will be called PROG, PAL and will be stored on the default dcjvice—cassette drive 0. There is no input file since one will be created from the console The Append command terminal keyboard. is used to insert text into the empty buffer. B Text is inserted. C The user makes a mistake RUBOUT key to correct it D More text is added. E The user notices a typing mistake he has made several lines back in the text. He types a CTRL/FORM to finish the Append illegal for the searchs command, character, corrects it, and then lists the line. F The P command writes the current buffer into the output file placing a form feed The K command after the last line. deletes all text in the current buffer in preparation for a new page of text. G The user inserts new text using the Append command. When he is finished he types a CTRL/FORM to end the command. H file; The user closes the Cassette the returns to Monitor. I the user In looking over the listing, notices einother mistake; he opens the in file, calling it by the same name both the input and output specification lines. J The Intra-Buffer Character String Search illegal the locate to used is instruction and list it. K The Single Character Search is used to find the letter to be corrected, and the RUBOUT key deletes it. L The file is closed and control returns to the Keyboard Monitor. 3-25 and uses the control Keyboard again CHAPTER 4 SYSTEM COPY 4.1 INTRODUCTION The CAPS-8 System Copy (SYSCOP) program allows the user to copy individual files or all files from one cassette to another, giving him the ability to make multiple copies of a cassette, add files to a cassette, emd "clean up" full cassettes so that they may become available for future use. System Copy transfers all non-empty files on the specified input cassette to the specified output cassette; space taken up by previously deleted files (*EMPTY files) is regained. (Single file transfers of ASCII files can be performed using the CAPS-8 EDITOR; see Chapter 3.) 4.2 CALLING AND USING SYSTEM COPY To call SYSCOP from the System Cassette, the user types: .R SYSCOP/Options in response to the dot 4.2.1 (.) printed by the Keyboard Monitor. System Copy Options There are three options available for use with System Copy; these options are discussed in Table 4-1.. (Option usage is explained in Chapter 2, Section 2.4.3.) Table 4-1 System Copy Options Option Meaning /F This option allows the user to transfer individual cassette files from one cassette to another. To use the /F option, the user responds to the request specification with the for input cassette drive number and the name of the file to be copied. If the user mcikes a typing error while entering the input specification, he can type CTRL/U to redo the entry. /U drive 1 If the /U option is specified, is copied to zeroed and then drive is is especially (The /U option drive 1. useful for making copies of the System Cassette.) When the /U option is used, specifications are further I/O no necessary. /Z This option causes the output drive (indicated in thes output specification line) to be zeroed before any copying begins. 4-1 4.2.2 Input and Output Specifications Before indicating the input and output drives to be used for the copy operation, the user must ensure that the proper cassettes are mounted. The input cassette (the one to be copied) should be write-locked to protect the data. The output cassette (the one that will be the new copy) should be write-enabled to receive the data. When the input and output cassettes are mounted on the correct drives, the user is ready to begin the copy operation. After SYSCOP has been called from the System Cassette, it asks for the input specification as follows: IN- The user responds with a single digit (0 through 7) specifying the input cassette drive number. A carriage return is not necessary. If the /F option was used, the user responds to the IN- query with the drive number and the name of the file to be copied; in this case, the user must also type a carriage return. In the following example, a file named ECHO is to be copied from drive 1. IN-:ECHO After the input specification has been entered. System the output specification as follows: Copy requests OUT- The user responds with a single digit (0 through 7) specifying the output drive number. The output drive number cannot be the same as the input drive number. If the user wishes to change the input/output specifications at this point, he may type a carriage return instead of the drive number eifter OUT- to return to the IN- message. After both input and output drives have been indicated, the copy operation starts. All non-empty files on the input cassette are copied, in order, onto the output cassette. (If a file is to be copied onto a cassette under the same filename and extension as one already present on the cassette, it will still be copied; however, future reference to the file will cause the first file under that name to be accessed. To circumvent this condition, the user should first delete any old files or 2ero the output cassette.) IVhen all files have been copied, control returns to the Keyboard Monitor. 4-2 through 7 are accepted in Only two responses other than the digits reply to the input/output specification messages: carriage return and CTRL/C. Carriage return returns the user to the input specification message; CTRL/C returns the user to the Keyboard Monitor. Any other response is considered illegal. Illegal responses are neither accepted nor echoed by System Copy; System Copy simply waits for the user to type a legal response. System Copy Example 4.2.3 In this example, the user wishes to make a copy of the System Cassette which is mounted on drive 0. One purpose of the copy operation is to A regain wasted space being taken up by previously deleted files. directory listing shows that the System Cassette currently contains the following files : C2B00T.BIN M0NTOR.BIN SYSCOP.BIN *EMPTY. 01/22/73 01/22/73 01/25/73 EDIT PALC BASIC 01/02/73 01/02/73 .BIN .BIN .BIN 01/l()2/73 EMPTY. EMPTY. EMPTY. EMPTY. ABC . 01/22/73 The user mounts a write-enabled cassette on drive He than calls System Copy as follows tape. 2 and rewinds the : _j_R SYSCOP/Z The /Z option will zero the cassette mounted on the cassette drive specified in the OUT- message (drive 2) , leaving only the sentinel System Copy then requests the input and output file on the cassette. drive numbers and the user responds as follows: INQ UT- 2 If System Copy detects any problems during The copy operation starts. the copy operation, it prints one of the error messages explained in Section 4.3. A successful copy operation returns control to the The user can then issue a Directory command to Keyboard Monitor. example, a In this ensure that all files were copied correctly. successful copy operation should produce the following directory listing: C2B00T.BIN MONTOR.BIN SYSCOP.BIN EDIT PALC BASIC .BIN .BIN .BIN ABC . 01/22/73 01/22/73 01/25/73 01/02/73 01/02/73 01/02/73 01/22/73 4-3 4.3 SYSTEM COPY ERROR MESSAGES Errors which occur during a System Copy operation may be of two types : user errors and cassette errors. User errors may be corrected with Cassette errors the appropriate action as detailed in Table 4-2. normally require the user to use cinother cassette (for either input or Control does not return to output) to complete the copy operation. The user may the Keyboard Monitor when a System Copy error occurs. use CTRL/C to return to the Monitor if he cannot correct the indicated error. Table 4-2 System Copy Error Messages Meaning Message INPUT ERROR ON UNIT n An input error has occurred on the cassette drive specified. The user should try the copy operation using another cassette. UNIT n NOT READY There is either no cassette on the cassette drive specified or no such drive exists. UNIT n WRITE LOCKED The user tried to write data when protect tab of the the write cassette on the drive specified was write-locked. OUTPUT ERROR ON UNIT n An output error has occurred on the The user cassette drive specified. should try the copy operation using another cassette. 4-4 . CHAPTER 5 PALC 5.1 INTRODUCTION PALC (an acronym for Program Assembly Language for Casse:tte) is an 8K 2-pass assembler (with em optional third pass) designed for the CAPS-8 System. A program written in PALC source language is translated by the assembler into a binary file in two passes. Pass 1 reads the input file and sets up the symbol table; pass 2 reads the input file and uses the symbol table created in pass 1 to generate the binary (object) file. The binary file may then be loaded into memory using the Cassette Keyboard Monitor. PALC allows I/O using any CAPS-8 device which handles ASCII text. It from the System Cassette using the Keyboard Monitor Rian is called command, accepts input generated by the CAPS-8 EDITOR, eind will generate output acceptable for use with both the Monitor Load and Run commands 5.2 CALLING AND USING PALC The user calls PALC from the System Cassette by typing; ^R PALC/Options PALC responds by printing: -INPUT FILES The user enters his input cassette drive number cind filename in answer to the asterisk printed by PALC; a total of three input specifications are allowed, so that the input interaction may appear as follows: -INPUT FILES *1 :TaA.PAL *0»THB.PAL jtllTKC.PAL Usually input files will contain the extension .PAL (see Chapter 2, Section 2.2.2), and PALC will assume this extension unless the user explicitly designates another. Thus in the above example the user may have responded by typing only 1:TRA, 0:TRB, and 1:TRC, in which case PALC would automatically assume and echo the .PAL extension. If the filename contains an extension other than .PAL, the user specify this extension when entering the input. For example: -INPUT FILES tFAIL.I jtS t TABLE .ASC .tf ISHOR. jfel 5-1 must In the case of the third input file (SHOR.) an extension is not to be indicated. If the user wants to prevent PALC from assuming .PKL, he must be sure to include a period in the input line; otherwise PALC will append .PAL and look for the filename with that extension. input line, the If the user does not specify a drive numtier in his device drive is assumed. PALC will automatically insert filename as the user has the 0: in the input line before echoing entered it. For example: default — — 0 8FLOA.HAL PALC assumed both The user actually typed only the characters FLOA; and the .PAL extension and correctly inserted these the drive number in the I/O line before echoing the complete line. A carriage return typed in response to any of the asterisks that there are no more input files. After the input specifications have been entered, binary output as follows: PALC indicates requests the -BINAHY FILE The user responds similarly here by indicating an output drive number Only one binary file is allowed and it should have the and filename. extension .BIN (since the Monitor Run and Load commands assume this If the user wants his binary file to be called by the extension) . same name as the first input file he need only type the drive number, PI<LC will echo this, adding the and a carriage return. a colon, For example: filename with a .BIN extension. -INPUT FILES *l : OPEN. HAL -BINARY FILE *e tOFEN.BIN and the extension (.BIN) are assumed if As in the input line, drive the user fails to specify them, and a response of only a carriage return indicates that no binary file is to be produced. Once the binary output line has been ansv/ered, PALC prints; -LIST TO The user has a choice of sending his output listing to either the console terminal or the line printer. To send output to the console terminal the user types the characters TTY in response to the asterisk as follows: -LIST TO *TTY 5-2 To send output to the line printer, the user responds by typing LPT: -LIST TO JtLPT A response of a carriage return indicates that no listing is to be produced. During a PALC assembly only one listing is produced and it may be sent to only one device, either the line printer or console terminal. A second listing must be produced by another assembly. If more cassettes are to be involved in the assembly than the user has TU60 unit drives, a certain procedure must be followed during the assembly process. For example, assume the user has only one TU60 dual cassette unit, and 3 input files are stored on individual cassettes. His I/O specification is as follows : -INPUT FILES *1 !F1 .PAL j!l0:F2.PAL *0:F3.PAL -BINARY FILE ±\ :RESLT.BIM - UIST TO *LPT PALC is a 3-pass assembler, therefore all three input files will be referenced 3 times. Assume the user has mounted IrFl.PiVL on drive 1, and 0:F2.PAL on drive 0; assembly begins. First the file Fl is processed, then F2 . After assembly of F2 PALC looks for F3, but since the file is on a third cassette which is not mounted, the assembly pauses and PALC prints: MOUNT FS.PAL'f This pause in the assembly allows the user to dismount a cassette and replace it with the cassette containing the file F3.PAL. The user then responds to the above I/O line with the drive niimber on which he has mounted the new cassette (assume 0), as follows: MOUNT F3.PAL70 is valid, PALC responds by typing a CR/LF and If the response continues pass 1 of the assembly. (An invalid response causes PALC to print a ?; the user may then type the correct response.) When pass 1 is completed PALC automatically begins the second pass, which creates the binary file. The binary output file specification must now be made. Regardless of the output specification indicated in the initial dialogue, PALC pauses and asks: MOUNT iiESLT.BIN? 5-3 : . The user must mount the output cassette which is to contain the binary file and respond with the drive numhier on which he has mounted it. Assume he decides to mount the cassette on drive 0. He replaces the cassette currently on that drive (containing F3.PAL) with the new cassette amd responds to the command line as follows: KOJNT HESLT.BIN7 PALC then opens the binary file on this cassette and prints: BINAHY FILE OPENED ON NOTE The cassette used for binary output may not contain any of the input files. Under no circumstances should the cassette containing th€! binary file be removed from the drive until pass 2 is completely finished. PAIiC will indicate completion of the pass by printing the message, "BINARY FILE CLOSED". After specification of the binary output file, PALC continues pass 2 of the assembly by processing the first input file, Fl.PAL, currently on drive 1. After this file is processed, PALC pauses smd asks: MOUNT F2.PAL? is only partially Since the binary file being created on drive complete at this point, the user musst not remove the cassette from that drive. He must instead remove the cassette from drive 1 and replace it with the cassette containing F2.PAL, He then types 1 in response to the I/O line and assembly continues until F3.PAL is needed. PALC again pauses and asks MOUNT F3»PAL? Again the user replaces the cassette on drive 1 with the appropriate one, correctly answers the I/O line, and assembly continues. — — Once pass 2 is done, pass 3 the listing pass must be processed. may again be used for input, cind assembly of input files Drive continues in the same manner as during passes 1 and 2 The procedure of mounting and dismovinting cassettes may be repeated as many times as necessary until all input files are processed and the during any of the If an I/O error occurs desired output produced. three passes or if an output cassette becomes full, the user must restart the assembly beginning with pass 1. 5-4 . , . . NOTE When the assembly is complete, PALC tC prints (CTRL/C) . The user then mounts the system cassette and types CTRL/C to return to the Monitor. 5.2.1 PALC Options Table 5-1 lists the options available in PALC which may in the Monitor Run or Load specification line. Option 5.3 be Table 5-1 PALC Options Meaning /D Generate a DDT- compatible symbol table (applicable only if a listing file is specified) /H Generate non-paginated output. Header, numbers page and page format are suppressed (applicable only if a listing file is specified) /K Used in assembling very large programs; causes system containing 12K or more of memory to use fields 2 and up as symbol table storage. /N Generate the symbol table, but not the listing (applicable only if a listing file is specified; the /H option is assumed) /S Omit the symbol table normally generated with the listing (applicable only if a listing file is specified) /T Output a carriage return/line feed in place of the form feed character (s) in the program (applicable only if a listing file is specified) CHARACTER SET The following characters are acceptable as input to PALC: 1. The alphabetic characters: A through 2. The numeric characters: 3. The characters described in following sections as special characters and operators through 5-5 Z 9 indicated 4. Characters which are ignored during assembly such as LINE FEED, FORM FEED, and RUBOUT All Other characters are illegal (except when used in a cause the error message: comment) and IC AT nnnn to be printed during pass 1; nnnn represents the location at which the illegal character occurred. (As assembly proceeds, each instruction is assigned a location determined by the current location counter (see When an illegal character or any other error is Section 5.7.3). encountered during assembly, the value of the current location counter is returned in the error message.) Illegal characters do not generally If an illegal character occurs in the middle cause assembly to halt. of a symbol, the symbol is terminated at that point. 5.4 STATEMENTS PALC source programs are usually prepared on the console terminal Each statement (using the CAPS-8 EDITOR) as a sequence of statements. typing the RETURN is written on a single line and is terminated by key. There are four types of elements in a PALC statement which are identified by the order of their appearance in the statement and by the separating (or delimiting) character which follows or precedes the These are: element. label, instruction operand /comment A statement must contain at least one of these elements and may contain all four types. The assembler interprets and processes the statements, generating one or more binary instructions or data words, or performing an assembly process. 5.4.1 Labels A label is the symbolic name created by the programmer to identify the If present, the Icdjel is location of a statement in the program. It must begin with cm alphabetic written first in a statement. character, contain only alphanumeric characters, and be terminated by no intervening spaces between any of the a comma; there must be characters and the comma. 5.4.2 Instructions An instruction may be one or more of the mnemonic machine instructions (Assembly or a pseudo-operation which directs assembly processing. pseudo-ops are described later in this chapter; Appendix C summarizes both the mnemonic machine instructions and pseudo-ops used by PALC.) Instructions are terminated with one or more spaces (or tabs if an 5-6 operand follows) or with a semicolon, slash, or described in Section 5.5.3. 5.4.3 carriage return, as Operands Operands are the octal or symbolic addresses of an ass£>mbly language instruction or the argument of a pseudo- operator, and can be any expression. In each case, interpretation of an operand depends upon the instruction or the pseudo-op. Operands are terminated by a semicolon, slash, or carriage return. 5.4.4 Comments The programmer may add notes or comments to a statement by separating these from the remainder of the line with a slash. Svich comments do not affect assembly processing or program execution but are useful in the program listing for later analysis or debugging. The assembler ignores everything from the slash to the next carriage return. (For an example see Section 5.5.3, Statement Terminators.) It is possible to have only a carriage return on a line, resulting a blank line in the final listing. No error message is given. 5.5 in FORMAT EFFECTORS The following characters are useful in controlling the format of an assembly listing. They allow a neat readable listing to be produced by providing a means of spacing through the program. 5.5.1 Form Feed The form feed code causes the assembler to output blank lines in order to skip to a new page in the output listing during pass 3; this is useful in creating a page-by-page listing. The form feed is generated by typing a CTRL/L on the console terminal. 5.5.2 Tabulations Tabulations are used in the body of a source prograrr; to separate fields into columns (for details refer to Chapter 3). For example, a line written: GO, TAD TOTAL/MAIN LOOP is much easier to read if tabs are inserted to form: 5-7 5.5.3 /MAIN LOOP TAD TOTAL GO, Statement Terminators The RETURN key is used to terminate a statement and causes a line feed/carriage return combination to occur in the listing. The semicolon (;) may also be used as a statement terminator and is considered identical to a carriage return except that it will not terminate a comment. For example: TAD A /THIS IS A COMMENT; TAD B The entire expression between the slash (/) and the carriage return is considered a comment. Thus in this case the assembler ignores the TAD B. of instructions If, for example, the user wishes to write a sequence to rotate the contents of the accumulator and link six places to the right, it might look like the following!; HTrt HTH However, the programmer can alternatively place all three instructions on a single line by separating them with the special character semicolon (;) eind terminating the entires line with a carriage return. The above sequence of instructions can then be written: HTH;HTH;HrR These multi-statement lines are particularly useful when setting aside For example, a a section of data storage for use during processing. 4-word cleared block could be reserved by specifying either of the following: LIST, 0; 0; 0; or LIST* Either format may be used to input data words (data words may be in the form of numbers, symbols, or expressions, explained next.) Each of the following lines generates one storage word in the object progrcun: 5-8 DATA> 7777 A+C-B S 123+82 5.6 NUMBERS Any sequence of digits delimited by either a SPACE, TAB, semicolon, or carriage return forms a number. PALC initally interprets numbers in octal (base 8) . This base can be changed to decimal using a special pseudo-operator (discussed in Section 5.10.2). Numbers are used in conjunction with symbols to form expressions. 5.7 SYMBOLS A symbol is a string of alphanumeric characters beginning with a letter and delimited by a non-alphanumeric character. Although a symbol may be any length only the first six characters are recognized; since additional characters are ignored, symbols which are identical in their first six characters are considered identical. 5.7.1 Permanent Symbols The assembler contains a table (called its permanent symbol table) which lists the symbols for all PDP-8 pseudo-op codes, memory Transfer) reference instructions, operate and lOT (Input/Output These instructions are symbols which are permanently instructions. defined by PALC and need no further definition by the user; they are summarized in Appendix C. For example: HLT 5.7.2 instruction This is a symbolic 7402 by the assigned the value assembler and stored in its permanent symbol table. User-Defined Symbols (and represented in its All symbols not defined by the assembler permanent symbol table) must be defined within the source program. A symbol may be used as a statement label, in which case it is assigned a value equal to the current location counter; it is called a symbolic address and Ccin be used as an operand or as a reference to an Permanent symbols (instructions, special characters, and instruction. pseudo-ops) may not be used as symbolic addresses. The following are examples of legal symbolic addresses: ADDH* TOTAL* SUM* Al« 5-9 The following are illegal symbolic addresses: AD>Kj 7ABC* LA BEL# D+TAG* LABEL t (contains an illegal character) (first character must be alphabetic) (must not contain imbedded spaces) (contains a legal but non-alphanumeric character) (must be terminated by a comma with no intervening spaces) 5.7.3 Current Location Counter As source statements are processed, PAIjC assigns consecutive memory addresses to the instructions and data words of the object program. The current location counter contains the address in which the next word of object code will be assembled <ind is automatically incremented each time a memory location is assigned. A statement which generates a single object program storage word increments the location counter by one. Another statement might generate six storage words, incrementing the location counter by six. The user sets or resets the location counter by typing an asterisk followed by the octal absolute address value in which the next program word is to be stored. If the origin is not set by the user, PALC begins assigning addresses at location 200. *300 /SET LOCATION COUNTER TO 300 TAG, CLA J MP B, A, A DCA B The symbol TAG (in the preceding example) is assigned a value of 0300, the symbol B a value of 0302, and the symbol A a value of 0303. If a symbol is defined more than 'once in this manner, the assembler will print the illegal definition diagnostic: ID address where address is the value of the location counter at the second occurrence of the symbol definition. The symbol is not redefined. (For cin explanation of diagnostic messages refer to Section 5.14 PALC Error Conditions.) For example: *300 CONTIN, TAD A DCA COUNTER JMS LEAVE A, JMP START -74 COUNTER, START, CLA CLL START, 5-10 : The symbol START would have a value of 0300, the symbol CONTIN would have a value of 0302, the symbol A would have a value of 0304, the symbol COUNTER (considered COUNTE by the assembler) would have a value When the assembler processed the next line it would print of 0305. (during pass 1) IR COUNTE+0001 Since the first pass of PALC is used to define all symbols, the assembler will print a diagnostic during pass 2 if reference is made For example: to an undefined symbol. *7170 A, TAD C CLA CMA HLT JMP A The dollar sign must terminate all PDP-8 assembly programs. 1 C, $ This would produce the undefined symbol diagnostic: US A+0003 5.7.4 Symbol Table Initially, the assembler's symbol table contains the mnemonic op-codes the machine instructions and the assembler pseudo-op codes as As the listed in Appendix C; this is its permanent symbol table. source program is processed, user-defined symbols along with their The symbol table is binary values are added to the symbol table. listed in alphabetical order at the end of pass 3. of During pass 1, if PALC detects that the symbol table is full (in other words, there is no more memory space in which to store symbols and their associated values) , the symbol table exceeded diagnostic is printed: SE address The assembler then prints +C and waits for a response from the user. If the By typing + C the user can return control to the Monitor. system contains more than 8K of memory, the user may choose the /K (see Section 5.2,1) , or more address option with the Run command also It is arithmetic may be used to reduce the number of symbols. possible to segment a program and assemble the segments separately, (See taking care to generate proper links between the segments. PALC's symbol capacity is 768 symbols. The permanent Section 5.11.) leaving space for 699 possible symbol table contains 69 symbols, user-defined symbols. Each additional 4K allows 768 new symbols. Section 5.10.12 provides instructions concerning altering PALC's permanent symbol table should the user wish to add instructions more suited to his programming needs. 5-11 5.7.5 Direct Assignment Statements The programmer may insert new symbols with their assigned values directly into the symbol table by using a direct assignment statement of the form: SYMBOL=VALUE VALUK may be a number or expression. No spaces or tabs may appear between the symbol to the left of the equal sign and the equal sign itself. The following are examples of direct assignment statements: A=6 EXITrJMP I C:A+B All symbols to the right of the equal sign must be already defined. The symbol to the left of the equal sign is subject to the same restrictions as a symbolic address , and its associated value is stored The use of the equal sign does not in the user's symbol table. increment the location counter; it is, rather, an instruction to the assembler itself. A direct assignment statement may also equate a new symbol to the In this case, the two value assigned to a previously defined symbol. symbols share the same memory location. BETAZ17 GAMMA^BETA The new symbol, GAMMA, is entered into the user's the value 17. symbol table with The value assigned to a symbol may be changed as follows: ALPHAr5 ALPHA=7 The second line of code shown changes the value assigned to ALPHA from legal but will generate an RD error message, (This is 7. 5 to explained below.) Symbols defined by use of the equal sign may expression. For example: be used in cUiy valid *?.00 A:100 B:400 A+B TAD A /DOES NOT UPDATE CLC /DOES NOT UPDATE CLC /THE VALUE 500 IS ASSEMBLED AT LOG. 200 /THE VALUE 1200 IS ASSEMBLED AT LOG. 201 If the symbol to the left of the equal sign has already been the redefinition diagnostic: defined, RD address will be printed as a warning, where address is the value of the The new value will be location counter at the point of redefinition. 5-12 stored in the symbol table; for example: CLA=7600 will cause the diagnostic: RD '^0200 Whenever CLA is used after this point, it will have the value 7600, 5.7.6 Symbolic Instructions Symbols used as instructions must be predefined by the assembler or If a statement has no label, the instructions may the programmer. appear first in the statement and must be terminated by a space, tab, semicolon, slash, or carriage return. The following are examples of legal instructions: TAD PAGE ZIP 5.7.7 (a mnemonic machine instruction) (an assembler pseudo-op) (an instruction defined by the user) Symbolic Operands Symbols used as operands normally have a value defined by the user. The assembler allows symbolic references to instructions or data Operands may be numbers or defined elsewhere in the program. expressions. For example: TOTAL* TAD AC I + TAG (already defined by the The values of the two symbols ACl and TAG add (see Section 5,8.1, 2's complement are combined by a user) Operators) . This value is then used as the address of the operand. 5.7.8 Internal Symbol Representation For PALC Each permanent and user-defined symbol occupies four words in the symbol table storage area. A PDP-8 instruction has an operation code and seven a page bit, of three bits as well as an indirect bit, The PALC assembler distinguishes between pseudo-ops, address bits. permanent symbols, and instructions, other memory reference user-defined symbols in the symbol table. 5-13 5.8 EXPRESSIONS Expressions are formed by the combination of symbols, numbers, and certain characters called operators, which cause specific arithmetic operations to be performed. An expression is terminated by either a comma, carriage return, or semicolon. 5.8.1 Operators There are seven characters in PALC which act as operators; + 1- % ! & SPACE Two's complement addition Two's complement subtraction Multiplication (unsigned, 12-bit) Division (unsigned, 12--bit) Boolean inclusive OR Boolean AND Treated as a Boolean inclusive OR except in a memory refctrence instruction Two's complement addition and subtraction are explained in detail in Chapter 1 of INTRODUCTION TO PROGRAMMING? the user should refer to that handbook if he wishes more information. No checks for overflow are made during assembly, and any overflow bits are lost from the high order end. For example: 7755+24 will give a result of 1 The operators + and - may be used freely as prefix operators. Multiplication is accomplished by repeated addition. No checks for sign or overflow are made. All 12 bits of each factor are considered as magnitude. For example: 3000+2 wall give a result of 6000 Division is accomplished by repeated subtraction. The number of subtractions which are performed is the quotient. The remainder is not saved and no checks are made for sign. Division by will arbitrarily yield a result of 0. For example: 7000%1000 will yield a result of 7 This could be written as: -1000%1000 in this case the answer might be expected to be -1 (7777) , but all bits are considered as magnitude and the; result is still 7. 12 Use of the multiplication and division operators requires ein attention to sign on the part of the programmer beyond that which is required for simple addition and subtraction. The following table of examples is given for reference. 5-14 Table 5-2 Use of Operators Expression Also written as: Result -1+2 -2-3 7777+2 7776-3 +1 7773 or -5 +2 2+ 1000+7 0%12 12%0 7777%1 7000%1000 7000 or -1000 -1%1 -1000%1000 7777 or -1 7 1%2 The operator causes a Boolean inclusive OR to be performed bit by bit between the left-hand term and the right-hand term. (The inclusive OR is explained in Cliapter 1 of INTRODUCTION TO PROGRAMMING.) For example: ! if A=l and B=2 then A!B=0003 The & operator causes a Boolean AND to be performed bit by bit between the left and right values. The operation is the same as that indicated by the memory reference instruction AND. SPACE has special significance depending on the context in which it is used. When it is used to separate two permanent symbols or two user-defined symbols, as in the following example: SMA CLA it causes an inclusive OR to be performed between them. In this case, SMA=7500 and CLA=7600. The expression SMA CLA is assembled as 7700. When SPACE is used following pseudo-operators and memory reference instructions, it merely delimits the symbol. User-defined example: symbols are treated as operate instructions. For A»333 222 B» CIA Possible expressions and their values using the symbols just defined are shown below. Notice that the assemhiler reduces each expression to one 4-digit (octal) word: A B A+B A-B -A 1-B B-1 Al B -71 0333 0222 0555 0111 7445 7557 0221 0333 7707 (an inclusive OR is performed) 5-15 If the information generated is to be counter is incremented. For example: loaded, the current location b-7;a+4;a-b produces three words of information; the current location incremented after each expression. The statement: counter is HALT=HLT CLA produces no information to be loaded (it produces an association in and hence does not increment the current location the symbol table) counter. *4721 TEMP, TEM2, The location counter is not incremented after the line TEMP,; the two symbols TEMP and TEM2 are assigned the same value, in this case 4721. Since a PDP-8 instruction has an operation code of three bits as well as an indirect bit, a page bit, and seven address bits, the assembler must combine memory reference instructions in a manner somewhat differently from the way in which it combines operate or lOT instructions. The assembler differentiates between the symbols in its permanent symbol table and user-defined symbols. The following symbols are used as memory reference instructions: AND TAD 0000 1000 2000 3000 4000 5000 ISZ DCA JMS JMP Logical AND Two's complement addition Increment and skip if zero Deposit and clear accumulator Jump to subroutine Jump When the assembler has processed one of these following it acts as an address field delimiter. symbols, the space *4100 JMP A A, CLA A has the value 4101, JMP has the value 5000, and the space acts as field delimiter. These symbols are represented as follows: A JMP a 100 001 000 001 101 000 000 000 The seven address bits of A are taken, e.g.: 000 001 000 001 The remaining bits of the address are tested to see if they are zeros (page zero reference) ; if they are not, the current page bit is set: 5-16 000 oil 000 001 The operation code is then ORed into the JMP expression to form; 101 Oil 000 001 or, written more concisely in octal: 5301 In addition to the above tests, the page bits of the address field are compared with the page bits of the current location counter. If the page bits of the address field are nonzero and do not equal the page bits of the current location counter, an out-of-page reference is being attempted and the assembler will take action as described in Section 5.11, Link Generation and Storage. 5.8.2 Special Characters In addition to the operators described in the previous section, PALC recognizes several special characters which serve specific functions in the assembly process. These characters are: = equal sign comma * asterisk dot . " double quote parentheses ( square brackets [] / slash semicolon ; <> angle brackets dollar sign $ , ) The equal sign, comma, asterisk, slash, and semicolon have previously described. The remainder will be described next. been The special character dot (.) always has a value equal to the value of the current location counter. It may be used as any integer or symbol (except to the left of an equal sign) , and must be preceded by a space when used as an operand. For example: iMP .+2 is equivalent to JMP 0202. Also, *300 • *-2400 will produce in location 0300 the quantity 2700. 2200 CALL»JMS 0027 I • 5-17 Consider: : : . . . The second line (CALL=JMS I.) does not increment the current location counter,' therefore, 0027 is placed in location 2200 and CALL is placed in the user's symbol table with an associated value of 4600 (the octal equivalent of JMS I) If a single character is preceded by a double quote ("), the 8-bit value of ASCII code for the character is used rather than interpreting the character as a symbol (ASCII codes are listed in Appendix A) . For example CLA TAD ("A The constant 0301 is placed in the accumulator. The code will be assembled as 0256. The character must not be a carriage return or one of the characters which is ignored on input (discussed at the end of this section) Left and right parentheses member is optional) () enclose a current page literal (closing *200 CLA TAD INDEX TAD (2) OCA I NDEX The left parenthesis is a signal to the assembler that the expression following is to be evaluated and assigned a word in the constants table of the current page. This is the same table in which the indirect address linkages are stored. In the above example, the quantity 2 is stored in a word in the linkage and literals list beginning at the top of the current memory page. The instruction in which the literal appears is encoded with an address referring to the address of the literal, A literal is assigned to storage the first time it is encountered; subsequent reference to that literal from the current page is made to the same register. The use of literals frees symbol storage space for variables and makes programs much more readable. If the programmer wishes to assign literals to page zero the current page, he may use square brackets, [and] to parentheses. This enables the literal from any page of memory. programmer to For example: *200 TAD [2] *500 TAD [2] 5-18 rather than in place of reference a single , The closing member is optional. forms: constant term, variable another literal. Literals may take term, instruction, the following expression, or NOTE Literals can be nested, for example: *200 TAD (TAD (30 This type of nesting may be continued in some cases to as many as 6 levels, depending on the number of other literals on the page and the complexity of the expressions within the nest. If the limits of the assembler are reached, the error messages BE (too many levels of nesting) or PE (too many literals) will result. Angle brackets are used as conditional delimiters. The code enclosed angle brackets is to be assembled or ignored contingent upon in the the definition of the symbol or value of the expression within the IFDEF, IFIMDEF, angle brackets. (The IFZERO, and IFNZRO pseudo-operators are used with angle brackets and are described in Section 5.10.9.) The dollar sign character ($) is mandatory at the end of a program and It may however occur is interpreted as an unconditional end-of-pass . interpreted in a text string, comment or " term, in which case it is in the same manner as any other character. The following characters are handled by the assembler for the listing, but are otherwise ignored: FORM FEED LINE FEED RUBOUT pass 3 Used to skip to a nev/ page Used to create a line spacing without causing a carriage return Used by the EDITOR to allow corrections in the input file. Nonprinting characters include: SPACE TAB RETURN These characters are used for format control and have been explained in Section 5.5. 5-19 previously INSTRUCTIONS 5.9 There are two basic groups of instructions: memory reference and microinstructions. Memory reference instructions require an operand, microinstructions do not. 5.9.1 Memory Reference Instructions In PDP-8 computers, some instructions require a reference to memory. They are appropriately designated memory reference instructions , and take the following format: 2 1 3 4 5 6 7 OPERATION CODE 1 9 8 10 11 ADDRESS 7 1 1 1 1 1 J INDIRECT ADDRBSING ) MEMORY PAGE Memory Reference Bit Instructions Bits through 2 contain the operation code of the instruction to be performed. Bit 3 tells the computer if the instruction is indirect (see Section 5.9.2). Bit 4 tells the computer if the instruction is referencing the current page or page zesro. This leaves bits 5 through In these 7 bits, 200 octal 11 (7 bits) to specify an address. (128 decimal) locations can be specified; the page bit increases accessible For a list of the memory locations to 400 octal or 255 decimal. reference instructions and their codes, see Appendix C. In PALC a memory reference instruction must be followed by tab(s), an optional I or Z designation, and any valid It may be defined with the FIXMRI instruction as explained 5.10.12, Altering the Permanent Symbol Tc±>le. Permanent or be defined using the FIXTAB instruction and may fields as shown below: be used a space (s) expression. in Section symbols may in address FIXTAB TAD 5.9.2 A Indirect Addressing When the character I appears in a statement between a memory reference instruction and an operand, the operand is interpreted as the address the (or location) containing the address of the operand to be used in Consider: current statement. 5-20 : TAD 40 which is a direct address statement, where 40 is interpreted as the location on page zero containing the quantity to be added to the accumulator. References to locations on the current page and page zero may be done directly. An alternate way to note the page zero reference is with the letter Z, as follows: TAD Z 40 This is an optional notation, not differing in effect from the previous example. Thus, if location 40 contains 0432, then 0432 is added to the accumulator. Now consider: TAD I 40 which is an indirect address statement, where 40 is interpreted as the address of the location containing the quantity to be added to the accumulator. Thus, if location 40 contains 0432, and location 432 contains 0456, then 456 is added to the accumulator. NOTE Because the letter I is used to indicate indirect addressing, it is never used as Likewise the letter Z, a variable. which is sometimes used to indicate a page zero reference, is never used as a variable. 5.9.3 Microinstructions Microinstructions are divided into two groups : operate and Input/Output Transfer (lOT) microinstructions. Operate microinstructions are further subdivided into Group 1, Group 2, and Group 3 designations. NOTE If a programmer mistakenly specifies an combination illegal of microinstructions, the assembler will perform for an inclusive OR between them; example CLL SKP is interpreted as SPA (7100) (7510) (7410) Operate Microinstructions Within the operate group, there are three groups of microinstructions Group 1 microinstructions perform clear, which cannot be mixed. complement, rotate and increment operations, and are designated by the presence of a in bit 3 of the machine instruction word. 5-21 1 1 1 1 5 CLA CLL 6 7 9 8 CMA CML 10 11 BSW lAC 1 ROTATE AC AND ROTATE AC AND D/^TATC (BSW 4 3 2 1 1 IF I RIGHT I LEFT D/-^CITI/-^ A IC 1 rt t O D /~\ciTir\MC IC A 1 1 1 BITS 8,9 ARE 0) 1-CLA 3-IAC LOGICAL SEQUENCE: Group , 2 -CMA, CML CLL 4-RAR,RAL,RTR,RTL,BSW Operate Microinstruction Bit Assignments 1 Group 2 microinstructions check the contents of the accumulator and continue to or skip the next and, based on the check, link Group 2 microinstructions are identified by the presence instruction. in bit 11 of the machine instruction word. of a 1 in bit 3 emd a 1 1 1 2 3 1 1 5 4 6 7 8 CLA SMA SZA SNL 9 10 OSR HLT 11 1 REVERSE SKIP SENSING OF BITS 5,6,7 IF SET LOGICAL SEQUENCE: 1 (BIT 8 IS (BIT 8 IS 1 0)-SMA OR SZA OR SNL - SPA AND SNA AND SZL I ) 2 -CLA 3- OSR, HLT Group Bit Assignments Operate Microinstruction 2 register. They the MQ are Group 3 instructions reference differentiated from Group 2 instructions by the presence of a 1 in bits 3 and 11. The other bits are part of a hardware arithmetic option. 2 1 OPERATION CODE 1 3 4 5 6 7 CLA MQA 7 1 CONTAINSAITO 11 WQL 1 SPECIFY GROUP 3 10 9 8 KE8-E EXTENDED ARITHMETIC 1 CONTAINS A 1 TO SPECIFY GROUP 3 ELEMENT Group 3 Operate Microinstruction Bit Assignments Group 1 and Group 2 microinstructions cannot be combined since determines either one or the other. 5-22 bit 3 ; within Group 2, there are two groups of skip instructions. be referred to as the OR group and the AND group. OR Group AND Group SMA SZA SNL SPA SNA SZL They can in bit 8, amd the AND group by a 1 The OR group is designated by a OR and AND group instructions cannot be combined since bit in bit 8. 8 determines either one or the other. the programmer does combine legal skip instructions, If important to note the conditions under which a skip may occur. 1. it is — OR Group If these skips are combined in a statement, the inclusive OR of the conditions determines the skip. For example: SZA SNL The next statement is skipped if the contains 0000 or the link is a 1 or both. 2. accumulator — AND Group If the skips are combined in a statement, the logical AND of the conditions determines the skip. For example SNA SZL The next statement is skipped only if differs from 0000 and the link is 0. the accumulator Input/Output Transfer Microinstructions These microinstructions effect an information Input/Output device (s); The Permanent printer. initiate operation of peripheral equipment and transfer between the central processor and the and line i.e., cassettes, console terminal, Symbol Table in Appendix C lists PALC's lOT's. 5.9.4 Autoindexing Interpage references are often necessary for obtaining operands when processing large amounts of data. The PDP-8 computers have facilities When one of the absolute to ease the addressing of this data. locations from 10 to 17 (octal) is indirectly addressed, the contents of the location is incremented before it is used as an address and the This allows the number is left in the location. incremented programmer to address consecutive memory locations using a minimum of statements. 5-23 It must be remeinbered that initially tliese locations (10 to 17 on page 0) must be set to one less than the first desired address. Because of their characteristics, these locations are called autoindex registers. No incrementation takes place when locations 10 to 17 are addressed directly. For example, if the instruction to be executed next is in location 300 and the data to be referenced is on the page starting at location 5000, autoindex register 10 can be used to address the data 3,3 f OlXOWS * 0276* 0277 0300 1577 TAD C4777 3010 DCA 10 TAD I 10 1410 /=5000-l /SET UP AUTO INDEX /INCREMENT TO 5000 /BEFORE USE AS AN ADDRESS 0377 4777 C4777,4777 When the instruction in location 300 is executed, the contents of location 10 will be incremented to 5000 and the contents of location 5000 will be added to the contents of the accumulator. When the instruction TAD I 10 is executed again, the contents of location 5001 will be added to the accumulator, and so on. 5 . 10 PSEUDO-OPERATORS The programmer uses pseudo-operators to direct the assembler to perform certain tasks or to interpret subsequent coding in a certain manner. Some pseudo-ops generate storage words in the object program, other pseudo-ops direct the assembler how to proceed with the assembly. Pseudo-ops are maintained in the permanent symbol table. The function of each PALC pseudo-op is described below. 5.10.1 Indirect and Page Zero Addressing The pseudo-operators I and addressing to be performed. Section 5.9.2. 5.10.2 Z are used to specify the type of These have been previously discussed in Radix Control Numbers used in a source program are initially considered to be octal However, the programmer may change or alternate the radix numbers. interpretation by the use of the pseudo- operators DECIMAL cuid OCTAL. The DECIMAL pseudo-op interprets all following until the occurrence of the pseudo-op OCTAL. numbers as decimal The OCTAL pseudo-op resets the radix to its original octal base. 5-24 5.10,3 Extended Memory The pseudo-op FIELD instructs the assembler to output a field setting so that it may recognize more than one memory field. This field setting is output during pass 2 and is recognized by the Run (or Load) command, which in turn causes all subsequent information to be loaded into the field specified by the expression. The form is: FIELD n n is an integer, a previously defined symbol, or an expression within the range 0<=n<=7. This field setting is output on the binary file during pass 2 followed by an origin setting of 200. This word is read when the Run (or Load) command is executed and begins loading information into the new field. The field setting is never remembered by the assembler and no initial field setting is output. A binary file produced without field settings will be loaded into field (or when using the Run Load) command. NOTE A symbol in one field meiy be used to reference the same location in any other field. The field to which it refers is determined by the use of the CDF and GIF instructions. (The programmer who is unfamiliar with thelOT'sbut wishes to use them should refer to the PDP/8E SMALL COMPUTER HANDBOOK and experiment with several short test programs to satisfy himself as to their effect.) CDF and CIF instructions must be used prior to any instruction referencing a location outside the current field, as shown in the following example: *200 TAD P301 CDF 00 CIF 10 JMS PRINT CIF 10 JMP NEXT P301 , NEXT, P302, PRINT, 301 FIELD 1 *200 TAD P302 CDF 10 JMS PRINT HLT 302 TLS TSF 5-25 .-1 J'^p CLA RDF TAD PS203 DCA .+1 000 .JMP PS203, I PRINT 6233 When FIELD is used, the assembler follows the new FIELD setting with For this reason, if the programmer wants an origin at location 200. to assemble code at location 400 in field 1 he must write: FIELD *400 /CORRECT EXAMPLE 1 The following is incorrect and will not generate the desired code: *42i0 /INCTORfiECT FIELD 5.10.4 1 End-of-File PAUSE signals the assembler to stop processing the file being read. The current pass is not terminated, and processing continues with the next file. The PAUSE pseudo-op should be used only at the physical end of a file and with two or more segments of one program. When a PAUSE statement remainder of the file is ignored and processing is reached the continues with the next input file. PAUSE must be present or a PH error will occur. 5.10.5 Resetting the Locatioh Counter The PAGE n pseudo-op resets the location counter to the first address of page n, where n is ein integer, a previously defined symbol, or a symbolic expression, all whose terms have been defined previously and to 37 inclusive. If n is not specified, the whose value is from For location counter is reset to the next logical page of memory. example: PAGE PAGE 2 6 sets the location counter to 00400 sets the location counter to 01400 an argument and the current If the PAGE pseudo-op is used without location counter is at the first location of a page, it will not be In the following example, the code TAD B is assembled into moved. location 00400: *377 J MP .-3 PAGE TAD B 5-26 If several consecutive PAGE pseudo-ops are given, the first will cause the current location counter to be reset as specified. The rest of the PAGE pseudo-ops will be ignored. 5.10.6 Entering Text Strings The TEXT pseudo-op allows a string of text characters to be entered as data and stored in 6-bit ASCII by using the pseudo-op TEXT followed by a space or spaces, a delimiting character (must be a printing character) , the string of text, and the Scime delimiting character. Following the last character, a 6-bit zero is inserted as a stop code. For example: TAG, TEXT/123*/ The string would be stored as: SI 62 63 52 0000 5.10.7 Suppressing the Listing Those portions of the source program enclosed by XLIST pseudo-ops will not appear in the listing file; the code will be assembled, however. Two XLIST pseudo-ops may be used to enclose the code to be suppressed first XLIST with no argument will suppress the in which case the listing, cind the second will allow it again. XLIST may also be used with an expression as an argument; a listing will be inhibited if the expression is equal to zero, or allowed if the expression is not equal to zero. 5.10.8 Reserving Memory ZBLOCK instructs the assembler to reserve; n words of memory containing zeros, starting at the word indicated by the current location counter. It is of the form: ZBLOCK n For example: ZBLOCK 40 causes the assembler to reserve 40 (octal) words. If n=0 , no locations are reserved. expression. 5-27 The n may be an S.10.9 Conditional A:-iseinb"ly The IFDEF pseudo-op takes tlie Pseudo- Operators form: iFDEF symbol "^soui'ce; coda> If the symbol indicated is previously defined, the code contained in the angle brackets is assembled; if the symbol is undefined, this code is ignored. Any number of statements or lines of code may be contained in the angle brackets. The format of the IFDEF statement requires a single space before and after the symbol. The IFNDEF pseudo-op is similar in form to IFDEF and is expressed; IFNDEF symbol < source code> If the symbol indicated has not been previously defined, the source code in angle brackets is assembled. If the symbol is defined, the code in the angle brackets is ignored. The IFZERO pseudo-op is of the form: IFZERO expresson <source ccde> If the evaluated (arithmetic or logical) expression is equal to zero, the code within the angle brackets is assembled; if the expression is non-zero, the code is ignored. Any numlDer of statements or lines of code may be contained in the angle brackets. The expression may not contain any imbedded spaces and must have a single space preceding and following it. IFNZRO is similar in form to the IFZERO pseudo-op and is expressed: IFNZRO expression < source code> If the evaluated (arithmetic or logical) expression is not equal to the source code within the angle brackets is assembled; if the zero, expression is equal to zero, this code is ignored. Pseudo-ops can be nested, for example: IFDEF SYM <IFNZRO X2 <«..>> The evaluation and subsequent i.nclusion or deletion of done by evaluating the outermost pseudo-op first. 5.10.10 statements is Controlling Binary Output NOPUNCH causes the assembler to cease binary output assembling code. It is ignored except during pass 2. but continue ENPUNCH causes the assembler to resume binary output after- NOPUNCH, For example, these two and is ignored except during pass 2. pseudo-ops might be used where several programs share the same data on When these programs are to be loaded and executed page zero. together, only one page zero need be output. 5-23 5.10.11 Controlling Page Format The EJECT pseudo-op causes the listing to jump to the top of the next page. A page eject is done automatically every 55 lines; EJECT is useful if the user requires more frequent paging. If this pseudo-op is followed by a string of characters, the first 40 (octal) characters of that string will be used as a new heaider line. 5.10.12 Altering the Permanent Symbol Table PALC contains a table of symbol definitions for the PDP-8 and CAPS-8 peripheral devices. These are symbols such as TAD, DCA, and CLA, which are used in most PDP-8 programs. This table is considered to be the permanent symbol table for PAI.C; all of the symbols it contains are listed in Appendix C. If the user purchases one or more optional devices whose instruction is not defined among the permanent symbols (for example EAE or an A/D converter) , he would want to add the necessary symbol definitions to the permanent symbol table in every program he assembles. Conversely, the user who needs more space for user-defined symbols would probably want to delete a] 1 definitions except the ones used in set his program. For such purposes , PALC has three pseudo-ops that can be used to alter the permanent symbol table. These pseudo-ops are recognized by the assembler only during pass 1. During either pass 2 or pass 3 they are ignored and have no effect, EXPUNGE deletes the entire permanent symbol table, except pseudo-ops. FIXTAB appends all presently defined symbols to the permanent symbol All symbols defined before the occurrence of FIXTAB are made table. part of the permanent symbol tcible until the assembler is reloaded. To append the following instructions to the symbol generates an ASCII file called SYMS.PHL containing; mY-lAP.5 DVI=7407 CLSK:6131 FIXTAB table, the user /MULTIPLY /DIVIDE /SKIP ON CLOCK IMTERRUPT /SO THAT THESE WON'T BE /PRINTED IN THE SYMBOL TABLE The ASCII file is then entered in PALC's input designation. The user may also place the definitions at the beginning of the source file. This eliminates the need to load an extra file- Each time the assembler is loaded, PALC's permanent symbol table is restored to contain only the permanent symbols shown in Appendix C. The third pseudo-op used to alter the permanent symbol table in PALC FIXMRI. is FIXMRT is used to define a memory reference instruction and is of the form; FIXMRI name:-value 5-29 . The letters FIXMRI must be followed by one space, the symbol for the instruction to be defined, an equal sign, and the value: of the symbol. The symbol will be defined and stored in the symbol table as a memory reference instruction. The pseudo-op must be repeated for each memory reference instruction to be defined. For example: EXPUNGE FIXMRI TAD:100f! FIXMRI DCA=5000 CLAr7200 FIXTAB When the preceding program segment is read into the assembler during pass 1, all symbol definitions are deleted and the three symbols listed are added to the permanent symbol table. Notice that CLA is not a memory reference instruction. This process can be performed to alter the assembler's symbol table so that it contains only those symbols used at a given installation or by a given prcgram. This may increase the assembler's capacity for user-defined symbols in the program. A sximraary of the PALC pseudo-ops is provided in Appendix C. 5.11 LINK GENERATION AND STORAGE In addition to handling symbolic addressing on the current page of memory, PALC automatically generates links for off-page references. If reference is made to an address not on the page where an instruction is located, the assembler sets the indirect bit (bit 3) and an indirect address linkage will be generated on the current memory page. If the off-page reference is already an indirect one, the error diagnostic II (illegal indirect) will be generated. For example: *?. 1 17 CLA A, *2S00 JMP A In the example above, the assembler will recognize that the register labelled A is not on the current page (in this case 2600 to 2777) and will generate a link to it as follows; word 1. In location 2600 the assembler will place the which is equivalent to JMP I 2777. 2. In address 2777 (the last available location on the current page) the assembler will place the word 2117 (the actual address of A) 5777 During pass 3, the octal code for the instruction will be followed an apostrophe (') to indicate that a link was generated. by Although the assembler will recognize and generate an indirect address linkage when necessary, the programmer may indicate eui explicit 5-30 . indirect address by the pseudo-op I. The assembler cannot generate a link for an instruction that is already specified as being as indirect reference. In this case, the assembler will print the error message For example: II (illegal indirect) . *21 17 CLA A, *2600 JMP I A The above coding will not work because A is not defined on the where JMP I A is attempted, and the indirect bit is already set. page Literals and links are stored on each page starting at page address (relative) (relative) and extending toward page address 177 Whenever the origin is then set to another page, the literal buffer This does not affect later execution. for the current page is output. There is room for 160 (octal) literals and links on page zero and 100 (octal) literals on each other page of memory. Literals and links are stored only as far down as the highest Further attempts to define literals will instruction on the page. error (page zero exceeded) or ZE result in a PE (page exceeded) message. 5.12 CODING PRACTICES A neat printout (or program listing, as it is usually called) makes subsequent editing, debugging, and interpretation much easier than if The coding practices the coding were laid out in a haphazard fashion. cind will result in a readable, listed below are in general use, orderly listing. 1. A title comment begins with a slash at the left margin. 2. Pseudo-ops may begin at the left margin; often, however, they are indented one tab stop to line up with the executable instructions. 3. They Address labels begin at the left margin. separated from succeeding fields by a tabulation. 4. Instructions, whether or not they are label field, are indented one tab stop. 5. A comment is separated from the preceding field preceded are by a by one (as required) and a slash; if the comment or two tabs occupies the whole line it usually begins with a slash at the left margin. 5-31 PROGRAM PREPARATION AND ASSEMBLER OUTPUT 5.13 The following program was generated using the CAPS-8 EDITOR and was assembled with PALC. TAB function of the *200 /EXAMPLE OF INPUT TO THE FORMAT /GENERATOR PROGRAM BEGIN, /START OF PROGRAM KCC KSF /WAIT FOR FLAG JMP .-1 /FLAG NOT SET YET KRB /READ IN CHARACTER DCA CHAR TAD CHAR TAD MSPACE /IS IT A SPACE? SNA CLA HLT /YES JMP BEGIN+2 /NO: INPUT AGAIN CHAR, /TEMPORARY STORAGE -2 40 MSPACE, /END OF EXAMPLE S The program consists of statements and pseudo-ops and is terminated by the dollar sign ($) . If the program is large, it can be segmented by placing it into several files; this often facilitates t:he editing of the source program since each section will be physically smaller. The assembler initially sets the current location cov.nter to This counter is reset whenever the asterisk (*) is processed. 0200. The assembler reads the source file for pass 1 and defines all symbols used. During pass 2, the assembler reads the source file and generates the binary code using the symbol table equivalences defined during pass 1. The binary file that is output may be loaded by the Load command. This binary file consists of an origin setting and data: words. During pass 3, the assembler reads the source file and generates the code from the source statements. The assembly listing is output in ASCII code. It consists of the current locatior, counter, the generated code in octal, and the source statement. The 5-digit first column is the field number and 4-digit octal address (current location counter) ; the 4-digit second column is the assembled object code. The symbol table is printed at the end of the pass. The peiss 3 output is: *200 PALC-Vl 03/06^73 0200 *200 /EXAMPLE OF INPUT TO THE FORMAT 0000 6032 6031 5202 6036 3213 1213 1214 7650 BEGIN, PAGE /GENtRATQP PROGRAM 00200 00201 00?02 00203 00204 00205 00206 00207 00210 /START OF PROGRAM KCC KSF JMP KRB OCA TAD TAD SNA .-1 CHAR CHAR MSPACE CLA 5-32 /WAIT FOR FLAG /FLAG NOT SliT YET /READ IN CHARACTER /IS IT A SPACE? 1 . 00311 00212 00213 TttiZlH 7«02 5202 0000 7540 : HLT JMP BEGIN + 2 /YES /NOHNPUT AGAIN CHAR, MSPACE, -240 /END OF EXAMPUE /TEMPORARY STORAGE S PALC-Vl •200 03/08/73 PAGE 1-1 BEGIN 0200 CHAR 0213 MSPACE 0214 5.13.1 Terminating Asseinbly PALC will a) terminate assembly, b) print a +C, and c) wait for the user to mount the System Cassette on drive and type iC, under any of the following conditions: — 1. Normal exit The $ at the end of the source program was executed on pass 2 (or pass 3 if a listing is being generated) 2. Fatal error One of the following error conditions found and flagged (see the next section) — BE 3. 5.14 "fC DE DF PH was SE — If typed by the user, control turns to the Monitor. PALC ERROR CONDITIONS PALC will detect euid flag error conditions and generate error messages on the console terminal. The format of the error message is: CODE ADDRESS where CODE is a 2-letter code which specifies the type of error, and ADDRESS is either the absolute octal address where the error occurred or the address of the error relative to the last symbolic tag (if there was one) on the current page. For example, the following code: BEG, TAD LBL ZTAD LBL 5-33 , would produce the error message: IC BEG+0001 since % is an illegal character. If at ciny time PALC prints tc, the user should make certain that the System Cassette is mounted on drive and then type + C to return to the Monitor. He should examine each error indication to determine whether correction is required. On the pass 3 listing, error messages are output as 2-character messages on the line just prior to the line in which the error occurred. The following table lists the PALC error codes. Those labeled Fatal Error are followed immediately by an effective +C. Table 5-3 PALC Error Codes Error Code Explanation BE Two PAL-C internal tables have overlapped, error assembly cannot continue. DE Device error. An error was detected when trying to read or write a device. Fatal error assembly cannot continue. DF Device full, continue IC Illegal character. The character is the assembly continued. ID Illegal redefinition of a symbol. An attempt was made to give a previously defined symbol a new value by means other than the equal sign. The symbol is not redefined. IE Illegal equals an equal sign was used in the wrong context. Considered a warning and may not indicate an error but rather an undefined symbol at that point. II Illegal indirect IP Fatal — — Fatal error — assembly cannot ignored and — — an off-page reference was made. Illegal pseudo-op — a pseudo-op was used m the wrong context or with incorrect syntax. — IZ Illegal page zero reference the pseudo-op Z was found in an instruction which did not refer to page zero. The Z is ignored. PE Current non-zero made to: page 5-34 exceeded — an attempt was Table 5-3 PALC Error Codes (Cont'd) Error Code Explanation 1. Override a literal with an instruction 2. Override an instruction with a literal 3. Use more literals than the assembler allows on that page. This can be corrected by decreasing either the number of literals on the page or the number of instructions on the page. PH — Phase error either no $ appeared at the end of the program, or < and > in conditional pseudo-ops did not match. Fatal error assembly cannot continue. — — RD Redefinition a permanent symbol has been defined with =. The new and old definitions do not match. The redefinition is allowed. SE Symbol table exceeded too many symbols have been defined for the amount of memory available. Fatal error assembly cannot continue. — — — UO Undefined origin an undefined symbol has occurred in an origin statement. US Undefined symbol a symbol has been processed during pass 2 that was not defined before the end of pass 1. ZE Page exceeded to page 0. — — same as PE except with 5-35 reference . . CHAPTER CASSETTE Bi\SIC (5 6. 1 INTRODUCTION Cassette BASIC is an interactive programming language derived from Dartmouth BASIC and designed to run vinder the Cassette Keyboard Monitor. The BASIC language is aimed at facilitating communication between the user and the computer. The user types his program as a series of numbered statements, making use of common English words and familiar mathematical notations. Because the BASIC language involves learning only a small number of commands, it is a very easy language to use. As the user gains familiarity with BASIC, he can add the advanced techniques available to perfoinn more intricate manipulations or express a problem more efficiently and concisely. Cassette BASIC provides approximately 1.7 to 2K of memory for program storage. 1Important features include and 2-dimensional subscripting, user-coded functions, program chaining, use of cassettes for program storage, and use of line printer, if available, for output Beginning programmers may find a more fundamental approach to language prograimming in Chapter 1 of THE EDUSYSTEM HANDBOOK, 6.2 BASIC CALLING BASIC (.R BASIC) Using the Cassette Keyboard Monitor, BASIC is called from Cassette by typing: System the ^R BASIC When it is first loaded into memory, BASIC asks the user use run-time file input and output as follows: USING RUN-TIME FILE I if he will /0?(Y OR N) The user responds with Y or N followed by a carriage return. Choosing the run-time I/O feature leaves the user approximately 1.7K of memory for program storage, whereas a response of N frees the space used by the run-time I/O routines and provides an additional . 3K of memory (enough for approximately 20-25 statements or 75 variables) Statements associated with the run-time I/O feature are: OPEN... FOR INPUT OPEN. ..FOR OUTPUT CLOSE IF END# PRINT* INPUT* COMMAS NO COMMAS 6L-.1 If any of these statements are used witJiout the rvm-time I/O option having been chosen during BASIC'S initial dialogue, BASIC will print a NO FILES ERROR message at run-time. BASIC then asks: NEW OR OLD- The user responds NEW if he intends to create a program at the keyboard, and must respond with the name of the new program when BASIC requests: NEW PROGRAM NAME- The program name is typed as a standard system filename (6 characters or less) and an optional extension (1 to 3 characters) ; a program name is entered even if the user does not intend to save the program for future use. (A response of only a carriage return causes BASIC to repeat the NEW PROGRAM NAME request. If the user types an ALT MODE in response to this request, the name NONAME.BAS is assigned by BASIC.) When the new program name has been entered, BASIC indicates that it is ready to accept input by issuing a carriage return/line feed combination. If the user responds OLD to BASIC'S initial dialogue, BASIC assumes that the program has been previously saved on a cassette and will ask: OLD PROGRAM iVAMEUNIT#(0-7): The user must respond with the correct program name and file extension (if any) , and then must specify which cassette unit drive the file is stored on. (An incorrect response will return an error message.) When this interaction is complete, BASIC will type: READY. and the user may edit or run his program. 6.3 NUMBERS Cassette BASIC treats all numbers (in both integer and real formats) real, or floating point, numbers. as That is, BASIC e.ccepts as input any number containing a decimal point and assumes a decimal ppint after any integer number entered. In addition to integer and real formats, a third format is recognized and accepted by BASIC in order to express numbers outside the range .01<=x<1000000. This format is called exponential or E-type notation. format, a number is expressed as a decimal nuimber times some In this power of 10, as follows: 6-2 :: where E represents "times 10 to the power of". A number in exponential notation is then read "xx times 10 to the power of n"; for example: 23.4E2 = 23.4*(10 to the power of 2) = 2340 Data may be input in any one or all three of these forms. Internal computations are carried out in floating point (real) format. Results of computations within the range .01<=x<1000000 are output as either real or integer decimal numbers (whichever is the correct but more concise format) results outside this range are output in exponential format. BASIC handles seven significant digits in normal operation and input/output, as illustrated below: ; Same Value Output By BASIC Value Typed In .01 .0099 .01 9.900000E-3 999999 l.OOOOOOE+6 999999 1000000 BASIC automatically suppresses the printing of leading and trailing zeros in integer and decimal numbers and, as shown above, prints all exponential numbers in the form; (sign) x.xxxxxx E (+ or -) n where x represents the number carried to six decimal places, E stands 10 for "times to the power of", and n represents the exponent. For example -3.470218E+8.is equal to -347021800 7.260000E-4 is equal to .000726 6.4 VARIABLES which A variable in BASIC is a symbol formed by example a single letter Acceptable Variables I B3 or a represents a number and is letter followed by a digit. For Unacceptable Variables 2C - A digit cannot begin a variable AB - Two or more letters cannot form a variable X 6-3 : The user may assign values to variables either by computing the values in a LET statement or by inputting the values as data; these operations are discussed later. 6.5 ARITHMETIC OPERATIONS BASIC performs addition, subtraction, multiplication, division and exponentiation, as well as more complicated operations explained in detail later in the chapter. The five operators used in writing most formulas are Symbol + * / f Meaning Example Addition Subtraction Multiplication Division Exponentiation (Raise A to the Bth power) A + B A - B A * B A / B A + B Priority of Operations 6.5.1 In any given mathematical formula, BASIC performs operations in the following order of evaluation: arithmetic 1. Parentheses receive top priority. Any expreession within parentheses is evaluated before an unpcirenthesized expression. 2. In absence of parentheses, the order of priority is: 3. a. Exponentiation b. Multiplication and Division (of equal pr;Lority) c. Addition and Subtraction (of equal priority) If either 1 or 2 above does not clearly dessignate the order of priority, then the evaluation of expressions proceeds from left to right. The expression AtB-^C is evaluated from left to right as follows: 1. A+B 2. (result of step = step 1 = answer 1) "tc The expression A/B*C is also evaluated from left multiplication and division are of equal priority: 1. A/B = step 1 2. (result of step 1)*C = answer 6-4 to right since : Parentheses and Spaces 6.5.2 Parentheses may be used by the progranmier to change the order of priority (as listed in rule 2 of the previous section) . Since expressions within parentheses are always evaluated first, the programmer can control the order of evaluation by enclosing expressions appropriately. Parentheses may be nested, or enclosed by a second set (or more) of parentheses. In this case, the expression within the innermost parentheses is evaluated first, and then the next innermost, and so on, until all have been evaluated. Consider the following example; A=7*C<Bt2+4>/X) The order of priority is 1. Bf2 = step 1 2. (result of step l)+4 = step 2 3. (result of step 2)/X = step 4. (result of step 3)*7 = A Parentheses also prevent any confusion expression is evaluated. For example: or 3 doubt as to how the A*Bt8/7+B/C+Dt2 C(A*Br8)/7)+f CB/C)+Dt2) Both of these formulas will be executed in the same way. However, most users will find that the second is easier to understand. Spaces may be used in a similar manner., ignores spaces, the two statements: LET B = Dt2 + Since the BASIC compiler 1 LETB=Dt2+l are identical, but spaces in reading. 6.5.3 the first statement provide ease in Relational Operators A program may require that two values be compared at some point to discover their relation to one another. To accomplish this, BASIC 6-5 makes use of the following relational operators: = < <= equal to less than less than or equal to > greater than >= greater than or <> equal to not equal to Depending upon the result of the comparison, flow of program execution may be directed to another part of the program, or the: validity of the (indicating a FALSE condition) relationship may cause a value of or (indicating a TRUE condition) to be assigned to a variable. 1 For example: 15 X=Y</', This statement assigns the value 1 to X if Y is greater than Z. Relational operators are used primarily in conjunction with IF and LET statements, both of which are later discussed in detail. In algebraic The meaning of the equal sign (=) should be clarified. the notation, formula X=X+1 is meaningless. However, in BASIC (cind most computer languages), the equal sign designates replacement rather Thus, the formula X=X+1 is actually translated: "add than equality. one to the current value of X and store the new result back in the same variable X"; whatever value has previously been assigned to X will be combined with the value 1. An expression such as A=B+C instructs the computer to add the values of B anc: C and store the result in a third variable A; the variable A is not being evaluated in terms of any previously assigned value, but only in terms of B and C. Therefore, if A has been assigned any value prior to its use in this statement, the old value is lost; it is instead replaced by the value Finally, the equal sign may be used in relational testing as of B+C. illustrated in the previous example. 6.6 IMMEDIATE MODE Commands are available which allow Cassette BASIC to act as a calculator that is, the user types an algebraic exjiression which is This is called to be calculated and BASIC types back the result. Immediate Mode since the user is not required to write a detailed program to calculate expressions and equations, but cem use BASIC to produce results immediately. The commands used in Immediate Mode are These are PRINT, LET and occasionally the FOR-NEXT combination. explained in the following paragraphs. — 6.6.1 PRINT Command The PRINT command is of the form: PRINT expression BASIC is instructed to compute the value of the expresssion eind print The expresision is a normal the result on the console terminal. 6-6 arithmetic expression v/hich may include nvimbers, variables, arithmetic functions (discussed in Section 6.8.12). A string of operators, eind For example: text may also be printed (see Section 6.8.5 PRINT), — l/8t8 5.9604 6'!)E-08 PRIiNJT 6.6.2 LET Command Values may be assigned to variables by follows; use of the LET command as LET variable=expression The computer does not type anything in response to this command, but computes the expression and assigns the value to the variable. The variable may then be used in another computation or may be output using the PRINT command. For example: LET PI =3. 141 59 PRINT Pl*4t2 6.6.3 Looping PRINT and LET Commands It is possible to include PRINT and LET commands in a loop so that Looping variables and results may be stored or printed in a series. FOR-NEXT statements in which the FOR is accomplished by means of statement sets the limits of the loop and the NEXT statement increments the count by 1. The only restriction in Immediate Mode looping is that the command and the looping statements must appear on character (\) This is accomplished by using the backslash one line. (The backslash is produced to separate multiple statements on a line. on an LT33 or 35 Teletype by pressing the SHIFT and L keys Other types of terminals provide a separate key.) For simultaneously. example: LET Pl=3. 14159 FOR 1=1 TO 3 SPRINT PlflNNEXT I This combination will print the results of 3.14159 to and 3rd powers respectively. the 1st, 2nd, More information on looping in general is provided in Section 6.8.7. 6-7 1 EXAMPLE RUN 6.7 The following Example Run is included at this point as an illustration of Cassette BASIC'S initial dialogue, the format of a BASIC program, the ease in editing and running it, and the type of output that may be The user calls in the program AVER from cassette drive 1 produced. Execution is halted by a SYNTAX ERROR at line and attempts to run it. The user lists the program, finds the mistake in line 30, and 30. He corrects these errors by also notices a mistake in line 85. retyping the lines, and then reruns the program. After execution he saves the corrected program on drive 1 under the original name. Following sections cover the statements and programming. commands used .R BASIC USING RUN-TIME FILE I/0?CY OR N)N MEW OR OLD -OLD OLD PROGRAM NAME-AVER UNIT#C0-7) : READY. HUN HOW MAMY STUDENTS^ HOW MANY GRADES PER STUDEMT SYXfTAX ERROR AT LINE 30 7 5,4 LIST 10 REM - PROGRAM TO TAKE AVERAGE OF 15 REM - STUDENT GRADES AND CLASS GRADES 20 PRINT "HOW MANY STUDENTS > HOW MANY GRADES PER STUDENT 30 INP(JT AjIB 40 LET 1=1 50 FOR J=I TO A 55 LET V=0 60 PRINT "STUDENT NUMBER =";j 7 5 PRINT "ENTER GRADES" 76 LET D=J 80 FOR K=D TO D+(B-1) 81 INPUT G 82 LET U=V+G 85 NEXT L 90 LET V=V/3 95 PRINT "AVERAGE GRADE =";V 96 PRINT 99 LET Q=Q+V 100 NEXT J 101 PRINT 102 PRINT 103 PRINT "CLASS AVERAGE =";Q/A 10^ STOP 40 END 1 &-.8 in BASIC . READY. 30 INPUT A*B 85 NEXT K RUN HOW MANY STUDENTS^ HOW MANY GRADES PER STUDENT ?5>4 STUDENT NUMBER = 1 ENTER GRADES ?78 ?86 ?88 ?74 AVERAGE GRADE = 81.5 STUDENT NUMBER ENTER GRADES = 2 ?59 ?86 ?70 ?87 AVERAGE GRADE 7 5.5 = STUDENT NUMBER ENTER GRADES = 3 ?58 ?64 ?75 ?g0 AVERAGE GRADE 69.25 = STUDENT NUMBER ENTER GRADES = 4 ?88 ?92 ?85 ?79 AVERAGE GRADE 86 = STUDENT NUMBER ENTER GRADES = 5 ?60 ?78 ?85 ?80 AVKWGE GRADE = 75.75 CLASS AVERAGE = 77.6 READY SAVE UWIT#(0-7):l READY. 6-9 . ; 6.8 BASIC STATEMENTS The statements described in this section are used in creating BASIC These statements make up the body of the program; they programs. perform arithmetic calculations and input and output operations , and control the order of program execution. 6.8.1 Statement Numbers An integer number is placed at the beginning of each line in a BASIC program. BASIC executes the statements in a prograir in numerically consecutive order regardless of the order in which they have been typed. A recommended practice is to number lines by fives or tens, so that additional lines may be inserted in a program without the (BASIC programs may necessity of renumbering lines already present. be created using either the BASIC Editor as described here, or the If the CAPS-8 EDITOR is used, the programmer must make CAPS-8 EDITOR. certain to type his program in numerically consecutive order, as BASIC will not sort it in this case.) Multiple statements may be placed on a single line by separating each statement from the preceding statement with a backslash (SHIFT/L) This feature is particularly useful since statement numbers require if unnecessary statement numbers are space in the symbol table; eliminated by use of the backslash, there will be more room for program storage. For example: 10 A=5\B=.3\C=3\PR1NT "ENTER DATA" All of the statements in line 10 will be executed before BASIC Only one statement number at the continues to the next line. However, it should be beginning of the entire line is necessary. noted that program control cannot be transferred to a statement within in which it is a line, but only to the first statement of the line contained (see Section 6.8.9, Transfer of Control Statements). 6,8.2 The or The The Commenting the Program (REM) REM or REMARK statement allows the programmer to insert comments remarks into a program without these comments affecting execution. BASIC compiler ignores everything on a line beginning with REM. form is (line number) REM (message) eind 15 are REMARK statements In the Example Run program, lines 10 It is often useful to put the name describing what the program does. of the program and information relating to its use at the beginning Remarks throughout the where it is available for future reference. body of a long program will help later debugging by explaining the purpose of each section of code within the program. 6-10 Terminating the Program (END and STOP) 6.8.3 The END statement (line 140 in the Example Run program) , if present, must be the last statement of the entire program. The form is: (line number) END Use of the END statement is optional. of the program and BASIC prints: If executed, it signals the end READY. Variables and arrays are left in an undefined state, any values they have been assigned during execution. thereby losing The STOP statement is used synonymously with the END statement to terminate execution, but while END occurs only once at the end of a program, STOP may occur any number of times. The format of the STOP statement is: (line number) STOP This statement signals that execution is to be terminated at that point in the program where it is encountered leaving variables in a defined state. (Variables will contain the values assigned when the statement is encountered.) 6.8.4 The Arithmetic Statement (LET) The Arithmetic (LET) statement is probcibly the most commonly used BASIC statement. It causes a value to be assigned to a variable and is of the form: (line number) (LET) x = expression where x represents a variable, and the cjxpression is either a number, cinother variable, or an arithmetic expression. The word 'LET' is optional; thus the following statements are treated the same: LET A=AtB+10 A=AtB+10 LET C=F/G C=F/6 As mentioned earlier, relational operators may be used in a LET statement to assign a value to a varialsle depending upon the validity If the statement is FALSE, the value of a relationship. is assigned For example: to the variable; if TRUE, the value 1 is assigned. IW'^ A=l 105 110 120 130 140 150 B=a C=A=B D=A>8 E=A<>B PRINT C,D,K EMD 6-11 : Translated, this actually means "let C=l if A=B (0 otherwise) ; let D=l if A>B (0 otherwise)" and so on. Thus, the values of C, D, and E are printed as follows RUN 1 READY. There is no limit to the number of relationships that may be tested in the statement. 6.8.5 Input/ Output Statements Input/Output statements allow the user to bring data into a program The console and output results or data at any time during execution. terminal keyboard, (LT33 Teletype reader and punch units, if present), cassettes, and line printer are all available as I/O devices in Cassette BASIC. Statements which control their use are described next. READ and DATA READ and DATA statements are used to input data into a program. One statement is never used without the other. The form of the READ statement is: (line number) READ xl,x2,...xn where xl through xn represent variable names. 10 For example: READ A>B^C Variables A,B, and C are variables to which values will be assigned. READ statements are in a READ statement must be separated by commas . generally placed at the beginning of a program, but must at least logically occur before that point in the program wheire the value is required for some computation. Values which will be assigned to the variables in a READ statement are supplied in a DATA statement of the form: (line number) DATA xl,x2,...xn where xl through xn represent values. The values must be separated by commas and must occur in the same order as the variables which are statement A DATA listed in the corresponding READ statement. appropriate for the preceding READ statement is: 73 DATA 1^2»3 Thus, after executing the READ statement, A=l, B=2 , and C=3. 6-12 (before The DATA statement is usually placed at the end of a program where it is easily accessible to the programmer the END statement) should he wish to change the values. A READ statement may have more or fewer variables than there are The READ statment causes BASIC to values in any one DATA statement. search all available DATA statements in consecutive line number order until values are found for each variatile in the READ. A second READ If at statement will begin reading values where the first stopped. some point in the program an attempt is made to read data which is not present or if the data is not separated by commas, BASIC will stop and print the following message on the console terminal: DATA ERROR AT LINE XXXX where XXXX indicates the line caused the error. number of the READ statement which RESTORE If it should become necessary to use the same data more than once in a program, the RESTORE statement will make it possible to recycle through the DATA statements beginning with the lowest numbered DATA The RESTORE statement is of the form: statement. (line number) RESTORE An example of its use follows: 15 READ B^C>D 55 RESTORE 60 READ E»F>G 80 DATA 6>3*4>7>9>2 100 END In this example, the READ statements in lines 15 and 60 will both read If the RESTORE the first three data values provided in line 80. statement had not been inserted before line 60, then the second READ would pick up data in line 80 starting with the fourth value. In recycling through data with a RESTORE statement, the programmer may the same variable names the second time through the data, or not, as he chooses , since the values are being read as though for the first skip unwanted values, the programmer may insert In order to time. replacement (or dummy) variables. Consider: use 6-13 2 REM 1 - PROGRAM TO ILLUSTRATE USE OF RESTORE 20 READ N PRINT "VALUES OF X ARE:" 30 FOR 1=1 TO N 40 READ X 50 PRINT X, 60 NEXT I 70 RESTORE 185 PRINT 190 PRINT "SECOND LIST OF X VALUES'" 200 PRINT "FOLLOWING RESTORE STATEMENT:" 210 FOR 1=1 TO N 220 READ X 230 PRINT X.. 240 NEXT I 25 2 50 DATA A, I, 251 DATA 3^4 300 END 1212 RUN VALUES OF X ARE: 3 4 SECOND LIST OF X VALUES FOLLOWING RESTORE STATEMENT: 4 3 READY. The second time the data values are read, the variable X (line 220) picks up the value originally assigned to N in line 20 , and as a result, BASIC prints: To circumvent this, the programmer could insert a dummy variable (for example, 205 READ Z ) , which would pick up and store the first value, but would not be represented in the PRINT statement. In this case the output would be the same each time through the list. INPUT The INPUT statement is used when data is to be supplied by the user from the console terminal keyboard while a program is executing, and is of the form: (line number) INPUT xl,x2,...xn where xl through xn represent variable names. For example: 25 INPUT A*B*C This statement will cause the program to pause during execution, print a question mark on the console terminal, and wait for tlie user to type three numerical values. The user must separate the values by commas; they are entered into the computer by pressing the RETURN key at the end of the list. 6-14 : If the user does not insert enough values to satisfy the INPUT statement, BASIC prints another question mark and waits for more values to be input. When the correct number has been entered, execution continues. If too many values are input, BASIC ignores those in excess of the required number. The values are entered only when the user types the RETURN key. OPEN Input and output files may be stored on cassette, and may be accessed during run-time (providing the user has chosen the run-time I/O option during BASIC'S initial loading dialogue) . Before an I/O file is accessed however, the user must first open it via one of the following commands (line number) OPEN "n:xxxx" FOR INPUT or (line number) OPEN "nixxxx" FOR OUTPUT where n represents the cassette drive numlDer (0-7) , and xxxx is any legal filename characters or less, and optional extension of 3 (6 characters or less) . Input files are created either by using BASIC or the CAPS-8 EDITOR (see Section 6.8.6), and must have been previously stored on cassette before being accessed. For example, the statement: 815 OPEN "1 :TEST.DAT" FOR INPUT opens an input file named TEST. DAT on cassette drive 1. Only one input and one output file may be open at any time, and only one file either input or output may be open on a given cassette drive at one time. — — CLOSE The CLOSE statement is used to close a currently open output file, and is of the form: (line number) CLOSE Suceeding OPEN FOR INPUT statements will perform an automatic close on open input file; however, the user should take note of a previously the following cases: 1. If the user attempts to open an input file on a cassette which is currently open for output, BASIC will return an I O ERROR, as the same cassette drive cannot be open for both input and output at the same time. 2. If the user has an input file open on a cassette, and is end-of-file has been its (that is, a CTRL/Z at detected) , BASIC will allow him to open an output file 6-15 # . the same cassette, since the input file is theoretically "closed". However, if the usier has an input file open on a cassette and is not at its end-of-file, an I O ERROR will occur if he then tries to open an output file on the same cassette. (See Section 6.8.9, IF END#, for more information on BASIC'S method of detecting an end-of-file.) on 3. If the user tries to open an output file and an output file is already open on any cassette, BASIC will return a "FILE OPEN ERROR"; before opening a new output file, the current output file must be closed. A close is automatically performed on both open input and open output files by STOP, END and CHAIN statements, as well as by all errors detected at run- time. INPUT Once an input file has been opened using the open statement, data can be called into a program using the INPUT* statement. The form of this statement is: (line number) INPUT# xl,x2,...xn where # signifies that the file is stored on cassette under the filename and drive number specified in the last "C1PEN...FOR INPUT" statement; xl through xn represent variable names. When the BASIC program reaches the INPUT# statement during execution, automatically called into the program from cassette and the data is INPUT # statements and INPUT statements may be execution continues. interspersed throughout a program. The input file need only be opened once before it is referenced. PRINT The PRINT statement is used to output results comments, values of variables, or plot points console terminal. The format is: (line number) cf computations, cf a graph on the PRINT expression When no expression is indicated in the statement line, a blank line is For example: output. MS PRINT 810 PRI'\)T By using Two blank lines will be output on the console terminal. certain kinds of expressions and the control chaiacters colon and semicolon, the user can create fairly sophisticated formats 6-16 : In order to print out the results of a computation and the value of a variable, the user types the line number, PRINT, and the variable name(s) separated by a format control character (in this case, commas) as follows: 5 10 A=16\B=5\C=4 PRINT A*C+B,SQR<A) print value above A are In BASIC, an output line is formatted into five columns (called The control character comma causes a zones) of 14 spaces each. In the to be typed beginning at the next available print zone. example, the value of A, the sum of A+B, and the square root of printed in the first three print zones as follows: RUN 4 9 16 A statement such as in line number 10 in this next example: 5 A=2.3\B=21\C=156.7 5\D=1 .134\E=23.4 A^BjC^D^E 10 PRINT the causes the values of the variables to be printed in using all five zones: RUN 2.3 same format 1.134 23.4 When more than five variables are listed in the PRINT sixth value begins a new line of output. statement, 156.75 21 the The PRINT statement may also be used to output a message or line of The desired message is simply placed in quotation marks in the text. PRINT statement as follows: 10 PRINT "THIS IS A TEST" when line printed: 10 is encountered during execution, the following is THIS IS A TEST A message may be combined with variable as follows: result the of a calculation or a 80 PRINT "AMOUNT PER PAYMENT ="^R Assuming R=344.96, when line 80 is encountered during results are output as AMOUNT PER PAYMENT = execution, the 344.96 If a number following a printed message is too long to be printed on a single line, the number is automatically moved to the beginning of the next line. The It is not necessary to use the standard 5-zone format for output. control character semicolon (;) causes the text or data to be output 6-17 immediately after the last character printed (separated from that character by a space and followed by another space) . If neither a comma nor a semicolon is used, BASIC assumes a semicolon. Thus both of the following; 80 PRINT "AMOUNT PER PAYMENT ="R 80 PRINT "AMOUNT PER PAYMENT =";R result in: AMOUNT PER PAYMENT = 344.96 The PRINT statement can also cause a constant to be printed on the console terminal. (This is similar to the PRINT command used in Immediate Mode.) For example; PRINT 10 1 .234>SQR< 10014) causes the following to be output at execution time: 1.834 100.07 Any algebraic expression in a PRINT statement is evaluated using the current value of the variables. Numlaers are printed according to the format discussed in Section 6.3. The following example program illustrates the use of the control characters comma and semicolon in PRINT statements . The user may also wish to refer to Section 6.8.12 for information pertaining to three functions available for additional character control TAB, PUT, and GET: — 10 READ A.,B,C S0 PRINT A>B^C >At2 ,Bt2..Ct2 30 PRINT 40 PRINT AiBJC ;At2 JBf2:!Ct2 50 DATA 4 ,5,6 60 END RUN 4 5 16 25 36 4 5 6 16 25 36 READY. Another use of the PRINT statement is to combine it with an statement so as to identify the data expected to be entered. example, consider the following program; 6-18 INPUT As an 9 REM 10 PROGRAM TO COMPUTE INTEREST PAYMENTS - 20 PRINT "INTEREST IN PERCENT'S 25 INPUT J 26 LET J==J/100 30 PRINT "AMOUNT OF LOAN"i 35 INPUT A 40 PRINT "NUMBER OF YEARS"; 45 INPUT N PRINT "NUMBER OF PAYMENTS PER YEAR"; INPUT M LET N=:N*M LET 1 = J/M 50 55 60 65 70 75 78 = LET B = 1+1 LET R ==A*i/(i-:l/BtN> = PRINT 80 PRINT "AMOUNT PER PAYMENT =";R 85 PRINT "TOTAL INTEREST =";r*isi-a 88 PRINT 90 LET B =:A 95 PRINT " INTEREST APP TO PR IN 100 LET L,=B*I 110 LET P =R-L 120 LET B =B-P t ] BALANCE" 1 ' 130 PRINT L/P,B 140 IF B> =RGO TO 100 150 PRINT B*I,R-B*I 160 PRINT "LAST PAYMENT ="B*I+B 200 END HUN INTEREST IN PERCENT? AMOUNT OF LOAN72 500 NUMBER OF YEARS72 NUMBER OF PAYMENTS PER YEAR?4 AMOUNT PER PAYMENT TOTAL INTEREST = 344.9617 = 2 59.. 6932 APP TO PRIN 288.7117 295.2077 301 .8498 43.1 1182 308.6415 36.32019 315.5859 29.37576 322.6866 22.27508 329.947 15.01463 337.3708 7.590824 LAST PAYMENT = 344.9608 INTEREST 56.25 49.75399 BALANCE 2211 .288 1916.081 1614.231 1305.589 990.0035 667.317 337.3699 READY. As can be noticed in this example, the question mark is grammatically useful when several values are to be input by allowing the programmer to formulate a verbal question which the input values will answer. 6-19 : PRINT* The PRINT* statement is similar to the PRINT statement with the exception that data and messages are sent to the current output file on cassette rather than to the console terminal. The form of the statement is: (line number) PRINT# xl,x2,...xn where # signifies that the output will be sent to the cassette drive number and filename of the currently open output file, and xl through xn represent data variables. (The current open file is determined by the OPEN FOR OUTPUT statement, as detailed earlier in this section.) If the user attempts to save data on a full cassette, BASIC prints an error message and returns control to its editing jahase. The data already output is lost, and the user will have to rerun his program using a different output cassette. COMMAS and NO COMMAS Data stored in an output file on cassette is often called later as input by another or the same program. (This is i.n fact the only method of passing data between segments of a chained program.) In order to be used as input, this data must be in the scime format as it would appear if written in a DATA statement. Cassette BASIC provides two statements for formatting this output COMMAS and NO COMMAS. — In order to be used as data, individual values must be separated by the COMMAS statement inserts a comma after each item of data; commas; (unless the COMMAS statement is inserted in the program prior to PRINT# statement, data will be output in the foirmat illustrated earlier under the PRINT statement.) The form is: (line number) COMMAS A NO COMMAS statement will set the format back to its original state. The COMMAS and NO COMMAS statements do not affect output on either the console terminal or line printer. The following example reads the "OUT. DAT", console terminal. writes out four values in a file called values back into memory and prints them on the 10 OPE!>J "1 :OfJT.DAT" FOR 15 COMMAS OUTPUT 20 PHINT# l;2J3;4 30 CLOSE 40 OPEN "1:OOT.DAT" FOR INPUT 50 INPUT# I:»J>K,L 60 PRINT IjJ>K>L 70 ElNJD Output appears as follows RUN 1 « 3 READY. 6-20 4 ) The COMMAS statement is not necessary if the user is only sending one value per line. The preceding example could have been coded as follows, with the same results: 10 OPEN "ItOQT.DAT" FOR OUTPUT 20 FOR 1=1 TO 4 30 PRINT* I 40 NEXT I 50 60 70 80 90 CLOSE OPEN "1: OUT. DAT" FOR INPUT INPUT* I^J^KiL PRINT 1,J,K,L END In this case the file OUT. DAT would appear; 1 2 3 whereas in the first case it would appear as follows: U2j3*4 The user must take care when inputting data from cassette files. example, if the file OUT. DAT is in the form: For 1^2,3*4 and the user attempts statement: 53 INPUT* to input these values using the following I^J^K the proper values for I, J, and K will be read, but the rest of the line will be lost as far as satisfying any future variables just as it would be lost if these values were input from the console terminal. INPUT statement in this (Refer to the information concerning the section. — LPT The LPT statement is used to generate output on the line one is available) and is of the form: (line number) printer (if LPT all subsequent By inserting this statement anywhere in a program, output, with the exception of error messages, will be printed on the The LPT statement is particularly advantageous for line printer. outputting large amounts of calculated data, as can be seen from this 6-21 . and following examples: 100 110 120 130 140 LPT FOR F=33 TO 60 STEP PRINT F^Fta NEXT F END 3 HON 30 33 3fe 39 HZ «5 aa 51 5a 57 60 900 10«9 1296 1521 176a 2055 230a 2601 2916 32a9 3600 When the END statement is encountered in device is reset to the console terminal. the program, the output TTY OUT The console terminal may be placed under program control so that during execution of a program output may be sent alternately between the console terminal and the line printer (if one is availcible on the system) Control is originally set with the console terminal. By issuing the LPT statement discussed previously, all subsequent outjput can be sent to the line printer. To return control to the console terminal from within the program, the statement: (line number) TTY OUT (Cassette I/O always returns control to the last device indicated, so that the TTY OUT statement need only be used when the line printer is involved.) is inserted. The following program makes use of almost all the availcible I/O devices. The console terminal and line printer output Ls included. HEM PROUF?AM TO DEMOMSTHATE ALL I/O DEVICES REM AVAILABLE IN CASSETTE BASIC 15 REM 20 PRINT "PROGRAM TO CALC'JLATE SQUARES AND SQUARE ROOTS" 25 PRINT 27 HEM GET LOOP LIMITS FROM USER 30 PRINT "INPUT LOWER LIMIT" 35 INPUT L '!10 PRINT "INPUT UPPER LIMIT" A5 INPUT U 50 PRINT "INPUT STEP" 55 INPUT S 57 HEM CREATE A CASSETTE FILE OF SQUARES OF NUMBERS 60 OPEN "1 :SnUARE.DAT"FOR OUTPUT 5 IP) 6-22 65 LPT 66 HEM PRIWT A FORM FHIRD OM LINEPRIMTEK 70 T=P'JTCia) 75 PRINT "TABLH: OF M'JMBERS AND THEIR SOMAHES" 80 PRINT 81 PRINT 82 PRIMT •• X'S" XtH" 83 PRINT 85 FOR X = L TO 'I STEP S 91^ PRINT X^X»^ 95 REM ALSO SEND SO'JARES TO 100 PRINT* Xta 135 ^JEXT X 11^6 CASSETTE FILE CLOSE 110 T=P'JT(ia) 11 1 TTY O'lT 112 PRINT 113 LPT 115 PRINT 13PI 125 126 127 128 130 135 136 l^lO) 150 155 160 165 "TABLE OF SO'JARES COMPLETE" "TABLE OF N'JMBRRS AND THEIR SO'JARE ROOTS" OPEN "1 :SO'TARE.DAT"FOR INPiJT PRINT PRINT PRINT " X"*" SORCX)" PRINT FOR X=L TO 'I STEP S INPIT* J PRINT JjSORCJ) NEXT X T=P'IT(12) TTY O'JT PRINT "PROGRAM COMPLETED" END nuN PROURAM TO CALC'JLATE SO'JARES AND SO'JARE ROOTS IN^'JT LOWER LIMIT ?1 INP'IT tJPPER LIMIT ?5^ INP'JT STEP ?1 TABLE OF SO'JARES COMPLETE 6-23 TABLE flF MJHBtRS ANO THfclR SQUARES X-d 1 1 4 3 h 7 ha B HI 1? 155/ 49 ^4iii1. 5PI TAbue OH NUMHtWS ANO TMfclk SfOUAkE WQOTS SOk(X) 1 1 4 ? 9 3 4 S b u9 7 (t.4 b «1 r'4F:l 49 SI? 6-24 NOTE Teletype is used as the If an LT33 terminal and it includes a console reader and punch, these devices may be used for I/O operations at any time; no special statement is required. To read in data from the reader, position the tape over the sprocket wheel; when input is required, set the reader to START and To the tape will begin reading in. set the punch to ON and punch a tape, all Teletype output will be punched on Using the paper tape I/O the punch. devices is, in effect, tJie same as using Characters will the Teletype keyboard. be typed on the Teletype keyboard as tapes are being read or punched. 6.8.6 Creating Run-Time Input Files Data files stored on cassette and used for input during execution can be created either by use of BASIC itself or by use of the CAPS-8 EDITOR. Using BASIC, the programmer creates a program which accepts values from the console terminal keyboard and then writes these onto the Data files consist of consecutive ASCII cassette as an output file. If the useful data in a file is to end before the actual characters. end-of-file, the last useful character must be followed by a CTRL/Z. inserted by BASIC when the user closes an output (This character is When later detected during input, BASIC sets an end-of-file file. the user can test an end-of-fil€i condition by using the IF-END# flag; statement.) The COMMAS statement is used to produce the correct format for a data file when more than one value is on a single line. The following program illustrates one method of doing this: 5 REM - PHOGRAM TO ACCEPT DATA FROM THE CONSOLE 10 REM - TERMINAL AMD CREATE A RUNTIME INPUT FILE 20 OPEN "0:RTIN.DAT" FOR OUTPUT 25 PRINT "INPUT A>B*CjD"i 30 INPUT A*B>C*D 35 COMMAS 40 PRINT* A>B*C>D 45 PRINT "INPUT FCI) FOR 1=1 TO 10" 50 DIM F(10) 52 REM - COMMAS NOT NEEDED SINCE ARRAY WILL 53 REM - BE OUTPUT ONE ELEMENT PER LINE 55 NO COMMAS 60 FOR 1=1 TO 10 70 PRINT "F("I")"i 7 5 INPUT FCn 80 PRINT# F(I) 85 NEXT I 90 PRINT "INPUT \}\,\J2.Z" 95 INPUT V\,V2.,Z 97 REM - COMMAS ARE NEEDED SINCE VU V2 AND Z 93 REM - WILL BE OUTPUT ON THE SAME LINE 6-25 100 COMMAS 105 PRINT# \}l,\J2^Z 1 10 1 1 5 CLOSE END rtUN SAVE UNlT#(0-7) :g READY. The The CAPS-8 EDITOR can also be used to create an input file. EDITOR first asks for input and output devices and filenames; then the user types the file using EDITOR commands and making sure the format The same data file in the above example can be correct for BASIC. is created using the EDITOR as follows: i.R EDIT * INPUT FILE- OUiVdl- FILE- 2rtfIN.DAT J.A 1 .37»2.346j.-13.267^-1 .056 23 3.56 1 .436 38 9.386 23.067 89 54 12.467 -1 123,34567^789 IL 1.37,2.346>-13.8 67,-1.0 56 23 3.56 1 .436 38 9.026 83.067 89 54 12.467 -1 123*34567*789 #E 6-26 . : 6.8.7 Loops (FOR, NEXT and STEP) A loop is a set of instructions which are repeated over and over again, each time being modified in some way until a terminal condition is reached. FOR and NEXT statements define the beginning and end of a STEP specifies an incremental value. The FOR statement is of loop; the form: (line number) FOR v=xl TO x2 STEP x3 where v represents a variable name, and xl, x2 , and x3 all represent formulas (a formula in this case means a numerical value, variable name, or mathematical expression), v is termed the index, xl the initial value, x2 the terminal value, and x3 the incremental value. For example 15 FOR K=a TO 20 STEP 2 This loop will be repeated as long as K is less than or equal to 20. Each time through the loop, K is incremented by 2 , so the loop will be executed a total of 10 times. A variable used as an index in a subscripted, although a common use subscripted variables using the value of defined variable (this is a previously Subscripted Variables) FOR statement must not be of loops is to deal with the index as the subscript of illustrated in Section 6.8.8, The NEXT statement is of the form: (line number) NEXT v where v is the index of the FOR loop and signals the end of the loop. When execution of the loop reaches the NEXT statement, the computer adds the STEP value to the index and checks to see if the index is If so, the loop is executed less than or equal to the terminal value. If the value of the index exceeds the terminal value, again. control falls through the loop to the following statement, with the value of the index equaling the value it was assigned the final time through (Note that this method of handling loops varies among other the loop. versions of the BASIC language.) (Since +1 is If the STEP value is omitted, a value of +1 is assumed. the usual STEP value, that portion of the statement is frequently omitted.) The STEP value may also be a negative number. This loop is The following example illustrates the use of loops. executed 10 times: the value of I is 10 when control leaves the loop. +1 is the assumed STEP value, 10 FOR 1=1 TO 10 20 NEXT I 30 PRINT I 40 END RUN 10 READY. 6-27 : If line 10 had been: 10 FOR 1=10 TO 1 STEP -1 the value printed by the computer would be 1. used in the FOR statement are As indicated earlier, the numbers these formulas are evaluated upon first encountering the formulas; While the index, initial, terminal and STEP values may be loop. changed within the loop, the value assigned to the initial formula remains as originally defined until the terminal condition is reached. To illustrate this point, consider the previous example. The value of I (in line 10) can be successfully changed as follows: 10 FOR 1=1 TO 10 15 LET 1=10 80 NEXT I The loop will only be executed once since the value 10 has been reached by the variable I and the terminal condition is satisfied. If the value of the counter variable is originally set equal to the terminal value, the loop will execute once, regardless of the STEP value. If the starting value is beyond the terminal value, the loop will also execute only once. It is possible to exit from a FOR-NEXT loop without the index reaching the terminal value. This is known as a conditional transfer and is explained in Section 6.8.9. Control may only transfer into a loop which has been left earlier without being completed, ensuring that the terminal and STEP values are assigned. Nesting Loops loops within a loop. This It is often useful to have one or more technique is called nesting, cind is allowed as long as the field of (the numbered lines from the FOR statemisnt the one loop to corresponding NEXT statement, inclusive) does not cross the field of another loop. A diagram is the best way to illustrate acceptable nesting procedures ACCEPTABLE NESTING TECHNIQUES UNACCEPTABLE NESTING TECHNIQUES Two Level Nesting 1 FOR FOR pFOR -FOR h^IEXT '-NEXT pFOR -NEXT '-NEXT NEXT 6-28 : Three Level Nesting — FOR —-FOR FOR FOR I pFOR r-FOR •-NEXT f-FOR L-NEXT pFC FOR EXT NEXT NEXT H-NEXT L-NEXT NEXT A maximum of eight (8) levels of nesting is permitted, limit will result in the error message: Exceeding that FOR ERROR AT LINfE XXXX where XXXX is the number of the line in which the error occurred. Subscripted Variables 6.8.8 In addition to single variable names, BRSIC accepts another class of variables called subscripted variables. Subscripted variables provide the programmer with additonal computing capabilities for handling tables, matrices, or any set of related variables. lists, Variables are allowed one or two subscripts. A single letter forms the name of the variable, followed by one or two integers in parentheses, separated by a comma, indicating the place of that variable in the list. Up to 26 arrays are possible in any program (corresponding to the letters of the alphabet) , subject only to the amount of memory space available for data storage. For example, a list might be described as A(I) where I goes from 1 to 5 , as follows: A(l) ,A(2),A(3),A(4) ,A(5) This allows the programmer to reference each of the five elements in the list A. A two dimensional matrix A (I, J) can be defined in a similar manner, but the subscriped variable A can only be used once (i.e., A(I) and A(I,J) cannot be used in the same program). It is possible however, to use the same variable name as both a suliscripted and am unsubscripted variable. That is, both A and A(I) are valid variable names for use in the same program. Subscripted variables allow data to be input quickly and easily, as illustrated in the following program (the index of the FOR statement in lines 20, 42 and 44 is used as the subscript) 10 11 15 18 P.0 25 30 35 38 39 40 HI zjg REM - PROGRAM DSMOMSTRAT IMU READ I Mb RKM - OF S'IBSCRIPTED VARIABLES DIM A(5),B(2*3) PRINT "ACn WHERE A = TO 55" FOR 1 = 1 TO 5 READ ACI) PRIMT ACn; MEXT I PRINT PHIMT PRINT ••B(l,J) WHERE 1 = TO P.:" PRINT AND J=l TO 3:" FOR 1 = TO 2 l 1 •• 1 6-29 43 PRINT FOR J=l TO 3 48 READ B(I,J) Zl^i 50 PRINT R(I*J); 55 NEXT J 56 NEXT 60 DATA I >8>3>4*5*6*7^8 DATA 8^ 7 ^6^5^4*3^2^! 65 END 1 61 H'JN WHERE A=l TO AC I ) 1 R 3 4 5 J 5 B{I>J) WViERE 1 = 1 TO 3: AND J=l TO 3: 6 8 7 7 8 6 READY. DIM From the preceding example, it can be seen that the use of subscripts requires a dimension (DIM) statement to define the maximum number of elements in the array. The DIM statement is of the fonri: (line number) DIM vl(nl), v2(n2,m2) where v indicates an array variable name and n and m are integer numbers indicating the largest subscript value required during the program. For example; 15 DIM AC6>10) The first element of every array is automatically assumed to have a subscript of zero. Dimensioning A(6,10) sets up room for an array with 7 rows and 11 columns. This matrix can be thought of as existing in the following form: AO , AO , 1 ... A1,0 Al,l ... A2,0 A2,l ... A0,10 Al,10 A2,10 A6,0 A6,l ... A6,10 and is illustrated in the following program: 6-30 10 REM - MATRIX CHECK PROGRAM 15 DIM A(6*10) 20 FOR 1=0 TO 6 LET A(Ij0)=I FOR J=0 to 10 LET A(0;.JJ=J PRINT A(I>J); 3 5 NEXT J 40 PRINT 4 5 NEXT I 50 END 22 25 28 30 RUN 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 READY. Notice that a variable assumes a value of zero until another value has been assigned. If the user wishes to conserve memory space by not making use of the extra variables set up within the array, he should set his DIM statement to one less than necessary, i.e. DIM A(5,9). This results in a 6 by 10 array which may then be referenced beginning with the A (0,0) element. More than one array can be defined in a single DIM statement: 10 DIM A(20>> B<4>7) This dimensions both the list A and the matrix B. A number must be used to define the maximum size of the array. A variable inside the parentheses is not acceptable and will result in run-time. The amount of memory not an error message by BASIC at filled by the program will determine the amount of data the computer In some programs can accept as input to the program at any one time. occur, indicating that memory will not hold an a TOO-BIG ERROR may In that event, the user should change array of the size requested. his program to process part of the datei in one run and then chain to another section to process the rest (see Section 6.8.10). 6.8.9 Transfer of Control Statements Certain control statements cause the execution of a program to jump to line either unconditionally or as a result of some a different condition within the program. Looping is one method of jumping to a designated point until a condition is met. The following statements give the programmer added capeibilities in this area. 6-31 Unconditional Transfer (GOTO) The GOTO (or GO TO) statement is an unconditional stattsment direct program control either forward or back in a program. of the GOTO statement is: used to The form (line number) GOTO n where n represents a statement number. When the logic of the program reaches the GOTO statement, the statement (s) immediately following will not be executed; instead execution is transferred to the statement beginning with the indicated line number. The following program never ends; it does a READ, prints something, and j lamps back to the READ via a GOTO statement. It atempts to do this over and over until it runs out of data, which is <in acceptable, though not advisable, way to end a program. 10 REM 11. REM 30 35 30 35 40 - PHOtiRAM ENDIfOU WITH KRROR MESSAUE WHi^M O'JT OF DATA READ X PRINT "X=*'X*"Xta = "Xt8 GO TO 80 DATA 1/5^10*15^20*85 END H'JN X= X= X= X= X= X= Xf8 = Xt8 = Xt8 = Xt8 = Xt8 = X»8 = 1 5 10 15 80 35 1 85 100 885 400 685 DATA ERROR AT LINE 20 jitADY. Conditional Transfer (IF THEN and IF GOTO) two values be compared at some point; control of program execution may be directesd to different In computing, procedures depending upon the result of the comparison. values are logically tested to see whether they are equal, greater than, less than another value, or possibly a combination of the three. This is accomplished by use of the relational operatoirs discussed in Section 6.5.3. A program sometimes requires that statements allow the programmer to test the numbers, or (variables, formulas between two relationship the IP Providing the relationship described in expressions) . statement is true at the point it is tested, control will be transfered to the line number specified, or the indicated operation will be performed. The statements are of the form: IF THEN and IF GOTO (line number) IF vl <relation> v2 GOTO [or THEN] 6-32 x ; where vl and v2 represent variable names or expressions, and x represents a line number or an operation to be performed. The use of either THEN or GOTO is acceptable. The following two examples are equivalent (the value of the variable A is changed or remains the same depending upon A's relation to B) 100 IF A>B THEN 120 110 A=AtB-l 120 C=A/D 100 IF A<=B THEN A=AtB-1 110 C=A/D IF END# The IF END# statement is used to verify cin end-of-file during run-time input. The form of this statement is: (line number) condition IF END# THEN n IF END# instructs BASIC to perform a check on the validity of the last INPUT* statement referencing the currently open input file; n represents a line number or operation to be performed. If an end-of-file (CTRL/Z) was detected during the last INPUT* statement, BASIC transfers control to the specified line number or performs the indicated operation. If an end-of-file was not detected, then no operation occurs. For example: 150 OPEN "l:UALUE" FOR INPUT 200 INPUT* A#B*C 210 IF END# THEN 530 215 LET X=SGNCA) 530 PRINT "INPUT FILE- -NOT ENOUGH DATA' 53 5 STOP 6-33 : In this example the programmer provides his ovm error message if there an insufficient number of values for his variables. is If there are two valid numbers remaining in the input file when staitement 200 is then the variables A and B will receive valid input. When reached, BASIC will detect an the program attempts to input a value for C, end-of-file and return a value of zero for C. As it executes the IF END# statement, BASIC will note that it has jusit reached the end-of-file, and will transfer control to statement number 530, as the user intended. However, assiame that as line 200 is executed there is only one valid data value left in the input file. An end-of-file is detected this When time when BASIC tries to read a value for B; B is set to zero. BASIC attempts to continue reading a value for C, an EOF ERROR will be returned (see Section 6.12) and program execution will terminate since A good way of the user has tried to read past the end-of-file. circumventing this condition is to include both the INPUT # and the IF Using this END# statements in a loop and input one value at a time. method allows the programmer's own error message to be printed before BASIC is allowed to read past the end-of-file. 6.8.10 Program Chaining (CHAIN) Since Cassette BASIC allows at most only 2K words of memory for program storage, it is possible that a program may be too large to fit However, Cassette BASIC compensiates for this in memory at one time. by allowing different segments of a program to be stored on cassette and called as needed. Although each program segment is restricted to The form 2K of memory, total program length is effectively unlimited. of the CHAIN statement is (line number) CHAIN "niXXXX" where n is the cassette drive number, and XXXX is the name of the file The CHAIN statement should be the last statement in to be chained to. When BASIC transfers to the progrcim specified in the user's program. Data is not it removes the old program from memoiry. the statement, passed in memory during the chain, so the user should be careful to (See Section save any data he will need in an output file. 6.8.5 PRINT#.) The chain automatically closes any open output file, transfers control to the lowest statement number in tJie new program, and continues execution. — For example, the following section of a program stores some values on an output cassette and chains to a file calltid PART2: OPEN "ItDATA" FOR OUTPUT COMMAS 460 PRINT* B>C*D*G*H*Z 465 NO COMMAS 473 FOR 1=1 TO 10 475 PRINT* A<n 480 NEXT I 485 CLOSE 490 CHAIN "1:PART2" 4 50 ^155 6-34 data The values stored by this section of the program in the cassette file DATA can be read in by the second section of the program PART2 and can continue to be used. PAPT2 might appear as follows: — — DIM AC 10) OPEN "1:DATA" for INPUT 10 INPUT# B,C>D^G>H>Z 1 5 15 FOR 1=1 TO 10 80 INPUT# AC I) 25 NEXT I 6.8.11 Subroutines (GOSUB and RETURN) A subroutine is a section of code performing some required at more than one point in the program. I/O operation for a volume of data, a mathematical too complex for a user-defined function, or processes may best be performed in a subroutine. operation that is Often a complicated evaluation which is any number of other Subroutines are generally placed physically at the end of a program, usually before DATA statements, if any, and always before the END statement. Two statements are used exclusively in BASIC to handle subroutines; these are the GOSUB and RETURN statements. A program begins execution and continues until it encounters statement of the form: (line number) a CX)SUB GOSUB x where x represents the first line number of the For example: then transfers to that line. subroutine. Control 50 GOSUB 200 When program execution reaches line 50, control transfers to line 200, and the subroutine is processed until execution encounters a RETURN statement of the form: (line number) RETURN The RETURN statement causes control to return to the statement Before transferring to the sxibroutine, following the (MSUB statement. BASIC internally records the next statement to be processed after the thus the RETURN statement is a signal to transfer GOSUB statement; different In this way, no matter how many control to this statement. subroutines are called, or how many times they are used, BASIC always knows where to go next. The following program demonstrates a simple subroutine: 6-35 5 REM - THIS PROGRAM ILLUSTRATES GOSUB A^5D RETURN DEF FNA<X)=ABSC1NTCX)) INPUT A^B^C GOSUB 100 LET A=FNA(A) 50 LET B=FNA(B) 60 LET C=FNACC) 70 PRINT 80 GOSUB 100 90 STOP 100 REM - THIS SUBROUTINE PRINTS OUT THE SOLUTIONS 110 REM - OF THE EQUATION: ACXt2) + BCX) + C = "A"*Xt2 + + 120 PRINT "THE EQUATION IS "B"*X 130 LET D=B*B-^*A*C 140 IF D<>0 THEN 170 150 PRINT "ONLY ONE SOLUTION... X ="-B/<2*A) 160 RETURN 170 IF D<0 THEN 200 180 PRINT "TWO SOLUTIONS... X ="; 185 PRINT (;-B+SQRCD))/(8*A)"AND X =" ( -B-SQRC D) )/<«*A) 190 RETURN 200 PRINT "IMAGINARY SOLUTIONS... X = C"; 205 PRINT -B/(2*A)"^"SQRC-D)/(2*A)") AND C"; 207 PRINT -B/(2*A)","-SQRC-D)/(2*A)")" 210 RETURN 1 10 20 30 40 "C 900 END RUN ?1^ .5^-. THE EQUATION IS TWO SOLUTIONS... X 1 = + *Xt2 AND X =-1 . 5 *X + -.5 .5 *Xt2 1 THE EQUATION IS IMAGINARY SOLUTIONS... X = + < ^ 1 ) + *X AND ( 1 >-l :i READY. Line 100 begins the subroutine. There are several places in which control may return to the main program, depending upon the flow of control through the various IF statements. The subroutine is called from line 30 and again from line 80. Vvlien control returns to line 90, the program encounters the STOP statement and execution is terminated. is important to remember that subroutines should generally be kept It distinct from the main program. The last statement in the main program should be a STOP or GOTO statement, emd subroutines are normally placed following this statement. A useful practice is to assign distinctive line numbers to subroutines. For example, if the main program is numbered with line numbers up to 199, 1:hen 200 and 300 could be used as the first numbers of two subroutines. Nesting Subroutines Nesting of subroutines occurs when one subroutine calls another subroutine. If a RETURN statement is encoxintered during execution of statement follov/ing the GOSUB a subroutine, control returns to the 6-36 which called it. From this point, it is possible to transfer to the beginning or any part of a svibroutine, even back to the calling Multiple entry points and RETURN statements make subroutine. subroutines more versatile. levels, The mciximum level of GOSUB nesting is about ten (decimal) Exceeding which should prove more than adequate for all normal uses this limit will result in the message: . GOSUB ERROR AT LINE XXXX An where XXXX represents the line number where the error occurred. Execution has been stopped by example of GOSUB nesting follows. Stopping a (see Section 6.11.4, typing a CTRL/SHIFT/P combination Run) , as the program would otherwise continue in an infinite loop. 10 REM - FACTORIAL PROGRAM USING GOSUB TO COMPUTE THE FACTORS 15 REM - RECURSIVELY ^0 INPUT N 50 IF N>20 THEN 120 60 X=l 70 K=l 80 GOSUB 900 90 PRINT "FACTORIAL •N'ft —ft X 110 GO TO 40 120 PRINT "MUST BE 10 OR LESS' 130 GO TO 40 200 X=X*K 210 K=K+1 220 IF K<=N THEN GOSUB 200 230 RETURN 240 END RUN ?2 FACTORIAL = 2 ?4 FACTORIAL = 24 = 120 ?5 FACTORIAL 7 STOP. READY. 6.8.12 Functions BASIC defines several mathematical calculations for the programmer, eliminating the need for tables of trig functions, square roots, and logarithms. These functions have a 3-letter call name, followed by an which can be a number, variable, expression, or another x, argument, BASIC. Teible 6-1 lists the functions available in Cassette function. described in and are not that are those self-explanatory; Most are greater detail are marked with an asterisk. 6-37 : Table 6-1 Cassette BASIC Functions Meaning Function Sine of x (x is expressed in radians) Cosine of x (x is expressecl in radians) Tangent of x (x is expressed in radians) Arctangent of x (result is expressed in radians) e to the xth power (e=2.71£;282) Natural log of x (loggx) Sign of x assign a value of +1 if x is positive, if X is zero, or -1 if x is negative Integer value of x Absolute value of x (|x|) Square root of x /x) Random number Print next character at space x Get a character from input device Put a character on output device User-defined function User-coded function (machine language SIN(x) COS(x) TAN(x) ATN(x) EXP(x) LOG(x) *SGN(x) — *INT(x) ABS(x) SQR(x) *RND(x) *TAB(x) *GET(x) *PUT(x) *FNA(x) *UUF(x) ( code) Sign Function (SGN(x)) if The sign function returns the value +1 if x is a positive value, For example, SGN(3.42)=1, and -1 if x is negative. zero, X is SGN(-42)=-l, cind SGN (23-23) =0. The following example illustrates the use of this function: 10 REM - SGN FUNCTION EXAMPLE 20 READ A>B 25 PRINT "A="A,"B="3 30 PRINT "SGNCA)="S6N(A)*"SGMCB)="SGN(B) 40 PRINT "SGNCINTCA) )="SGNCINT(A)) 50 DATA -7.32> .44 63 END Integer Function (INT(x)) The integer function returns the value of the nearest integer not greater than x. For example, INT (34. 67) =34 . By specifying INT(x+.5) the INT function can be used to round numbers to the nearest integer; INT can also be used to round numbers to any INT (34. 67+. 5) =35. thus, given decimal place by specifying: INT (X*10 +D+. 5) /lO -fD where D is the number of program illustrates this typing a CTRL/SHIFT/P decimal places desired, function; execution has 6-38 The following been stopped by > 10 REM - INT FUNCTION EXAMPLE 20 PRINT "NUMBER TO BE ROUNDED" 30 INPUT A 40 PRINT "NO. OF DECIMAL PLACES"; 50 INPUT D 60 LET 3=IMT(A*10tD+.5)/10tD 70 PRINT "A ROUNDED = "B 80 GO TO 20 90 END RUN NUMBER TO BE ROUNDED? 55. 6534l2 NO. OF DECIMAL PLACES72 55.65 A ROUNDED = NUMBER TO BE R0UNDED778 .375 NO. OF DECIMAL PLACES? -2 100 A ROUNDED = NUMBER TO BE R0UNDED?67 .89 NO. OF DECIMAL PLACES?-! A ROUNDED = 70 NUMBER TO BE ROUNDED? STOP. READY. negative number, the value returned is the largest negative integer (rounded to the higher value) contained in the number. For example, INT (-23) =-23 but INT (-14.39) =-15. If the argxjinent is a Random Number Function (RND(x)) The random number function produces a random number n which is in the range 0<n<l. The nvimbers are not reproducible, a fact the programmer should keep in mind when debugging or checking his program. The argument x in the RND(x) function call can be any number, as that value is ignored. The following program illustrates the use of this function to generate a table of random numbers. 10 REM - RANDOM NUMBER EXAMPLE 25 PRINT "RANDOM NUMBERS" 30 FOR 1=1 TO 30 40 PRINT RNDC0)^ 50 NEXT I 60 END RUN RANDOM NUMBERS .7759228 .4857633 .6156673 .3796163 .9547609 .05880478 READY. .08069808 .4192038 .5921191 .2023254 .2890875 .3859534 .5008833 .1433537 .01170888 .7974058 .1416765 .8404774 6-39 .2790171 .08728769 .7411813 .9635064 .2482717 .5692836 .1661529 .2335427 .341708 .6043865 .2145417 .8514056 It is possible to generate random nvunbers over any range by using following formula: the (B-A)*RND(0)+A This produces a random number (n) in the remge A<n<B. For exeunple, in order to obtain random digits in the range 0<n<9, line 40 in the previous example is changed to read: 40 PRINT 9+RNDC0), To obtain random integer digits , the INT functi on is used in conjunction with the RND function (using the same values for A and B above) as follows: 40 PRINT INT(9*RNDC0))> When the program is run, the results will look as folli^ws: HUN RANDOM NUMBERS 4 5 8 2 8 8 1 7 8 8 4 7 7 7 7 1 8 7 1 3 8 5 8 4 2 5 READY. Notice that the range has changed to 0<=n<9. This is because the INT function returns the value of the nearest integer not greater than n. Tab Function (TAB(n)) The TAB function allows characters anywhere on the positions can be thought of console terminal line (1 to The form of this to right. the user to position the printing of teleprinter (or line printer) line. Print as being numbered from 1 to 72 across the 80 across the line printer line) from left function is: TAB(n) (from 1 to the total where the argument n represents the position number of spaces available) in which the next character will be typed. For example, TAB (3) causes the character to be printed at position 3. Each time the TAB function is used, positions are counted from the beginning of the line, not from the current position of the printing For example, the following statement: head. 10 PRINT "X =";TABC3>r'/";3. 14159 will print the slash on top of the equal sign, as shown below: RUN X * 3.14159 6-40 The following is an example of the sort of graph with BASIC using the TAB function: that can be drawn 30 FOR X=0 TO 15 STEP .5 40 PRINT TABC30+15*SIN<X>*EXP(-.1*X));"*" 50 NEXT X RUN * * * * * * * * * * * * * * * * * * * PUT and GET Functions (PUT(x) , GET(x)) Cassette BASIC provides two additional functions, PUT and GET, to increase input/output flexibility on the console terminal or line Using these statements, the programmer can "PUT" an ASCII printer. character on the current output device, or "GET" a character from the (ASCII character codes are listed in Appendix current input device. A.) GET is of the form: GET(x) where the argument x is a dvurany variable which may be any value. will be assigned the decimal value of the ASCII code of the GET(x) next character input on the current input device. For example, if the following statement appears in a program: 10 LET L=GET<0) 6-41 and the next character input is an M, the variable L will be the value 77 (decimal). assigned PUT is of the form: PUT(x) where the argument x represents either the decimal value of the ASCII code of the character to be output, or the characte:r itself. For example, the statement: 15 L=PUTCGETCV>) will wait for a character to be read from the current input device and then print it on the current output device. A statement such as; 30 PRINT PUT<Q) will print the character typed as well as the decimal value of the ASCII code for that character. (Since both the character and the decimal value are typed, PUT and GET statements should not be used with cassette files.) NOTE If the user is inputting characters from paper tape via the paper tape reader on cm LT33 Teletype, he should be careful to position the tape on the first character to be input. Otherwise blank tape may be entered, which is interpreted as a "BREAK" and stops a running program. The PUT function can also be used to format output. For example, to print a trig table on the line printer with a heading and 50 data lines per page, the form feed character (12 decimal) can be "puT" to the printer as follows: 100 110 120 125 130 140 150 160 165 170 180 190 LPT GOSUB 1030 GOSUB 500 REM - SET UP TRIG TABLE FOR J=0 TO 360 STEP .5 LET L=L+1 LET B=J/180*3.14 PRINT J»SIN(B)>COS<B)>TAN(B).ATtg(B) REM - PRINT 50 ENTRIES IN TABLE IF L=50 THEN GOSUB 500 NEXT J GOSUB 1000 200 GOSUB 1000 210 STOP 500 REM - PRINT HEADER 50 5 GOSUB 1000 510 PRINT 520 PRINT 530 PRINT "ANGLE". "SINE"/"COSINE"»"TANGENT". "ARCTANGENT" 540 PRINT 550 RETURN 1000 REM - PRINT FORM FEEDS TO ADVANCE PAPER 1005 X=PUT(ia) 1010 L=0 1020 RETURN 1030 END 6-42 The beginning of the line printer output from this program follows. The first page of the table continues through an angle of 24.5 degrees: then the header and the next 50 entries are printed on the next page, and so on until the values have been output (in steps of .5) for all angles through 360 degrees. ANGLE SINE COSINE TANGENT ARCTANGENT 6,722444E- 03 .01744621 .02617264 .03490305 ,04363878 ,05238116 ,06113134 ,06989125 ,07866164 ,08744408 ,09623993 ,1050506 ,1138774 ,1227217 ,131585 .1404687 ,1493741 a.722001E-03 ,01744268 ,0261607 ,03487474 .0435835 .05228564 .06097986 ,06966486 .07833935 ,08700204 ,09565166 .1042869 ,1129067 ,1215095 ,1300944 «.5 .1131461 ,1218079 .1304604 .139103 .147735 ,999962 ,9998479 ,9996577 ,9993915 ,9990492 ,9986309 .9961367 .9975665 .9969205 ,9961986 .9954009 ,9945274 ,9935764 ,9925537 ,9914535 ,9902779 ,989027 2«.5 .414496 ,9100512 ,4554645 ,4038923 1 e,7a2ll2E-03 .01744356 ,02616368 .03468181 ,04359729 ,05230945 ,06101763 .06972117 .0784194 .08711167 ,09579731 .1044757 .5 1 1.5 2.5 3 3.5 a tt.5 5 5,5 6 6.5 7 7.5 B FNA" Function ,13666 ,1472052 (DEF FNA(x)) In some programs it may be necessary to execute the same mathematical formula in several different pj.aces., Cassette BASIC allows the programmer to define his own function in the BASIC language and then call this function in the same manntjr as the square root or a trig function is called. Only one such user-defined function may be included per program. The function is defined once at the beginning of the program before its first use, and consists of a DEF statement in combination with a 3-letter function name, the first two letters of which must be FN. The format of the DEF FNA statement is as follows: (line number) DEF FNA(x) =formula(x) The A in the FNA portion of the statement may be any letter. The argument (x) has no significance; it is strictly a dummy variable but must be the same on each side of the equal sign. The function itself be defined in terms of numbers, several variables, other can functions, or mathematical expressions. For example: 10 DEF FNA(X)=Xt2+3*X+4 or 6-43 : 20 DEF FNCCX)=SQR(X+4)+l The function 10 DEF FNL(S)=St2 will cause the later statement: 20 LET R=FNA(4>+1 to be evaluated as R=17. The user-defined function can be a function of only one variable. User-Coded Function (UUP) The user-coded function is explained in detail in the next section. 6.9 IMPLEMENTING A USER-CODED FUNCTION (UUF) A special user-coded function is available in Cassette BASIC for the prograiraner who is familiar with the PD:p-8 instruction set and 27-bit mantissa floating-point format. BASIC'S internal format is 27-bit, sign-magnitude mantissa floating-point; thus, all user-generated values must be in that format and all coding must be compatible with The user codes the function in the PDP-8 series machine language it. instructions, assembles it with the PAL(3 Assembler, and loads the resulting binary file as an overlay to one of the existing functions (ATAN, LOG, etc.) Thus, while BASIC is running, this special function can be requested and used in a fashion analogous to the built-in BASIC functions. The user-coded function, if present, is specified in the BASIC program as: UUF{n) where n can be any BASIC expression. 6.9.1 Coding Formats Due to memory restrictions, the user-coded function must replace one or more of the existing Cassette BASIC functions. Table 6-2 lists the functions which may be overlaid and the areas of memory they occupy. Also listed is the transfer table address through which BASIC calls the given extended function. 6-44 Table 6-2 Function Addresses Function Locations Occupied Transfer Tadjle Address FNA ATN SQR RND TAB 5453-5546 6200-6271 5412-5452 5350-5406 5547-5572 1131 1134 1137 1143 1147 The functions SIN, COS, and TAN are interdependent, but all three may be deleted as follows: SIN COS TAN 5600-5674 1132 1133 1144 Almost a full page is freed by deleting the following: FNA SQR 5412-5572 1131 1137 1147 TAB For each function replaced by the UUF, the user must set the corresponding transfer table location to point to an error routine so calls to that function will generate an error that accidental condition rather than a spurious call to the UUP. The \iser does this by inserting a statement such as the following in his UUF: + 1143 64/!ll ADDHESS FOR R^JD /P0IMT5R TO SYN)TAX ERROR RO'JTINE /TABL'=: requd.red for the To include a user-coded function, all conventions PALC Assembler must be observed. The coding language is PDP-8 machine the modified in language code, but can include instructions floating-point package, which is described later in this chapter in Section 6.10. When floating-point statements are to be included in the program, it necessary only to indicate the start of floating-point notation by is including the following operator: FENTER immediately before the first floating-point statement. floating-point coding is terminated by the operator: Similarly FEXIT immediately after the last floating-point statement. There can be as many sections of floating-point code as necessary in the. program, but each must be delimited in this mcinner. 6-45 : 6.9.2 Floating-Point Format The floating-point format used by Cassette BASIC allocates three storage words in sign magnitude convention as follows (in sign magnitude convention the sign bit rather than the mantissa, expresses the sign of the entire number) WORD 2 EXPONENT -SIGN BIT Five memory locations are accumulator, as follows: used to represent the floating-point Table 6-3 Floating-Point Accumulator Location Name Value ACS 0024 Sign ACE 0025 Exponent (200 octal biased; i.e. the constant 200 is added to the exponent to make the range 0-377) ACl 0020 High order word AC2 0017 Mid order word AC 3 0016 Low order word Contents All of BASIC'S mathematical operations are in floating-point format; therefore, if any temporary storage locations are required by the UUF subroutine, they must specify three words. For example; UTEMP>0;0;0 6.9.3 Incorporating Subroutines with UUF When adding a user function, it becomes necessary to reference some of Cassette BASIC'S subroutines at specific times in the coding. Most of these calls are needed in order to preserve a compatible format throughout the system. The BASIC subroutines which may be referenced (The complete BASIC symbol table is included as are described below. Tcible 6-7 at the end of this chapter.) 6-46 BEGFIX If a value is to be returned to the accuiniulator as a result of the user function, tliat value must be in noiinalized floatin<j-point format. If floating-point arithmetic is used throughout the user function, then the value in the FAC (floating-point accumulator) is in normalized floating-point format and need not be converted. If fixed-point arithmetic is used anywhere in the function, then the subroutine BEGFIX must be referenced before the value (::loating-point) is saved in order that the storage locations are properly initialized to accept a floating-point value. Using this procedure, the five FAC locations are prepared accordingly. However, because the value to be stored only requires 12 bits, a subsequent DCA AC3 statement is BEGFIX is located at 3760 and is called via a JMS sufficient. instruction. ANORM If a fixed-point value is added to the FAC, ANORM normalizes the in order that it be in a format suitable for Cassette BASIC. FAC The routine supplies the acceptable values for the locations ACE, ACS, ACl and AC2. ANORM is assigned the location 4600. FIX To convert a value in the FAC to an integer, as when printing character, the subroutine FIX is called; it is located at 4744. 6.9.4 Writing the Program A user-coded function must respt one of Cassette BASIC'S tables to recognize the function, otherwise, UUF is considered to be an undefined fionction. The pointer is at location 1150; a statement such as the following is required: *1150 UUF Procedures for loading a user-coded function are contained in Examples of user-coded functions follow. 6.11.5. Section 6.9.5 Examples of User-Coded Functions — Example 1 This program calculates squares and square series of values. The BASIC program is as follows: 100 110 120 130 FOR A=33.1 TO 33.9 STEP PRINT A*'rJF(A>*SQR(A) NEXT A END .1 6-47 roots for a . : The user-coded function is PALC-V/l 18/87/72 PAUB' 1 /'JSER-CODED FiJiMCTION TO CALCaLATE /SQtJARES OF NUMBERS / 4435 2000 0200 6000 0000 01 134 6441 1134 6441 01 150 6200 1 06200 06801 06208 06803 06804 06805 06806 06207 06810 /THE FUNCTION LOADS INTO FIELD /INTO THE AREA OCCUPIED BY THE 'ATN' /FUNCTION FENTEP[=4435 FST=2000 FWD=800 FMP=6000 FEXIT=:0000 SXERR=:6441 *U34 SXERR *1150 150 6200 0000 4435 2204 6803 0000 5600 0000 0000 0000 0001 3000 /SO REFERENCES TO ATN WILL /YIELD AN ERROR /DEFINE UfJF IJ'JF IN FUNCTION TABLE *6200 UIJF, FENTER /INTO FLT.PT.PKG.-A FST+FWD+X-. /SAVE A FMP+FWD+X-. /A*A FEXIT JMP I UUF /ALL DONE X* FIELD 3000 ; IS IN FAC ; 1 /TO START BASIC WHEN LOADED S PALC-Vl FENTER 4435 FEXIT 0000 6000 FMP 2000 FST 0800 FWD SXERR 6441 6800 TJF 6806 X output after execution is: HUN 1095.61 33.1 33.2 1 108.24 33.3 108.89 33.4 1 1 15.56 33.5 1 188.85 33.6 188.96 33.7 135.69 33. 148.44 33.9 1 149.81 1 1 1 P! 1 5.75386 5.761944 5.770615 5.779873 5.787918 5.796551 5.80517 5.813777 5.888371 READY 6-48 18/27/78 PAUE 1-1 — Example 2 The following program tests a student's ability to convert the octal value in the console switches to its decimal equivalent. Line 120 will set P equal to the decimal value of the setting. Line 130 determines if the correct answer was typed: 100 110 180 130 140 150 PRINT "WHAT DECIMAL VAL'JE DO THE SWITCHES EQiJAL?" INP'JT M LET P = 'J'JF(0) IF P = JJ THEN 800 PRINT "TRY A(iAIN" GO TO 100 200 PRINT "CORRECT" 300 END The user-coded function is: PALC-Vl 13/37/73 PAtiE 1 /'.ISER-CODED F'INCTION TO READ THE CONSOLE /SWITCHES AMD COMVERT TO FLOATIML. POIMT / /THE FWCTION LOADS IMTO FIELD ZERO /INTO THE AREA PREyio'jsLY occ'jpie:d by /THE •H^JD F'JMCTIOM-THE RANDOM NvFMBER /UENERATOR / 3300 4435 0030 4030 8030 0230 3763 4630 3016 6441 1 FIELD FeNTER=4435 KEXIT=3333 FAD=4003 FST=a030 FWn=333 3E(jFIX = 3760 AHOHM=4603 AC3=16 SXERR=6441 143 1 143 SXERR 01113 6441 aiisn 5353 iJ'IF 053S!1 !?53S1 5353 3300 4756 *5353 PI535a 7604 LAS PI5353 3316 DCA 05354 05355 05356 05357 4757 5750 3760 4630 0031 3033 JMS JMP 1 /SO REFERENCES TO H.MD /WILL YIELD AN ERROR *1 153 150 'DF, /DEFINE 'JiJF IN F'INCTION 3 JMS I 'IBEUFIX /PREPARE FOR /INTEUEH VALJE /UET CONTENTS /OF SW. REli. /SAVE IN LOW /ORDER FAC ACS I ')ANORM I :j'JF /NORMAL /RET JRN I ;1E 'JBElJFIX.BEUFIX lANORM, AMOHM FIELD *3330 1 /TO START ')P BASIC JHE.M LOADED PALC-yi 3316 ANORM 4603 BEUFIX 3763 4030 FAD FENTER 4435 FEXIT 0033 2300 FST 3P03 FWD SXERR 6441 JANOHM 5357 JBEGFI 5356 5353 lUF AC 3 6-49 ia/27/7a page i-i : An exeunple of a run swi tches f ol lows in which 200 (octal) was set ;Ln the console RUN WHAT DECIMAL VALUE DO THE SWITCHES; EQUAL? ?120 TRY AGAIN WHAT DECIMAL VALUE DO THE SWITCHES EQUAL? ?ia8 CORRECT READY. 6.10 FLOATING-POINT PACKAGE Information concerning the PDP-8 modified Floating-Point Package which the programmer will find useful in coding a function follows. 6.10.1 Instruction Set The legal instructions in the modified Floating-Point Package used Cassette BASIC are explained in Table 6-4: Table 6-4 Floating-Point Instructions Meaning Instruction Value FST 2000 FLD 3000 FAD FSB 4000 5000 FMP 6000 FDV FJMP FENTER FEXIT 7000 1000 4435 0000 FWD 0200 BKWD 0600 FSNE FSEQ FSGE FSLT FSGT FSLE 0040 0050 0100 0110 0140 0150 Store the contents of the floating accumThe contents of the (FAC) . ulator FAC are not changed. relative with contents of Load FAC address. Add contents of relative address to FAC. address Subtract contents of relative from FAC. Multiply the contents of the FAC by the contents of the relative address. Divide FAC by contents of relative address. Floating-point jiamp to relative address. Start floating-point code. Return to PDP-8 Exit floating-point code. code. Access a relative location in the forward direction. Access a relative location in the backward direction. Skip if FAC <> Skip if FAC = Skip if FAC => Skip if FAC <0 Skip if FAC >0 Skip if FAC <= 6-50 by The following instructions require indirect (and relative) addressing and therefore only address field 1. Their operation is the same as the corresponding direct instruction. Table 6-5 Relative Addresses Instruction Valu Operation FSTI FLDI FADI FSB I FMPI FDVI FJMPI 2400 3400 4400 5400 6400 7400 1400 Store Load Add Subtract Multiply Divide Jump 6.10.2 Addressing The Floating-Point Package uses relative addressing. Thus, all statements that address a location must include one of the operators FWD or BKWD plus a reference to the current location. Such a reference is generally in the form: op code instruction + FWD (BKWD) + LTEMP-. The operator FWD is used when the address of the location to be referenced is numerically greater than the current address; BKWD is used when the address of the location to be referenced is numerically less than the current address. LTEMP-. in conjunction with the FWD or BKWD operator defines the relative address of the location to be (LTEMP) operated on with respect to the current location. This relative displacement is then used by tiie Floating-Point Interpreter This can best be to access the contents of the three wo3rds at LTEMP. seen in an example: 4010 fad+fv;d+ltemp-. 4363 LTEMP»0;0;0 locations forward The contents of that location which is (4063-4010) from the current address, (i.e. the contents of LTEMP) , are added to Similarly: the FAC. 146 ALOC>0;0;0 « 152 FMP+BKWD+.-ALOC At line 152 the contents of FAC are multiplied by the contents of the (152-146) locations backward from the current location that is address. 6-51 : . 6.11 EDITING AND CONTROL COMMANDS Errors made while typing at the console keyboard are easily corrected. BASIC provides jspecial commands to facilitate the editing procedure. 6.11.1 Erasing Characters and Lines (SHIFT/0, RUBOUTS, NO RUB OUTS , ^iLTMODE) There are two methods available for erasing a character or series of characters one at a time. Typing a SHIFT/O causes the deletion of the (or last character typed and echoes as a back arrow («-) on the LT33 (— Teletype, or as an underscore on most other console 35) terminals. One character is deleted each time the key is typed. ) The RUBOUT key (or DELETE key on some terminals) may also be used deletion of characters one at a time providing the command: for RUBOUTS This has been typed on the keyboard before the editing is done. command eneibles the RUBOUT key to be used and must be typed each time If the user has neglected to type this a new program is in memory. command, he may not use the RUBOUT key. A later command of: NO RU)30UTS disables the key for use. For example 10 LEB-T A=10*B The user types a B instead of T and immediately notices the mistake. He may type SHIFT/O (or RUBOUT key, if enabled) once to delete the B, are to be (and as many times more as characters, including spaces, After the correction is made, he may continue typing the deleted). The typed line enters the computer only when this RETURN key is line. Before that time any number of correctionis can be made to pressed. the line. 20 DEN F---F FNA(X*y)=Xt2+3*Y When the RETURN key is typed, the line is input as: 20 DEF FlMA(X>Y)=Xt2 + 3*Y Notice that spaces, as well as printing characters, may be erased. The user may erase an entire line (provided the RETUR]^ key has not been typed) by typing the ALTMODE key (ESCAPE key on some keyboards) BASIC echos back: 6-52 : ; DELETED at the end of the line to indicate that the line has been removed. The user continues as though it were a new line. If the RETURN key has already been typed, the user may still correct the line by simply typing the line number and retyping the line correctly. He may delete the line by typing the RETURN key immediately after the line number, thus removing both the line number and line from his program. If the line number of a line not needing correction is accidentlally the SHIFT /O or RUBOUT key may be used to delete the number (s) typed, the user may than type in the correct numbers. Assume tile line: 10 IF A>5 GOTO 230 is correct. The programmer intends to insert a line 15, but instead types 10 LET He notices the mistake and makes the correction as follows: 10 LET-—---5 LET X=Z-3 Line 10 remains unchanged, and line 15 is entered. Following cin attempt to run a program, error messages may be output on the console terminal indicating illegal characters or formats, or other user errors in the program. Most errors can be corrected by typing the line number (s) and correction (s) and then rerunning the program. As many changes or corrections as desired may be made before runs. 6.11.2 Listing a Program (LIST, LIST and LPT) An indirect program or data can be listed on the active output by typing the command: device LIST followed by the RETURN key. listed. The entire program (or data) A part of a program may be listed by typing LIST followeid will be by a line This causes that line and all following lines in the program number. For example: to be listed. LIST 100 will list line 100 cuid all remaining lines in the progrcim. 6-53 : The LIST command may be used in conjunction with the follows: LPT command as This will list the current program on the line printer. Control reset to the console terminal after the listing is completed. is LPT LIST 6.11.3 Running a Program (RUN, RUN and LPT) a BASIC program has been typed and is in memory, it i; This is accomplished by simply typing the command: L. RUW followed by the RETURN key. The program will begin execution. If errors are encountered, appropriate error messages will be typed on the keyboard; otherwise, the program will run to completion, printing whatever output was requested. When the END statement is reached, BASIC stops execution and prints READY. The line printer, if available, can be used in RUN command, as follows: conjunction with the LPT RUM After this command is issued, all output during progreim execution is diverted from the console terminal to the line printer, eliminating the need of inserting the LPT statement within the program. The output device is reset to the console t€:rminal after execution. 6.11.4 Stopping a Run (CTRL/C, CTRL/0, CTRL/SHIFT/P, BREAK) To Stop a program during execution or to return to the Keyboard Monitor at any time, type a CTRL/C (by pressing the CTRiLi key and the C key simultaneously) . This causes the current operation to be eiborted immediately and the Cassette Keyboard Monitor to be re-bootstrapped from the System Cassette. (produced by typing the CTRL and keys O The command CTRL/0 The is used to stop teleprinter output temporarily. simultaneously) program will continue to execute but output will not be printed unless an error occurs or unless BASIC is waiting for a command or for data is In the latter case, the console terminal from an input stiitement. the expected input device. This feature is particularly useful for request a programs that print lengthy introductions and then user-specified parameter. Typing CTRL/0 after the program is started will cause BASIC to bypass printing the introduction and wait until 6-54 : : the parameter is specified, thereby saving the time required to print the message. A second CTRL/0 will resume output. NOTE For most programs that do not wait for input from the terminal, processing of the program after an initial CTRL/0 will be completed before a second CTRL/0 can be typed. Thus, it is veiy possible for no output to be printed rather than the anticipated partial output. Certain terminals (such as Teletype models LT33 and 35) are equipped with a BREAK key which may be used in Cassette BASIC to interrupt program execution. Pressing the BREAK key causes a halt in execution and a return to the BASIC Editor for more commands. For those systems containing terminals not equipped with the BREAK feature, the same result can be produced by pressing the CTRL, SHIFT, and P keys simultaneously. 6.11.5 Loading a User-Coded Function A user-coded function is created using the CAPS-8 EDITOR; it is assembled using PALC. The resulting binary file is loaded with BASIC using the Monitor Run or Load commands as follows: .R BASIC, drive #:filename or .L BASIC, drive #:filename UUF.BIN is stored on cassette drive 3. Assume also that the file UUF.BIN has been coded so as to include the correct starting address for BASIC. The user runs BASIC loading the function as follows Assiame a user-coded function called .R BASIC^UUF The starting address for BASIC is included in the program and coded as follows FIELD i •31300 S The new function may now be used in any files the user wishes to and run. 6.11.6 Erasing a Program in Memory (SCRATCH) The command; SCRATCH 6-55 edit : or SCR is provided to allow the programmer to clear his storage area, deleting any commands or a program which may have been previously entered, and leaving a clean area in which to work. If the storage area is not cleared before entering a new program, lines from previous prograuns may be executed along with the new program, causing errors or misinformation. The SCRATCH command eliminates all old statements cind numbers and should be used before ciny new programs are read into memory or created at the keyboard. Note that the SCR command does not clear the program name. If the user wishes to create a new program with a new name, he should use the NEW command which also performs a SCRATCH. 6.11.7 Renaming a Program (NAME) The user may change the name of the program in memory by command issuing the NAME BASIC responds by asking: NEW PROGRAM NAME- The user specifies a new filename (and extension, if desired) . This changes the name of the program without, affecting its image in memory. All subsequent references to the program must use this new name. 6.11.8 Saving a Program (SAVE) Once the user hais created or edited a program, he may \jant to save the new version on a cassette for later use. He does this by typing: SAVE BASIC asks; UMIT #<0-7): to which the user responds with the number of the cassette drive on which he wishes the program to be stored. The progrcim is saved under its current name that is, the name used in BASIC'S initial dialogue, (If or its new name if the NAME command has been used to change it. the the filename is the same as one already present on the cassette, old file is replaced by *EMPTY in the directory and the new file is — 6-56 written onto the cassette.) After the program has been still in memory eind may be RUN or edited further. saved, it is Attempting to save a program on a full cassette causes BASIC to return to the editing phase; the user must save the program on another cassette. If the user does not specify a name for his program in the initial dialogue (by responding with an ALT MODE to the NEW PROGRAM NAME request) , the program will be saved under the assigned name NONAME.BAS. If the user SCRATCHes a program, creates another program without assigning a name to it by use of the NEW or NAME commands, and then attempts to save it, it will be saved under the name of the last program which was in memory, possibly deleting that program if saved on the same drive. 6.12 CASSETTE BASIC ERROR MESSAGES BASIC checks all commands before executing them. If for some reason it cannot execute a command, BASIC indicates this by typing one of the following error messages and the number of the line in which the error occured. The form is: ERROR MESSAGE AT LINE XXXX Table 6-6 lists execution. the errors BASIC checks for reports and before Table 6-6 Cassette BASIC Error Messages Message Meaning ARGUMENT ERROR A CHAIN ERROR A cassette error occurred while doing program chaining; the user should not attempt to run the prograni in memory function has been argument; for example: given an SQR(-l) illegal again. DATA ERROR There were no more items in EOF ERROR An attempt was made to reeid past the end-of-file during run- time input. Program execution terminates and control returns to the Keyboard Monitor. EXPRESSION ERROR One of BASIC'S internal lists overflowed while attempting to 6'valuate an expression. FILE NAME ERROR A mistake or illegal character was found in the user's specification of a cassette drive # or file name in either a CHAIN or an OPEN statement. 6-57 thie data list. . Table 6-6 Cassette BASIC Error Messages (Cont'd) Message Meaning FILE OPEN ERROR The user attempted to open a run-time output file when one was alre.ady open, or a hardware error occurred. FOR ERROR FOR loops were nested too deeply. FUNCTION ERROR The user attempted to call which had not been defined. GOSUB ERROR Subroutines were nested too deeply. a function ERROR The user attempted to do run--time input and output to the same cassette at the same time. IN ERROR A cassette error occurred while attempting to carry out an OLD command or while doing I run- 1 ime input LINE TOO LONG LINE # ERROR A line of more than 80 characters was entered; BASIC ignores the whole line and waits for the user to enter a new line. A GOTO, GOSUB, or nonexistent line. IF referenced LOOKUP ERROR BASIC could not find a run-time: input file on the drive specified. NEXT ERROR FOR and NEXT statements were not paired. NO FILES ERROR The user attempted to do run- time file I/O without first specifying so during BASIC'S initial dialogue. OUT ERROR occurred An error (proba!bly end-of-tape) while doing cassette output either during If the a SAVE or during run-time output. error occurred during a SAVE, the user should retry the SAVE to a. different cassette. If the error occurred during he should re- run his run- time output, program using a different cassette for output. RETURN ERROR A RETURN statement was issued under control of a GOSUB. SUBSCRIPT ERROR A subscript has been used which is outside the bounds defined in the DIM statement. 6-58 properly when not Table 6-6 Cassette BASIC Error Messages (Cont'd) Message Meaning SYNTAX ERROR A TOO BIG, LINE IGNORED The combination of program size and number of variables exceeds the capacity of the computer. Reducing one or the other may help. Otherwise, the user must break his program into parts and chain them together. A large number of DATA statements might be put into a run-time input file. command did not correspond to the language syntax. Common examples of syntax errors are misspelled commands, unmatched parentheses, and other typographical errors. Reference to an undefined UUF will also produce this diagnostic. The following programming errors are not reported by Cassette BASIC, but instead are used in the computation as specified. They are included here for the programmer's reference. 1. Attempting to use a number in a computation which is too large for BASIC to handle will produce a result which is meaningless. 2. Attempting to use a number in a computation which is too small for BASIC to handle will result in the value zero being used instead. 3. Attempting to divide by zero will produce a result which is meaningless. 6.13 CASSETTE BASIC SYMBOL TABLE Table 6-7 lists the Cassette BASIC symbols and their values. This information is useful when writing user-coded functions. 6-59 Table 6-7 Cassette BASIC Symbol Table /POP-8/fc CASStTTE BASIC ACE fciy^S AcN a« 1 7 ACS 0He::4 AC) tJMaV! AC? AC^ ^P 1 7 CLUSt CLOSED CMSwCH cnamst CNCLk CNtRP CNTFnO B«lh C ^J r L AHCDEF Ann RES 1763 t! P7 1 biiPlB OvLOOP b245 117^' Owi?IT 0176 na5a 0141 05W1 ECHO EOIT 7a« 7 1301 UUh*) LNilO 1U6M 314 CnuELO I?!0P'4 COLUMN «130 COMCK P?77 ALi AMATCH ANOPM AhGERR ^hf^t «*)5a LdiiMAS 61715 bSkJ^! LOMKON 3377 ahyia COi-'ON 7-^47 ARi-LOC <A'^i^:i Ak 1 4aK? ASKAGN WS"^ ATLINt b4b) 11?3 13b7 CONST COkEIN PI423 COS Stl6 L (Vv T 7 14 3 AT^^HIG ATNilOW ^^t""! URlF LkLFU 6531 52S7 6<?£e0 CPLFPi* 37'^fc AT^NPt bP.-i? HaOCHN 7i,?b4 CK wDS KEr.t-ix a "d t-Hifib CTklC CTKLCJ 7604 LTHLZI ^fcSe? CTH/CK 'Ml 3 CTKZhP wH'i5i? tvlLOO "^ViP.e fiKfAK bS,?,P hSKIP ^73S rtLiFtMD b?/it1 UFCExP H043 uECFHA <343 UftPEK ^I53lri MljE&T bat.'tl UEF lb75 LELKTE *>b01 L'FVCOH rsba A T f^ (:< e> ^ t" B S s?*?'-! CAM 7t'r'V CAPKET Shha C ASINi hbl 4 CaSOUT 6/i/3 OHaf' CCNT« CGtT be.bt C M A 1 M ChA(.-Nt L' A 1 AEK 1 Ibl, UP 317 6 6b^7 / i1 i 1 LJ I It 6 tt 7 ri «l'Vl iy 1 CHAW OK a>>al, ChtCKw e;i4U CHK.en f>4^^ifl ChN:FWh( 358P HF LA blVLP OIvxTt UOITNU uPuEN SW 34 FATiNTT biiSl 4/H5 FulGIT FDV 3 335 i>l I/-I U CMNMS 3 56 i DCK'iCi^T Chftr-ET 04 1 / uor7E«^ 6576 CKhKAK t34a u P r L A t> C K C, T W Z r, L E A » V uf.Uf.TX C L I- V CLOS /' S b kii^^b 'A 6 "> 0746 00ki0 FtXlT FEXPCl 6072 FtXPC2 6075 Ft)(PC3 6100 Ft XHC4 6 103 FtXPC5 6106 FE)(PC6 6111 Ft^(P l^' 3i^!42 334^ 3162 uOuHTK "6 2'D I'P I C-h) 1 6bS7 ICK 7.<3/ 7 F'DWl OfUb it'ic3 IN 000 7400 FtNTfcP 4435 3341 1247 Ci-f-'G 4 1 4 (? a b a FATNAX 627 3 FA PNC 6337 FaTNCH 634? FATnCJ 6345 FATNCl 6304 FAFNC? 6307 FATNC3 6312 FATNC4 6315 FATNC5 6320 FATNC6 6323 FATNC7 6326 FATNCa 6331 FATNC9 6334 FaTnSX 6?/2 FATNT 6276 6 7 f? u- 64 4 FALT VihlH 3«e21 UlulMl 3^?2 U Ib I T 6731 7023 2412 2400 ENOLIN 57fc)2 EMINM 733? EM3NUM 3321 ENOPDL 5743 EMEP 6404 EOFAO 4526 EOFkTN 665M EHTR k)060 EKKOR 4136 EVAL 1000 EvALGO 1004 EXECljT 0213 2407 EXIT 6H00 EXP EXPGOO b242 ExPcnN 5764 EXPOK 5265 EXTLOC 0224 FAO 4000 FAOEXT 1314 4 400 FAO I CNlLOZ «134 ALLOC ALTMOD EM.) It^bV' ALf<^:LP AL L ^ l?/Z7/12 PAi.a-v8 6-60 PAGE 51 FEXPF FEXPI FEXPU FHER FILALT FILNAM FILNR FILl FINOIT FINOLU FIOER FIX FIXEXI FIXITU FIXLIN FIXLUP FIXUP FJMP FJMPI 6067 6061 6064 5117 0367 0600 1356 0606 0560 0566 7135 4 7 44 4 7 73 5200 2135 4750 5143 1000 1400 FJUMp1130 5000 FLD FLUI 3400 FLOGCl 6172 FLQGC2 6153 FLOGCS 6156 FL0GC4 6161 FMP 6000 FMPT 6400 FMTENF 5121 FMTl 5123 FMT2 5051 FMT3 5126 FN 5453 FNtRH 5172 FNEXIT 1200 FOR 0415 FOHCT 0065 FOROON 0663 FORERR 0503 FORLIM 0721 FORLIS 5744 FORSTE 0724 FORVAR 0454 FOUND 0576 FPAOO 4456 FP&nUR 4504 FPOIV 466/ FPOOIT 4237 FPFLAG 0154 FPGOrn 4273 FPJMP 4317 FPJUnP 4274 FPLAC 4351 FPLOOP 4202 fPMUL 4530 2 Table 6-7 Cassette BASIC Symbol Table /P0P-8/£ CASSETTE BASIC FPNOAD FFOPER FPPG7 FPSKIP FPSTQ FPSue 4305 GETOPR uFTUNi a?.?.! tjEfVAR a31« 4322 4U55 420H 1243 bEfWD bLOnp uNtXT GObOTH bOLIST bn&UB GOIEMP bOTiT 12fol U-OTITI 5n0a 1?P2 2101 i^OTSS PAL«-V8 12/27/72 r-Vlf,?. 1557 IF 0573 0434 4034 4076 0553 0272 4007 7316 2027 lNSt<T5 2025 6434 INT IM»IDTM 4136 lONAM 0227 lOUNJT 1301 IPNDPE 4024 ISDEF2 3511 ISUIG 6532 ISOIM 1472 4564 ISIT ISITOF 0551 ISITFU 1105 ISITLI 4100 4422 ISITl ISLIT 4127 ISSDME 1643 ISU^^IN 1010 ITSDEF 3513 ITSOP 3217 ITSt 3253 nSOP 1220 ITSP 3270 6660 lUNlT jBPtNT 3707 JISOIG 3344 JMATCH 2770 JPUTCH 0763 JUST0 3142 JUST0F 3152 JUSTBP 3155 3137 JUSTl JUST2 3141 KbUiN 0421 KbDINP 7626 KHUFEN 6762 KbUFST 6737 f-itX Pf-ifc 1 XFl KfcPTW GfeTADD 14C.".'' FPT a27(7i FPTfcMP 457f> FPTH FPZOIV FPINP FRINPI FRMDx FROUT FkSTNE FSB FSBI FSFQ 0061 4V3fe 50fc'0 5400 a^lb?! FSGfe 0l0fi F s (.- T i/'lau FSINCI FSIMC3 FSIKC4 FSlNCb F8IMC6 FSINC/ bTlS b7l6 57?! 5/24 5727 5732 FSItviM4 5735 FSI'vjOK 5657 5705 FSlNZ FSINZZ 5710 FSIN10 5b41 1.31 5W FSLt FSLT ann FSNtfc I3B4P FSOkX 54P7 2i:S0C' FST 24P0 FSTI FT4NT1 567' FTANT2 57i^2 Fu^JTAB 1131 FUPKCI 5Vb2 Fwo /isrc^ FVXPFX fei123 7242 GALT GhTbLK I7t» r, P. T CH 7 2 Cn» GhTCHk tin/ GtTCS «7 12 Gfcinf k?27 5 GtTj 17b5 GtTLIN 2^tl2 GtTL«t 2577 I^LC)OP 11^12 0^240 C1303 1^177 INUUPF INPUUP INPPTR InPSET INPTN INPUT I\PUTN INSERT 2711 «b07 0534 5764 PI507 P'tiSS 7207 721^ Gtno M521 GOiOPK 1202 11^.71 GOTSTE 0634 bOUT 7244 GPTR KKfe2 b«tJ 7223 GPUELA 7221 GSriEND S777 bSBPTW f*163 GSSl 1555 GSS2 155b GToKLP 1722 GTtMP 727115 ijTJMH 0442 btjMPl v^42/f oTPTR 0(^36 HAP 043 7 PI451 HALF filGHwD 4333 MLOOP ?t>77 27 31 nLOPl HLP 4163 HMOL«< h800 nPfP 0063 lAMLES 2103 ii'SiOO 6764 lAO 1257 iCASEP 5157 iruiJNT ^062 JEKR 6663 iti(TL.C 02 35 0372 0403 IGMOkE 2137 ImmEl) 007 7 0231 KICiNOP 1676 KEYlAiU n55 KM200 ZI/ilS KM4H0a 2170 K50M0 2167 Kb201 7005 LAStKK bfel2 LttEGIN 5622 LtftP 3355 IMMEOA 1155 iN 3430 iNCHN 7 403 (^131 JNUPV iMUFxi ''nn4 lNUEx2 0015 iN'LCTM 4t!77 6-61 (Cont'd) PAGE 51-1 LET LETDO LETTER LFXLUP LHALF LIMIT LINBUF LINENO LINFIX LIST LISTAL LISTLU LISTSO LIST2 LIST3 LIST4 LISTS LITRAL LJMS LKER LKERR LLSOUT LNQENO LOADED LOCCTR LOCTEM LCCTMP LCG LCGACE LCGFwO LC'GOKW LC'OK LOOKER LOOKUP LOWLOC LPTQUT LLIKERR LUNIT LLIP LUPF L4LUP MAYZER MEiHEAK 0304 0205 3445 2331 3067 1600 5551 0054 2326 3600 3610 3612 3611 3636 3655 3661 3676 3123 7255 1312 0330 7400 3626 4123 0045 0671 1677 6114 6165 6164 6167 0306 7310 7002 2166 7347 0326 0332 3404 0430 3664 4612 7603 MENOLI 00<11 MENOPD 2361 MGOLIS 0720 MGSrtEN 0527 m:;nus 1316 MLBEGI 0171 MLEMD 0172 MLINbU 0040 MNSONE 0736 MONITR 0100 MOREDI 6470 MQREIN 4000 Table 6-7 Cassette BASIC Symbol Table /P!)P-8/t LASStTTK F^ASIC PAl.b-v8 MOkfRO lt£C rjO'HER Movfc ^aic'i ^OIKkU MOVLUP MPkJNT <il^t NOT MOW 011100 fct!!c3 fjUrsUN Oil MPY b ?? 1 MpVLUH ubb? MfOA 0'437 PI3P5 1776 3271 MOITXT P236 IMOIVAK NOlXll^ ^^236 MUL /St;l 7ac'l MSTt-ei a^iS Nsr MTA /^ M7 X y 1 T i 1 7 3 "'37 1 inTCmAN 122i(; J5?b7 NIILiM 1201^ MinHIJf-' MULCLrt MUL^-XH MULxTt iiatfi MULXl 33/1 MU5TBE aShfe NAM ti3^? KAMCHK 0hSl N(UYtT 6741 53 MAMfcK 003? UCbUNT 5335 M7?b 3124 4435 2574 5205 8761 NAMLOC i<l316 uEh'R 67 5/ MCTHL;£ hTi'i UIH HfW 1 UJUMH 7^5 7 1276 U 1ii5 7 Nfc'.'JflO U-ibi! ULUdO 10h2 NtWLlN 'dhi'h lU:^ ULL.KLr, UL'JMfcS Pi.'ifS Mfci-'MES Nt^T ff. ().-.) ULUnP ('!H7ii NtXTfeR Pfo/3 ULL'3 NtXTR UML 11 PIP'' 1^147 ^J A (-1 f 10 3 7 V? U 7 NUPCHK Mi/ULMS JtCO uCAStff UC:C t'l. NJ t > T V A M-MtS t7b7 0^37 g^t:7 Nt-DPEN b3bS N'M lf143 NOPLiMP 463? ^OCHNiG 304k1 MOCOM NDCOMM NOCk NHNbLN MONZEK NHPAWE NOPCP NOPE NOBLFT NORMED NORMIT NORUHO 4C156 3104 5KH4 103? UPtRAN OPNERR 1354 UPUTAB 71316 i???0 UPS l?026 7147 OPl Vi0?'i S?.i<i ap2 0P3 OTtMP 0T£MP1 OTHER OUNIT ^0Z^ 0021 b207 5574 1457 N'OSSl N0SS2 1452 NOT 3426 NOTbAD 2153 NDTl^lG 4620 MGTCP 3P123 NOTEM 6626 NOTFUL 6712 2 7 72 077 1562 2356 ^762 2745 514 4 3352 0027 3353 0064 07700 u7706A O7706C 07715 07725A 07725» 07737 07740 07741 07743 07745 07/53 07762 07763A 07/63B 07764A 07764R 07764C 07766 07770 07771 07772 07773 U7774 07776 PACN 1151 0153 3350 5344 0175 01/4 02 3 1366 Oc'i3 3770 0240 0051 0253 5145 0255 5146 0256A 5153 0256B 6575 0260 0012 02/ 3345 0305 5147 032 3115 036 2771 03734 1152 03737B 0776 03755 1273 0377 00/3 04 0156 040 2777 04014 1153 042 3103 04200 3102 04213 1154 05400 5347 0046 06203 07 0074 0700 1272 O7000A 2565 O7000B 3473 07077 1275 0/520 5150 07545 4777 0/570 6456 07577 4577 12P1K 1/075 uPuTC 07600 07603 07610 O7640A 076408 07673 0200 O2040A 02062 0212 0215 3575 1314 2171 3547 506 2357 0067 02 02 Pfc30 fea?3 0013 0177 017/0 UMtDIM U'61 ONtSS 1B73 OrLVl 5312 UC76l^0 5452 00/736 2324 OPuONE 1203 1271 7012 3(^00 6760 OUPSET 1026 OUTDEV 0133 QurD2 013? UUTNUM 5000 UurOK 1332 6-62 PAGE 51-a Ola 01 /4B UU OPt OPtN UPtNl 6)76 ti3(?7 1^/27/7? OV 0110 012 0122 013 014 O140A 0140a 017 \\IA?. (Cont'd) PAD PAOOQN PAKBUF PALI PANOKM PAKGER PARI PASSCR PBARKD PBEGFI PCCUNT PCHKFI PCLOS PCOMMA PCQwT POL POLIST PEOIT PENON PENONM PERMSY PERROR 4345 2774 5345 0754 2765 3306 0140 2610 6544 3472 2775 3075 3346 3116 0056 3743 4743 0160 3101 2325 0761 3076 1274 3077 3351 5151 0057 5152 5154 5346 1561 3347 4/42 0347 0741 0763 0146 0144 0047 0145 0474 2773 1773 0744 0161 0143 0273 0137 0036 5703 0122 0271 0365 5111 0101 X 1 Table 6-7 Cassette BASIC Symbol Table CASSfcTTP BASIC /f'(iF-8/fc P 1. 1^ s; w H /a7 KKV AL a 1 k' 3 P f- X k C U C^ P (- X P 5776 Pe 1 i-Ji PPNEPhi Ui 5 u' "jSab PFPLCO «5/S PtETAIJ t?tta PGfcTBL 0117 HLitTCH fcCJiS PRETLI aw^ PPKXgO PPcNT PKtStT HPINbL KKlNCn PPINKX PPINHA PRINQU PPIMSK PPJNT PRINTC P»lMTG KRiMrh PAL6-V8 \\bi S5ib Ml3h ^?6feJ ?3?0 ?17? ^^07 ?t>Hb 0:?b'5 P I ^ T b^78 PRM Pi.'^iTL PL ''» GI :m7:^ v^ 1 /? HPuGiMA PLtrnO t1?(;,ii PP n =5 PLfcTTt 31 CM PL J f- IT eS^b PL I^HU fe737 PL INK I I" PL I ST P L t T I? A lb? ^b/n 33b u t^ da3 1114 PPoUbP 37?? i tMP l^ t^ 42 PPTXPt 37?0 PSAve ?4b3 PSIjN S675 PSKIPI Iblfe PSLHUP «l?f. PSPACE lbb0 p.") TICK 0l?3 tSlOP 3776 PLU? b7yb 13iy PMHk'EA iiSbi;; PMPY blb5 psrovtt, 0114 PSxE«;k" 011712 ^^Mrt^6 blbfi pr. PNe.u,LI 117 7 VMTA PTAhOE PNONBL PNOTMQ PNUMBU POADU PDIP POP POPERA P0P3 POUINU PPASSC 0124 db73 PTABf-L Sb71 PTArtLE 2776 iia'ia PTtN PTtXT PTUBIG PUatPP PUbH 015((1 PIJTCH PijTEK 07 4 1 PLL'L. PPOHS 01bb a035 ixXh^ 31.?1 aa3a 0121 011.? k51c7 i?b72 i,7ai PPERMS PPPLOn PPFORL 17ba PPINT 606?l PPOP 01i?j7 PPRINT 011f) PPWINLI Bl?5 PPUSH 0106 PPUTCH 0333 S:3ERR S:5FIX SI50NE SSTi^Q 0771 K C H hi i-;"?:^ iS Pf.OLTS 21^2 PC-OTPP icM 11 QMK RtAD 1622 PhADIT 6664 WtADLQ 80'»6 WtADY 6525 PELATfc 1342 WfcMPAC 3043 i^tCEER 6700 PeStTl 7072 HtSTOk 3771 PtTNEK 0713 HtTUPN 0677 PhALF 3071 RIGHT 0433 RIP 6661 RI^LtPT 6413 RMJ 5353 HNOJMP 5350 RTBEND 1600 PTilUF 1400 HTIOME 3103 RUBO 5573 RUN 2457 RUMC 2456 RUMIN 2510 PUNLUP 2472 RU^^INuT 2504 RIjN2IN 2550 RUN2LU 2521 RUN2N0 2544 SAVE 1000 SAVtl 2461 SCHMUR 1656 5CRATL 2445 SCRATl 0332 StARCH 1657 SETINC 0200 StrSGN 4512 St-N 0726 5IMPLV 3465 SIN 5624 SJUMP 0241 S^IPIT 0471 SKPSYM 2762 SLASH 1332 SLOOP 2675 SLSHTM 1337 SNUMFL 0066 SPACER 1163 SPLtFT 0142 SQEXIT 5450 Pir.r-.:(jw P 1. 1 T V A SQLOOP 5435 SQR 5412 P3l?b Pr"?? at;s2 'ib70 0100 3021 SSas 2362 PIJTCOF 7014 7000 3b50 0647 eb57 3744 3117 ?b71 3120 3122 2567 PZtWDO 65«5 PUTJ PWhEPE PXPORL PXLlNb PXXCKL PXXFnF PXXEXI PXXLIT PXxThE 6-63 PAGE 51-3 P7640 0722 QtPKOP 1571 ??lb •-HLP 1.S76 \?J?im RBSwCH 0135 .?31^e? ?^?a PPlNTr-' 73P^ PSiMTx 370^ PPIMI? PI 74 PkiMjM ?74b PRi^Vw 3h51 PWLOOP 371 pr,tTnp (Cont'd) 6763 ST STAR S'^ARTH STICKI S'^OBUF S'^QP S"ORCH S-OVAR SWP SXER SKERR TAB TaSDES TAriDO TaBFLG TaBL TaBTHP TAN THEGFI TEMP TEMPS TEN TMESKI TLSDUT TMP TOOLON TPRINT TRALUP THANSF TRYAGI TRYAL TRYALT THYQLO TRYSTE TTYO TTYOUT TUBIG TWIOTH TWOLF TWOSS TVTPAK TVQUES UDOPER UCIHl UJM8 UMOPER UMOERF UNIT UPARRO 1563 4/75 0336 0337 3005 1327 3000 6430 0747 2401 0704 0333 7521 0551 6441 5547 6375 6350 2343 3652 2360 5600 5572 0003 3102 0000 1353 7402 0031 5162 6376 2131 2126 5131 0270 0271 3075 0626 7024 7350 1173 2355 3557 1074 3046 1145 1363 3561 0004 1321 4645 0012 6457 Table 6-7 Cassette BASIC Symbol Table (Cont'd) /PDP-8/fe CASSETTE BASIC PALB-VS UPARRX 5740 1,IPARR2 4365 nSERFN Ifel? UTEH 0411 UTEMl 0021 XKTAN 5204 XXTeXT 5540 X)1THEN 5305 XXTO 5lfc5 XXTTYO 5437 XxUNA« 5542 XXUPAR 5122 X>:UUF 5253 X10 0010 ZCNTLO 7147 ZtMOON 5142 7.t«0 0150 ZHXtX 4767 yf.KSTl (-.533 XGf<LiS7 VISIT ?270 71?4 XXbOSU 5321 *XbOTO 5300 XXCiT 514? XXiF 5312 XXINPT 5332 *XlNPU 5337 XXINT 5231 XXLbRA 5163 XXLE 5124 XXLET 527a *XLIS 5502 XXUIST 5476 XXLIT0 5545 XXLOG 5212 5i»tti4 xVLPT XXUT 5145 XXMINU 5114 AXNAM S534 xvNiOMt 5530 XXNCOM 5447 XXMh; 5132 *VNEW 5525 XXNEXT 5326 VlSjn 0S2'^ JiXNHUB 5467 l.iUJMP 0ari0 laUHS 0401 ULiUJMS 0416 VAk 0335 VAi^TEM 0554 VSCHIN 3S23 VbCHLU 34ya VSCHNO 3517 l^iAJT 6200 VUITR 6601?WOIEMP 1072 UjO»D 005E I'iTEM 6613 xexfccu 0aia XKISIT Ml"^ XNOST /ay/ XMUSTl 05al xptG2 0i^'ii XHirC 0010 VkPlT PCI 11 yxAhS 52<r3 XXATN 520/ XXf^?LS 5260 XxChAN 5a27 XXCLOS 5155 VxClSE 5U16 XXfJJMA 5ii55 yyCUMM 5151 XXCfj.S 5201 XXCRLE 5256 yxi:ATA 54ti2 XXOrF XXDIM 53/2 5355 5135 XXt[> xxtL VXENO 514r'i vyf•:NO^ 54ij6 5454 b54l 514i XxExIT 55aa yxF.XP 5215 XXKINl 5543 XXFN 5176 vyfoP 5315 XXGF-; 5127 524S Xxr,|-,T XXf-nP XXf-U xxuDi 0005 xxQr)(J 0i/iP6 xxan3 XXULU XXUPt> XXUPN 0007 5522 5161 5412 XXUIJTP 5u22 XXHLUS 5ll<^ XXKRIN 52h7 xXHRNt 5262 XXPUI 5242 XXRBRA 5157 xxkEAD 537b XXREM 53^6 XXkETR 534a XXKMl) 5234 aXRSTU 5361 XXHue 5462 XXKUN S505 S517 xkSav r.vSAvK 5513 Ay&r.hi S51n XViiEMl xxb(iN AXSlNi SI 53 522b 5237 AX6LA3 5i20 AXbQK 5220 XXSTrtR 5116 xxSTtP 5171 xv.'^roP 53S1 xxlAp 5250 6-64 12/27/72 PAGE 51-4 , CHAPTER 7 USING CAPS- 8 CODT Using CODT, the programmer can run his binary program on the computer, control its execution, and make alterations to his program by typing at the Teletype keyboard. CODT occupies any four pages of core, in the same field, that the user desires. The user may change the location of these four pages of core If the user progreun resides in the by reassembling the source. first few pages of memory, then CODT should be loaded in the upper pages of any memory, and vice versa. The user progrcim cannot occupy (overlay) location used by CODT, including the breakpoint locations (locations 4, 5, and 6 on page zero). 7.1 FEATURES octal CODT features include location examination and modification; core dumps to the Teletype using the word search mechanism; and The instruction breakpoints to return control to CODT (breakpoints) . user's program can run with interrupts on. CODT may reside in any field, not necessarily the same as the user's field. When debugging The breakpoint is one of CODT's most useful features. a program, it is often desircible to allow the program to run normally up to a predetermined point, at which the programmer may examine and possibly modify the contents of the accumulator (AC) , the link (L) or various instruction or storage locations within his program, depending on the results he finds. To accomplish this, CODT acts as a monitor to the user program. The user decides how far he wishes the program to run and CODT inserts an instruction in the user's program v^hich, when encountered, causes CODT immediately preserves in control to transfer back to CODT. designated storage locations the contents of the LINK and AC at the breedc. It then prints out the location at which the break occurred, CODT will as well as the contents of the LINK and AC at that point. then allow excunination and modification of any location of the user's program (or those locations containing the AC cind L) . The user may also move the breakpoint and request that CODT continue running his This will cause CODT to restore the AC and L, execute the program. trapped instruction and continue in the user's program until the breakpoint is again encountered or the program is terminated normally. 7-1 . 7.2 USING CODT When the programmer is ready to start debugging a new program computer, he should have at the console: at the 1, A binary copy of the new program on a cassette. 2, A complete octal/symbolic program listing. 3, A binary copy of the CODT program (previously assembled so as not to interfere with the user's program). RUN PROG, CODT The binary of CODT must be the automatically begins in CODT. 7.2.1 last file to be run. Execution Commands SLASH (/) — OPEN PRECEDING LOCATION The location examination character (/) causes the location addressed by the octal number preceding the slash to be opened eind its contents printed in octal. The open location Ccin then be modified by typing the desired octal number cind closing the location. Any octal number Typing a fifth digit from 1 to 4 digits in length is a legal input. is an error and will cause the entire modification to be ignored cuid a Typing / with no preceding question mark to be printed by CODT. argument causes the latest named location to be opened (again) Typing 0/ is interpreted as / with no argument. For example: 400/6046 400/6046 2468? 400/6046 12345? /6046 The memory field referenced is that field specified by the location in CODT symbolically referenced by F. For example, if the contents of F were 20, then the command 423/ would examine location 423 in memory field 7-2 2. . : RETURN — CLOSE LOCATION If the user has typed a valid octal numlDer, after the content of a location is printed by CODT, typing the RETURN key causes the binary value of that number to replace the original contents of the opened location and the location to be closed. If nothing has been typed by the user, the location is closed but the content of the location is not changed. For example: location 400 is unchanged location 400 is changed to contain 2345, replace 6046 in location 400. 400/6046 400/6046 2345 /2345 6046 Typing another command example will 400/6046 401/6031 2346 400/6046 401/2346 LINE also close an opened register. For location 400 is closed and unchanged and 401 is opened and changed to 2346. FEED— CLOSE LOCATION, OPEN NEXT LOCATION The LINE FEED key has the same effect as the RETURN KEY, but, in addition, the next sequential location is opened and its contents printed. For example: 400/6046 0401/6031 1234 0402/5201 location 400 is closed unchanged and 401 is opened. User types chcuige, 401 is closed containing 1234 and 402 is opened SEMICOLON — CLOSE LOCATION, AND UNOBTRUSIVELY OPEN NEXT LOCATION The SEMICOLON key has the same, effect as the LINEFEED key except that the location and contents of the next sequential location are not printed. Therefore, 400/6046 3211; 4162; 5000 has the same effect as 400/6046 3211 401/6031 4162 402/5201 5000 This makes it convenient for the user locations. f (SHIFT/N) to — CLOSE LOCATION, TAKE CONTENTS change AS several MEMORY sequential REFERENCE AND OPEN SAME The up arrow (circumflex) will close an open location just as will the RETURN key. Further, it will interpret the contents of the location as a memory reference instruction, open the location referenced and print its contents . For exetmple : 7-3 : 404/3270+ 0470/0212 0000 «- : 3270 symbolically is "DCA, this page, relative location 70," so CODT opens location 470. (SHIFT /O) CLOSE LOCATION, OPEN INDIREICTLY The Back arrow (or iinderscore) will close the currently open location and then interpret its contents as the address of the location whose contents it is to print cind open for modification. For exeimple: 365/5760+ 0360/0426^ 0426/5201 nnnnG—TRANSFER CONTROL TO USER AT LOCATION nnnn Clear the AC then go to the location specified before the G (in the All indicators and registers will be specified by F) . field Typing G initialized and the breakpoint, if any, will be inserted. alone will cause a jump to location 0. nnnnB — SET BREAKPOINT AT USER LOCATION nnnn Instructs CODT to establish a breakpoint at the location specified If B is typed alone, CODT before the B (in the field specified by F) . the removes any previously established breakpoint and restores original contents of the break location. A breakpoint may be changed to another location, whenever CODT is in control, by simply typing nnnnB where nnnn is the new location. Only one breakpoint may be in effect at one time; therefore, requesting a new breakpoint removes any previously existing one. A restriction in this regard is that a breakpoint may not be set on any of the floating-point instructions which appear as arguments of a For example JMS . TAD DCA JMS FADD BrecUcpoint legal here. Breakpoint illegal here. may not be set on a CIF instruction, nor on cui instruction which is meant to be executed between a CIF and its corresponding JMP or JMS instruction. A breakpoint A breakpoint may not be set on a memory references an auto-index register. reference instruction which A breakpoint may not be set on a two-word EAE instruction, nor may be set on ciny of the following instructions 7-4 it : SKON ION lOF The breedcpoint (B) command does not make the actual exchange of CODT instruction for user instruction, it only sets up the mechemism for doing so. The actual exchange does not occur until a "go to" or a "proceed from breakpoint" command is executed. When, during execution, the user's program encounters the location containing the breakpoint, control passes immediately to CODT (via location 4, 5, and 6). The C (AC) and C(L) at the point of interruption are saved in special locations accessible to CODT. The user's data field is stored in location D and his instruction field is stored in location F as well as internally by CODT. The user instruction that the breakpoint was replacing is restored; before the address of the trap and the content of the LINK amd AC: are printed. The restored instruction has not been executed at this time. It will not be executed until the "proceed from breakpoint" command is given. Any user location, including those containing the stored AC and Link, can now be modified in the usual manner. The breakpoint can also be moved or removed at this time. An example of breakpoint ITERATE LOOP...". A usage follows the section 'CONTINUE AND — OPEN C(AC) When the breakpoint is encountered the C(AC) and C(L) are saved for Typing A after having encountered a breakpoint later restoration. opens for modification the location in which the AC weis saved and prints its contents. This location may now be modified in the normal manner (see Slash) and the modification will be restored to the AC when the "proceed from breakpoint" command is given. Similarly, other key locations in CODT may be examined and modified as follows L — OPEN CONTENTS OF LOCATION L (LINK) F— OPEN CONTENTS OF LOCATION F — OPEN CONTENTS OF LOCATION D (USER'S DATA FIELD) D 7-5 NOTE Whenever any of the locations A, L, F, D, M are referenced, CODT automatically sets the value of F to be the field of CODT. C — PROCEED (CONTINUE) FROM A BREAKPOINT Typing C, after having encountered a breakpoint, causes CODT to insert the latest specified breakpoint (if any) ; restore the contents of the previous AC and Link; execute the instruction trapped by the breakpoint; and transfer control back to the user program at the appropriate location. The user program then runs until the breakpoint is again encountered. Regardless of the value of F, the C command resumes program execution The user's the precise spot where it had been previously stopped. data field is first set to that specified by location D. at NOTE If a trap set by CODT is not encountered running the object CODT is (user's) program, the insstruction which while causes the break to occur will not be removed from the user's program. nnnnC — CONTINUE AND ITERATE LOOP nnnn TIMES BEFORE BREAK The progrcimmer may wish to establish the breakpoint at some location Since loops often run to many within a loop of his program. iterations, some means must be available to prevent a break from occurring each time the brecik location is encountered. This is the After having function of nnnnC (where nnnn is an octal number) . encountered the breakpoint for the first time, this command specifies how many additional times the loop is to be iterated before another The brecik operations have been described is to occur. break previously in the section on the B command. Given the following program, which increases the value of the AC by increments of 1, the use of the breakpoint command may be illustrated. 7-6 *200 0200 0201 0202 0203 0204 0205 0206 0207 A B CNT ONE 7300 1206 2207 5202 A, B, CLA CLL TAD ONE ISZ CNT JMP B JMP A HLT 5201 7402 0001 ONE ,1 0000 CNT ,0 0201 0202 0207 0206 0201B 200G 0201 (0;0000 C 0201 (0;0001 C 0201 (0;0002 4C 0201 {0;0007 CODT has been loaded and started. A breakpoint is inserted at location 0201 and execution stops here showing the AC initially set to 0000 and the link 0. The use of the Proceed command (C) executes the program until the breakpoint is again encountered (after one complete loop) and shows the AC to contain a value of 0001. Again execution continues, incrementing the AC to 0002. At this point, the command 4C is used, allowing execution of the loop to continue 4 more times (following the initial encounter) before stopping at the breakpoint. The contents of the AC have now been incremented to 0007, M— OPEN SEARCH MASK Typing M causes CODT to open for modification the location containing the current value of the search mask and print its contents. Initially the mask is set to 7777. It may be changed by opening the mask location and typing the desired value after the value printed by CODT then closing the location. LINE FEED — OPEN LOWER SEARCH LIMIT The word immediately following the mask storage location contains the location at which the search is to begin. Typing the LINE FEED will open for modification the first location after the mask, and its conInitially, the lower search limit is set to tents will be printed. 0001. It may be changed by typing the desired lower limit after that printed by CODT, then closing the location. 7-7 . LINE FEED . . — OPEN UPPER SEARCH LIMIT The next sequential word contains the location with which the search to terminate. Typing the LINE FEED key to close the lower search is limit causes the upper search limit to be opened for modification and Initially, tlie upper search limit is the contents printed. its beginning of CODT itself, 7000 (1000 for low version). It may also be changed by typing the desired upper search limit after the one printed by CODT, then closing the location with the RETURN key. nnnnW — WORD SEARCH The command nnnnW (where nnnn is eui octal number) will cause CODT to conduct a search of a defined section of core, using the mask and the lower and upper limits which the user has specified, as indicated The searching operations are used to determine if a given above. quantity is present in any of the locations of a particular section of memory The search is conducted as follows: CODT masks the expression nnnn which the user types preceding the W and saves the result as the quantity for which it is searching. CODT then masks each location within the user's speci f ied limits with C (M) and compares the result If the two quantities are to the quantity for whi ch it is searching. identical, the addres s and the actual unmasked contents of the matching location are printed and the search continues until the upper limit is reached. The search occurs in the memory field specified by F. For example: of any location. Search location 3000 to 4000 for all ISZ instructions regardless of what location they refer to (i.e. search for all locations beginning with an octal 2) A search never alters the contents FOOlO M7777 20 7453/0001 3000 7454/7000 4000 7000 2000W 0200/2467 3057/2501 3124/2032 7.3 Set the field to 2 Chcmge the mask to 7000, open lower search limit. Change the lower limit to 3000, open upper limit. Change the upper limit to 4000, close location. ISZ for the search Initiate instructions These are 4 ISZ instructions in this section of core. ILLEGAL CHARACTERS Any character that is neither a valid control character nor an octal digit, or is the fifth octal digit in a sequence, causes the current ignored and a question mark printed. For example: be line to 7-8 . 7.4 7.4.1 4:? 4U? CODT opens no location. 0406/4671 67K /4671 CODT ignores modification location 406. cind closes ADDITIONAL TECHNIQUES TTY I/O- FLAG CODT automatically notes the status of the TTY flag after encountering a breakpoint and restores it after performing a CONTINUE., 7.4.2 Interrupt Program Debugging CODT executes an lOF when a breeikpoint is encountered. {It does not do this when more iterations remain in an nnnnC command.) This is done so that an interrupt will not occur when CODT prints the breakpoint information. CODT thus protects itself against spurious interrupts and may be used safely in debugging programs that turn on the interrupt mode. CODT restores the interrupt facility to its former state when it resumes execution. 7,4.3 Octal Diomp By setting the search mask to zero and typing W, all Locations (in field F) between the search limits will be printed on the Teletype. 7.4.4 Indirect References When an indirect memory reference instruction actual address may be opened by typing + and respectively) 7.5 is -<- encountered, the (SIIIFT/H and SHIFT /O, ERRORS The only legal inputs are control characters and octal digits. Any other character will cause the character or line to be ignored and a question mark to be printed by CODT. Typing G alone is an error. It must be preceded by an address to which control will be transferred This will elicit no question mark also if not preceded by an address, but will cause control be transferred to location 0. 7-9 7.6 7.6.1 OPERATION AND STORAGE Storage Requirements - CAPS-8 System (octal) CODT can be run in a standard CAPS-8 system and requires 1000 core locations and three locations (4,5,6) on page zero of every field which uses a breakpoint. CODT is page-relocatable. The source tape can be re-origined to the start of any memory page except page zero and assembled to reside in the four pages following that location, assuming they are all in the same memory bank. 7.6.2 Programming Notes Summary page CODT must begin at the start of a memory page (other than and must be completely contained in one memory field. The user's program must not use or reference occupied or used by CODT and vice versa. any core zero) locations Breakpoints are fully invisible to "open location" commands; however, breakpoints may not be placed in locations which the user program will modify in the course of execution or the breakpoint will be destroyed. If a trap set by CODT is not encountered by the breakpoint instruction will not be removed. user's The user may type CTRL/C at any time to return to the (assuming his program did not destroy CAPS-8). 7-10 program, CAPS-8 the Monitor 7.7 COMMAND SUMMARY nnnn/ Open location designated by the octal nnnn. / Reopen latest opened location. RETURN key Close previously opened location. LINE FEED key Close location ajid open the one for modification. + (SHIFT/N) *- (SHIFT /O) Illegal character number next sequential Close location and allow modification of the next location. immediate Close location, take contents that of location as a memory reference and open it. Close location, open indirectly. Current line typed by user is types: ? (CR/LF) Ignored, CODT . nnnnG Transfer program control to location nnnn. nnnnB Establish a brecikpoint at location nnnn. B Remove the breakpoint. A Open for modification the location in which contents of the AC were stored when the breakpoint was encountered. the L Open the location storing the link. C Proceed from a breakpoint. nnnnC Continue from a breakpoint and iterate past the breakpoint nnnn times before interrupting program the the user's at breakpoint location. M Open the search mask. LINE FEED key Open lower search limit. LINE FEED key Open upper search limit. nnnnW Search the portion of core as defined by the upper and lower limits for the octal value nnnn. F Open location F. D Open location 7-11 D. CHAPTER 8 CAPS- 8 UTILITY PROGRAM 8.1 INTRODUCTION The CAPS-8 Utility Program (UTIL) allows the user to take files stored on paper tape and transfer them to cassette, using either the high-speed or low-speed reader. The Utility Program will transfer both ASCII and BINARY files. 8.2 CALLING AND USING THE UTILITY PROGFIAM To call the Utility Program from the system cassette, the user types: .R UTIL/OPTIONS in response to the dot 8.2,1 (.) printed by the Keyboard Monitor. Utility Program Options There are two options available for use with the Utility Program; these options are discussed in Table 8-1. (Options usage is explained in Chapter 2, Section 2.4.3.) Table 8-1 Utility Program Options Option Meaning /H The /H option is used to designate the high-speed reader as the input device. Note that the high-speed reader is the default input device. That is, if no option is specified the program assumes that the high-speed reader is the input device. /L The /L option is used to designate low-speed reader as the input device. 8-1 the ) Input and Output Specifications 8.2.2 Before indicating the input and output devices to be used in the file transfer, the user must ensure that the proper reader is ready and that the cassette the file is to be copied onto is write-enabled. When this has been done, the user is ready to begin the file transfer. After UTIL has been called from following: the system cassette, it asks the MODEThe user responds with a single character (A or B) to indicate whether the file being put on the cassette is ASCII or BINARY. OUTThe user responds by typing the drive number the output cassette is mounted on and the name of the output file to be put onto it, i.e., 3:F00. In B mode, .BIN is the default extension. After these two queries have been answered UTIL prints the following: f The user responds by typing any character; this response starts the file transfer. (If /L had been typed, the user merely turns on the low-speed reader. 8.3 UTILITY PROGRAM ERROR MESSAGES Errors which occur during the Utility Program operation may be of two types: User errors and cassette errors. User errors may be corrected with the appropriate action as detailed in Table 8-2. Cassette errors normally require the user to use another cassette to complete the copy operation. Control does not return to the Keyboard Monitor when a Utility Progreim error occurs. The user may use CTRL/C to return to the Monitor if he cannot correct the indicated error. Table 8-2 Utility Program Error Messages Message Ifeaning UNIT n NOT READY There is either no cassette on the cassette drive specified or no such drive exists. OUTPUT ERROR ON UNIT n An output error has occurred on the cassette drive specified. The user should try the tremsfer operation using another cassette. Or perhaps, the user tried to write data when the write protect tab of the cassette on the drive specified was write- locked. 8-2 ENTER ERROR ON UNIT n An error occurred while trying to open a cassette file. UNIT n FULL There was not enough room on the cassette. CLOSE ERROR ON UNIT n An error occurred during a close operation. INPUT ERROR In binary mode, the paper tape reader stopped or ran out of tape before a checksum was encountered. CHECKSUM ERROR In binary mode, the checksum did not agree; probably a hardware read error. Try again. Whenever cin error occurs, the program writes a open cassette if possible. 8-3 new sentinel on new the CHAPTER 9 BOOT BOOT is used to make it convenient to bootstrap from one system to another, or from, one device to another by typing commands on the keyboard. BOOT can run conveniently from CAPS-8 and other monitor systems, i.e., OS/8 and COS-300. 9.1 OPERATING PROCEDURES To run BOOT from CAPS-8 the user types: .R BOOT the system will respond by typing a slash, at which time the user responds with the device mnemonic. If an illegal mnemonic is typed, the system types "NO" slash to allow the user to try again. and prints a In this case, the user can type RUBOUT to erase a line and try again. If a legal mnemonic was given, but the system configuration does not include the corresponding device (or the device is not ready) , the bootstrap may hang. The following is a list of legal mnemonics; System or Comments CA TA8E cassette CAPS-8 DK Any disk (RF08, OS/8, COS-300 DF32, RK8E, RK8) DL L INC tape DIAL-V2, DIAL-MS DM RF08 or DF32 Disk Monitor DT OS/8, COS-300 LT Any tape (TC08, TD8E, LlNCtape) L INC tape PT PTBE Papertape Loads BINLDR into field OS/8, COS-300 9-1 . : System or Comments Mnemonic Device RE RK8E disk OS/8, COS-300 RP RF08, DF32 disks OS/8, COS-300 RK RK8 disk OS/8, COS-300 TD TD8E DECtape OS/8, COS-300 TY TC08 DECtape unit TC TC08 DECtape 4 Typeset Bootstrap types boot's version number OS/8, COS-300, Disk monitor, DEC library system, and others Zeroes core (field ZE 0) If the device mnemonic is followed by a period, the program will load the correct bootstrap into core and then halt. Hitting continue branches to the bootstrap. Example ^R BOOT /DT The preceding bootstraps onto a DECtape system (on DECtape unit 0) The underlined characters were typed by the computer. 9-2 APPENDIX A ASCII CHARACTER SET Character A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 8-Bit Octal 7-Bit Octal 301 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 260 261 262 263 264 265 266 267 270 271 101 102 103 104 105 106 107 110 111 112 113 114 115 116 117 120 121 122 123 124 125 126 127 130 131 132 260 261 262 263 264 265 266 267 270 271 Character 1 n # $ % & 1 ( ) * + » • / • • 1 < = > 7 @ [ \ ] i -^ Leader/Trailer BELL TAB LINE FEED FORM CARRIAGE RETURN CTRL/Z SPACE RUB OUT BLANK A-1 8~Bit Octal 7-Bit Octal 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 272 273 274 275 276 277 300 333 334 335 336 337 200 207 211 212 214 215 232 240 377 000 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 272 273 274 275 276 277 133 134 135 136 137 240 APPENDIX B ERROR MESSAGE Al^D COMMAND SUMMARIES The following summaries are provided for the user's convenience; they are grouped in alphabetical order according to the SyEtem Program to which they pertain. As these are only summaries the useir is referred to the appropriate chapters for details. KEYBOARD MONITOR (Chapter 2) Error Messages Message Meaning BAD COMMAND The user has failed to follow the correct syntax for Monitor commands. FILE NOT FOUND The Monitor could not locate the file (or files) specified. 10 ERROR ON UNIT n An I/O error has occurired on the cassette unit drive specified. The user should try the I/O transfer specifying another cassette. UNIT n NOT READY There is no cassette on the unit drive specified, or no such drive exists. UNIT n WRITE LOCKED The user tried to write data when the write protect tab of the cassette on the drive specified was wjrite- locked. Commcinds Command Explanation DATE Allows the user to enter the month, day, and year. This date is then represented in directory Listings. DELETE Causes the file named in the command line to be deleted from the cassette drive specified. DIRECTORY Causes a cassette line. B-1 directory specified listing in the of the command . KEYBOARD MONITOR (Con't) Coram and Explanation LOAD Instructs the Monitor to load the file(s) specified in the command line. (The correct starting address is then set in the switch register and execution is started by pressing CONTinue.) REWIND Causes the cassette on the drive specified be rewound to its to beginning. RUN Instructs the Monitor to load and execute the file(s) specified in the command line VERSION Causes the version number of the Monitor currently in use to be printed on the console terminal. ZERO Causes deletion of all files following the filename specified in the command line. If no filename is indicated, all files are deleted and the sentinel file is moved to the beginning of the cassette. EDITOR (Chapter 3) Error Messages Error codes are printed in the form of the following: Pn+C where n Code represents one Meaning The EDITOR failed in reading from a device. An error occurred in the device handler; most likely a hardware malfunction. 1 The EDITOFl failed in writing onto a device; generally a hardware malfunction. 2 A file close error occurred. output file could not be closed. A question mark syntax error. (?) may appear any time B-2 the EDITOR encounters The a In addition, the EDITOR contains the following error message: Message UNIT HAS OPENED FILE Meaning Two files cannot be open on the cassette at the same time. same Commands Command Meaning A Append text from the keyboard to whatever is present in the text buffer. B List the niamber of avai].able locations in the text buffer. C Change the text of a or lines. D Delete the specified lin€!(s) from the buffer. E Output the current buffer and transfer all input to the output file; close the output fi.le. F Find the next occurrence of the string currently being searched for. G Get and list the next line which a label associated with ;Lt. has Insert text before a line I memory spescified speicified line in the text buffer. J Initiate an inter-buffer search for a character string. K Kill the buffer; rese: the text buffer pointers so that: there is no text in the buffer. L List entire contents (or specified lines) of the text buffer on console terminal. M Move specified lines from one place in the text to another, deleting the old occurrence of the text. N Write the current buffer to the file, kill the indicated output buffer and read the next logical page from the input file. B-3 : . EDITOR (Con't) Meaning Command Write the specified buffer. P entire text lines) to buffer (or the output Immediate end-of-file. Q causes text buffer to be output to output file and the file closed. the the Read from the specified input device and append the new text to the current contents of the buffer. S Search for the character specified. V List the entire text buffer (or only specific lines) on the line printer. Skip to a logical page in the input file, without writing any output. Perform a search for string of characters. a specified or List the current line number (.=) list the last line number in the text buffer (/=) or . . = /= or /: List the next line in the text buffer on the console terminal. List the previous line in the buffer on the console terminal. LINE FEED Key SYSCOP (Chapter text List the next line in the text buffer on the console terminal. 4) Error Messages Meaning Message INPUT ERROR ON UNIT n An input error has occurred on the The user cassette unit specified. should try the copy operation using another cassette. UNIT n NOT READY There is no cassette on the unit drive specified, or no such drive exists. B-4 SYSCOP (Con't) Message Meaning UNIT n WRITE LOCKED The user tried to write data when the write protect tab of the cassette on the drive specified was write- locked. OUTPUT ERROR ON UNIT n An output error has occurred on the cassette unit specified. The user should try the copy operation using another cassette. PALC (Chapter 5) Error Messages Explanation Error Code BE Two PALC overlapped. DE An error was detected when trying read or write a device. DF Device full. IC Illegal character. The character ignored and assembly continues. ID Illegal redefinition of The syiTibol retains definition. IE Illegal equals. An equal used in the wrong context. sign II indirect, Illegal reference was made. off-page IP Illegal pseudo-op. A pseudo-op was used in the wrong context or with incorrect syntax. IZ The Illegal page zero reference. found in an pseudo-op Z was instruction which did net refer to page zero. The Z is ignored. PE Current non-zero page attempt was made to: 1. Internal tables Fatal error. Override a instruction B-5 An a have to is symbol. its old was exceeded, An with an literal . PALC (Con't) Meaning Error Code 2. Override an literal 3. Use more with instruction literals than a the assemhiler allows on that page PH Either no $ appeared at Phase error. the end of the program, or < and > in conditional pseudo-ops did not match. RD Redefinition. A permanent symbol has been defined with =. The new and old definitions do not match. The redefinition is allowed. SE Too many Symbol table exceeded. symbols have been defined for the amount of memory available. UO Undefined origin. symbol has occurred statement. An in undefined origin an US Undefined symbols. A symbol has been processed during pass 2 that was not defined before the end of pass 1. ZE exceeded. Same as Page with reference to page 0. BASIC (Chapter PE except 6) Error Messages Meaning Message illegal an SQR(-l) ARGUMENT ERROR A function was given argument; for example: CHAIN ERROR A cassette error occurred while doing program chaining. DATA ERROR There were no more items in the data list. EOF ERROR The user attempted to read past the end- of- file during run- time input. EXPRESSION ERROR lists internal BASIC'S One of to attempting while overflowed evaluate an expression. B-6 BASIC (Con't) Message Meaning FILE NAME ERROR A mistake was FILE OPEN ERROR The user attempted to open a run- time output file when one was already open, or a hardware error occurred. FOR ERROR FOR loops were nested too deeply. FUNCTION ERROR The user attempted to call a function which had not been defined. GOSUB ERROR Subroutines were nested too deeply. I O ERROR IN ERROR found in the user's specification of a cassette drive # or filename in either a CHAIN or an OPEN statement. The user attempted to do run-time input and output to the same cassette at the same time. A cassette attempting command or error occurred while to carry out an OLD while doing run- time input. LINE TOO LONG A line greater than 80 characters in length was typed; BASIC ignores the line and waits for a new one to be entered. LINE # ERROR IF statement A GOTO, GOSUB, or referenced a nonexistent line. LOOKUP ERROR BASIC could not find a run-time input file on the drive specified. NEXT ERROR FOR and NEXT statements properly paired. NO FILES ERROR The user attempted to do run-time file 1/0 without first specifying so during BASIC'S initial dialogue. OUT ERROR An error (probably end-of-tape) occurred while doing cassette output either during a SAVE or during run- time output. RETURN ERROR A RETURN statement was issued not under control of a GOSUB. B-7 were not when BASIC (Con't) Meaning Message SUBSCRIPT ERROR A subscript was used which was outside the bounds defined in the DIM statement. SYNTAX ERROR A commcind did not correspond to the language syntax, or an undefined UUF was referenced. TOO BIG, LINE IGNORED The combination of program size of variables exceeded capacity of the computer. niimber eind the Statements Meaning Statement CHAIN Link to next user program. CLOSE Close open output file. COMMAS Output data values to a cassette inserting a comma between each value. DATA Set values for a READ. DEF Define a function. DIM Dimension subscripted variables. END Signals the end of program execution. FOR-TO-STEP Set up a program loop; increment the counter by a value specified using STEP. GOSUB Transfer control to a subroutine. GOTO Transfer control to the line number specified in the command line. IF-END#-THEN perform an (or Transfer control depending upon operation) the the last INPUT# of validity statement. IF-GOTO IF-THEN (or perform an Transfer control upon the depending operation) variables between relationship specified in the command line. B-f ## . statement . Meaning INPUT Input values terminal. INPUT Input values from a data file. LET Assign a value to a variable. LIST List program (or specific console terminal. lines) on LIST# List program (or specific line printer. lines) on LPT Send output to the line printer. NAME Rename the program in memory. NEW Specify a new progreim name. NEXT Continue a program loop until terminating value is reached. NO COMMAS Terminate outputting of commas. NO RUBOUT Disable the RUBOUT command. OLD Call saved program from cassette into memory. OPEN FOR INPUT /OUTPUT Open a file on cassette for input output PRINT Print values or specified text on the console terminal PRINT Output values to a data file. READ Read values from a data list. REM Insert remarks program. RESTORE Reset DATA value. RETURN Return from a subroutine to the body of the program. RUBOUTS Allow the use of the delete characters. RUBOUT key to SAVE Save the program in memory cassette to be specified. on the B-9 from or value the console a or comments in to original its the main . BASIC (Con't) Meaning Statement SCR Delete the current program in memory. STOP Transfer control statement. TTY OUT Return output to the console terminal (after using LPT) to the Functions Function Meaning SIN(x COS(x TAN(x ATN(x EXP(x LOG(x SGN(x INT(x ABS(x SQR(x RND{x TAB(x GET{X PUT(x FNA(x UUF{x Sine of x Cosign of x Tangent of x Arctangent of x Exponential value of x Natural log of x Sign of x Integer value of x Absolute' value of x Square root of x Generate a random number Print character at space x Get character from input device Put character on output device User-defined function User-coded function B-10 END APPENDIX C PALC PERMANENT SYMBOL TABLE The following are the most conunonly used elements of the PDP-8 instruction set and are found in the permanent symbol table within the PALC assembler. For additional information on these instructions and for a description of the symbols used when programming other, optional, I/O devices, see THE SMALL COMI'UTER HANDBOOK, available from the DEC Software Distribution Center. (All times are in microseconds and respresentative of the PDP-8/E.) Mnemonic Operation Code Time Memory Reference Instructions AND TAD DCA JMS JMP 0000 1000 2000 3000 4000 5000 Mnemonic Code ISZ Group NOP lAC RAL RTL RAR RTR CML CMA CLL CLA BSW 1 Logical AND Two s complement add Increment and skip if sero Deposit and clear AC Jump to subroutine Jump ' 7000 7001 7004 7006 7010 7012 7020 7040 7100 7200 7002 Sequence Operation Operate Microinstructions No operation Increment AC Rotate AC and link Rotate AC and link Rotate AC and link Rotate AC and link Complement link Complement AC Clear link Clear AC Swap Bytes in AC C-1 2.6 2.6 2.6 2.6 2.6 1.2 (1 cycle =1.2 microseconds) 3 left one left two right one right two 4 4 4 4 2 2 1 1 4 Mnemonic Group HLT OSR SKP SNL SZL SZA SNA SMA SPA Operation Code 2 Operate Microinstructions 7402 7404 7410 7420 7430 7440 7450 7500 7510 Sequence (1 cycle) Halts the computer Inclusive OR SR with AC Skip unconditionally Skip on nonzero link Skip on zero link Skip on zero AC Skip on nonzero AC Skip on minus AC Skip on positive AC (zero is positive) 3 3 1 1 1 1 1 1 1 Combined Operate Microinstructions CIA STL GLK STA LAS 7041 7120 7204 7240 7604 Complement and increment AC Set link to 1 Get link (put link in AC, bit 11) Set AC to -1 Load AC with SR MQ Microinstructions MQL MQA CAM SWF ACL 7421 7501 7621 7521 7701 Load MQ from AC, then clear AC Inclusive OR the MQ with AC Clear AC and MQ Swap AC and MQ Load MQ into AC Internal lOT Microinstructions SKON ION lOF SRQ GTF RTF SGT CAF 6000 6001 6002 6003 6004 6005 6006 6007 Skip if interrupt ON, euid turn OFF Turn interrupt processor on Disable interrupt processor Skip on interrupt request Get interrupt flags Restore interrupt flags Skip on greater than flag Clear all flags C-2 2,3 1,2 1,4 2 2,3 Mnemonic Code Operation Keyboard/Reader KSF KCC 6031 6032 KRS KRB 6034 6036 KCF KIE 6030 6035 (1 cycle) Skip on keyboard/reader flag Clear keyboard/reader flag and AC; set reader run Read keyboard/reader buffer (static) Clear AC, read keyboard buffer (dynamic) clear keyboard flags Clear keyboard/reader AC 11 to keyboard/reader interrupt enable F.F. , Teleprinter/Pmich TSF TCF TPC TLS 6041 6042 6044 6046 TFL TSK 6040 6045 Line Printer LSF LCF LSE LPC 6661 6662 6663 6664 LIE LLS 6665 6666 LIF 6667 Cassette (1 KCLR KSDR KSEN KSBF KLSA 6700 6701 6702 6703 6704 KSAF KGOA 6705 6706 KRSB 6707 (1 cycle) Skip on teleprinter/punch flag Clear teleprinter/punch flag Load teleprinter/punch and print Load teleprinter/punch, print, and clear teleprinter /punch flag Set teleprinter/punch flag Skip on printer or keyboard flag (1 cycle) Skip on character flag Clear character flag Skip on error Load printer buffer; print on full buffer or control character Set program interrupt flag Clear line printer flag, load character and print Clear program interrupt flag cycle) Clear all Skip on data flag Skip on error Skip on ready flag Load status A from AC 4-11, clear AC, load 8-bit complement of status A Skip on any flag or error Assert the contents of status A, transfer data if read or write Read status B into AC 4-11 C-3 . Mnemonic Code Operation Memory Extension Control, Type MC8/E CDF CIF RDF RIF RIB RMF CDI (1 cycle) Change to data field N Change to instruction field N Read data field Read instruction field Read interrupt buffer Restore memory field Change to data field and instruction field N 62N1 62N2 6214 6224 6234 6244 62N3 PSEUDO-OPERATORS The following is a summary of the PALC assembler pseudo-operators and a brief description of their functions. Detailed information concerning these pseudo-ops is contained in Chapter 5 DECIMAL - OCTAL - FIELD EXPUNGE FIXTAB - PAGE XLIST - IFDEF - IFNDEF - IFZERO - IFNZRO - FIXMRI ENPUNCH NOPUNCH ZBLOCK EJECT - TEXT - I Z Causes all following nuiriiers to be decimal. Causes all following numbers to be interpreted as interpreted as octal. Causes a field setting. Represents indirect addressing. Denotes a page zero reference. Deletes the entire permanent symbol table. Appends presently defined symbols to the permanent symbol table. Resets the location counter to the next page. Suppresses listing while continuing assembly; a second XLIST continues listing. If the symbol is defined, the code within brackets is assembled. If the symbol is not defined, the code within brackets is not assembled. If the expression is zero, the code within brackets is assembled. If the expression is not zero, the code within brackets is not assembled. Defines a memory reference instruction. Resumes binary output after NOPUNCH. Continues assembling code but stops binary output. Reserves words of memory. Causes the listing to jump to the top of the next page. Allows a string of text characters to be entered. C-4 . APPENDIX D SYSTEM DEMONSTIW.TION RUN The following example run, in which the user creates a binary and listing file from an ASCII source file, illustrates a typical use of the CAPS-8 System. The machine output is coded by letters in the left margin which correspond to the textual explanations found following the run r .DA 01/04/7 3 _.DI ^ 1 01/04/73 .BIN FILE .DAT MATH • ^ .rt ia/17/72 V2 1 ^ALC -INt^Ur FILES *2:rESr.FAL -BINAriY FILE -LIST TO JS US STArtT L260 »0001 KCLR>6700 PALC-Vl 6700 6701 6702 6703 6704 6705 6706 6707 7002 3602 KCLR»6700 KSDR«670l KSEN»6702 KS6F»6703 KLSA=6704 KSAF»6705 KGOA«6706 KRSB»6707 BSW«7002 LOC«3602 4000 *400U 1000 1206 6704 6706 6703 5204 7264 START, CRCCHK, US ?«e!00 04001 04002 04003 04004 04005 0400fe RDCOD, L260, TAD fl>re TAD L260 KLSA KGOA KSBF JMP .-1 CML STA RAL D-1 01/04/73 PAGE 1 - r US 04007 04010 04011 5^4012 04013 0401it 04015 0<»01^ c o n t i n u e d 04017 04020 04021 04022 04023 04f!24 04025 04026 04027 04030 04P)31 04032 04033 04034 04035 04(23^ 0403'/ 0000 7610 3211 3636 1205 670a 6706 6701 5216 7002 7430 1636 7022 3636 7420 2236 2235 5215 7346 7002 3235 5201 7737 3557 7730 iJ^rlN LOOPf SKP CLA DCA . OCA I PTR TAD RDCOD KLSA /t,OiiD lUTO srA. Rfe6. A KGOA KSOR JMP ,-l-*|/WA 1-*|/WAIT FOR DATA FLAG bZL TAD CML DCA SNU I5Z ISZ JMP STA I PTR BSkn I PTR PTK KNT LOOP CLL RTL BStN KNT, PTW, H5B, OCA KNT JMP CRCChK 7737 LOC-23 -50 % KCLRs670ld CRCCHK a0foi KNT LOC LOOP 4035 L260 M5P^ PTR RUCOD START .rt PALC-Vl 36Li2 4(^15 4006 4037 4036 4fc65 EDIl INPUT FILE 2 :TEST.PAL fOUTPUr FILE- 1 :TESr.HAL D-2 fcl/0<»/73 PAGE 1-1 i £n STAKT^ TAD Krt0 STAHT* TAD i«;h\50 7L #. KDEN < jt-; KDVSEN _4.L #. 5S /LOAD INTO STA. KEG. A KLSA j;$l"L JK^' . -1 JMH . - /WAIT FOri DATA FLAG #.ii /WAIT #£ r irt i^ALC/N -INPUT FILES *1 MEST.PAL -BINAftV FILE it^: TEST. BIN -LIST TO ATT If BINArtY FILE ON UNIT 2 L V. BINAHV FIL^ CLOSED CRCCHK 40(^1 /•(^35 KNT 36(^2 LOG ^P115 LOOP 4006 L2 6&) 4037 M50 PTR 4036 RDCOD 40555 START 4000 < .DEL 2:TEST.HAL D-3 FOrt DATA FLAG A The Keyboard Monitor is loaded and the DAte command is used to indicate the current date. The user requests a directory listing of cassette drive 1; he decides to zero the directory, thereby deleting all files present on the cassette. B PALC is called from the System Cassette. The input file, TEST. PAL, is stored on cassette drive 2. The user decides to specify as output only a listing on the line printer. Two errors are flagged by the assembler and printed on the console terminal during its second pass. C The listing is printed on the line printer. The user then marks this listing with appropriate corrections and insertions. D PALC prints a .fC; the user makes sure that the System Cassette is still mounted on drive and then types a +C to cause control to return to the Monitor. E The Editor is next called from the System Cassette so that the errors in the file TEST. PAL may be corrected. The input is again drive 2, and the output file will be sent to the previously zeroed cassette on drive 1. F The R command brings in the first page of text and the intra-buffer search is used to find the first error. This misspelling is corrected using the single character search command and the rubout character. G The next mistake occurs 7 lines further in the listing; the incorrect character is found and corrected. The line is also listed to make sure the correction was made properly. H The user inserts a comment in the 5th line forward from this line by skipping eihead 5 lines, searching for the A, and then adding the comment to the line. I The intra-buffer search is used to locate the next correction; a tab is inserted between the 1 and the tcib already present. J The file is closed. K The user calls PALC again, specifying the edited file on drive The /N option is used to obtain only a listing 1 as the input. of the symbol table; the binary file is output to drive 2, and the symbol table is listed on the console terminal. L After assembly, PALC prints -tC and waits while the user makes sure the System Cassette is mounted on drive 0. He then types +C and control returns to the Monitor. The user deletes the first input file (the uncorrected TEST. PAL) from the cassette on drive 2 to complete his session. D-4 APPENDIX E MONITOR SERVICES Included in this Appendix is information the user needs if he intends to create files using the PAL machine language or reference system device handlers. E.l MONITOR MEMORY MAP The CAPS-8 Keyboard Monitor occupies the following memory locations; if the user's program does not overwrite these areas of memory, the routines they contain will be available for use fro:ii within his program and the Monitor may be restarted after execution. (Section E.2 provides more information concerning these routines.) Table E-1 Monitor Mejmory Map Address Contents FIELD LPT and Console Terminal Handlers Bootstrap, KBD Handler, Interrupt Routine 7400 7600 FIELD 5200-6200 6200 6400 6600 7000 7200 7400 7600 1 Keyboard Monitor and Commands WAIT and part of Cassette HANDLER CLOSE and ENTER Cassette HANDLER LOOKUP UTIL and part of Cassette HANDLER Binary Loader Buffer E.2 MONITOR SERVICE UTILITY SUBROUTINES program to one of the following utility the routine has not been overwritten or The user may direct his subroutines providing otherwise destroyed. Table E-2 Utility Subroutines and Locations Address Name Location LPOCHR 07400 Service This routine is used to print a character on the line printer. The calling sequence is: E-1 . ) Table E-2 Address Name . . Utility Siibroutines and Locations (Cont'd) Location Service CDF (current field) GIF TAD character JMS I (LPOCHR The character in bits 5-11 of the AC added to the line printer ring is buffer to be printed. TTOCHR 07402 This routine is used to print a character on the console terminal. The calling sequence is: CDF (current field) GIF TAD character JMS I (TTOCHR The character in bits 5-11 of the AG is added to the teleprinter ring (The character buffer to be printed. will not print if ECHO is off at the time, but can be designated as a "must print" character by turning AC bit 3 on. This causes the character to force ECHO on . LPPUTP 07404 This address contains the next free location in the line printer buffer. LPGETP 07405 LPGETP contains the previous location which was output in line printer buffer (never a pointer) LPCHCT 07406 This location contains the number of line printer interrupts yet to be expected. ECHO 07407 If this address contains -1, ECHO is if it is set to 0, (no ECHO) ; off ECHO is on. TTSIZ 07410 This address contains the length of the teleprinter ring buffer (niamber of characters it can hold) TTPUTP 07411 contains TTPUTP location in the buffer. TTGETP 07412 the last contains This address location which was output in the teleprinter buffer (never a pointer) E-2 the next free teleprinter output . Table E-2 , . Utility Subroutines and Locations (Cont'd) Address Name Location TTCHCT 07413 Service TTCHCT contains the interrupts teleprint€jr number yet to of be expected. LPSIZ 07414 This location contains one less than the length of the line printer ring buffer (number of characters it can hold -1) MONRES 07415 MONRES is the location in field which can be branched to in order to Monitor in restart the Keyboard memory (assuming the Keyboard Monitor Control has not been destroyed) . from this location to the jumps routine MON. 07600 Branching to this location causes a complete rebootstrap of the Keyboard Monitor from the System Cassette on If an I/O error occurs or drive 0. if the cassette on drive does not contain the file MONT0R.BIN, the system waits for the user to mount a good Syst«im Cassette; typing a CTRL/C will then rebootstrap. KBDFLG 07601 If this location contains a non-zero number, it signifies that a character was (other than CTRL/0 or BREAK) typed on the keyboard and has not yet been read. It is lost if a second character gets typed before the previous one is read. KBDIN 07602 the last This location contains typed on the keyboard, character (Here BRE;\K and CTRL/0 do count.) BREAK 07603 This location contains a 1 if a BREAK if it has. has not been used; CTRLCJ 07604 If this location is 0, then whenever CTRL/C is typed, the Monitor will branch to 07600 and bootstrap (after cassette operation current the finishes). If not 0, then when the current cassette operation finishes transferred (with control is to this location in interrupts on) field 0. Set this to point to MONRES if the Keyboard Monitor has not been des troyed E-3 . Table E-2 Address Name KBDCHR . Utility subroutines and Locations (Cont'd) Service Location 07605 Saine as 07600. 07626 This routine reads a character from the keyboard. It waits for KBDFLG to and be non-zero, then zeroes it returns the contents of KBDIN in the The calling sequence is: AC. CDF (current) CIF JMS I (KBDCHR DISMIS 07645 The systera branches to this to dismiss an interrupt. INTRPT 07657 The interrupt routine begins at address. LPBUFR 07731 LPBUFR is the start of the default line printer ring buffer (initially of length 2) TTBUFR 07734 TTBUFR is the start of the default teleprinter ring buffer (initially of length 30) MONSTART 15200 Branching to this location starts the Monitor, assuming that the entire The Monitor is still in memory. routine waits for TTY and LPT then and defaults to resets buffers Sets CTRLCT to point empties them. Sets ECHO on and sets to MONRES. BREAK to 1. Notes cassettes as not being in use. MON 15201 This routine restarts the Monitor but does not do any of above. 15400 also location this Starting at Monitor and resets the restarts locations that may be in a temporary state if the Monitor has been stopped (e.g., by hitting STOP) prematurely. 16200 last This routine waits for the cassette operation (if there was one) The calling sequence to complete. WAIT is; E-4 location this >> Table E-2 Address Name Utility Subroutines and Locations (Cont'd) Service Location CDF (current) CIF 10 JMS I (WAIT <error return <nonnal return > taken, bit be on and bits 4-11 will contain the contents of status register B at This routine the time of error. should be called sometime after every call to HAI^DLER. If an error return is may CINUSE 16273 location contains a this If 0, means ready; 1 are cassettes -1 means cassettes are in use; cassettes had an error in a previous operation. ESTATE 16274 This location contains the status of register B at termination of cassette operation. CLOSE 16400 Calling this subroutine terminates an output file and writes a new sentinel The file at the end of the cassette. calling sequence is: TAD (UNIT CDF (current field) CIF 10 JMS I (CLOSE < error return < normal return> The error return is taken only if an end-of-tape is encountered before the successfully is file sentinel written. BACK 16402 This routine positions the cassette so that the header record of the current file may be written over. The calling sequence (field 1 only) is: JMS I (BACK < error return> < normal ENTER 16404 return> a new siob routine opens calling '.:he file on a cassette. sequence is: Calling this E-5 > Table E-2 Address Name Utility Siibroutines and Locations (Cont'd) Service Location TAD (UNIT CDF (current field) CIF 10 JMS I (ENTER <error return > <norinal return > where UNIT is the cassette unit drive Before making this call, the number. user must set up the new filename in an in-core header record known as the SINCH. ENTER automatically puts the date eind record size into the SINCH (The SINCH format is for the user. The described in Section E.4). INCH is destroyed. HANDLER 16600 calls the system This routine cassette handler which is resident system and will be used by all The handler routine is programs. also available to any user who does Before calling not load over it. this hcUidler, the user must ensure that the cassette is correctly positioned. See also LOOKUP, ENTER, and CLOSE. The calling sequence is: CDF (current field) CIF 10 TAD (UNIT JMS I (HANDLER ARGl (function control word) ARG2 (buffer address) < error return <normal return > The unit number is left in the AC. Only bits 8-11 are used (units 0-17 octal). However, to specify unit 0, least one other bit (of bits 0-7) at It is more convenient, must be on. therefore, to leave the unit number (0-9 would as a character in the AC in the AC be 60-71). A real 12-bit (The means use the previous unit. initial unit is 0.) The function control following form: word means read means write Bits 6-8: field of buffer Other bits are ignored. Bit 0: 1 E-6 has the ! Table E-2 Address Name Utility Subroutines Lcoations (Cont'd) aiid Location Service The length of the record 8-bit (in bytes) must have been previously stored in location BSIZE. The specified record size must be between 1 and 377. LOOKUP and ENTER return with BISZE set to 200 (octal), the usual record size. made, the AC If an error return is bits 4-11 specify the contents of status register B when the error occurred. These bits are summarized below bit 4: bit 5: bit 6: bit 7: bit 8: bit 9: bit 10 bit 11 : : CRC/block error timing error EOT/BOT EOF drive empty rewind write lock oui: ready Bit of the AC will be a 1 if the on th(» previous occurred error the handler 3all as opposed to This is hcmdler call. current (by because the handler will wait if it is called while calling WAIT) The user can it is already in use. th«j cassette meinually wait for operation to be completed Ijy calling If of WAIT. an error occurss , bit the AC will always be on in this 1 < case. The user may check to see if the handler is in use without waiting by interrogating the location CINUSE. Non-zero means that the handler is in use. Two successive calls to HANDLER made \fithout am be not should intervening call to WAIT. contains the current BSIZE 17000 This location record size. LOOKUP 17002 Calling this subroutine positions a cassette at a specified file to be The calling sequence is: read. E-7 > : Table E-2 Address Name Utility Subroutines and Locations (Cont'd) Service Location TAD (UNIT CDF FROMFLD CIF 10 JMS I (LOOKUP CDF (filename fid) ptr to filename <error return > <not found return > < found return > UNIT represents the cassette unit The header is put in drive number. the INCH. The filename consists of 11 consecutive ASCII characters. UTIL 17200 to This routine allows the user specify that a utility operation be The user must be familperformed. iar with the hardware specifications as described in the TU60 CASSETTE MANUAL TAPE TRANSPORT MAINTENANCE (DEC-00-TU60-DA) to understand what these operations do and what conditions cause errors. The calling sequence is CDF n CIF 10 TAD (UNIT JMS I (UTIL utility code <error return <normal return> legal utility The following are codes; all other codes are illegal. 10 30 40 50 70 OPTl 0PT2 OPT 3 17400 17401 17402 rewind backspace file gap write file gap backspace block gap skip to file gap Switch option characters (e.g., /A) stored as 36 bits for A-Z, 0-9 as shown in diagram in Figure E-1. E-8 . Table E-2 Utility Subroutines and Locations (Cont'd) Address Name OPT Location Service D E F G H I J K L N P Q R S T U V W X Z 1 2 3 4 5 6 7 8 9 1 A B OPT 2 M OPT 3 Y C Figure E-1 Switch Option Characters SINCH 17403 See ENTER. DATE 1753117540 These locations contain 8 characters representing the date (e.g., 01/22/73) INCH 17600 See LOOKUP. E.3 RING BUFFERS (4000-7777) Ring buffers must be located in upper core of field 0. They consist of one or more buffer segments, each one of which consists of two or more consecutive locations (the last one pointing The last segment points to the first one. to the next segment) . Ring buffers can be changed by System Programs. Figure E-2 Ring Buffers E-9 . E.3.1 Modifying : t±ie . : Ring Buffers The initial ring buffer supplied by the Monitor consists of one buffer segment of length LPSIZE (TTSIZE) not counting the pointer. The first location is called LPBUFR (TTBUFR) and the last location is called LPBFND (TTBFND) . The value LPSIZE-1 (TTSIZE) is stored in the location LPSIZ (TTSIZ) . The buffer is initially empty. The next location free in the buffer is pointed to by LPPUTP (TTPUTP) and the previous location which has already been output is known as LPGETP (TTGETP) . Both these locations point only to positive words, never to negative pointers. LPCHCT (TTCHCT) is the ones complement of the number of characters left in the buffer to be output if I/O is still in progress. (Specifically, it is the number of flags which have yet LPCHCT to come up.) (TTCHCT) is zero (0) if there is no output in progress To enlarge the ring buffer, wait until LPCHCT (TTCHCT) is zero. Then set LPBFND (TTBFND) to point to the start of the buffer and have the end of the buffer point to LPBUFR (TTBUFR) . Change LPSIZ (TTSIZ) to be the length of the buffer (length -1 in case of LPSIZ) not counting pointer words. Interrupts may be on while this is done providing no LPT (TTY) I/O is initiated. E.4 HEADER RECORD FILE STRUCTURE All files the user creates must begin with a header record octal (40 bytes long) , followed by 200 octal byte long records. The structure of a header record is as follows Table E-3 Header Record Structure Description Bytes (octal) 1-6 Filename; may consist of any alphabetic character or digit and is padded with spaces on the right. 7-11 Filename extension; see Table 2-1 for recommended extension names. 12 File type; maintained by the system for its convenience and for standard compatibility. File types are 1 2 12 ASCII file Standard DEC Binary File (Specified for Bad file deleted files) Refer to Section 2.2.1 these file types. for em explanation all of 13-14 File record length; always has the value 0,200 (i.e., 200) for compatability with standards. 15 File sequence number (not used) E-10 8 Table E-3 Header Record Structure (Cont'd) Description Bytes (octal) 16 Header continuation byte; always 0. 17-24 ASCII date stored as dd nun yy, or 6 spaces if no date was specified when the file was saved. This is the creation date of the file. 25 New files are version cind File version number. automatically incremented by the CAPSare EDITOR. 26-40 Not used. E-11 E.5 CAPS- 8 BOOTSTRAPS The CAPS-8 Hardware Bootstrap is used to load the Cassette Keyboard This bootstrap is stored in the computer in Monitor into memory. read-only-memory so that it is always available for use. Pressing the SW switch on the computer console causes this bootstrap to be executed; it calls the program C2B00T.BIN into memory from the System Cassette. The CAPS-8 Hardware Bootstrap is comprised of the following instructions, included here for the user's information: /CASStTTt SYSU'h miUTSlKAH PALC-Vl Kl/ia«/73 PAGE 1 /CASbFTTt SYSTEM HCOTSTWAP / COPYKIGHT / DltiXTAl. / MAYNAPl;, / S .K . 197r? tQl,'lP:-l!:'NT MASS. CORPORATION 1^175^ /STAKTiNG LHCATION tNOWMALLY): /STAKTXNG LOCATION FOW CJS/S: (^ K S 7 f 1 1< maiAO 3777 s b 7 1! 1 AStN = fi7ii^ bTCv? c7i>^ KSriH=h7i(i3 (\ L S A s b 7 P a e 7 ., a KSAFsb7(^5 Kt'OAsb/Pb b7if;S b7K;t7 fe7v'7 7?.i^? KH5t*sh/k'7 i^i'P, LqC = ifeH^ abi0 «4t50M /P0P-8/£, -8/F, AND -b/M ONLY /LOCATION WHERE StCONOAHY /600TSTPAP REALLY GETS LOADED oSKtsTPii^i^ IFDEI- GSB P<».?K0 1?37 START, TAD f<bi^ pi*&l(il \i:i]h CRCCMK, TAD L?bi?! r/«?l"? b7.jw KLSA i'a^j^J b7t-b KGOA Pl««i?a 0ui7i0S b7i;? 5?v?a RDCOU. PttP0b 7^t.a L2pI^» 0af".^7 piavUi? 671",? l^ia^ll 3Sn KSBF JMP .-1 CmL STA RAL kSEN SKP CLA DCA , 0U'/HS i'lSb DCA 04ei3 04014 l?k54 fe70u TAD KDCOD ^LSA <*3777;CLL> /INITIALIZE PULSE CLEARS THE LINK /CHANGE READ CRC CODE Cfe5 TO /REWIND <1> [SIN] /LOAD READ CRC CODE INTO STATUS [JMP I START] /kEGISTER a /FIKST TIME THROUGH, LINK MUST HERE 1 /INITIATE THE OPERATION (READ /CRC OR REWIND OR FRWD KIlE GAP) /READY? /ot 7f,lH 1 PTR E-12 /NO, WAIT /SET L = l AND AC= A HALT C7776) /any errors? /NO /HALT ON ANY ERROR EXCEPT FOR /REwInD OR FRWD FILE GAP /CAN'T ALLOW 'TAO I PTR' LATER /TO AFFECT LINK /GET CODE FOR READ C0] /LOAD INTO STATUS REGISTER A 04015 fe/fcfe Kagllfr b7Bl KSOR 04017 5Slt> 7vl02 0«e:?l 7430 •1 JMP HSw SZL TAD 1 PTft CML HSw 040?2 1<536 04^l^3 7P22 /CASSfcTTtr SYSTF.I- C/j 4 i? ^ u 3^36 ''^ "!:' ?5 7 4?ri 4 ^h 51 i'i 4 3! 3 P Mae31 LODP, KGOA /FIRST TIME STORES 173 INTO MEMORY /(fl-8IT COMPLIMENT OF RDCOD) /OTHER TIMES READS ONE 6-BIT /BYTE OF PAIR /NEW DATA WORD READY? nflUTSTKAP OCA SNL 1 PalC-VI b?l5 7 34b 04^33 04 34 PI4P3S n ii KN.T, JMP CKCChK 7737 iLi4i5:<fo 3Sb7 PTh, L0C-a3 37 7 7.V-) Mhn , tt '^^ eil/04/73 PAGE 1-1 /INDICATE NEXT BYTE /STORE BACK INTO MEMORY /ARE WE DONE LOADING BOTH 6-81T /BYTES? /YES, SO POINT TO NEXT MEMORY WORD /BUMP COUNTER /REITERATE PT» TSZ PTR ISl KNT JMP LOcr ?STA CLL kTL bSw UCA KNT •0403a IJ' WAIT /MOVE 6-BIT BYTE Tn H.O. AC /WHICH fe-BlT BYTE DF THE PAIR? /^ND, SO ADO IN 1ST BYTE /SWAP BACK AGAIN. SET LINK TO /NO, /SET AC=7b7/ /SET COUNT TO ALLOw READING A /200 BYTE RECORD /en CHECK THE CRC /ONES COMPLIMENT OF NUMBER OF /BYTES TO LOAD /MtMORY LOCATION TO BEGIN LOAD AT /CLA SPA SZL /ThJ ^ -^ouiiNit Binary luauS binary ULES into memory, /II dtulNS tY LOAiUNG A RECORD OF SIZE 43, /TMf N criNTiMutS to LOAU SUCCESSIVE RECORDS EACH OF SIZE ''^'/i /r['i0 /ThI b p p u r ESS C ONTIN UE5 UNTIL IT DESTROYS ITSELF. AND 4ti01 ARE REPLACED BY JMP KBTN] /Py iHt St CONDA RY bO OTSTKAP. /THf-: FlKST rfc.MO RY LO CATION BEFORE A NEw CASSETTE RECORD WITH A RANDOM VALUE (173). /IS K A f) I N IS LUAUE /.SI, C U h S S i V E wOR OS AR c LOADED WITH THE 12-6IT QUANTITY, W Ht-kE A AND d ARE SUCCESSIVE b-B]T BYTES FROM / U;w M + O /tK<E CASSE TIE R ECOKO T N b L E 5 w kOS G ET LUAUEU IF THE CASSETTE CONTAINS /"'ir* hYT ls as CAN (AhM") DUES5 HAPPEN WHEN 'LOADING'' i,T AK n WhE N 'LOADING' THE ORIGIN AT THE /THf Mt AOt W /BtG iNNlMG OP T Mt kE C K . / [in I. A I ION S 4 1'l t-, , ; I rj S> , E-13 /CASSETTE. SYSTEM bOUTSTRAP CRCCHK KNT LDC LOOP PALC-Vl «0iJl aP«35 36(5? aK15 L2fcZI Mb0 PTR RDCOD STAWT ft!33V 4036 aPMS «0K0 E-14 01/04/73 PAGE 1-2 ^ C2B00T.BIN is the bootstrap which loads the Keyboard Monitor into memory. It is stored on the System Cassette and is comprised of the following instructions: / icCONOAn r HOO r / -5 T'^'Ar' .^hi-ONDAKY 1 i^OOTSrkAf- / COPYKli.Hf / UliUTAL / riAVfjAffU, I'^/d ("fJUlP'-ifcNT MmS6, LOKPOkATION Vilfb^ S.H . / ? ii page '-'AlC-vI "d '-s^i-iz'/ ;i s bT\6i KSHFsb7Cii b't M* i«;LSA = t»/0U fiOPUtMCH 3h Mhh'.'d •:) r*. ?u ^S-ii'?. 7 ?>3k:)3 .5M7 tiS*Ji.'!y Oibn-a I-^iJ i;?3n w^swb i^ii!*:! nsn^r., .'''3^:^7 7?4!'i bTNji.uR, iii^ia ii07 a?«< '.1 r> I N , ITSf^LO, S 1 A ijCA th;i»,M TAu hCa dca LOF;<i |-lu dhl, /assumls qhtgin always appears /AKTtP FIEUO SfcTTlNti C13M!5 /:JvV Ci3r.l3 iWd 6Ta dca okcjS»v JMS GETbYT «Sw CLl kTH ?i36ia t^i^lS M^f'lb /u<;/) SiilL b^3S ;i3*5l7 <f<i;7 iV5b5H 7Tei.l a3b^l 7?,:j4 JMp SPEC SPA JSZ DRGSw NOP kal CLL KAL [ICa TEM jMS bRTdYT ?li*'ll f-uOL» 7br-3 «3>^2^ 7 1/ja i')3*»e'3 iiBb nSoSa ttc'a3 r^ocfb •?!3^?b 130f ?307 H3b^/ b?/.b ii<*>3vl /U03 N/Wihi-l, FLD, lAO TE^" ISZ OWbSi»: JMP ITbORU HLT DCa I ORG ISZ ORG CUE M JMP biNLOR 3MaJMp MON ,US31 37i:lS Mi^h'i ^iaS '>'3*>33 b?ril iH.J7 CDf-0, SPECf vi3<537 7^^^ 530^ 7^3i 036a0 »<?23 rTL AND M7H00 i!3»5ai i-riho? 7?i(£)a iaSi.1 b.?8« V13^a3 ;V10ii ?i3^tta i-13f>a5 5317 55/4 eS^ttb 13ll (^3c>3a M3fr3b I'l^feSb JMP ITSFLO GETHYT, ISZ JMH TAO GRKNT RDbYTE X260 E-15 /hlT a= l 4= CTWO KiOPO COMMAND? /IS ORIGIN /tilT 1(3 /COMBJNiE /ORIGIN ; , , , riLiii I C) ^>:^ti,"|;J^^'' / 1 ; I Prfl.C-Vt Vrth' 1 t. ;> A :> i PAGE 1-1 ^ ri u a '1 < ;: ' »or r. JKH Sr"il I 5 " b S S • -14 ' - <, NI .( y i-i 4 / r' / i >i >r i rtl, X / / t I la CL« •SZa 1 T ' ,,' /-, S-.M T 4i) r i c' .' STL JMf ' _S r^ "^ il IT K.. T ^ p-» '^ h < M ,' 1.1 CA <^^/ 1 ^ ^' \ All 1 X'4 vs f ir" I Al; I 1 X, 6 IZ z. MjT %? ^LSA o / :>^ ^ -, ".- ^ f- SU I- ^ !•; A •• S| i(- .-1 -1 / !»> ^ ' y « p i 7 n I .IflP s -. ? i,t' T I /riLOCK 'ijb7 by r .r/(li-. /LOCATItJiM 3701 IS /PKIMfthtY LOAOEW SKIPPED HY fj'jpi 'nCh 'H/.'l, ' '' ' '1 1 tNPUf.Cli'.S-'>'^ h-^13 i..S 'i'^< e) / 03 / :iu br':-'l ,^,S?''^ .^/n UP ^^ ;'./.;-,,/( T ? i', .<, / i,'^ '•.S(v'/ :"! -.'.v.. . 'i '^ '.,' I ^ COK Llr liO J i'^ K . '"j P r % ij «' ^A S i'' V ' p i) ..-rii--' x^.'ia. c>^ii^i 1 ..r^O*) XSh^f ,^hii •^^/T ,X ^7 C , 2/*' S i:' 3 7 1 ? 1/'. / 1 3 7 13 1^3714 / 7 3 7 a '1 3 '.^ trni /737 xk;jT. a^53S <uj3'-' 3 f^ xw rf<« 3 / 1 <^ •^37 1 7 4.^^2 xa--?<e H'.ll'i? ,''/.;" &f<H, ^. r v ^ 37^ y37P) /Y >-! 37 1 ^ ii .,1 y i'l . M nn ^13 7<i? 1 h i^57a3 •J. A v1 "J 1/1 + 1 S2J.1 1-37 i;! i' I /7a X7?7'* ? 1 •' S -1 t- i X/nW,l Ke 5K ^ . 7ti.l'1 r /Str UP PRIMARY rtOOTSTHAP i') i^37aa 1313 T AU M37^5 37 lU nCA I X773/ XKNT E-16 SECQNOArfY BOOTSTRAP / 3715 133^ 373? blii Ifli7?b ViT?J H57 3f^ t!3'31 vyiU'i {".nii X3gl 1, xatUi, 3£?11 40 n H U 1^ 3<S3^ 3 1, ?li/3'4 i) i':U\\V\<d ?.4i1t5l M1 XPTW DCa I TAD X3P11 OCA 1 x«v^n JMP I kESKT 3211 4011 2BL0CK a«»0JMP I .-1 HoorsiKAp CUr.1 ih&l Shii FIRST U^l POCiL f;r_lDYT 3*143 ITSFLD 3 ri ITSflki, 3 6 "1 h b 7 .n 361^ 3/17 K S 1 ) F If) , i-j 4 3 7;',ie ^Juri-;,T 3hb5 7 :i 1' C^ 3r.^''' I Ok 5 3 / n K' ]; s ^1 3 7ii7 3 >W 4 ^ D r- Y T t - r. .^ r. T SPtC T e. '.' :i iJe5 ^ (5 3 S --^ i / /, iS Y ^. M r X c> 1 , 3 7 1? i r' : ': ^ c- 1 :• 37 1(1 i/ X r: / :-i 5/1.^ n ''3';i 1 f a ; 1 1 3/3? 3 / 1 '^ t ?>..' /. 3 7 33 37 ?P V / / .S 7 J/M X 7 / 4 3/d.i / "DCA KDR LOCATION 4011 /MUST tND IN OCTAL PALC-Vl 3^|1^ r..: /A PAGE 1-8 6llN i^i r/1 .Sf-:coNOAwY / f'«LC-Vl E-17 i<10 PA[,E 1-3 APPENDIX F ASSEMBLY INSTRUCTIONS CAPS-8 source programs are supplied on DECtape. Thesie sources are assembled with PALS and copied to cassette with PIPC. To build the CAPS-8 system cassette with PIPC, the user must load the OS/8 cassette handlers as described in USING AND LOADING YOUR NEW OS/8 CASSETTE HANDLERS (DEC-S8-UCASA-A-D) . The following instructions may be used to assemble the sources, print source listings, and cieate the CAPS-8 system cassette on drive 0. .H PALtt *C2B00T ^TEKH <C2B00T .H CHEF .ri HAL8 MONT OH* TEMP <CAS^50N •a CriEF *TEMP • ri PALti *SYiiC0P*TEM4^<SYSC0P .H CHEF TEKP •a PAL8 *ED1TC*TEMP<EDITC .H CriEF *TEKP •H HAL8 *PALC*TEMP<PALC .H CriEF • TEKP .H PAL8 *CBASIC*TEKP<CBASIC/K • ri PIP *lpt:<temp.ls •a PIPC *CSA0:</Z *CSA0 :C2B00T<C2B00T/B *CiiA0 :I«!ONTOri<KONTOH/B *CSA0 :i3VSC0P<SYSC0P/B *CiiA0 :E0ITC<EDITC/B *CSA0 tPALC<PALC/B *C S A0 : CBAS I C <CB AS I C /B *TTY:<CSA0:/L F-1 INDEX 6-51 Addressing, BASIC, 3-12 Alteration of text, ALTMODE Key, 6-52 in BASIC, 3-7 in Editor, 5-15 AND, Boolean, Angle brackets, left/right (<>) 3-7 Editor, 5-19 PALC, 6-47 ANORM subroutine, BASIC, 3-9 Append command. Editor, 6-4 Arithmetic operators, BASIC, 6-11 Arithmetic statement, BASIC, 6-29 Arrays, BASIC, 6-28 maximum number, maximum size, 6-30 ASCII character set, A-1 2-1 ASCII format files, Assembler output, PALC, 5-32 Assembly instructions, CAPS-8, F-1 5-23 Autoindexing, PALC, Cassette 2-1 direictory listing, 1-4 file, 1-4 format, handler, E-6 mnemonic code, PALC, C-3 mounting/dismounting, 1-4, 1-5 Cassette, BASIC, 6-1 CHAIN statement, BASIC, 6-33 Changing text. Editor, 3-12 Characters, ASCII, A-1 CTRL, 2-4 3-4 Editor special, Monitor switch option, E-10 5-5 PALC, 5-17 PALC special, 3-16 Character searches. Editor, Character string search. Editor, 3-15, 3-17, 3-19 6-15 CLOSE statement, BASIC, 6-44 Coding formats, BASIC, 5-32 1-2, 6-1 BASIC language, Coding practices, PALC, 6-1 7-1 CODT, arithmetic statements, 6-2 additional techniques, 7-9 calling, 7-2 to 7-8 commands, editing and control commands, 6-52 6-57 command summary, 7-11 error messages, 7-9 ERRORS, B-6 error message summary, 7-1 6-8 features, example run, 7-8 6-50 illegal characters, floating point package, 7-9 indirect references functions summary, B-10 6-6 interrupt program debugging, 7-9 immediate mode, 7-9 6-2 octal dump, numbers, 7-9 6-10 operation and storage, statements, programming dates, 7-10 statement summary, B-8 7-10 6-59 storage requirements, symbol table, 7-9 6-3 TTY I/O-FLAG, variables, 7-2 6-47 using, BEGFIX subroutine, BASIC, 3-7 2-1 Colon {:), Binary format files, 3-8 Command format. Editor, Binary output, controlling PALC, 3-4 5-28 Command mode. Editor, 6-51 Commands BKWD statement, BASIC, 6-6 5-15 BASIC, Boolean AND, B-3 5-15 Editor summary, Boolean inclusive OR, keyboard monitor summary, B-1 Bootstraps, E-13 6-20 9-1 COMMAS statement, BASIC, BOOT PROGRAM, Comma used as format control 9-1 BOOT, 6-17 9-2 character, Legal Mnemonics, Commenting the program, BASIC, 6-10 Brackets, 5-7 Comments, PALC, 5-19 angle (<>) , Conditional assembly pseudo-operators, 2-4 square ([]) 5-28 PALC, BREAK command, BASIC, 5-19 Conditional delimiters, PALC, Conditional transfer, BASIC, 6-28, Calling 6-32 6-1 BASIC, 5-2 4-1 Console terminal output, PALC, Editor, 6-17 Control characters, BASIC, 5-1 PALC, 6-52 Control commands, BASIC, 4-1 System Copy, 5-28 Controlling PALC binary output, CAPS-8 Cassette, see cassette 2-1 of systeni, Conventions 4-3 return, Carriage , , X-1 2-3 Corrections, Keyboard Monitor, Creating run-time input files, 6-25 BASIC, CTRL/C 4-3 Editor, 6-54 BASIC coiranand, 2-4 CTRL characters, CTRL keys. Editor, 3-5, 3-7 CTRL/0 command, BASIC, Current line counter. Editor, 3-6 Current location counter, PALC, 5-10 Editor, 3-21, 3-22 summary, B-2 Keyboard Monitor, 2-12 summary, B-1 PALC, 5-34 summary, B-5 System copy, 4-3 summary, B-4 E-type notation, 6-2 Example programs, BASIC, 6-8 Expansion of text. Editor, 3-12 Exponential format, 6-2 Expressions, PALC, 5-14 EXPUNGE pseudo-op, PALC, 5-29 Extended memory, PALC, 5-2 7 Extensions of filenames, 2-2 DATA statement, BASIC, 6-12 DAte command, 2-7 DECIMAL pseudo-op, PALC, 5-2 4 Default device, PALC, 5-2 DEF statement, BASIC, 6-4 3 DElete command. Keyboard Monitor, 2-8 Deletion of page. Editor, 3-14 Deletion of text, 3-12, 3-13 Delimiters, PALC conditional, 5-11 Delimiting character, PALC, 5-6 Device, default, PALC, 5-2 Device handlers, 2-11 Devices, I/O, 2-2 DIM statement, BASIC, 6-30 Direct assignment statement, PALC, FAC function, BASIC, 6-4 7 FENTER statement, BASIC, 6-4 5 FEXT statement, BASIC, 6-4 5 FIELD pseudo-op, PALC, 5-2 5 Field of nesting loops, 6-2 8 File formats, 2-1 File gap, 1-4 File header record, 1-4 Filenames, 2-2 Files, multiple input. Editor, 3-2 Files, transferring individual. System Copy, 4-1 File types, E-11 FIX subroutine, BASIC, 6-4 7 FIXMRI pseudo-op, PALC, 5-29 FIXTAB pseudo-op, PALC, 5-29 Floating-Point format, 6-4 6 normalized, 6-4 7 Floating-point package, 6-45, 6-50 FNA function, BASIC, 6-4 3 Form Feed Editor, 3-5 PALC, 5-7 ?ormat control characters, BASIC, 6-17 Formats for BASIC numbers, 6-2 Formats of files, 2-1 FOR-NEXT loop, BASIC, 6-2 7 exiting from, 6-2 8 FOR statement, BASIC, 6-2 7 Function addresses, BASIC, 6-4 5 Function control word, E-6 Functions. BASIC, 6-3 7 summary, B-10 Editor, 3-4 user coded BASIC, 6-4 4 FWD statement, BASIC, 6-51 5-12 Directory command, 2-7 options, 2-8 Directory of system cassette, 2-1 Dismounting a cassette, 1-5 Editing and control commands, BASIC, 6- 52 Editor calling, 3-1 character searches, 3-16 commands, 3-8, 3-12 command summary, B-3 demonstration run, 3-23 error messages, 3-21, 3-22 error message summary, B-2 operating modes, 3-4 text collection, 3-15 EJECT pseudo-op, PALC, 5-30 End of file, PALC, 5-2 6 End of pass, PALC, 5-19 END statement, BASIC, 6-11 ENPUNCH pseudo-op, PALC, 5-2 8 Entering text strings, PALC, 5-2 7 Equal sign (=) BASIC, 6-6 Editor, 3-7 Editor, 3-5 Erase (CTRL/U) Erasing a program in memory, BASIC, , 6-5 5 Errors, Keyboard Monitor loading, 2-3 Errors in Programming, BASIC, 6-59 Error recovery. Editor, 3-5 Error Messages, BASIC, 6-5 7 summary, B-6 GET function, BASIC, 6*-41 Getting on-line, 2-1 GOSUB nesting, maximum level, 6-3 7 GOSUB statement, BASIC, 6-3 5 GOTO statement, BASIC, 6-32 X-2 £ , Hardware bootstrap (MI8-E) , 1-1 Hardware components, 1-2, Keyboard reader mnemonic code, PALC, C-3 Keys, special Editor, 3-5, 3-6, IFDEF pseudo-op, PALC, 5-2 8 IF END* statement, BASIC, 6-3.4 IF GOTO statement, BASIC, 6-32 IFNDEF pseudo-op, PALC, 5-2 8 IFNZRO pseudo-op, PALC, 5-28 IF THEN statement, BASIC, 6-32 IFZERO pseudo-op, PALC, 5-28 Illegal symbolic addresses, PALC, 5-10 Immediate mode, BASIC, 6-6 Implementing a user-coded function, BASIC, 6-44 Incorporating subroutines with UUF, BASIC, 6-46 Incremental value, BASIC, 6-27 Index in FOR statement, BASIC, 6-2 7 Indirect addressincf, PALC, 5-2 0, 5-24 Initial value in FOR statement, BASIC, 6-27 Input commands. Editor, 3-9 Input file extensions, PALC, 5-1 Input files, creation of, BASIC, 6-2 5 Input specifications Editor, 3-2 PALC, 5-1 System Copy, 4-2 INPUT statement, BASIC, 6-14 INPUT* statement, BASIC, 6-16 Input/output devices, 2-2 Input/output statements, 6-12 Input/output transfer microinstructions, PALC, 5-2 3 Insert command. Editor, 3-14 Instructions, PALC, 5-6, 5-30 Instruction set, BASIC, 6-50 Interactive programming language, BASIC, 6-1 Integer number format, BASIC, 6-2 Inter-buffer character string search. Editor, 3-19 Internal format, BASIC, 6-4 4 Internal symbol representation for PALC, 5-13 Ihtra-buffer character string search. Editor, 3-17 INT function, BASIC, 6-3 8 INT(x), integer function, BASIC, 3-7 Labels, PALC, 5-6 Language, interactive programming, 6-1 (BASIC) Leader-trailer tape, 1-3 Left angle bracket (<) , Editor, 3-7 LET command, BASIC, 6-7 LET statement, BASIC, 6-11 Levels of nesting, maximum, 6-29 LINE FEED key. Editor, 3-6 Line printer listing. Editor, 3-11 Line Printer mnemonic code, PALC, C-3 Line printer output, PALC, 5-3 Link generation and storage, PALC, 5-3 LIST and LPT command, BASIC, 6-5 4 LIST command, BASIC, 6-5 3 List commands. Editor, 3-10 Listing a program, BASIC, 6-5 3 List of arrays, BASIC, 6-28 Literals, assigning PALC, 5-18 Load command, 2-7 Loading keyboard monitor, 2-3 Local symbolic addresses, PALC, 5-9 Loops 6-2 7 LPT and RUN commands, BASIC, 6-54 LPT statement, BASIC, 6-21 , , Matrices, BASIC, 6-2 9 Maxim\am level of GOSUB nesting, BASIC, 6-3 7 Memory extension control, PALC, C-4 Memory map. Monitor, E-1 Memory reference instructions , PALC 5-2 0, C-1 Microinstructions, PALC, 5-21, C-1, C-2 MI8~E hardware bootstrap, 1-1 Monitor, see Keyboard Monitor Mounting a cassette, 1-5 Move text. Editor, 3-15 MQ microinstructions, C-2 Multiple files, 2-6, 2-7 Editor input, 3-2 Multiple input cassettes, PALC, 5-3 Multiple statements, BASIC, 6-10 Multistatement lines, PALC 5-8 6-3 8 I/O designations, 2-5 lOT microinstructions, PALC, C-2 NAME command, BASIC, 6-56 Nested parentneses, BASIC 6-5 Nesting, level of GOSUB, BASIC, 6-37 Keyboard monitor, 1-1, 1-2 commetnds, Nesting, Levels of, 6-2 8, Nesting loops, 6-2 Nesting procedures, 6-2 8 Nesting subroutines, 6-3 6 NEW statement, BASIC, 6-2 NEXT statement, BASIC, 6-2 7 NO COMMAS statement., BASIC, 6-20 2-5 command summary, B-1 error messages, 2-12, B-1 loading and using, 2-3 memory map, E-1 services, E-1 X-3 , , NOPUNCH pseudo-op, PALC, 5-28 Normalized Floating-Point format, BASIC, 6-47 NO RUBOUTS command, BASIC, 6-52 Niimbers in BASIC, 6-2 in PALC, 5-9 of statements, BASIC, 6-10 Numbers, version, 3-3 Octal pseudo-op, PALC, 5-24 OLD statement, BASIC, 6-2 OPEN statement, BASIC, 6-15 Operands, PALC, 5-7 Operate microinstructions, PALC, 5-21, 5-22, C-1, C-2 Operating modes, Editor, 3-4 Operators BASIC arithmetic, 6-4 PALC, 5-14, 5-15 relational, 6-11 Options, PALC, 5-5 OR, Boolean inclusive, 5-15 Order of execution of BASIC statements, 6-10 Output commands. Editor, 3-10 Output file extensions, PALC, 5-2 Output file. Editor, 3-3 Output specifications Editor, 3-2 PALC, 5-2 System Copy, 4-2 PAUSE pseudo-op, PALC, 5-26 Permanent symbols, PALC, 5-9 Permanent symbol table, altering PALC, 5-29 PRINT command, BASIC, 6-6 Print positions, BASIC, 6-40 PRINT statement, BASIC, 6-16 PRINT# statement, BASIC, 6-20 Print zones, 6-17 Priority of operations, BASIC arithmetic, 6-4 Programming errors, BASIC, 6-59 Program Assembly Language for Cassette, see PALC Program chaining, BASIC, 6-34 Program preparation, PALC, 5-32 Program storage, BASIC, 6-1 Pseudo operators, PALC, 5-24 summary, C-4 PUT function, BASIC, 6-4 2 Radix control, PALC, 5-2 4 Read command. Editor, 3-10 Reader record file structure, E-11 READ statement, BASIC, 6-12 Real format, BASIC, 6-2 Record, file header, 1-4 Relational operators, BASIC, 6-11 Relative addressing, BASIC, 6-51 REMARK statement, BASIC, 6-10 Renaming a program, BASIC, 6-5 6 RETURN key. Editor, 3-5 RETURN statement, BASIC, 6-3 5 Return to command mode. Editor, 3-5 Page deletion, 3-14 Reserving memory, PALC, 5-2 7 5-29 Page format, PALC, Resetting location counter, PALC, PAGE n pseudo-op, PALC, 5-2 6 5-26 Page zero addressing, PALC, 5-2 4 RESTORE statement, BASIC, 6-13 PALC (Program Assembly Language for Rewind button, 1-6 Cassette) , 1-2 REwind command, 2-10 assembler output, 5-3 2 Right angle bracket (>) , Editor, 3-7 calling, 5-1 Ring buffers, E-10 coding practices, 5-31 RND(x) function, BASIC, 6-39 character set, 5-5 RUBOUT command, BASIC, 6-5 2 delimiting character, 5-6 Rubout key, 2-3, 3-5 error codes and conditions, 5-33, Run command, 2-6 5-34 RUN command, BASIC, 6-5 4 error message summary, B-5 Running a BASIC program, 6-5 4 format effectors, 5-7 Run-time input file creation, BASIC, instructions, 5-2 6-2 5 link generation and storage, 5-3 Run-time output files, BASIC, 6-15 numbers, 5-9 options, 5-5 permanent symbol table, C-1 SAVE command, BASIC, 6-5 6 program preparation, 5-3 2 Saving a program, BASIC, 6-5 6 pseudo-operators, 5-2 4 SCRATCH command, BASIC, 6-5 5 statements. 5-6 Search for character. Editor, 3-16 symbols, 5-9 Search for character string. Editor, Parentheses in BASIC, 6-5 3-13, 3-15, 3-17, 3-19 Pass 1, PALC, 5-1, 5-3 Semicolon used as BASIC format control Pass 2, PALC, 5-1, 5-3 character, 6-17 Pass 3, PALC, 5-4 X-4 , Sentinel file, 1-4 Service utility subroutines, Monitor, E-1 SGN(x) function, BASIC, 6-38 SHIFT/0 command, BASIC, 6-52 Single character search. Editor, 3-16 Sign bit, BASIC, 6-4 6 Skip command. Editor, 3-15 Slash (/) symbol. Editor, 3-6 Software components, 1-2 Spaces, BASIC, 6-5 Special characters, PALC, 5-17 Specification options, 2-5 Square brackets ([]), 2-4 Statement numbers, BASIC, 6-10 Statement summary, BASIC, B-8 Statements, PALC, 5-6 direct assignment, 5-12 Statement terminators, PALC, 5-7 STEP value, BASIC, 6-2 7 Stopping a run, BASIC, 6-54 STOP statement, BASIC, 6-11 String search termination. Editor, 3-20 Subroutines Monitor service utility, E-1 Subroutines, BASIC, 6-35 Subscripted variables, BASIC, 6-2 9 Subscripts, BASIC, 6-30 Suppress listing, PALC, 5-2 7 Switch option characters, E-10 Symbolic addresses illegal in PALC, 5-10 Symbolic Editor, 1-2, 3-1 symbolic instructions, PAEC, 5-13 Symbolic operands, PALC, 5-13 Symbols, PALC, 5-9 Symbol table, BASIC, 6-59 PALC, 5-11 Syntax error. Editor, 3-22 System cassette, 1-4 directory, 2-1 System conventions, 2-1 System Copy (SYSCOP) , 1-2 calling, 4-2 error messages, 4-4 error message summary, B-4 example, 4-3 options, 4-2 System demonstration run, D-1 System programs, 2-1 , TAB function, BASIC, 6-40 Tabulation (CTRL/TAB) Editor, 3-7 Tabulations, PALC, 5-7 Teleprinter/Punch mnemonic code PALC, C-3 Terminal value in BASIC loop, 6-27 Terminating assembly,. PALC, 5-34 Terminating string search, Editor, 3-20 Terminating the BASIC program, 6-11 Text collection. Editor, 3-15 Text mode. Editor, 3-4 TEXT pseudo-op, PALC,. 5-27 Text transfer commands. Editor, 3-11 Transfer of control statements, BASIC 6-31 Transferring individual files, System Copy, 4-1 Transition between modes. Editor, 3-4 TTY OUT statement, BASIC, 6-22 TU60 dual cassette unit, 1-5 , Unconditional transfer, BASIC, 6-32 Underlining in examples, 1-6 User-coded functions,, examples of BASIC, 6-4 7 User-defined symbols,, PALC, 5-9 Using cassette, BASIC, 6-1 Utility codes, E-9 UTILITY PROGRAM, 8-1 8-2, 8-3 error messages, 8-1 options, UTIL, 8-1 Variables, BASIC, 6-3 subscripted, 6-2 9 Version command, 2-10 Version numbers. Editor, 3-3 Write protect tabs, 1-3 Writing the program, BASIC, 6-4 7 X-5 XLIST pseudo-op, PALC, 5-2 7 Zero command, Keyboard Monitor, 2-9 Zeroing output file, 4-2 . Cassette Programming System Users Manual DEC-8E-0CASA-B-D READER'S COMMENTS NOTE: This form is for document comments only. Problems with software should be reported on a Softv/are Problem Report (SPR) form (see the HOW TO OBTAIN SOFTWARE INFORMATION page) Did you find errors in this manual? If so, specify by page. Did you find this manual understandable, usable, and well-organized? Please make suggeistions for improvement. Is there sufficient documentation on associated system programs required for use of the software described in this manucil? If not, what material is missing and where should it be placed? Please indicate the type of user/reader that you most n€;arly represent. I I I I I I I I Assembly language programmer Higher-level language programmer Occasional programmer (experienced) User with little programming experience I I Student programmer I I Non-programmer interested in computer concepts and capabilities Date Name Organization Street City State Zip Code or Country If you do not require a written reply, please check here. Q -Fold Here- -- Do Not Tear - Fold Here and Staple - FIRST CLASS PERMIT NO. 33 MAYNARD, MASS. BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Postage will be paid by: Software Communications Box F Maynard, Massachusetts 01754 P. O. HOW TO OBTAIN SOFTWARE INFORMATION SOFTWARE NEWSLETTERS, MAILING LIST The Software Communications Group, located at corporate headquarters in Maynard, publishes newsletters and Software Performance Summaries (SPS) for the various Digital products. Newsletters are published monthly, and contain announcements of new and revised software, programming notes, software problems and solutions, and documentation corrections. Software Performance Summaries are a collection of existing problems and solutions for a given software system,, and are published periodically. For information on the distribution of these docuinents and how to get on the software newsletter mailing list, write to: Software Communications 0. Box F Maynard, Massachusetts 01754 P. SOFTWARE PROBLEMS Questions or problems relating to Digital's software should be reported A specialist is located in each to a Software Support Specialist. Digital Sales Office in the United States.. In Europe, software problem reporting centers are in the following cities. Reading, England Paris, France The Hague, Holland Tel Aviv, Israel Milan, Italy Solna, Sweden Geneva, Switzerland Munich, West Germany Software Problem Report (SPR) forms are available from the specialists or from the Software Distribution Centers cited below. PROGRAMS AND MANUALS In Software and manuals should be ordered by title and order number. the United States, send orders to the nearest distribution center. Digital Equipment Corporation Software Distribution Center 146 Main Street Maynard, Massachusetts 01754 Digital Equipment Corporation Software Distribution Center 1400 Terra Bella Mountain View, California 94043 Outside of the United States, orders should be directed to the nearest Digital Field Sales Office or representative. USERS SOCIETY DECUS, Digital Equipment Computer Users Society, maintains a user exchange center for user-written programs and technical application information. A catalog of existing programs is available. The society publishes a periodical, DECUSCOPE, and holds technical seminars in the United States, Canada, Europe, and Australia. For information on the society and membership application forms, write to: DECUS Digital Equipment Corporation 146 Main Street Maynard, Massachusetts 01754 DECUS Digital Equipment, S.A. 81 Route de I'Aire 1211 Geneva 26 Switzerland
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies