MACLKSSM.DOC MACREL/LINK Software Support Manual AA-J073A-TA DISCLAIMER This document file was created by scanning the original document and then editing the scanned text. As much as possible, the original text format was restored. Some format changes were made to insure this document would print on current laser printers using 60 lines per page. The original spelling and grammar has been preserved. 1-Apr-1997 MACREL/LINK Software Support Manual AA-J073A-TA September 1980 This manual describes the internal data structures and processes of the MACREL Assembler and the LINK Linking Loader. Its purpose is to provide experienced users with the detailed technical information necessary to allow them to effectively maintain or modify these programs. This is a new document. OPERATING SYSTEM: OS/8 Version 3D SOFTWARE: MACREL Version 2C LINK Version 2AG ---------------------------------------------------------------------- | To order additional copies of this document, contact the Software | | Distribution Center, Digital Equipment Corporation, Maynard, | | Massachusetts 01754 | ---------------------------------------------------------------------- digital equipment corporation - maynard, massachusetts First Printing, September 1980 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 document. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies. Copyright (c) 1980, by Digital Equipment Corporation. All Rights Reserved. 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: DEC DECnet IAS DECUS DECsystem-10 MASSBUS Digital Logo DECSYSTEM-20 PDT PDP DECwriter RSTS UNIBUS DIBOL RSX VAX EduSystem VMS VT M10000 CONTENTS Page PREFACE xi PART I MACREL CHAPTER 1 INTRODUCTION 1-1 1.1 SYSTEM LAYOUT 1-1 1.1.1 Resident Code 1-1 1.1.2 Overlay Code 1-2 1.2 IMPLEMENTATION LANGUAGE 1-2 1.3 LABEL AND SYMBOL CONVENTIONS 1-2 1.3.1 Directive Routine Labels 1-3 1.3.2 Labels for Macro-Processing Modules 1-3 1.3.3 Global Symbol Definition File (MGLOB.MA) 1-3 1.3.4 Labels for Commonly Used Routines and Constants 1-3 1.3.5 Local (Page) Symbols 1-6 1.4 ROUTINE CALLING CONVENTIONS 1-6 1.4.1 ERROR Routine Calls 1-6 1.4.2 Subprogram Interfaces and Calling Sequences 1-6 1.4.3 Overlay Module Calling Conventions 1-7 1.5 DATA FORMATS AND REPRESENTATIONS 1-7 1.5.1 Character Encoding and Packing Schemes 1-8 1.5.2 15-Bit Pointers 1-8 1.5.3 Chunks 1-9 1.5.4 Symbol Table Organization 1-9 1.5.4.1 Character Codes for Symbol Table Entries 1-9 1.5.5 Symbol Table Entry Formats 1-9 1.5.5.1 Regular Symbol Table Entry Format 1-10 1.5.5.2 .MACRO Symbol Table Entry Format 1-12 1.5.5.3 Pseudo-Operator and Pseudo-Macro Symbol Table Entry Format 1-12 1.5.5.4 .EXTERNAL Symbol Table Entry Format 1-13 1.5.5.5 .ASECT Symbol Table Entry Format 1-13 1.5.5.6 .DSECT Symbol Table Entry Format 1-14 1.5.5.7 .RSECT Symbol Table Entry Format 1-14 1.5.5.8 .FSECT .XSECT and .ZSECT Symbol Table Entry Format 1-15 1.5.5.9 Auxiliary Symbol Table Chunk Entry Format 1-15 1.6 TABLES, STACKS, AND BUFFERS 1-16 1.7 DEFAULT CONDITIONS 1-17 1.8 ERROR AND EXCEPTION REPORTING 1-18 CHAPTER 2 DESCRIPTIONS OF THE MODULES 2-1 2.1 EXPOVR (Overlay 32) 2-2 2.1.1 BACKL 2-2 2.1.2 IDIV 2-4 iii CONTENTS Page 2.1.3 IMUL 2-4 2.1.4 SNGLQQ 2-5 2.1.5 UPAROQ 2-5 2.2 FIN0 (Overlay 10) 2-7 2.2.1 NEXTT 2-7 2.2.2 OPEN1 2-8 2.2.3 OPEN2 2-8 2.2.4 OPEN3 2-8 2.2.5 OPEN4 2-10 2.2.6 FIN5 2-10 2.2.7 AINIT 2-11 2.2.8 CPYTOC 2-12 2.2.9 REIT 2-13 2.2.10 IOINIT 2-13 2.2.11 IONIT2 2-14 2.3 FIN2 (Overlays 12 and 14) 2-14 2.3.1 Unlabeled Routine 2-14 2.3.2 LSDOUT (Overlay 12) 2-16 2.3.3 ZPAD (Overlay 12) 2-18 2.3.4 LSDINI (Overlay 14) 2-18 2.3.5 FINIO (Macio) 2-19 2 4 FIN3 (Overlays 11 and 13) 2-20 2 4.1 Unlabeled Routine (Overlay 11) 2-20 2.4.2 STPRNT (Overlay 11) 2-22 2.4.3 PRNT2 (Overlay 11) 2-23 2.4.4 PRN (Overlay 13) 2-23 2.4.5 XPRINT (Overlay 13) 2-23 2.4.6 PRNT6 (Overlay 13) 2-25 2.5 MACERR (Special Overlay) 2-25 2.5.1 Error Typeout Routines 2-26 2.5.2 Creating New Error Messages 2-27 2.5.3 Number of Errors Detected 2-29 2.6 MACEXP 2-29 2.6.1 EXPR 2-29 2.6.2 TERM 2-31 2.7 MACINI 2-33 2.7.1 DATE 2-33 2.7.2 ONCE 2-34 2.7.3 CORE 2-34 2.7.4 LIMSET 2-34 2.7.5 PREFORM 2-35 2.7.6 SYMINI 2-35 2.8 MACIO 2-36 2.8.1 IOINIT and IONIT2 2-37 2.8.2 FINIO (MACIO) 2-37 2.8.3 READOS 2-37 2 8 4 SWITCH 2-38 2 8 5 SWBACK 2-39 2.8.6 GETOS and ORET Coroutines 2-39 2.8.7 MGET and RGET Coroutines 2-40 iv CONTENTS Page 2.8.8 ZGET 2-40 2.8.9 OFIX 2-40 2.8.10 SPUSH 2-40 2.8.11 SPOP 2-41 2.8.12 LOCPSH 2-42 2.8.13 LOCPOP 2-42 2.8.14 OFETCH 2-42 2.8.15 PUTBUF 2-42 2.8.16 LISTOR, LSTRET, and OUTLST 2-42 2.8.17 CONV 2-42 2.8.18 DELETE 2-42 2.8.19 LOOKU 2-43 2.8.20 ZINIT 2-43 2.9 MACLIT (Overlay 31) 2-43 2.9.1 ZSECTG 2-43 2.9.2 ZL 2-44 2.9.3 GENUN 2-44 2.9.4 ZLIT 2-44 2.9.5 PRGSPL 2-45 2.9.6 KLU10 2-45 2.9.7 PURGEL 2-45 2.9.8 OUTLIT 2-45 2.9.9 CMNMOV 2-46 2.10 MACMAC (Overlays 26, 27, and 30) 2-47 2.10.1 $MACRO 2-47 2.10.2 PART2 2-47 2.10.3 $REPT 2-47 2.10.4 MC 2-48 2.10.5 $MEXIT 2-48 2.11 MACOPN (Overlay 33) 2-48 2.11.1 OPEN 2-48 2.11.2 OPENTC 2-49 2.11.3 OFETCH 2-49 2.12 MACORG (Overlay 7) 2-49 2.13 MACRO 2-49 2.14 MACRTH (Overlay 6) 2-51 2.15 MACTBL 2-52 2.16 MAC2 2-52 2.16.1 PUXBIN 2-53 2.16.2 BPUT 2-53 2.16.3 PUNBIT 2-53 2.16.4 PUTBIT 2-54 2.16.5 ORIG 2-54 2.16.6 PUTB 2-54 2.16.7 PUNY 2-54 2.16.8 PUTLC 2-54 2.16.9 UNNAM 2-54 2.17 MAC24 2-55 2.17.1 NEX 2-55 2.17.2 GETLSD 2-55 v CONTENTS Page 2.17.3 IGNORE 2-55 2.17.4 CNVADR 2-55 2.17.5 $PAUSE 2-55 2.17.6 HGHSCT 2-56 2.17.7 LOAD 2-57 2.17.8 SETIT 2-57 2.17.9 PRZLIT 2-57 2.17.10 PRGLIT 2-57 2.17.11 BACKSL 2-57 2.17.12 ERROR 2-57 2.17.13 NEXTCHAR 2-58 2.17.14 GETSYM 2-58 2.17.15 PUTSYM 2-58 2.17.16 READLN 2-59 2.17.17 $FIXMRI 2-59 2.17.18 EQL 2-60 2.17.19 GETCHR 2-60 2.17.20 SCAN 2-60 2.17.21 GET 2-60 2.17.22 CTRLC 2-60 2.17.23 FINI 2-60 2.17.24 BACKUP 2-60 2.17.25 BRAN 2-61 2.17.26 NUMLCL 2-61 2.17.27 BRANCH 2-61 2.17.28 ASEMBL 2-62 2.17.29 GETEX 2-62 2.17.30 ASEMLV 2-62 2.17.31 OUTDATA 2-62 2.17.32 TAGCOM 2-62 2.17.33 TAGCOL 2-62 2.17.34 ORIGIN 2-62 2.17.35 LETTER 2-63 2.17.36 TSTMAC 2-63 2.17.37 DIGIT 2-63 2.17.38 ROTL6 2-63 2.17.39 PARSYM 2-63 2.17.40 EOS 2-64 2.17.41 LOOP 2-64 2.17.42 CALLIT 2-64 2.17.43 GETKAR 2-65 2.17.44 PUSH 2-65 2.17.45 POP 2-65 2.17.46 LOOKUP 2-65 2.17.47 CREF 2-65 2.17.48 ENTER 2-66 2.17.49 KLU4 2-66 2.18 MAC30 (Overlay 15) 2-66 2.18.1 PRINTY 2-66 2.18.2 PRLINO (MAC2) 2-66 vi CONTENTS Page 2.18.3 SETT 2-67 2.18.4 DPRINT 2-67 2.18.5 OPRINT 2-67 2.18.6 NPRINT 2-67 2.18.7 CRLF 2-67 2.18.8 LIST 2-68 2.18.9 PRNDSH 2-68 2.18.10 PRNBIN 2-68 2.18.11 TAB 2-68 2.19 MAC3R 2-68 2.19.1 OUT 2-68 2.19.2 NEWPAG 2-69 2.19.3 LISTER 2-70 2.19.4 OVRLIN 2-70 2.19.5 PASS3 2-70 2.20 OVRA (Overlay 1) 2-70 2.20.1 $PAGE 2-71 2.20.2 $ZBLOCK 2-71 2.20.3 $TEXT 2-71 2.21 OVRB (Overlay 2) 2-72 2.21.1 $IFNZRO 2-72 2.21.2 $IFZERO 2-73 2.21.3 $IFDEF 2-73 2.21.4 $IFNDEF 2-73 2.21.5 $IF 2-73 2.22 OVRC (Overlay 3) 2-74 2.22.1 TASKY 2-74 2.22.2 $OCTAL 2-75 2.22.3 $DECIMA 2-75 2.22.4 $RADIX 2-75 2.22.5 $FILENA 2-75 2.22.6 $DEVICE 2-76 2.22.7 $ENABLE 2-76 2.22.8 $DISABL 2-78 2.23 OVRD (Overlays 4 and 35) 2-78 2.24 OVRE (Overlay 5) 2-79 2.24.1 $CHAIN 2-79 2.24.2 $INCLUD 2-79 2.24.3 $ENTRY 2-80 2.24.4 $EXTERN 2-80 2.24.5 $ZTRNA 2-80 2.24.6 $GLOBAL 2-80 2.24.7 GLOB2 2-80 2.25 OVRQ (Overlays 21 and 34) 2-81 2.25.1 BLKLET 2-81 2.25.2 OUTBLK 2-81 2.25.3 BINFO 2-82 2.26 OVRR (Overlay 22) 2-82 2.26.1 $XLIST 2-82 2.26.2 PREFIN 2-82 vii CONTENTS Page 2.26.3 $NOPUNC 2-83 2.26.4 $ENPUNC 2-83 2.26.5 $JSW, $VERSIO, and $START 2-83 2.26.6 $NOLIST and $LIST 2-83 2.27 OVRS (Overlay 23) 2-84 2.27.1 $FIXTAB 2-84 2.27.2 $EXPUNGE 2-84 2.28 OVRT (Overlay 24) 2-84 2.28.1 LNKCHN 2-84 2.28.2 KRFCHN 2-85 2.28.3 $FIELD 2-85 2.29 OVRU (Overlay 25) 2-85 2.29.1 $SBTTL 2-85 2.29.2 $EJECT 2-85 2.29.3 $TITLE 2-86 2.29.4 $RELOC 2-86 2.29.5 $PUSH and $POP 2-86 2.30 PAS2 (Overlay 16) 2-86 2.30.1 PUTBN 2-87 2.30.2 CHKFUL 2-87 2.30.3 PUTBT 2-87 2.30.4 GETFLG 2-88 2.30.5 BPUTX 2-88 2.30.6 CREFX 2-88 2.30.7 MORCRF 2-88 viii CONTENTS Page PART II LINK Chapter 3 INTRODUCTION 3-1 3.1 INTRODUCTION 3-1 3.2 SYSTEM LAYOUT 3-1 3.3 IMPLEMENTATION LANGUAGE 3-1 3.4 LABEL AND SYMBOL CONVENTIONS 3-1 3.5 ROUTINE CALLING CONVENTIONS 3-2 3.6 DATA FORMATS AND REPRESENTATIONS 3-2 3.7 TABLES 3-2 3.7.1 Global Symbol Table (GST) 3-2 3.7.2 Binary Buffer Table (LDBUFS) 3-4 3.7.3 Pointer Table (PTRTAB) 3-5 3.7.4 Module Descriptor Table (MODTAB) 3-5 3.7.5 .SECT Table (SECTAB) 3-5 3.7.6 Core Image Table (CIMAG, CIMAGl, CIMAG2, and CIMAGE) 3-8 3.7.7 Overlay Transfer Vector (TRANVC) 3-8 3.7.8 User Overlay Level Data Table (QUSRLV) 3-9 3.7.9 Overlay Level Information Table (LHDR) 3-10 3.7.10 Main Binary Section Table (MBST) 3-10 3.7.11 Memory Segment Control Double Words 3-12 3.7.12 Library Table (LIBTB) 3-12 3.8 DEFAULT CONDITIONS 3-12 3.9 LINK ERROR AND EXCEPTION REPORTING 3-14 CHAPTER 4 DESCRIPTIONS OF THE MODULES 4-1 4.1 LNKALL 4-1 4.2 LNKBN1 AND LNKBN2 4-3 4.3 LNKCAL 4_4 4.4 LNKCD 4-5 4.5 LNKMAN 4-5 4.6 LNKLSD 4-8 4.7 LNKMSG 4-10 4.8 LNKMAP 4-10 APPENDIX A CHARACTER SETS A-1 APPENDIX B MACREL MAINTENANCE PROCEDURES B-1 APPENDIX C SUMMARY OF MACREL'S MAJOR MODULES C-1 APPENDIX D BATCH FILES FOR ASSEMBLING AND LINKING MACREL, LINK, AND KREF D-1 APPENDIX E MEMORY UTILIZATION AND MODULE SUMMARY E-1 ix CONTENTS Page APPENDIX F MACREL COMMAND DECODER OPTIONS F-1 APPENDIX G DISCUSSION OF SELECTED ROUTINES IN LINK G-1 G.1 ADJPTR (LNKLSD) G-1 G.2 ALLOC (LNKALL) G-1 G.3 BULDTV (LNKBN2) G-1 G.4 CPIC (LNKALL) G-2 G.5 NEWBB (LNKBN2) G-2 G.6 NEWORG (LNKBN2) G-2 G.7 PUTBIN (LNKBN2) G-2 G.8 RELOCA (LNKBN2) G-2 G.9 SEARCH (LNKMAN) G-3 G.10 SSORT (LNKALL, LNKLSD, and LNKMAP) G-3 INDEX Index-1 FIGURES FIGURE 1-1 OS/8 ASCII Character Packing 1-8 1-2 15-Bit Pointer Format 1-9 2-1 Memory Limit Table (LIMTBL) Layout 2-35 2-2 Formal Argument Table Entry Format 2-47 2-3 Actual (macro) Argument Table Layout 2-51 3-1 Main Binary Section Table Layout 3-11 3-2 Library Table Layout 3-13 D-1 BATCH File for Building MACREL, LINK, and KREF D-2 TABLES TABLE 1-1 Summary of Commonly Used Resident (Field 0) Routines 1-4 1-2 Symbol Table Flag Word 1-10 1-3 Format for Regular Symbol Table Entries 1-11 1-4 Format for Regular Symbol Table Entries with Extended Names 1-11 1-5 Extended Symbol Name Field Definitions 1-12 1-6 Format for .MACRO Symbol Table Entries 1-12 1-7 Format for Pseudo-Operators (PSEUD) and Pseudo-Macros (PSEUM) Symbol Table Entries 1-13 1-8 Format for .EXTERNAL Symbol Table Entries 1-13 1-9 Format for .ASECT Symbol Table Entries 1-14 1-10 Format for .DSECT Symbol Table Entries 1-14 x CONTENTS Page 1-11 Format for .RSECT Symbol Table Entries 1-15 1-12 Format for .XSECT, .ZSECT, and .FSECT Symbol Table Entries 1-15 1-13 Symbol Table Layout for Auxiliary Chunks (.SECTs only) 1-16 1-14 Summary of Tables, Stacks, and Buffers 1-17 2-1 MACREL Module Summary 2-1 2-2 Basic Letter Block Widths vs Listing Device Column Width 2-9 2-3 LSD Entry Type Codes 2-17 2-4 Loader Symbol Dictionary Entry Types, Destinations, and Tasks 2-24 2-5 Layout of MACERR Within MACREL.SV 2-26 2-6 MACERR Output Routine Summary 2-26 2-7 Local Variables Saved on the Expression Stack 2-30 2-8 EXPR Previous Operator Dispatch Table 2-31 2-9 TERM Character Dispatch Table 2-31 2-10 Internal Storage Format of OS/8 Date Words 2-33 2-11 Initial Symbol Table Entry Format 2-36 2-12 Symbol Table Flags Definitions 2-40 2-13 Summary of Routines in the MACRO Module 2-50 2-14 Descriptions of MACRTH Routines 2-51 2-15 Character Branch Table (MACTBL) Classification Codes 2-53 2-16 Assembly Listing Symbol Name Qualifiers 2-66 2-17 TEXT Directive Coroutines 2-72 2-18 .IF Directive Conditions 2-74 2-19 $ENABLE Condition Options 2-76 2-20 $DISABL Condition Options 2-78 2-21 OVRD Entry Points and CST Values 2-78 3-1 Global Symbol Table Entry Format 3-3 3-2 Global Symbol Table Symbol Type Codes 3-4 3-3 Number of Binary Buffers as a Function of Memory Size 3-5 3-4 Module Descriptor Table Format 3-6 3-5 .SECT Table Format 3-6 3-6 Core Image Table Format 3-8 3-7 Overlay Transfer Vector Format 3-9 3-8 Overlay Level Data Table Format 3-10 3-9 Overlay Information Table Entry Format 3-10 3-10 Memory Segment Control Double Word Entry Format 3-12 4-1 Routines in LNKMAN 4-6 A-1 MACREL Special 6-bit Character Codes A-1 A-2 ASCII Character Set A-1 E-1 MACREL Memory Utilization E-1 E-2 Overlay Module Data Summary E-4 xi PREFACE ABOUT THIS MANUAL The MACREL/LINK Software Support Manual describes the internal data _______________________________________ structures and processes of the MACREL Assembler and the LINK Linking Loader. Its purpose is to provide experienced users with the detailed technical information necessary to allow them to effectively maintain or modify these programs. To use this manual effectively, you must be completely familiar with PDP/8 computer hardware and macro assembler programming using the MACREL and LINK programs. You should also be familiar with OS/8 system operation and OS/8 terminology. The manual is designed for use in conjunction with the MACREL/LINK ___________ User's Manual and the MACREL and LINK assembly listings. Though the ______________ listings are well commented, but some of the comments may be obsolete. If there is a conflict between the listing comments and this manual, this manual takes precedence. The manual is divided into two parts: Part 1, MACREL; Part 2, LINK. SYNOPSIS Chapter 1 introduces the MACREL assembler and describes its internal structure and conventions. Chapter 2 consists of detailed descriptions of the major routines in each of MACREL's source modules. The chapter presents the modules in alphabetical order by module name. Chapter 3 introduces the LINK linking loader and describes its internal structure and conventions. Chapter 4 consists of functional descriptions of LINK's source modules. The chapter presents the modules in alphabetical order by module name. The appendixes contain MACREL and LINK batch assembly procedures, MACREL maintenance procedures, summary descriptions of MACREL's overlays and major routines, character codes. xii REFERENCES TO DOCUMENTS The text of this manual contains references to the following documents: MACREL/LINK User's Manual (AA-5664A-TA) _________________________ OS/8 Language Reference Manual (PAL8 section) (AA-H609A-TA) ______________________________ MACREL and LINK Assembly Listings (contained in files residing on _________________________________ DECtapes: AL-5643B-SA (MACREL); AL-5644B-SA (MACREL); AL-H602B-SA (LINK); AL-H603B-SA (LINK) DOCUMENT CONVENTIONS This section describes the conventions and symbology used in the manual. o Fully capitalized words in the text are the names of either source modules, routines, entry points, or variables. o References to routines, entry points, and variables that reside in a module other than the one being discussed are followed by the module name enclosed in parentheses. For example, in the discussion of the PAS2 module, a reference to the QPUT routine in module MACIO would appear as: ... text ... QPUT (MACIO) ... text ... xiii PART I MACREL CHAPTER 1 INTRODUCTION MACREL is a four-pass assembler. Pass 1 defines all the symbols and creates the table-of-contents. Pass 2 creates the binary output file. Pass 3 creates the listing file. Pass 4 creates the data file used by the KREF program to generate a cross-reference listing. Four separate passes are necessary because the OS/8 operating system does not permit more than one output file to be open on the same device. MACREL accepts input from various sources called input streams, which may be internal or external. The main input stream is the OS/8 input file that contains the user's source program. MACREL switches to other input streams in response to the following directives and macros in the source file: o The .CHAIN directive permanently switches the input stream to another, external, OS/8 input file. o The .INCLUDE directive temporarily switches the input stream to another, external, OS/8 input file. o A macro invocation switches the input stream to an internal source called the macro input stream. o The real arguments to a macro switch the input stream to an internal source called the argument input stream. o The .REPT directive switches the input stream to an internal source called the repeat input stream. The streams are controlled by a switching control routine and input coroutines. The switching control routine uses a software pushdown stack to preserve the entire state of a coroutine so that input can be switched from one routine to another and back without loss of context. The input coroutines fetch characters from their associated sources. 1.1 SYSTEM LAYOUT The following paragraphs describe the memory layout of MACREL's resident and overlay code. Table E-1 (Appendix E) shows the memory allocation for each MACREL module. 1.1.1 Resident Code 1-1 INTRODUCTION MACREL's resident code consists of seven modules: MAC2, MAC24, MAC3R, MACEXP, MACIO, MACRO and MACTBL. MAC24 is the main module and resides in Field 0. It contains the assembler's main processing loop, which issues calls to all other modules. 1.1.2 Overlay Code MACREL's overlay code consists of 28 modules (see Appendix E). During execution these modules reside in one of four primary overlay areas: 1. Directives Overlay Area. Contains the overlays that process MACREL's directives. 2. Pass Specific Overlay Area. Contains the overlays that are functionally related to the current assembly pass. 3. Auxiliary Overlay Area. Contains extension overlays to the overlays that cannot reside completely in one of the other overlay areas. NOTE When this area is not used to contain overlay extensions to directive-processing routines, it contains the overlays that process little-used expression constructs and complex relocatable expressions. It is important to note therefore that overlays that call the expression processor (MACEXP) must not load code into this area. 4. Extremities Overlay Area. Contains overlays that perform end-of-pass processing (FIN code) and start-of-next-pass initialization code. During specific passes, this area is the input buffer (INPBUF). 1.2 IMPLEMENTATION LANGUAGE MACREL is coded in itself. Since it is written to run on all PDP-8 processors, it does not use the MQ register. 1.3 LABEL AND SYMBOL CONVENTIONS 1-2 INTRODUCTION 1.3.1 Directive Routine Labels Labels for entry points to routines that implement MACREL language directives begin with a dollar sign ($) followed by the name of the directive. For example, the routine that implements the PAGE directive is labeled $PAGE. A period (.) is not included in the label for a directive that has a leading period in its name. For example, the code that implements the .CHAIN directive is labeled $CHAIN. Only the first (leftmost) six characters of a MACREL symbol, excluding a leading dollar sign ($), are significant. Thus, the labels for the directive processing routines may not exactly match their directive keyword counterparts. For example, the routine that implements the DECIMAL directive is labeled $DECIMA. 1.3.2 Labels for Macro-Processing Modules Many of the modules related to processing of macros and their arguments have labels consisting of one or two letters and a number. These numbers correspond to the step numbers given in comments at the beginning of the module. 1.3.3 Global Symbol Definition File (MGLOB.MA) The global symbol definition file is a parameter file that consists of global symbol definitions. The symbols are referenced by a large number of MACREL's source modules. The beginning of each source module contains an .INCLUDE MGLOB.MA directive to make sure that the assembler reads the symbol definitions before assembling a module. The file establishes the common symbolic linkages between the source modules. When assembling a module, you must be sure that this file resides on the OS/8 device assigned to DSK:. CAUTION Do not change the value of a global symbol by redefining it in one of the modules. You must make the change in MGLOB.MA and then reassemble all the MACREL source modules to complete the process. 1.3.4 Labels for Commonly Used Routines and Constants Labels to commonly used routines prefixed with the letters QQ are part of the Field 0 resident code and are transfer vectors. For example, 1-3 INTRODUCTION JMS I QQENTER is a subroutine call to the ENTER routine that resides in Field 0 in the MAC24 module. Table 1-1 contains a summary of these routines. Commonly used constants may use either a QQ (positive constant) or QM (minus constant) prefix. For example, QQ177 is the constant 177, while QM10 is the constant -10 (7770). Table 1-1 Summary of Commonly Used Resident (Field 0) Routines ---------------------------------------------------------------------- | Name | Function | |------------------|-------------------------------------------------| | ASEMLV | Sends the currently assembled statement to the | | | binary file. | | | | | BACKUP | Moves the line buffer pointer (LINPTR) back one | | | position. | | | | | BRAN | Performs an indexed branch into a table of | | | addresses, and branches to the selected address.| | | | | CREF | Sends the symbol name and line number | | | information to the cross reference (KREF) file. | | | | | CRLF | Sends a carriage return /line feed sequence to | | | the listing file. | | | | | DPRINT | Sends the decimal number in the accumulator | | | (AC) to the number-printing routine NPRINT. | | | | | ENTER | Enters a symbol in the symbol table when that | | | symbol is specified in the symbol table work | | | area. | | | | | EOS | Determines whether the current character in | | | BITS is a statement delimiter. | | | | | ERROR | Calls the error message processor to print an | | | error message. | | | | | EXPR | Parses a term and returns the absolute part of | | | the result in the accumulator (AC) and the | | | relative part in EXPREL. | | | | | GETCHR | Obtains a character from the line buffer and | | | determines its type code. | | | | | GETKAR | Obtains a character from the line buffer. | | | | | GETSYM | Loads a copy of a symbol table entry into the | | | symbol table work area. | ---------------------------------------------------------------------- (continued on next page) 1-4 INTRODUCTION Table 1-1 (Cont.) Summary of Commonly Used Resident (Field 0) Routines ---------------------------------------------------------------------- | Name | Function | |------------------|-------------------------------------------------| | HGHSCT | Obtains the highest address used by a program | | | section. | | | | | LETTER | Determines if the current character (CHAR) is | | | an upper-case or lower-case letter, a period | | | (.) or a dollar sign ($). | | | | | LISTER | Sends characters to the listing file. | | | | | LOOKUP | Searches the symbol table for a symbol. | | | | | OPRINT | Sends the octal number in the accumulator (AC) | | | to the number-printing routine NPRINT. | | | | | ORIG | Sets up the flag word (FLG) and sends a new | | | location counter (PC) value to the binary file. | | | | | OUT | Sends a line to the listing file. | | | | | PARSYM | Parses a symbol from the current input stream. | | | | | PASS3 | Determines if a pass is pass 3. | | | | | POP | Removes (pops) a value from the expression | | | stack and leaves it in the accumulator (AC). | | | | | PUNBIT | Sends a binary entry and its flag field to the | | | binary file; prints the current line during | | | Pass 3. | | | | | PUSH | Places (pushes) the contents of the accumulator | | | (AC) on the expression stack. | | | | | PUTBIT | Sends a binary entry without a flag field to | | | the binary file during pass 2. | | | | | PUTSYM | Inserts the data in the symbol table work area | | | into to the symbol table. | | | | | PUXBIN | Sends a binary entry and its flag field to the | | | binary file. | | | | | READLN | Reads a logical line of text from the current | | | input stream into the line buffer. | ---------------------------------------------------------------------- (continued on next page) 1-5 INTRODUCTION Table 1-1 (Cont.) Summary of Commonly Used Resident (Field 0) Routines ---------------------------------------------------------------------- | Name | Function | |------------------|-------------------------------------------------| | ROTL6 | Rotates the accumulator (AC) and the link 6 | | | bits leftward. | | | | | SCAN | Skips over a sequence of spaces and tabs. | ---------------------------------------------------------------------- 1.3.5 Local (Page) Symbols In some modules, you will find that unimportant symbols are created by appending a single letter (or digit) to the end of the module name. Such symbols are referenced only within the (listing) page where they reside; they can be converted to local symbols if necessary. 1.4 ROUTINE CALLING CONVENTIONS 1.4.1 ERROR Routine Calls Almost all calls to the ERROR routine have labels of the form: ERnn or IOnn where: nn is the error number These labels are defined as external symbols in the MACERR module. 1.4.2 Subprogram Interfaces and Calling Sequences Most of MACREL's main routines reside in Field 0, while the I/O routines reside in Field 1. This minimizes cross-field communication. When a cross-field call or jump is necessary, MACREL does not use the general PDP-8 calling convention of setting the data field to the current field. This is because MACREL routines know the fields where their callers are located. Also, for further efficiency, most Field 0 routines are written so that they can only be called from Field 0. For the rare cases where it is necessary to call these routines from Field 1, the auxiliary 1-6 INTRODUCTION subroutine CALLIT is used. For example, if a routine in Field 1 is to call a routine SUB in Field 0, the call would be as follows: CIF 0 JMS I (CALLIT SUB This allows routines to pass an argument back and forth in the accumulator (AC). 1.4.3 Overlay Module Calling Conventions When control passes to a routine that resides in an overlay, the routine that is currently running must call the overlay loader LOAD by using the calling sequence described in Section 2.17.7. In many cases, the calling routine will then pass control to a routine in the overlay by a JMP or JMS to an entry point that is a global symbol. Since the symbol will be in the cross-reference listing, you can easily locate its origin and other references. For example, if in Overlay 6 there is an entry point named CMPLXE, the call to this code from MAC24 is: JMS I (LOAD AUXOVR+6 JMP I (CMPLXE The loader loads Overlay 6 into the area that begins with location AUXOVR, and the calling routine then passes control to CMPLXE. In other cases, the calling routine will simply pass control to the first location in the overlay area rather than to a named entry point of a routine in the overlay. For example, if in Overlay 10 (FIN0), the module's code begins with the tag NEXTT, the call to this code from MAC24 is: JMS I (LOAD INHAND+10 JMP I .+1 INHAND The loader loads Overlay 10 into the overlay area that begins at INHAND, and the calling routine then branches to the beginning of the overlay area. Thus, the call to the entry point in the overlay is difficult to locate in a listing, since the call is not associated with a symbol in the cross-reference listing. 1.5 DATA FORMATS AND REPRESENTATIONS 1-7 INTRODUCTION This section describes MACREL's character codes, packing schemes, and data formats, including the symbol table. 1.5.1 Character Encoding and Packing Schemes MACREL uses three different character codes and two character packing schemes for its internal operations. (This is in addition to the .ENABLE directive's character packing options described in the MACREL/LINK User's Manual.) The character codes are: MACREL's ____________________________ special 6-bit code and the ASCII 6-bit and 7-bit codes (described in Appendix X). The packing schemes are: OS/8 and 6-bit. MACREL accepts characters for input in 7-bit ASCII (the eighth bit is ignored), that are packed using the OS/8 packing scheme shown in Figure 1-1. bit 0 3 4 11 ----------------------------------------- word 1 | character 3 | character 1 | | (bits 0 - 3) | | |-----------------|---------------------| word 2 | character 3 | character 2 | | (bits 4 - 7) | | ----------------------------------------- ML-027-80 Figure 1-1 OS/8 ASCII Character Packing For storage in the symbol table, MACREL converts these characters either into MACREL 6-bit code or into 6-bit ASCII code (depending on the operation). It packs the characters two characters per word (6-bit packing) and maps the lower-case ASCII characters into their upper-case equivalents. MACREL converts characters for output into OS/8 packed 8-bit ASCII (7-bit ASCII with parity bit always set). 1.5.2 15-Bit Pointers The 15-bit pointer is a method for encoding a 15-bit address in a 12-bit word. Figure 1-2 illustrates the format. 1-8 INTRODUCTION bit 0 2 3 11 ------------------------------ | field | address | ------------------------------ ^ ^ | | | | | --- 12-bit location divided by 8. Append | three zeros to the right of this | value to obtain the complete | address. | --- Memory field of location. ML-028-80 Figure 1-2 15-Bit Pointer Format 1.5.3 Chunks MACREL formats all memory not used by itself or by OS/8 into 8-word groups called chunks. It links these chunks together into a chain from which it allocates memory for both symbol table and macro storage. The first word of each chunk contains the 15-bit pointer to the next chunk. Location FREESPACE contains the 15-bit pointer to the first chunk in the chain. The last chunk in the chain contains a pointer of zeros. 1.5.4 Symbol Table Organization The symbol table is a collection of linked lists called buckets. There are 100 (octal) buckets in the symbol table. They are assigned numbers in the range 0 through 77. Each bucket consists of 0 or more chunks linked together with 15-bit pointers. Each chunk in a bucket contains the data for one symbol (that is, a symbol table entry). Each entry is sorted into one of the buckets. The sort is based on a match between the bucket number and the number formed by the first 6 bits of the first character of the symbol's name (or bits 0 through 5 of word 1 of the symbol table entry). 1.5.4.1 Character Codes for Symbol Table Entries - Except for symbol table entries with extended names, MACREL uses the special character codes shown in Table A-1 (Appendix A) when storing symbol names in the symbol table. 1.5.5 Symbol Table Entry Formats MACREL stores a symbol's information in the symbol table using an entry format that is based on the symbol type. The flag word (word 1-9 INTRODUCTION 5) of each entry specifies the symbol's type as shown in Table 1-2. The sections that follow describe these formats. Table 1-2 Symbol Table Flag Word ---------------------------------------------------------------------- | Bit | Meaning | | | (when set to 1) | |---------------|----------------------------------------------------| | | | | 0 | Symbol is defined | | 1 | Symbol is a memory reference instruction (MRI) | | 2 | Symbol is a permanent symbol | | 3 | Symbol was defined during pass 1 | | 4 | Symbol is a local symbol | | 5 | Symbol was defined before being referenced or | | | is an unnamed program section | | | | | 6-8 | 0 = Not a program section | | | 1 = .ASECT | | | 2 = .RSECT | | | 3 = .FSECT | | | 4 = .DSECT | | | 5 = .ZSECT | | | 6 = .XSECT | | | 7 = Reserved | | | | | 9-11 | 0 = Regular symbol | | | 1 = User macro | | | 2 = Pseudo-macro (PSEUM) | | | 3 = Pseudo-operator (PSEUD) directive | | | * 4 = .ENTRY | | | * 5 = .GLOBAL symbol | | | * 6 = .EXTERNAL | | | * 7 = .ZTERNAL | ---------------------------------------------------------------------- * Bit 9 is set to 1 when the symbol belongs to the LSD. If the symbol is undefined, all other bits are ignored. 1.5.5.1 Regular Symbol Table Entry Format - Table 1-3 shows the format of a symbol table entry for a regular symbol. If the symbol is a numeric local symbol or a literal, it is entered in the symbol table as a regular symbol with an extended name in words 1 through 3 of the entry, as shown in Tables 1-4 and 1-5. 1-10 INTRODUCTION Table 1-3 Format for Regular Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |------------|-------------------------------------------------------| | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | absolute value | | 5 | flag (see Table 1-2) | | 6 | 15-bit .SECT pointer | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. Table 1-4 Format for Regular Symbol Table Entries with Extended Names ---------------------------------------------------------------------- | Word | Use | |-------|------------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | bits | | | 0-5 = typcode = 36 or 76 to signify extended name | | | 6-11 = prechar = 6-bit ASCII (space, V or L) | | 2 | number = symbol name, literal value, or | | | literal address | | 3 | bits | | | 0 = r = 0 (octal radix) or 1 (decimal | | | radix) | | | 1-5 = unused | | | 6-11 = postchar = 6-bit ASCII ( $ or + ) | | 4 | absolute value | | 5 | flag (see Table 1-2) | | 6 | 15-bit .SECT pointer | | 7 | LSD number | ---------------------------------------------------------------------- 1-11 INTRODUCTION Table 1-5 Extended Symbol Name Field Definitions ---------------------------------------------------------------------- | Use | prechar | number | r | postchar | | | (6-bit) | | (radix) | (6-bit) | |-------------------|---------|---------|-----------|----------------| | Numeric Local | | symbol | name | 1 (decimal) $ | | Symbol | | | | | | | | | | | | Literal Reference | | literal | | | | by Value | V | value | 0 (octal) | + (if | | | | | | relocatable) | | Literal Reference | | literal | | | | by Location | L | address | 0 | + (if | | | | | | relocatable) | ---------------------------------------------------------------------- 1.5.5.2 .MACRO Symbol Table Entry Format - Table 1-6 shows the format of a symbol table entry for a .MACRO name. Table 1-6 Format for .MACRO Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | 15-bit pointer to the first chunk of the macro definition | | 5 | flag (see Table 1-2) | | 6 | 15-bit pointer to the last chunk of the macro definition | | 7 | unused | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.3 Pseudo-Operator and Pseudo-Macro Symbol Table Entry Format - Table 1-7 shows the format of a symbol table entry for either pseudo-operators or pseudo-macros. 1-12 INTRODUCTION Table 1-7 Format for Pseudo-Operators (PSEUD) and Pseudo-Macros (PSEUM) Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | 12-bit address to Field 0 routine (flag = PSEUD) or entry | | | into overlay (PSEUM) if flag = PSEUM. | | 5 | flag (see Table 1-2) | | 6 | number of overlay to load if PSEUD, or unused if PSEUM | | 7 | unused | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.4 .EXTERNAL Symbol Table Entry Format - Table 1-8 shows the format of a symbol table entry for a .EXTERNAL symbol. Table 1-8 Format for .EXTERNAL Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | unused | | 5 | flag (see Table 1-2) | | 6 | unused | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.5 .ASECT Symbol Table Entry Format - Table 1-9 shows the format of a symbol table entry for an .ASECT symbol. 1-13 INTRODUCTION Table 1-9 Format for .ASECT Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | highest current location counter (PC) value in the .ASECT | | 5 | flag (see Table 1-2) | | 6 | 15-bit pointer to auxiliary symbol table chunk (See | | | Table 1-13) | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.6 .DSECT Symbol Table Entry Format - Table 1-10 shows the format of a symbol table entry for a .DSECT symbol. Table 1-10 Format for .DSECT Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | lowest current location counter (PC) value in the .DSECT | | | (length of the program section) | | 5 | flag (See Table 1-2) | | 6 | 15-bit pointer to auxiliary symbol table chunk (see | | | Table 1-13) | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.7 .RSECT Symbol Table Entry Format - Table 1-11 shows the format of a symbol table entry for an .RSECT symbol. 1-14 INTRODUCTION Table 1-11 Format for .RSECT Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | highest relative current location counter (PC) value in | | | the .RESCT (length of the program section) | | 5 | flag (see Table 1-2) | | 6 | 15-bit pointer to auxiliary symbol table chunk (see | | | Table 1-15) | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.8 .FSECT .XSECT and .ZSECT Symbol Table Entry Format - Table 1-12 shows the format of a symbol table entry for .FSECT, .XSECT and .ZSECT symbols. Table 1-12 Format for .XSECT, .ZSECT, and .FSECT Symbol Table Entries ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | 1 | char 0 /char 1 | | 2 | char 2 /char 3 | | 3 | char 4 /char 5 | | 4 | highest location counter (PC) value in the program section| | 5 | flag (see Table 1-2) | | 6 | 15-bit pointer to auxiliary symbol table chunk (see Table | | | 1-13) | | 7 | LSD number | ---------------------------------------------------------------------- Note: char = character of symbol name in MACREL 6-bit code. 1.5.5.9 Auxiliary Symbol Table Chunk Entry Format - Table 1-13 shows the format of symbol table entry for an auxiliary chunk. This type of entry is used only in conjunction with the program section symbol table entries described in Sections 1.5.5.5 through 1.5.5.7. 1-15 INTRODUCTION Table 1-13 Symbol Table Layout for Auxiliary Chunks (.SECTs only) ---------------------------------------------------------------------- | Word | Use | |--------|-----------------------------------------------------------| | | | | 0 | 15-bit pointer to next chunk in the bucket | | | | | 1 | bits 0-2 = field number for absolute program sections | | | | | | = restriction type for relocatable program | | | sections: | | | | | | 0 = No restriction | | | 1 = Absolute field restriction specified | | | in word 2 | | | 2 = 12-bit absolute PC restriction in | | | word 2 | | | 3 = Same page and field as 15-bit pointer | | | in word 2 | | | 4 = Same field as 15-bit pointer in word 2| | | bits 4-11 = LSD number | | | | | 2 | restriction for the PC according to the contents of bits | | | 0-2 in word 1 (above). (For .ASECTs this word is low | | | current location counter (PC).) | | | | | 3 | LEVEL/OVERLAY: bits 0-2 = 0 | | | 5-7 = level number | | | 8-11 = overlay number | | | | | 4 | bits 0-10 = unused | | | 11 = CONCAT keyword | | | 0 = not specified | | | 1 = specified | | | | | 5 | Length of .FSECT without literals | | | | | 6 | unused | | | | | 7 | unused | ---------------------------------------------------------------------- 1.6 TABLES, STACKS, AND BUFFERS Table 1-14 lists the tables, stacks, and buffers contained in MACREL. They are discussed either in the detailed description of the module where they reside or in the comments of the assembly listing for that module. 1-16 INTRODUCTION Table 1-14 Summary of Tables, Stacks, and Buffers ---------------------------------------------------------------------- | Name | Module | Section | Description | |----------|----------|----------|-----------------------------------| | | | | | | AT | MACRO | 2.13 | Actual .MACRO Argument Table | | | | | | | CURPAG | MACIO | 2.9.8 | Current Page Literal Table | | | | | | | EXPSTK | MACIO | --- | Expression Parser Stack | | | | | | | FT | MACMAC | 2.10.1 | Formal (dummy) .MACRO Argument | | | | | Table | | | | | | | INPBUF | MACIO | 2.8.2 | Input Buffer | | | | | | | LIMTBL | MACINI | 2.7.4 | Memory Limit Table | | | | | | | LINBUF | MACIO | 2.17.16 | Line Buffer | | | | | | | MACTBL | MACTBL | 2.15 | Character Branch Table | | | | | | | MESLIST | MACERR | 2.5 | Error Message Pointer Table | | | | | | | MESTBL | MACERR | 2.5 | Error Message Table | | | | | | | PAGE0 | MACIO | 2.9.8 | Page 0 Literal Table | | | | | | | PTRTBL | FIN3 | 2.4.1 | Symbol Table Listing Format | | | | | Pointer Table | | | | | | | OUTBUF | MACIO | 2.8.14 | Output Buffer | | | | | | | RADBUF | EXPOVR | 2.1.1 | Contains value of current term | | | | | in the current radix | | | | | | | STRSTK | MACIO | 2.2.10 | Input Coroutine Stream Stack | | | | | | | SYMTAB | MACINI | 2.7.6 | Initial Permanent Symbol Table | | | | | | | USRSTK | MACIO | 2.29.5 | PUSH and .POP Directives' | | | | | Stack | ---------------------------------------------------------------------- 1.7 DEFAULT CONDITIONS All default operating conditions are explained in the MACREL/LINK ___________ User's Manual. The default value for an undefined symbol is absolute ______________ 0. 1-17 INTRODUCTION 1.8 ERROR AND EXCEPTION REPORTING Whenever possible, MACREL attempts to continue after an error. Therefore, it processes error calls using a JMS instruction rather than a JMP instruction when calling the error message processor ERROR. When control returns to the calling routine, it attempts to continue processing the current line. If this is not possible, it scans the remainder of the line looking for an end-of-statement delimiter so it can parse the next line. MACREL's main operating concept is that assembly should continue at all costs. For example, when the symbol table becomes full, further assembly is not possible. Rather than terminating operation, MACREL displays an error message and simulates an end-of-input-file condition. This allows it to proceed to the next pass so that the user can obtain a partial listing of the program, no matter how catastrophic the error. MACREL also displays error messages at the terminal that are of sufficient detail to let the user correct the error without resort to a listing. 1-18 CHAPTER 2 DESCRIPTIONS OF THE MODULES This chapter contains the detailed descriptions of the modules in MACREL. They are presented in alphabetical order by module name. Table 2-1 lists the modules and the sections where they are described. Within each module description, the various routines are described in order of their appearance in the source code. Table 2-1 MACREL Module Summary ---------------------------------------------------------------------- | Module | Description | Section | |--------|-------------------------------------------------|---------| | EXPOVR | Overlay to the expression processor module | 2.1 | | | (MACEXP) | | | | | | | FIN0 | Pass initialization overlay | 2.2 | | | | | | FIN2 | End-of-pass overlay for passes 1, 2, and 4 | 2.3 | | | | | | FIN3 | End-of-pass overlay for pass 3 | 2.4 | | | | | | MACERR | Error message overlay | 2.5 | | | | | | MACEXP | Expression processor (resident) | 2.6 | | | | | | MACINI | Once-only initialization code | 2.7 | | | | | | MACIO | I/O module (resident) | 2.8 | | | | | | MACLIT | Literal processor overlay | 2.9 | | | | | | MACMAC | Macro processor (overlay) | 2.10 | | | | | | MACOPN | File open routines (overlay) | 2.11 | | | | | | MACORG | Program counter (origin) processor (overlay) | 2.12 | | | | | | MACRO | Macro processor (resident) | 2.13 | | | | | | MACRTH | Global arithmetic processor (overlay) | 2.14 | | | | | | MACTBL | Character branch table (resident) | 2.15 | ---------------------------------------------------------------------- (continued on next page) 2-1 DESCRIPTIONS OF THE MODULES Table 2-1 (Cont.) MACREL Module Summary ---------------------------------------------------------------------- | Module | Description | Section | |--------|-------------------------------------------------|---------| | MAC2 | Code specific to passes 2 and 4 (resident) | 2.16 | | | | | | MAC24 | Main routines (resident) | 2.17 | | | | | | MAC30 | Code specific to passes 1 and 3 (overlay) | 2.18 | | | | | | MAC3R | Code specific to passes 1 and 3 (resident) | 2.19 | | | | | | OVRA | .PAGE, ZBLOCK, and .TEXT directives (overlay) | 2.20 | | | | | | OVRB | Conditional assembly directives (overlay) | 2.21 | | | | | | OVRC | Radix control, FILENAME, DEVICE, | 2.22 | | | .ENABLE, and .DISABL directives (overlay) | | | | | | | OVRD | Program section (.SECT) directives (overlay) | 2.23 | | | | | | OVRE | Global declarations and .INCLUDE and .CHAIN | 2.24 | | | directives (overlay) | | | | | | | OVRQ | Block letter printer (overlay) | 2.25 | | | | | | OVRR | Listing directives, pre-end-of-pass | 2.26 | | | overlay, and .START, .JSW, .VERS, NOPUNCH, and | | | | ENPUNCH directives (overlay) | | | | | | | OVRS | FIXTAB and EXPUNGE directives (overlay) | 2.27 | | | | | | OVRT | FIELD directive and "pass 5 " (post-processing) | 2.28 | | | (overlay) | | | | | | | OVRU | .TITLE, .SBTTL, RELOC, .PUSH, and .POP | 2.29 | | | directives (overlay) | | | | | | | PAS2 | Code specific to passes 2 and 4 (overlay) | 2.30 | ---------------------------------------------------------------------- 2.1 EXPOVR (Overlay 32) This module is an auxiliary overlay for the expression processor module (MACEXP). 2.1.1 BACKL 2-2 DESCRIPTIONS OF THE MODULES The routine BACKL processes the backslash (\) operator. Its calling sequence is: JMS BACKL routine where: routine is the address of the routine that receives characters BACKL performs the following operations: 1. Stores the state of the symbol parser (PARSYM in MAC24) on the expression stack (EXPRSTK) by saving the contents of locations: FILESW, PDSWT, IDKNT, DOLFLG, NAMPTR, NAME1, NAME2, NAME3, NAME4, PARSYM, UNARYM, and TERM. This is for cases where BACKL is called during a symbol parse operation. This serves no purpose when BACKL is called while processing an actual macro argument (MC in OVRX). NOTE BACKL must save TERM because it calls the term processor recursively to obtain the value of the term that follows the backslash. 2. Parses a term by calling TERM. An error results if the value of the term is not absolute. 3. Removes the values saved previously from EXPRSTK to restore the context of the current invocation of TERM. 4. Converts the value of the term to its representation in the current radix. The number is treated as unsigned. The conversion is accomplished by dividing the term successively by RADXWD and storing the result temporarily in a 6-word buffer called RADBUF. The computed digits are stored in reverse order. RADBUF is terminated by a negative number. Five divisions are always performed, because dividing to completion could cause buffer overflow if the radix is small (for example, a two). Therefore, the routine returns only the low order five digits of the result. 5. Scans the buffer in a forward direction ignoring leading zeros and sending the remaining characters to the appropriate routine, by using the call: TAD char JMS I SNDRTN where: 2-3 DESCRIPTIONS OF THE MODULES char is a MACREL 6-bit code for any numeric character (0 through 9) SNDRTN points to one of two routines specified by the caller 6. Causes SNDRTN to point to SYMSTO (MAC24) if called by the symbol parser, PARSYM (MAC24). SYMSTO packs characters into MACREL 6-bit code and places them in locations NAME1 through NAME4 of the symbol table work area (MAC24). 7. Causes SNDRTN to point to STORMS (MACRO) if called by the actual macro argument processor, MC (MACMAC). STORMS stores characters in macro argument space. The following is a list of common variables that BACKL uses: LD0FLG Leading zero flag. It is set to zero at the beginning of the second scan through RADBUF. It is set to a non-zero value if a non-zero digit is found. Thus, a zero means a leading zero. RADPTR Points to RADBUF. SNDRTN Contains the address of the routine that is to receive the digits (in radix representation) that followed the backslash. BCKNT Counter that prevents overflow of RADBUF. It is initially set to -5. 2.1.2 IDIV IDIV is a routine that performs 12-bit unsigned division by repeatedly subtracting the divisor from the dividend. The quotient is left in the AC and the remainder is deposited in REMAIN. If the divisor is 0, an error message is generated and the quotient is set to 0, with the number becoming the remainder. It tests the link to check for completion. QUO contains the partial quotient while the routine is running. The calling sequence is: TAD dividend JMS IDIV 12-bit address of divisor 2.1.3 IMUL 2-4 DESCRIPTIONS OF THE MODULES The routine IMUL performs 12-bit unsigned multiplication by successively adding the multiplicand to itself. The multiplier is the iteration count. The temporary product resides in QUO, and the final product in the AC. The calling sequence is: TAD multiplicand JMS IMUL 12-bit address of multiplier 2.1.4 SNGLQQ The routine SNGLQQ processes the single quote (') ASCII conversion operator. It is called by the expression processor (MAXEXP) when a single quotation mark occurs at the beginning of a term. SNGLQQ performs the following operations: 1. Calls (QQ)GETKAR (MAC24) to get the next two characters from the input stream. 2. Converts the two characters into 6-bit ASCII and packs them into one word. The first character resides in the most significant six bits, and the second character in the least significant six bits. 3. Stores the result as an absolute value in TRMABS. 4. Generates an error message and aborts the statement if two characters do not follow the single quote. 5. Calls (QQ)GETCHR (in MAC24) so that the first character after this term becomes the current character. NOTE SNGLQQ does not zero the relative part of the term. Instead, MACEXP performs this task when SNGLQQ returns control to it. 6. Returns to the calling routine with the two 6-bit characters packed in the AC. 2.1.5 UPAROQ The routine UPAROQ implements the temporary (local) radix control command constructs: B, D, and O, and the control character construct 2-5 DESCRIPTIONS OF THE MODULES ". It is called from the expression processor (MACEXP) when it encounters an uparrow (^) at the beginning of a term. UPAROQ performs the following operations: 1. Saves the current radix, residing in RADXWD (MAC24), by storing it in HLDRAD. 2. Reads the next character, and takes action according to which one of the following situations obtains: a. If the routine finds no character, it assumes the end of line was reached, generates an error message, and aborts the statement. b. If it finds a character other than B, D, O, or ", it generates an error, sets the result (TRMABS, TRMREL, and TRMCOD) to absolute 0, and returns to the caller. c. If the routine finds B, D, O, or ", it branches to the appropriate entry point. Character Entry Point Condition B BINOVR Binary radix D DECOVR Decimal radix O OCTOVR Octal radix " CNTCON Control Character NOTE Decimal radix, indicated by a number that ends with a period (decimal point), is detected by GETNUM (MACEXP), which sets DFLG to 0. 3. Sets RADXWD to 10, 8, or 2 respectively, and passes control to the radix override portion of the code. This code determines whether the next character is a digit. If no digit follows, it generates an error message and aborts the statement. If a digit is present, it calls GETNUM (MACEXP) to parse the number in the new (local) radix. This value becomes the absolute part of the resulting term. 4. Restores the original radix, and checks to determine if the current radix conflicts with the original radix. If there is a conflict (the number ended in a period [decimal point] and the radix override option is not D), it generates an error message. (GETNUM indicates that the number ended with a period by setting DFLG to 0.) No error is generated if an D preceded the number. (This is redundant, but not an error condition.) 2-6 DESCRIPTIONS OF THE MODULES NOTE TENFLG always contains a 0, except when a D is detected-in which case it is set to 4000. This indicates whether or not decimal radix is in effect so that radix conflicts can be detected. UPAROQ does not zero the relative part of the term. Instead, MACEXP performs this task when UPAROQ returns control to it. The CNTCON routine does not reside in this module because it shares code with the DBLQ routine in MACEXP. 2.2 FIN0 (Overlay 10) FIN0 is the pass initialization overlay. At the beginning of each assembly pass, control returns to this module through its entry point NEXTT. NOTE The call to this module may be hard to locate in the listing and will not be found in the cross-reference listing. This is because the call does not refer to the entry point NEXTT by name. The call occurs at symbol INHAND (location NEX+3) in MAC24. 2.2.1 NEXTT The routine NEXTT is the entry point to this module. It is called at the beginning of each pass to perform the following tasks: 1. Calls IONIT2 (MACIO in Field 1) to perform preliminary pass initialization. 2. Zeros location 01400 to indicate that the Pass-Specific Overlay Area is unoccupied. 3. Loads the pass-specific overlay, using either MAC30 for passes 1 and 3, or PAS2 for Passes 2 and 4. 4. Increments the pass number (PASS in MAC24), and branches to OPEN1, OPEN2, OPEN3, OPEN4, or FIN5 depending on which pass 2-7 DESCRIPTIONS OF THE MODULES is beginning. Each of these routines branches to REIT when completion. (If a routine decides to abort a pass, it branches to NEXTT to proceed with the next pass. The overlays are loaded redundantly when this happens.) 2.2.2 OPEN1 The routine OPENl opens the table of contents (TOC) file at the beginning of Pass 1 by calling OPENTC (MACOPEN, Overlay 33). On completion, control returns to REIT. 2.2.3 OPEN2 OPEN2 is a routine that calls OPEN (MACOPEN, Overlay 33) to open the binary output file at the beginning of pass 2. The default file name extension is .RB. OPEN2 then stores the starting block number of the file that resides in OUTLOC (MACIO) by depositing it in RBFILE (MACIO) in case the user requested chaining to LINK. This is because the Command Decoder's output file table contains file names but no starting addresses. Upon completion, control returns to REIT. If the user did not specify a binary file, OPEN2 skip pass 2 by branching back to NEXTT. 2.2.4 OPEN3 OPEN3 is a routine that is called at the beginning of pass 3 to open the listing file, print the block letter heading, and print the table-of-contents. It performs the following operations: 1. Loads zeros into location LOCOFF (MACIO). LOCOFF is used by the OPEN (MACOPN) routine. Whenever OPEN is called, it adds the contents of LOCOFF to the starting block number of the file to establish the block where output is to begin. During pass 2 LOCOFF contains a value that is equal to the number of blocks in the Loader Symbol Dictionary (LSD) area of the binary file. This offset allows OPEN to skip over the file's LSD area. This result is not desirable during pass 3. 2. Calls OPEN (MACOPEN) to open the listing file. The default file name extension is .LS. It sends characters to the output file in 8-bit character mode. 3. (if no listing file was specified) Skips Pass 3 by branching back to NEXTT. 4. (if a listing file was specified) Checks to see if the user specified the /B option. If /B was not specified, control branches to CPYTOC to print the table-of-contents (TOC) in 2-8 DESCRIPTIONS OF THE MODULES the listing file. If the /B option was specified, OPEN3 proceeds to print a block letter heading at the top of the listing before branching to CPYTOC. Each block letter consists of a number of basic letter blocks. The basic letter block is the fundamental structural element for creating block letters. It consists of an array of identical letters. The width of the array varies between 1 and 3 letters, depending on the width of the page. The horizontal image area for a block letter is 6 basic letter blocks wide (5 plus a space). By changing the width of the basic letter block, the overall width of the block letter heading can be altered. Since a file name can contain up to 6 letters, a minimum of 36 character positions is required on the output device to contain a block letter heading. 5. Adjusts the block letter width relative to the width of the listing device page by dividing the column width of the listing device (WIDTH in MAC24) by 44(octal). The resulting value determines the width of a basic letter block as shown in Table 2-2. If the result of the division is 0, the output device's width is too small to print a block letter heading and control branches directly to CPYTOC to print the table-of-contents. If the result is greater than 3, OPEN3 ignores it and maintains a basic letter block width of 3 for devices wider than 108 columns. Table 2-2 Basic Letter Block Widths vs Listing Device Column Width ---------------------------------------------------------------------- | Listing Device Width | Basic Block Width | |------------------------------------|-------------------------------| | 1-35 | 0 letters | | 36-71 | 1 letter | | 72-107 | 2 letters | | greater than 107 | 3 letters | ---------------------------------------------------------------------- 6. Loads Overlay 21, the block letter printer BLKLET (OVRQ) and Overlay 24, MACREL's fish caricature printer BINFO (OVRQ). 7. Calls BLKLET to print the block letters. (It passes the width of the basic letter block as a negative value in the AC.) 8. Calls BINFO to print the fish caricature, MACREL's version number, and the number of errors (if any). 9. Calls CPYTOC to send the table-of-contents (TOC) to the listing file. Thereafter, control returns to REIT. 2-9 DESCRIPTIONS OF THE MODULES 2.2.5 OPEN4 OPEN4 is a routine that is called at the beginning of pass 4 to open the cross-reference (KREF) file. It performs the following operations: 1. Loads zeros into location LOCOFF (MACIO). LOCOFF is used by the OPEN (MACOPN) routine. Whenever OPEN is called, it adds the contents of LOCOFF to the starting block number of the file to establish the block where output is to begin. During pass 2 LOCOFF contains a value that is equal to the number of blocks in the Loader Symbol Dictionary (LSD) area of the binary file. This offset allows OPEN to skip over the file's LSD area. This result is not desirable during Pass 4. 2. It calls OPEN (MACOPN) to open the KREF output file. (OPEN uses the default extension .KF if one does not already exist in the Command Decoder's output file table.) The output mode is 12-bit binary. 3. Takes action according to which one of the following circumstances obtains: a. If the user specified the /C option and did not enter a device or file name as the third (KREF) output file specification, OPEN4 inserts the default specification SYS:KF.TM into the appropriate position in the OS/8 Command Decoder's output file table. b. If the user did not specify the /C option or a KREF file specification, OPEN4 skips pass 4 by branching back to NEXTT. c. If a KREF file was specified, OPEN4 stores the starting block number of the KREF output file (OUTLOC in MACIO) in location KFFILE (MACIO). This information in necessary if the user requested chaining to KREF, since the starting block number is not stored in the file's Command Decoder's file table. 4. Upon completion, control returns to REIT. 2.2.6 FIN5 The routine FIN5 determines whether to return control to the OS/8 Monitor or to chain to KREF or LINK. It is called after all requested passes are processed. If the user selected the /L, /G, or /C options, FIN5 passes control to location LNKCHN in Overlay 24 (OVRT) to scan the options, modify the command decoder area, and set up the chain to KREF or LINK as specified. If none of these options was specified, MACREL operation is complete and FIN5 returns control to the OS/8 Monitor by branching to absolute location 7605. 2-10 DESCRIPTIONS OF THE MODULES 2.2.7 AINIT The routine AINIT sets initial values before starting each pass. It performs the following operations: 1. CONCNT to 0, to indicate that there are no conditional directives in effect. 2. PAGENO (listing page number) to 0. 3. LINENO and LINEN2 (listing line number) to 0. 4. RELOK to 0, to inhibit RELOC directive. 5. ERKNT (error counter) to 0. 6. Increments PPASS (physical pass number) by 1 each time a pass is actually begun. Notice that PPASS is different from PASS, which contains the logical pass number. The physical pass number is used by the error processor (MACERR module) to determine whether or not an error message should be printed at the terminal. (Many error messages only appear during the first physical pass during which they occur). 7. Deposits spaces in the subtitle line locations (SUBTL through SUBTL+(SUBLEN-1)) in MAC24. 8. Sets QUAL to 0, to indicate that a local symbol block (LSB) is not being processed. 9. Sets CURFLD (current field) to 0. 10. Sets LITPAG (Page of the current page literals) to page 200. 11. Sets PUNFLG to 0, to enable binary output (punching). 12. Sets LITSCT to 0. 13. Sets CLTLOC and ZLTLOC to 0 to indicate that no current page or Page 0 literals have been detected. 14. Sets EXTPC to 0, to indicate that MACREL's current location counter (PC) is not external (in case the last pass ended by changing the current location counter to the value of an external symbol). 15. Calls UNNAM (MAC2) to set up the default program section to be an unnamed absolute program section. 16. Sets the initial values of ENABWD and LISTWD as the contents of INIENAB and INILST (the initial ENABLE and LIST conditions) respectively. You can patch these locations to different values if you want to establish your own initial conditions. 2-11 DESCRIPTIONS OF THE MODULES 17. Sets the default radix to be octal by depositing 10 (octal) in RADXW. 18. Deposits 0 in OLDSCT, to indicate that there was no previous .SECT directive in effect. (This prevents a user from starting with a .SECT directive.) 19. Deposits 0 in ZSECTN to clear the name of any page 0 literal program section. 20. Deposits 0 in BNFLAG and PCFLAG so that no binary or current location counter (PC) value will be printed in the listing unless requested. 21. Sets MACLEV (macro nesting level) to 0. 22. Deposits 0 in LNKGEN, to indicate that a link has not been generated yet. 23. Calls IOINIT (MACIO in Field 1) to perform further initialization. (This code resides in MACIO [Section 2.8] to reduce the number of globals in this module.) 2.2.8 CPYTOC The routine CPYTOC copies the table-of-contents (TOC) from the scratch blocks on the system device (SYS:) to the listing file. It performs the following operations: 1. Checks to see if a table-of-contents was created on the previous pass. By examining the contents of the .SBTTL directive counter SBTKNT (MAC24). If SBTKNT contains 0, there are no .SBTTLs and CPYTOC exits. Otherwise, it checks to see if the output buffer is empty. (The output buffer might not be empty if the block letter heading was just printed and the last buffer has not been written yet.) If the output buffer is not empty, CPYTOC sends it to the listing file by padding the buffer with NULs (repetitive calls to (QQ)LISTER(MAC3R) with AC=0000). 2. Begins the copy operation, starting at a block boundary to avoid a longer listing buffer. NOTE The extra zeros will not affect the block length of the file. Any program that reads this file should discard these NULs. 2-12 DESCRIPTIONS OF THE MODULES 3. Copies the blocks directly from the scratch area on SYS: to the listing file. It reads them by making calls to the system handler. It writes them out by calling PUTBUF. TOCSIZ specifies the number of blocks to transfer. NOTE If the system handler detects a read error, it is fatal. This causes MACREL to halt because there may be no way to recover. 2.2.9 REIT The routine REIT performs file initialization once an output file is opened. It calls AINIT to initialize variables, then passes control to LOOP (MAC24). 2.2.10 IOINIT The routine IOINIT, though logically part of FIN0, resides in Field 1 in module MACIO. It performs the following pass initialization steps: 1. Marks the stream input routines: ORET, ZRET, MRET, and RRET as being unused. 2. Initializes AT1 (MAC24), the main macro argument table pointer. 3. Sets OV1 to 0 to indicate that the number of nested macros does not exceed the nesting limit. 4. Empties the stream stack by zeroing location STRSTK+1 (MACIO). 5. Calls SWITCH to establish ZGET as the initial stream input coroutine. (This coroutine does nothing but return CTRL/Z codes.) 6. Calls SWITCH to establish OGET as the next stream input coroutine. This is a protective device to force a return to ZGET in the event an internal error in the coroutine switching mechanism causes stream stack underflow past the initial OGET. 7. Sets DVNO to 0 to signify to the OGET coroutine that no input file is open yet. Thus, when the first character is sent to OGET, READOS will be called, which in turn will branch to EOS (MAC24) to read the first OS/8 input file. 2-13 DESCRIPTIONS OF THE MODULES 2.2.11 IONIT2 The routine IONIT2, although logically part of FIN0, resides in the MACIO module in Field 1. It performs the following pass initialization steps: 1. Zeros FILENO to indicate that the first input file has not been read. 2. Sets INI.EN to 0 to indicate that no input file blocks have been read. 3. Deposits the pointer to the first input file specification of the CD area in INPTR. 2.3 FIN2 (Overlays 12 and 14) The FIN2 module consists of two overlays: 12 and 14. They perform general-purpose, end-of-pass tasks such as: writing the Loader Symbol Dictionary (LSD) to the output file, emptying buffers, and closing files. They are called at the end of passes 1, 2, and 4. Overlay 12, the main overlay, resides in the Extremities Overlay Area; Overlay 14, the auxiliary overlay resides in the Directives Overlay Area during pass 2. 2.3.1 Unlabeled Routine This is an unlabeled routine that consists of the code that begins with the (overlay) number 12 and ends at the label LSDOUT. There is no label because this routine is entered by a direct branch to the start of the overlay area. It performs the following tasks: 1. Zeros LSDNUM. This step provides coding consistency. It can be removed without effect, since the contents of LSDNUM are initially 0 when the overlay is loaded. 2. (if this is the end of pass 2) a. Sends an end-of-text code (a word containing NUL with a 3 as the flag field value) to the binary file. b. Dumps the last buffer of binary code by calling ZPAD. c. Closes the binary file by calling CLOSO (MACIO). d. Calls FINIO (MACIO). e. Loads the extension overlay (Overlay 14) and calls subroutine LSDINI. 2-14 DESCRIPTIONS OF THE MODULES 3. Scans the symbol table according to the following conditions: a. If the symbol belongs to the Loader Symbol Dictionary (LSD), calls LSDOUT. A symbol belongs in the LSD if it is a program section name (flag bits 6-8 are nonzero), or if it is EXTERNAL, ZTERNAL, ENTRY, or GLOBAL (flag bit 9=1). b. If the symbol is a program section name, the routine deposits zeros in SYMVAL (high current location counter). c. If the symbol is an .ASECT name, the routine sets word 2 of the auxiliary chunk (low current location counter) to -1 to indicate that the lowest location counter value is not yet determined. 4. (if this is the end of pass 1) Estimates the number of blocks required to store the LSD entries in the binary output file and stores this value in LOCOFF (MACIO). (The assumption is that all LSD entries are defined during pass 1.) It does this by performing the following sequence: a. Computes the maximum size that the LSD could be by multiplying the number of LSD entries (LSDNUM) by 6 (since each LSD entry is not more than 6 words long). b. Adds this value to the maximum length of the LSD preface (currently assumed to be 40 [octal] words long). c. Rounds this result up to the next multiple of 400 (a block boundary) to produce the maximum expected length of the LSD portion of the binary file. d. Stores this value in LOCOFF (MACIO). The OPEN (MACOPN) routine uses this value as an offset to determine the first block of the binary file where it can begin storing the LSD text. The routine stores the text portion of the binary file before the LSD, because the exact lengths of floating program sections that contain current page literals are unknown. NOTE Because the number of current page literals may decrease due to literal sharing, the length of .FSECTs cannot be determined until the end of pass 2. 5. (if this is the end of pass 1 and there is no table-of-contents [SBTKNT=0]) Branches to NEX (MAC24) to proceed to the next pass. 2-15 DESCRIPTIONS OF THE MODULES 6. Sends the last buffer to the output file and closes the file. Two different procedures are used depending upon whether the output mode is binary or ASCII. a. If the output mode is ASCII, (that is, an odd-numbered pass), the routine: i. Transmits the last buffer to the output file by sending a bufferful of CTRL/Zs to the listing file ( (QQ)LISTER in MAC3R). This guarantees that the last buffer will be written out and that the output file is terminated with a CTRL/Z. ii. Stores the length (in blocks) of the output file contained OUTSIZ (MACIO) in TOCSIZ (MAC24). This information is used when the table of contents is copied to the listing file at the start of pass 3. iii. Passes control to NEX (MAC24) to proceed with the next pass. b. If the output mode is binary (that is, an even-numbered pass), and if this is also the end of pass 2, the routine: Calls ZPAD to force the last buffer to be transmitted to the output file and to pad the unused portion of the Loader Symbol Dictionary (LSD) area in the file with NULs (It could be that the length originally estimated for the LSD area was too short. For example, if the file contained a large number of external symbols.) The routine writes blocks of NULs up to, but not including the first text block. The block number for the first text block is stored in TXTBLK (MACIO). If this is the end of Pass 4, the routine calls Z PAD once to dump the buffer. Then it calls CLOSO (MACIO) to close the KREF file. 7. Control transfers to NEX (MAC24) to begin the next pass (if there are any more). 2.3.2 LSDOUT (Overlay 12) The subroutine LSDOUT sends the Loader Symbol Dictionary (LSD) entry information to the LSD portion of the binary output file. It performs the following tasks: 1. Increments the LSD number (LSDNUM) by 1, to maintain a count of the number of LSD entries. LSDNUM also represents the number of the current LSD entry. The LSD entries are 2-16 DESCRIPTIONS OF THE MODULES numbered and are sent to the binary file in alphabetical order. This is convenient for maintenance purposes, but not necessary for proper LINK operation. 2. Inserts the LSD number for the current symbol (LSDNUM) into bits -11 of its QUAL word in the symbol table. Any previous contents of this field are lost. LSDOUT stores the LSD entry number, because the LSD entry is referred to by its number during output to the .RB file. 3. Exits to FIN2 if this is not pass 2. 4. Sends the 3 words containing the LSD entry's name by using PUTBIT (PAS2). 5. Computes the type code used by LINK to identify this LSD entry and stores it temporarily in LTYPE. Table 2-3 specifies these codes. Table 2-3 LSD Entry Type Codes -------------------------- | Code | Entry Type | |-----------|------------| | 1 | .SECREF | | 2 | .RSECT | | 3 | .RSECT | | 4 | .FSECT | | 5 | .DSECT | | 10 | .XSECT | | 11 | .ZSECT | | 14 | .GLOBAL | | 15 | .ZTERNAL | | 16 | .EXTERNAL | -------------------------- 6. Sends the type code to the LSD. The code resides in the low order 4 bits of the 12-bit word (bits 8-11), while the high-order 8 bits (bits 0-7) contain the LSD entry number of the entry that this entry is relative to. This address is derived from the 15-bit pointer in the SYMSCT (MAC24) entry for this LSD entry as follows: a. If this symbol is not a program section name and SYMSCT is 0, it must be an EXTERNAL or ZTERNAL symbol. The high order 8 bits of the word are set to 0. b. If SYMSCT is a program section name, the high-order 8 bits must contain the restriction type as specified by the high order 3 bits of the QUAL word (MAC24) for this 2-17 DESCRIPTIONS OF THE MODULES LSD entry. (Refer to the MACREL/LINK User's Manual for _________________________ the definition of the LSD restriction types.) 7. Sends the program section length to the LSD (unless the symbol is XTERNAL or ZTERNAL). Except for .ASECTs, the length is stored in the SYMVAL (MAC24) word for this LSD entry. If the LSD entry is an .ASECT, the length of the .ASECT is obtained by subtracting its low PC (location counter) value from its high PC value (SYMVAL). 8. It returns control to the caller if the symbol is not a program section name. Otherwise, it continues with step 9. 9. Sends the restriction word to the LSD. The word is the LSD number of the symbol table entry specified by the 15-bit pointer in word 2 of the auxiliary .SECT chunk (see Section 1.5.5.8) for the current LSD entry. If the entry is an .ASECT, there is no restriction code and the field number of the .ASECT is sent instead. 10. Sends the LEVEL/OVERLAY word (word 3 of the auxiliary .SECT chunk) to the LSD if the program section is an overlay. 2.3.3 ZPAD (Overlay 12) This subroutine inserts 400 (octal) NULs into the page buffer to force the current contents of the page buffer to be sent to the output file. 2.3.4 LSDINI (Overlay 14) The routine LSDINI sends the Loader Symbol Dictionary (LSD) Preface items to the binary output file by performing successive calls to (QQ)PUTBIT (MAC2) via PUTHDR. (See the MACREL/LINK User's Manual and _________________________ the program listing for more information on the LSD Preface.) The preface items reside in packets within LSDINI. Their form corresponds approximately to that used for the external (binary file) preface. Each packet begins with a negative number that specifies the number of words in the packet (including the count word). The next word in the packet is the item title code for this preface entry. (See MACREL/LINK User's Manual for the code definitions.) The ___________________________ remaining words in the packet contain the preface item data itself. LSDINI sends the first five packets as a group to the output file. It sends the remaining packets individually to the output file. The number of packets being sent is passed to PUTHDR as a negative value in the AC. For selected packet entries, LDSINI performs the following computations before sending them to the output file: 2-18 DESCRIPTIONS OF THE MODULES 1. Obtains the current date from OS/8 and inserts it into the current date packet. This packet is 2 words long so that it can contain dates after 1977. LSDINI obtains the additional date bits location 07777 and inserts the entire word into the packet. 2. Inserts the page number into the page number packet. The page number is the contents of PAGENO (MAC24) plus 2. The increment of 2 is necessary to account for the fact that the symbol table is considered to be a page. LINK does not use this information. 3. Obtains the Job Status Word (JSW) from location JSW (MAC24). It sends the job status word packet to the binary file if the .JSW directive is encountered; JSWKEY (MAC24 is zero.) 4. Sends the starting address packet to the output file if the .START directive was encountered; STARTK (MAC24) is zero. LSDINI computes one of the following item title codes from the contents of STARTR (MAC24): Code Meaning 1 Starting address is absolute 2 Address is relocatable If the contents of STARTR are less than 10 (octal), the starting address is absolute and this number is the field number. Otherwise, the starting address is relocatable and this number is a 15-bit pointer to the relative part. START (MAC24) contains the entire absolute address (code = 1) or the absolute part of the relative address (code = 2). 5. Obtains the user-specified version number (.VERSION directive) from UVER (MAC24). LINK does not use this information. 6. Obtains the current patch level of MACREL from PTCHLOC (HEADING in MAC24). 2.3.5 FINIO (Macio) The FINIO subroutine reinitializes the binary output file's control parameters. This allows FIN2 to send the Loader Symbol Dictionary (LSD) preface and data to the area reserved for it at the beginning of the binary output file. Remember that the binary data (text) is sent to the output file first and the file is closed. FIN2 then calls routines that send the LSD directly to the file via calls to the 2-19 DESCRIPTIONS OF THE MODULES device handler. The file is not explicitly opened via a call to the USR. Although logically part of FIN2, FINIO resides in MACIO due to space limitations. FINIO is called by FIN2 after it has closed the binary output file. It performs the following tasks: 1. Stores OUTLOC, which is the starting block of the binary file, in OUTREC so that the LSD will be stored at the beginning of the binary file. 2. Stores zeros in OUTSIZ and HOLSIZ to indicate to the output routine (PUTBUF in MACIO) that there is enough room in the output file. 3. Initializes the output buffer pointer (OPTR1) to the first location in the output buffer (contents of OUTBUF+1 ). 4. Zeros FLGFLG to indicate that no flag field is to be sent with the LSD. 5. Zeros HDRWRD to specify in the block header that this is an LSD block. (0 means LSD, 4000 means text.) 2.4 FIN3 (Overlays 11 and 13) FIN3 formats the symbol table printout, sends it to the listing file, and closes the listing file. It is called at the end of pass 3. The module consists of two overlays: Overlay 13, the main overlay, loads into the Extremities Overlay Area; Overlay 11, the auxiliary overlay, loads into the Directives Overlay Area. FIN3 is segmented into subroutines primarily because of boundary restrictions on the PDP-8's memory pages (most of the routines are called only once). Consequently, the following description treats FIN3 as if it were a single logical entity. 2.4.1 Unlabeled Routine (Overlay 11) This is an unlabeled routine that consists of the node that begins with the overlay number 11 and ends at the label STPRNT. It performs the following tasks: 1. Loads the extension overlay (Overlay 11) into memory. 2. Sets LISTWD to 0 to prevent the creation of a listing by overriding any program-initiated request. 2-20 DESCRIPTIONS OF THE MODULES 3. Scans all the buckets, and links and creates a single large bucket (Bucket A) that contains all the symbol table entries in alphabetical order. This improves the efficiency of printing the symbol table although pass 4 processing becomes somewhat more inefficient. Since the bucket pointers that follow Bucket A are still present, pass 4 efficiency decreases only when the symbols that are added during pass 4 are processed. Notice that the permanent symbols remain in the chain, because the chain must be intact for pass 4. 4. Calculates the number of columns of symbol table entries to print by adding 8 to WIDTH (number of columns on the output device) and then dividing the result by 32 (decimal). The remainder is the number of columns. Since not more than 7 columns are allowed, the routine takes the result modulo 8. If the number is 0, it uses 1 column. Otherwise, it uses up to 7 columns. It stores the number of columns to print in COLNUM. 5. Formats each page so that the symbol table entries can be printed in alphabetical order and in columns rather than in rows. To do this, it creates an auxiliary array, called PTRTBL which, though dimensioned at 8, can contain from 1 to 7 pointers; one pointer for each column of the page. As an example, the third pointer in PTRTBL is the pointer to the chunk that contains the first symbol name to be printed at the top of the third column in the listing. A pointer value of 0 means that there is no item to print in this position. It sets up these pointers as follows: a. Scans the symbol table beginning with the first chunk to be printed on the current page. b. Maintains, during the scan, a count of the chunks to determine which chunk will begin the next column. c. Stores the pointer to the 55th chunk in PTRTBL when the chunk count reaches 54 (decimal). d. Ignores, during the count, permanent, FIXTAB, or local symbols (bits 2 or 4 set to 1 in their flag words). These symbols are not to appear in the symbol table listing. (Notice that the last chunk computed is the first chunk to be printed on the next page. Its pointer is stored in SYMNUM, not in PTRTBL.) e. Waits until a full page of pointers is set up in PTRTBL and stores a 0 as the final entry (which is why PTRTBL 2-21 DESCRIPTIONS OF THE MODULES has room for 8 entries). It then calls STPRNT to print this page of the symbol table. 6. Passes control to location DLUP to format and print the next page after the page is printed, and if there are still symbols left to print. 7. Inserts a CTRL/Z into the buffer when there are no more pages to print, it fills the remaining buffer space (less 1) with NULs to send the contents of the buffer to the listing device. 8. Calls CLOSO (MACIO) to close the listing file. 9. Branches to NEX (MAC24) to proceed to the next pass. 2.4.2 STPRNT (Overlay 11) The routine STPRNT prints a physical page of symbol table text. Pointers in PTRTBL point to the symbol table chunks containing the symbols that begin the top of each listing column. STPRNT performs the following tasks: 1. Calls NEWPAG (MAC3R) to begin a new page, and increments the sub-page number (SUBPAG) by 1. 2. Loops 54 (decimal) times, once for each row (line) of text on the page. During each iteration, it scans PTRTBL to get the chunk pointers for each symbol in the row. For each column, it performs the following tasks: a. Branches to ENDROW if the chunk pointer is 0 (end-of-the row). b. (if the chunk pointer is not 0) Copies the information for that symbol into the symbol table work area (NAME1 through QUAL in MAC24) and calls PRN to print the name the symbol. c. Prints a TAB, then calls XPRINT to print the additional information associated with this symbol name. d. Zeros the symbol's current location counter (PC) if the entry is a program section name. If it is an .ASECT, the routine sets the symbol's low PC to -1. e. Replaces the current chunk pointer in PTRTBL, with the pointer to the next chunk for this column. It skips both local and permanent symbols. It inserts 0 if there are no more chunks for this column. f. Advances to the next column. 2-22 DESCRIPTIONS OF THE MODULES 3. Exits if it encounters a 0 as the first entry in PTRTBL, because there are no more symbol table entries to print. Otherwise, it prints a RETURN/IF sequence and decrements the loop counter (KNT). 4. Processes the next row (step 2) if the value of KNT is not zero. If KNT is zero, this is the last row on this page and STPRNT returns control to the caller. 2.4.3 PRNT2 (Overlay 11) The routine PRNT2 sends the two 6-bit characters in the AC to the listing file. It calls PRNT6 twice; once to print the character in the left byte and once to print the character in the right byte. 2.4.4 PRN (Overlay 13) The routine PRN prints a symbol name. If the first word of the name (NAME1 of the symbol table work area) is negative, it removes the sign bit from NAME1 and prints a dollar sign($) followed by the name. If NAME1 is positive, it prints the name by itself. PRN performs successive calls to PRNT2 to do the actual printing. 2.4.5 XPRINT (Overlay 13) The routine XPRINT prints a symbol's binary value and associated qualifying information. It performs according to the following conditions: 1. If the symbol is in the Loader Symbol Dictionary (LSD) so that bit 9 of its flag word = l, control passes to one of the four routines listed below. This depends on the LSD entry type specified in bits 10-ll of the flag word. Entry types, destinations and tasks are shown in Table 2-4. 2. If the symbol is a macro name (.MACRO), XPRINT: a. Changes the value word (which has been moved to PRTVAL) to 0. It does not change SYMVAL, because its contents may be written back into the symbol table later. b. Prints an M before the symbol's value (0000). 3. If the symbol is not one of the types covered above, it prints a space before the symbol's value. 2-23 DESCRIPTIONS OF THE MODULES Table 2-4 Loader Symbol Dictionary Entry Types, Destinations, and Tasks ---------------------------------------------------------------------- | Entry Type | Destination and Task | |---------------|----------------------------------------------------| | | | | 0 | XENTRY and prints an E (.ENTRY) before printing | | | the symbol's value. | | | | | 1 | XGLOB and prints a G (.GLOBAL) before printing | | | the symbol's value. | | | | | 2 | XEXT and prints an X (.EXTERNAL) or a Y (.SECREF) | | | before printing four asterisks (****) in place of | | | the symbol's value. | | | | | 3 | XZTE and prints a Z (.ZTERNAL) before printing a | | | zero followed by three asterisks (0***) in place | | | of the symbol's value. | ---------------------------------------------------------------------- 4. If the symbol is undefined (flag word is negative), it calls UNDF, which: a. Prints four asterisks followed by a left arrow (****<-- ) and a TAB in place of a value. b. Exits from the routine. 5. If the symbol is defined, it calls OPRINT (MAC30) to print the value of the symbol as a 4-digit octal number with leading zeros. 6. If the symbol is a .SECT name, it prints two spaces and the type of sect (.ASECT, .RSECT, .FSECT, .DSECT, .ZSECT, or .XSECT) to the right of the value. It obtains the program section type from bits 6-8 of the flag word, then exits from the routine. 7. If the symbol is not a .SECT name (flag bits 6-8 are 0), it branches to NOTSCT, which performs a branch depending on the symbol's type (bits 9-11 of the flag word). a. If the symbol is a .MACRO name, pseudo-macro, MACREL directive, .EXTERNAL, .ZTERNAL, or absolute (implicit or explicit .ASECT), it prints a TAB and exits. b. If the symbol is a .ENTRY name, a .GLOBAL name, or resides in a relocatable program section, its value must be displayed in relation to the beginning of the program section. To show this, XPRINT prints a plus sign (+), a space, and the name of the program section where the 2-24 DESCRIPTIONS OF THE MODULES symbol resides. Following this, it prints a TAB, then exits. 2.4.6 PRNT6 (Overlay 13) The routine PRNT6 sends the 6-bit ASCII character in the right (low order) byte of the AC to the listing file. It automatically converts MACREL's internal codes for dollar sign (33) and period (44) to their 6-bit equivalents (44 and 56 respectively). It calls (QQ)LISTER to print the appropriate ASCII character. 2.5 MACERR (Special Overlay) The MACERR module is the error message overlay. It contains both the routines that print the error messages and the error message text. This is a special overlay in the sense that it is not loaded via a call to LOAD like the other MACREL overlays. Instead, when a routine detects an error, it performs a subroutine jump to ERROR (MAC24), which loads MACERR and passes control to ERRTN. CAUTION MACERR must always be exactly 23 blocks long to allow ERROR to perform overlay address computation. ERRTN uses the address of the error call to find and print the actual error message text as follows: 1. Obtains the address of the call (JMS), and searches for an entry in a table (ERLST) that contains the addresses of all error calls. 2. Finds the matching address in the table and then calculates the ordinal position of that entry from the beginning of the table. 3. Uses this value to index into the message pointer table (MESLST) and obtain a pointer that is the 12-bit virtual address of the desired error message in MACREL.SV. The pointer is the message's address that is assigned at assembly time. (Error message pointers have virtual addresses in the range 3400-7377.) 4. Calculates the block number in MACREL.SV where the message resides and reads this block into a buffer that begins at memory location 10400. (Table 2-5 shows the relationship 2-25 DESCRIPTIONS OF THE MODULES between the block numbers in MACREL.SV and MACERR's assembly time addresses.) 5. Calculates exactly where an error message resides in the buffer (block). 6. Prints the message on either the terminal, the BATCH log device, or in the listing, using the output routines described in Table 2-6. 7. Returns control to ERROR, when MACERR finishes to restore to memory the five blocks that it swapped out. (It is important that these blocks never contain code that calls ERROR.) Table 2-5 Layout of MACERR Within MACREL.SV -------------------------------------------- | Relative | | Assembly-time | | Block | Contents | Addresses (MACERR) | |----------|----------|--------------------| | 101-104 | code | 51000-52777 | | 105 | unused | (53000) | | 106 | : | 53400 ERRBLK+6 | | 107 | : | 54000 | | 110 | message | 54400 | | 111 | text | 55000 | | 115 | : | 55400 | | 113 | : | 56000 | | 114 | : | 56400 | | 115 | : | 57000 ERRBLK+15 | | 116-122 | | 60000-62377 * | -------------------------------------------- * These are the five blocks that are swapped to and from the swap area located at addresses 10400-12777 during run time. 2.5.1 Error Typeout Routines MACERR contains the output routines listed in Table 2-6. Table 2-6 MACERR Output Routine Summary ---------------------------------------------------------------------- | Name | Task | |--------|-----------------------------------------------------------| | | | | TYPERR | Types error message on error log (TTY or BATCH log | | | file). | ---------------------------------------------------------------------- (continued on next page) 2-26 DESCRIPTIONS OF THE MODULES Table 2-6 (Cont.) MACERR Output Routine Summary ---------------------------------------------------------------------- | Name | Task | |--------|-----------------------------------------------------------| | PRCHR | Prints single characters on a device specified by | | | OUTDEY. (The AC will be non-zero when PCHR returns to | | | the caller.) | | | | | PRNAM | Prints a 6-character name on a device specified by | | | OUTDEY. (The AC will be non-zero when PRNSM returns to | | | the caller.) | | | | | PR6A | Prints a 6-bit ASCII character on a device specified by | | | OUTDEY, ignoring NULs. | | | | | SETNAM | Sets up name to be printed by PRNAM; followed by CDF, | | | then PTR. | | | | | PR | Prints a character on the error log device if CTRL/O is | | | not in effect. Also checks for CTRL/O, CTRL/C, CTRL/S, | | | and the E, F, and L options. | | | | | TPUT | Types a character unconditionally on the error log device.| | | | | TP | Types a character unconditionally on the terminal. | | | | | PR2 | Prints two 6-bit ASCII characters using PR. | | | | | PRO | Prints one 6-bit ASCII character using PR. | | | | | PR12 | Prints one 12-bit number as 4 octal digits using PR. | | | | | STNAM | Sets up a symbol table name for printing, and obtains the | | | value of the symbol in VAL. | | | | | CHKKBD | Checks to see if CTRL/C, CTRL/S, CTRL/O, E, F, or L was | | | typed on the keyboard. | | | | | OUTDEY | Contains either PR or LPUT, as set up by TYPERR and | | | PRNERR. | | | | | CRLFF | Prints carriage return/linefeed on OUTDEY. | | | | | TYPE | Prints a 6-bit ASCII character (carriage return/line feed | | | if NUL character) on a device specified by OUTDEY. | ---------------------------------------------------------------------- 2.5.2 Creating New Error Messages The following rules describe how to create new error messages. 2-27 DESCRIPTIONS OF THE MODULES 1. The calling routine must: a. Make sure that the data field is set to the data field here the routine resides. b. Perform a call to ERROR as follows: ERnnn, JMS QQERROR where: ERnnn is a defined as a global symbol in the global definition file MGLOB.MA 2. The error address table, ERLST, must contain an entry that is the negated address value of the location of the call to ERROR. A -1 ends this table. The form of the entry is: .EXTERNAL ERnnn -ERnnn 3. The message pointer table, MESLST, must contain an entry that is in the same relative position as its corresponding entry in ERLST. (The pointers are grouped by module.) 4. The error message table must contain a message in the form: adr pass TEXT /xx msg/ where: adr is the address of the fixup routine (This is a routine that can be called to perform preprocessing before the error message is printed. If this entry is 0, no routine is called.) pass is the number of the physical pass where the error was detected xx is the two-character error message code msg is the text of the error message The pass number represents the physical (not logical) pass number on which this error message should be given. For example if there is no binary requested, then the listing pass is physical pass 2 even though it is logical pass 3. No message is given if this is the wrong pass. The assumption is that the message has already been printed on a previous pass. This avoids message duplication. For errors that are pass independent, such as I/O errors, MACREL uses the pass number code 4000. These messages are printed regardless of which pass is in effect. 2-28 DESCRIPTIONS OF THE MODULES Two special codes are permitted within the text of the error message: # Print the symbol name that is in NAME1 through NAME3 of the symbol table work area (MAC24) at this point in the error message. ? Print the character enclosed in quotes residing in CHAR at this point in the error message. 2.5.3 Number of Errors Detected In order to print the number of errors detected, FIN0 simulates an error at the end of the assembly using ER230 (FIN0). The ER1 (MACERR) routine prints the ERRORS DETECTED message if necessary and then returns to the address immediately following the ER230 label. 2.6 MACEXP The module MACEXP contains the memory-resident routines that perform expression parsing. It consists of the main routine EXPR and a number of subordinate routines. MACEXP loads its extension overlay, EXPOVR, only as needed. 2.6.1 EXPR EXPR is the controlling routine for expression parsing. Routines call EXPR to parse an expression beginning with the current character in the input stream. The call to EXPR is: JMS I (QQEXPR Control returns to the caller at the address stored in EXPR with the absolute (12-bit) part of the expression in the accumulator (AC) and the relative part of the expression in EXPREL (15-bit pointer). EXPR operates recursively. Before it calls itself, it saves the local variables listed in Table 2-7 on the expression stack (EXPSTK). When it returns from the (recursive) call, it removes these variables from the stack and restores EXPR to its previous operational state. EXPR performs the following tasks. 1. Sets the variables PRVOPR, EXPABS, EXPREL, and EXPCOD to zero. This specifies that no previous binary operator has been found and that the initial value of the expression is 0. 2. Calls TERM to obtain and evaluate a term of the expression. 2-29 DESCRIPTIONS OF THE MODULES Table 2-7 Local Variables Saved on the Expression Stack ---------------------------------------------------------------------- | Name | Use | |----------|---------------------------------------------------------| | | | | EXPABS | Absolute part of total expression computed so far | | | | | EXPCOD | Relocation type: | | | -1 = Value of expression is top entry | | | on LINK's stack. | | | 0 = Simple relocation; add absolute | | | part to relative part | | | 1 = .FSECT relocation | | | 2 = CDF relocation; add field of | | | relative part, multiplied by 10 | | | (octal) to absolute part | | | | | EXPR | Return address from EXPR | | | | | EXPREL | Relative part of result of total expression so far | | | computed | | | | | TERM | Return address from TERM | | | | | UNARYM | Number of minuses seen on term to be combined with | | | expression result | | | | | PRVOPR | Previous operator; used to combine new value with old | | | result | ---------------------------------------------------------------------- 3. (if it cannot perform the requested binary operation) a. Calls HARD to set up loader codes that request LINK to perform the operation. b. Obtains the next operator and stores its code in PRVOPR (see Table 2-7). c. Calls TERM again (step 2 above). 4. (if it can perform the requested binary operation) Passes control to the routine specified by the code in PRVOPR to process the previous operator (see Table 2-8). On return, the results reside in EXPABS, EXPREL, and EXPCOD. 2-30 DESCRIPTIONS OF THE MODULES Table 2-8 EXPR Previous Operator Dispatch Table ---------------------------------------------------------------------- | Code | Operator | Processing Routine | Use | |------|----------------|--------------------|-----------------------| | 0 | NUL | NOPREV | No previous operator | | 1 | + | ADD | Addition | | 2 | - | SUB | Subtraction | | 3 | ^ | MUL | Multiplication | | 4 | % | DIV | Division | | 5 | or TAB | OR | Logical inclusive OR | | 6 | & | ANDY | Logical AND | | 7 | ! | SHIFT | 6-bit left shift | | 10 | ! | OR | Logical inclusive OR | ---------------------------------------------------------------------- 2.6.2 TERM The routine TERM parses and evaluates a term from the current input stream. The calling sequence is: JMS TERM address if term is empty address for normal return It scans all characters and passes control to the appropriate processing routine listed in Table 2-9. It skips over spaces and if the term is empty, returns control to the caller at the first return address. Control normally returns to TRM's caller at the second return address. Table 2-9 TERM Character Dispatch Table ---------------------------------------------------------------------- | Character |Processing| Function | | | Routine | | |---------------|----------|-----------------------------------------| | | | | | A - Z, a - z | SYMM | Parses a symbol period (.), performs a | | and comma (,) | | symbol table lookup, and exits from | | | | TERM. | | | | | | 0 - 9 | NUMBR | Parses a number and exits from TERM. | | | | | | - | UNOPM | Increments the minus sign count and | | | | reiterates TERM. | ---------------------------------------------------------------------- (continued on next page) 2-31 DESCRIPTIONS OF THE MODULES Table 2-9 (cont.) TERM Character Dispatch Table ---------------------------------------------------------------------- | Character |Processing| Function | | | Routine | | |---------------|----------|-----------------------------------------| | ( | PENP | Parses a current page literal | | | | (including the right parenthesis), | | | | performs a symbol table lookup, and | | | | exits from TERM. | | | | | | [ | OPENB | Parses a page zero literal (including | | | | the right square bracket), performs a | | | | symbol table lookup, and exits from | | | | TERM. | | | | | | " | DBLQ | Parses an expression of the form: 'A, | | | | where A is a single character. It | | | | inserts the 8-bit ASCII code for the | | | | character in TRMABS if bit 4 of ENABWD | | | | is set to a 1, then exits from TERM. | | | | | | ' | SNGL