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. | | | | | | ' | SNGLQ | Parses an expression of the form: "AB, | | | | where A and B are single characters. | | | | It inserts the 6-bit ASCII code for A | | | | in bits 0 - 5 of TRMABS and the code | | | | for B in bits 6 - 11 of TRMABS, then | | | | exits from TERM. | | | | | | ^ | UPAROW | Parses the temporary radix control | | | | operators (^B, ^D, ^O and ^") and | | | | their arguments, then exits from TERM. | | | | | | + | TRM1 | Skips over spaces and tabs (HT) then | | | | branches to the appropriate routine | | | | depending on the next character. | | | | | | < | OPENA | Evaluates an expression of the form | | | | by performing recursive | | | | calls to EXPR. If the expression is | | | | absolute, it checks to see if a dollar | | | | sign ($) follows. If this is true, it | | | | branches to OTSYM. If this is not | | | | true, it branches to PREFIX to perform | | | | a unary minus operation on the current | | | | term. | | | | | | > | VACTRM | Causes an exit from TERM to the first | | | | address following the call (empty term | | | | address). | ---------------------------------------------------------------------- (continued on next page) 2-32 DESCRIPTIONS OF THE MODULES Table 2-9 (cont.) TERM Character Dispatch Table ---------------------------------------------------------------------- | Character |Processing| Function | | | Routine | | |---------------|----------|-----------------------------------------| | other | | | | characters | ER22 | Calls the error routine to send an | | | | error message for illegal characters, | | | | then branches to TRM1. | ---------------------------------------------------------------------- 2.7 MACINI The module MACINI contains MACREL's initialization routines. This is once-only code that resides in I/O buffer and overlay space. Control passes to ONCE from NIXT (MAC24) immediately after MACREL is started. 2.7.1 DATE The DATE routine obtains the OS/8-stored system date, converts it to a printable string, and stores it (one character per word) in the listing header buffer. If no OS/8 date was entered, it fills the buffer with blanks. The date resides in absolute memory locations 17666 and 07777 (bits 3 and 4). Table 2-10 shows the internal storage format. Table 2-10 Internal Storage Format of OS/8 Date Words ---------------------------------------------------------------------- | Location | Bits | Value Range | Use | | | | (octal) | | |--------------|--------|-------------|------------------------------| | | | | | | 17666 | 0-3 | 1-14 | Month (Jan. through Dec.) | | | 4-8 | 1-37 | Day of Month | | | 9-11 | 0-7 | Year-1970 (modulo 8) | | | | | | | 07777 | 3-4 | 0-3 | (Year-1970)/8 | ---------------------------------------------------------------------- The format for the converted date is: dayname dd-mon-yy where: 2-33 DESCRIPTIONS OF THE MODULES dayname is the 3-character abbreviation of the name of the day (Monday through Sunday) dd is the day of the month (1 through 31 (decimal)) mon is the 3-character abbreviation for the name of the month (Jan. through Dec.) yy is the least significant digits of the year (1970 modulo 8) 2.7.2 ONCE The ONCE routine performs the following tasks: 1. Interrogates the locations that contain the user-specified options to the Command Decoder. 2. Sets various option-related flags. 3. Moves a copy of the option settings to SWATOL, SWMTOX, and SWYTO9 in Field 0 (MAC24) so they can be referenced without executing CDF instructions. 2.7.3 CORE The CORE routine determines the real physical size of memory and returns to ONCE with the size value in the AC. 2.7.4 LIMSET The LIMSET routine sets up the memory limit table (LIMTBL) to specify the portions of memory that are available for symbol table allocation. This is a table of eight 2-word entries; one entry for each field that MACREL can use (see Figure 2-1). The first word of an entry specifies the lower memory limit for the field. The second word specifies the first address that is not available in the field. It sets the first word of an entry to -l to indicate that this field and all higher fields are unavailable. To set up the table, LIMSET must determine whether: o BATCH is running o there is a one/ or two page system handler o the system handler is TD8E (Simple DECtape) 2-34 DESCRIPTIONS OF THE MODULES Word ----------------------------------- 0 | Field 0 low address limit | |---------------------------------| 1 | Field 0 high address limit | |---------------------------------| . | . | . | . | . | . | |---------------------------------| | Field 7 low address limit | |---------------------------------| 15 | Field 7 high address limit | ----------------------------------- ML-029-80 Figure 2-l Memory Limit Table (LIMTBL) Layout o the Y option was selected o there is more than 12K words of memory (If there is not, it automatically sets the Y option.) 2.7.5 PREFORM The PREFORM routine formats all memory not used by MACREL into 8-word chunks. It chains these chunks together using 15-bit pointers (see Section 1.5.2). The first word in each chunk is a 15-bit pointer that points to the next chunk in the chain. It deposits the pointer to the first chunk in the chain into location FREESPACE. A forward pointer of 0 marks the last chunk in the chain. NOTE The initial symbol table is not in chunk format and is designed not to use any pointer addresses. This is because PREFORM formats over the initial symbol table without destroying it. 2.7.6 SYMINI The SYMINI routine builds the run-time symbol table using FREESPACE chunks and the symbols contained in the initial symbol table (SYMTAB). It uses the global routines (QQ) LOOKUP, (QQ) ENTER, and (QQ)PUTSYM routines to insert the permanent symbols into the run-time symbol table. The initial symbol table consists of a number of 8-word entries as described in Table 2-11. SYMINI reads each entry in the 2-35 DESCRIPTIONS OF THE MODULES initial symbol table (SYMTAB) and determines whether the entry is affected by the A, O, Q, or R options. Table 2-11 Initial Symbol Table Entry Format ---------------------------------------------------------------------- | Word | Use | |------|-------------------------------------------------------------| | | | | 0 | Unused | | | | | 1 | = 4000 - PDP-8/A or PDP-8/E specific symbol (A command | | | option) | | | = 0100 - Redundant (unnecessary) symbol (R command option) | | | = 0200 - EAE symbol (Q command option) | | | = 1000 - Directive that pertains to macros (O command | | | option) | | | | | 2 | char 0 / char 1 char = character of symbol name | | 3 | char 2 / char 3 in MACREL 6-bit code. | | 4 | char 3 / char 5 | | | | | 5 | Symbol value or address depending on word 6 | | | | | * 6 | = 0000 - Regular symbol. Word 5 contains symbol value and | | | word 7 contains 0000. | | | = 0002 - Pseudo-macro. Word 5 contains address of field 0 | | | processing routine and word 7 contains 0000. | | | = 0003 - Pseudo-operator. Word 5 contains the address of | | | the processing routine located in the overlay | | | specified by the contents of word 7. | | | = 2000 - Memory reference instruction. Word 5 contains | | | symbol value and word 7 contains 0000. | | | | | 7 | Overlay number | ---------------------------------------------------------------------- * The codes in this word may be ORed together. SYMINI uses the (QQ)LOOKUP, (QQ)ENTER, and (QQ)PUTSYM routines in MAC24 to insert the permanent symbols into the symbol table. 2.8 MACIO The MACIO module contains the Field 1 resident input/output routines. 2-36 DESCRIPTIONS OF THE MODULES 2.8.1 IOINIT and IONIT2 These routines, although resident in MACIO, are logically part of the FIN0 Overlay. They are described in Sections 2.2.10 and 2.2.11. 2.8.2 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 device handler. The file is not explicitly opened via a call to the USR. 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.8.3 READOS READOS is a subroutine that reads characters from an OS/8 file. It is called by GETOS to fill the input buffer from the current input device. Although it can use input buffers of various sizes, buffer size in this version of MACREL is limited to 2 blocks (a block is 2 memory pages). The buffer begins at INPBUF; its length in blocks is specified by INPLEN (MAC24). READOS performs the following tasks: 1. Resets OS8PTR to point to the beginning of the input buffer (the word before the first word of the next double word to be read). 2-37 DESCRIPTIONS OF THE MODULES 2. Determines how many blocks are left in the input file so that nonexistent blocks are not read. If there are fewer blocks remaining than are specified by INPLEN, the subroutine calls READSHORT to read the exact number of blocks left in the current input file. If the input device is not block (file) structured, the subroutine reads the maximum number of blocks (INPLEN). 3. Stores the actual number of blocks read in INSIZ. 4. Subtracts INSIZ from INLEN if the device is not block (file) structured. This is because INLEN specifies the actual number of blocks left to read from the input device. 5. Sets RDSIZ and BUFKNT according to the contents of INSIZ. BUFKNT contains the negated number of double-words of actual data in the OS/8 input buffer. RDSIZ contains the function control word passed to the input device handler. Bits 6-8 of this word contain a 1 to indicate that the input buffer is in Field 1. Bits 1-5 specify the number of pages of data to be read. 6. Calls the device handler (address is in INHNDLR) to perform the read operation. 7. Calls INERR to determine the nature of any error it detects during the read operation. If it was an end-of-file, operation continues. This is because only non-file-structured device handlers return end-of-file errors. These handlers always put a CTRL/Z in the buffer after the data. INERR generates the appropriate error messages for all other I/O error conditions. 8. Increments INREC by the value of INSIZ when the read operation is complete. This is because INREC always contains the number of the next block to read from the input device. 2.8.4 SWITCH The routine SWITCH is the controlling routine of the input coroutine switching mechanism. It is called with a single argument that follows the call. The argument is a pointer to the new stream input routine. SWITCH performs the following tasks: 1. Places the name of the current stream on the stream stack so that the specified stream becomes the new current stream. 2. Sets up the following variables with information about the new stream. 2-38 DESCRIPTIONS OF THE MODULES SGET contains the address of the new stream. SLOC contains the address of the context block for the new stream. SRET contains the address of the partner coroutine for the new stream SSTRT contains the address of the beginning of the code for the new stream. (This address becomes the initial value stored in the partner coroutine entry point.) 3. Places all the local variables and SRET on the stream stack if the contents of SRET are non-zero. (In this case, SRET serves as a flag at the end of the stack to indicate that local variables are stored on the stack.) 4. Initializes SRET to the contents of SSTRT. Notice that it does not have to save local variables on the stack when a new coroutine is entered unless that coroutine had been previously in use (that is, this call is recursive). 2.8.5 SWBACK The routine SWBACK switches from the current input coroutine to the previous input coroutine. It is called when an input coroutine determines that it has reached the end of the current input stream and data must come from the previous input stream. Since IOINIT (FIN0) establishes ZGET as the initial input stream coroutine, stream stack underflow cannot occur. 2.8.6 GETOS, and ORET Coroutines The GETOS routine gets 7-bit packed ASCII characters from the OS/8 input buffer (INPBUF), unpacks them and sends each one via the AC to ORET. It performs the following tasks: 1. Forces the character to be 7-bit ASCII. 2. Loads the character into the AC and returns to NEXTCHAR (MAC24) if the character is not a CTRL/Z. 3. Causes ORET to branch to EOF, which performs the following steps if the character is a CTRL/Z: a. Sets up the next input file and returns control to GETOS to continue the process. 2-39 DESCRIPTIONS OF THE MODULES b. Calls SWBACK to make ZGET the current input stream if there is no further file input. 2.8.7 MGET and RGET Coroutines The MGET and RGET routines obtain characters that reside in the symbol table, 7 ASCII characters per chunk. These characters are stored in 7-bit ASCII. The high-order bit (bit 0) of the word, ordinarily zero, is a special flag when it is non-zero. Table 2-12 defines these symbol table flags. Table 2-12 Symbol Table Flags Definitions ---------------------------------------------------------------------- | Flag | Description | |-----------------|--------------------------------------------------| | 4000+n | argument marker for argument n | | 7770 | end-of-macro-body marker | | 7771 | end-of-argument marker | | 7772 | end-of-repeat range marker | | 7773 | argument expression indicator (for an | | | expression that occurs within a substring | | | construct) | | 7774 | argument symbol indicator (for a symbol that | | | occurs within a substring construct) | | 7775-7777 | reserved for future use | ---------------------------------------------------------------------- 2.8.8 ZGET The input coroutine ZGET always returns CTRL/Z codes. It prevents stream stack underflow. 2.8.9 OFIX The routine OFIX re-fetches an OS/8 handler and re-reads an OS/8 input file block as necessary when switching back to OGET. This is to make sure that the desired handler was not overlaid by another handler left over from a previous pass. 2.8.10 SPUSH The routine SPUSH is a general-purpose routine that places (pushes) 2-40 DESCRIPTIONS OF THE MODULES the contents of the AC on a standard pushdown stack. The calling sequence is: TAD value JMS I [SPUSH stackname where: value is the value to be saved (pushed) on the stack stackname is a pointer to the beginning of the stack The stack must reside in Field 1 and be of the following form: stackname, -length elements . . stack area . . where: stackname is the name of the stack -length is a negative value that is the length of the stack area elements is the number of elements currently on the stack (This value is initially 0.) stack area is the words that form the stack area itself 2.8.11 SPOP The routine SPOP is a general-purpose routine that removes (pops) an entry from a pushdown stack. The stack must reside in Field 1 and be of the form described in Section 2.8.10. SPOP returns control to the calling routine with the "popped" stack entry in the AC. The calling convention is: JMS I [SPOP stackname where: stackname is a pointer to the beginning of the stack 2-41 DESCRIPTIONS OF THE MODULES 2.8.12 LOCPSH The routine LOCPSH places (pushes) the coroutine local variables on the stream stack. 2.8.13 LOCPOP The routine LOCPOP removes (pops) the coroutine local variables from the stream stack. 2.8.14 OFETCH The routine OFETCH loads an OS/8 handler into memory. 2.8.15 PUTBUF The routine PUTBUF sends the full output buffer (OUTBUF) of characters to the listing file one block at a time. Although it can use buffers of various sizes, the size of the output buffer in this version of MACREL is limited to 2 blocks (a block is 2 pages). The buffer begins at OUTBUF. Its length in blocks is specified by OUTLN (MAC24). 2.8.16 LISTOR, LSTRET, and OUTLST The coroutines LISTOR, LSTRET, and OUTLST send characters to the output file on odd passes. They use the standard OS/8 packing scheme to fill the output buffer with characters (see the MACREL/LINK User's ___________________ Manual). On even passes, no packing is required, so PUTBUF can be ______ called directly. 2.8.17 CONV The routine CONV converts a 15-bit pointer into a CDF instruction and a 12-bit address. Upon entry, the AC contains the 15-bit pointer. CONV creates a CDF instruction to the appropriate field and stores this CDF at the location specified by the first argument. It then loads the 12-bit address to the first word of the chunk into the AC and passes control to the calling routine. 2.8.18 DELETE The routine DELETE deletes a string of characters from macro space. 2-42 DESCRIPTIONS OF THE MODULES Before calling this routine, you must set up two words, DE1 and DE2. DE1 points to the first chunk to be deleted, and DE2 points to the last chunk to be deleted. 2.8.19 LOOKU The routine LOOKU looks up a file on the device. The file name is specified in locations NAME1 through NAME4 of the symbol table work area (MAC24). The device number resides in the AC. Upon return, FN contains the starting block number and LOOKLN contains the file length. LOOKU is called by the $INCLUDE (OVRE) and LNKCHN (OVRT) routines. 2.8.20 ZINIT The routine ZINIT initializes the state of the macro processor at the beginning of each pass. 2.9 MACLIT (Overlay 31) The overlay MACLIT contains the code that generates literals and controls the literal pool. 2.9.1 ZSECTG The routine ZSECTG obtains a pointer to the program section (.ZSECT) for a Page 0 literal. It automatically defines a .ZSECT for Page 0 literals that are referenced from either named or unnamed program sections. It performs the following tasks: 1. Takes the pointer to the symbol table entry for the program section of current symbol (CURSCT (MAC24)), obtains the program section name, and inserts it into NAME1 through NAME4 of the symbol table work area (MAC24). 2. Encodes a leading dollar sign ($) in the name by setting bit 0 of NAME1 to a 1. (The dollar sign signifies a MACREL-generated .ZSECT.) 3. Passes control to GENUN for further processing if bit 5 of the program section's flag word is 1, indicating an unnamed .ASECT. (The symbol table contains a MACREL-defined default name in the form: FLD:nn.) 4. Searches the symbol table for a program section with a name as specified in NAME1 through NAME4 if bit 5 of the flag word 2-43 DESCRIPTIONS OF THE MODULES is 0 indicating a named program section. The routine proceeds depending on the following situations: a. If the name is not there, this is the first occurrence of a Page 0 literal for this program section. The routine defines a new .ZSECT that resides in the same field as the program section where the literal reference resides. It uses the original program section name with the dollar sign appended to it as the name of the new .ZSECT (NAME1 through NAME4). It enters this new program section name into the symbol table ((QQ)ENTER). b. If the name is there, it calculates the 15-bit pointer to the symbol table entry for the .ZSECT that contains the Page 0 literal, stores it in ZSECTN and exits with this value in the AC. 2.9.2 ZL The routine ZL dumps the Page 0 literal pool for named program sections. It is an extension of ZLIT and performs the following tasks: 1. Exits to the caller if there are currently no page 0 literals for the current program section. 2. Calls ZSECTG to get the program section name, if there are Page 0 literals. 3. (if this is pass 2) Inserts the loader code into the binary file (QQ)PUNBIT to instruct LINK to load this program section and sends the literals to the binary file (OUTLIT). 4. (if this is not pass 2) Exits to the caller. 2.9.3 GENUN The routine GENUN generates Page 0 literals for unnamed .ASECTs. It inserts these literals into Page 0 of the field where the .ASECT resides. The literals are assigned locations that begin at location 177 and continue in decending address order. GENUN computes new high and low boundaries for this .ASECT, and branches to COMN (MACEXP) to continue processing. 2.9.4 ZLIT The routine ZLIT purges the Page 0 literal pool. It branches to KLU1 to see if this pool is for an unnamed .ASECT (in which case KLU1 2-44 DESCRIPTIONS OF THE MODULES branches to PRGSPL). If this pool is for a named program section, ZLIT branches to ZL to purge the pool. Thereafter, ZLIT clears ZLTLOC (MAC24) and ZSECTN (MAC24) to indicate that this Page 0 literal pool is no longer needed. 2.9.5 PRGSPL The routine PRGSPL purges Page 0 literals that reside in an unnamed .ASECT. It resets CLTLOC, LPAG, and KIND (to indicate to PLIT that the current page literals are to be purged) and branches to PLIT. Notice that in an unnamed ASECT, Page 0 literals are in fact the same as current page literals if the current page is Page 0. 2.9.6 KLU10 KLU10 is a patch to PURGEL that could not fit on the same page as PURGEL. It is functionally part of PURGEL, which is described in Section 2.9.7. 2.9.7 PURGEL The routine PURGEL purges literals from a literal pool. The pool type code resides in the AC upon entry to PURGEL (0 for current page pool, 1 for Page 0 literal pool). It performs the following tasks: 1. (if this is a Page 0 literal pool) Branches to ZLIT to purge the pool. 2. (if this is current page literal pool) Sets LPAG to point to the current page literal pool and checks to see if there are any literals in the pool. a. Exits to the caller if there are no literals in the pool. b. Calls OUTLIT to do the actual purging if there are literals in the pool. (CLTLOC must be zeroed before OUTLIT is called.) 3. Returns from OUTLIT, and clears CLTLOC and HGHLOC to indicate that this literal pool is unused. 2.9.8 OUTLIT The routine OUTLIT sends a literal pool to the binary file to the listing file, or to the KREF file, according to the pass currently in effect. The calling sequence is: 2-45 DESCRIPTIONS OF THE MODULES TAD (loc JMS OUTLIT pointer where: loc is the location of the last literal generated in this pool pointer is the pointer to the literal table, either PAGE0 (Page 0 literal table) or CURPAG (current page literal table) (These pointers must begin on a page boundary.) It performs the following tasks: 1. (if this is pass 2) Sends the literals via OUTDATA (MAC24) to the binary file. 2. (if this is pass 3) Sends a line of dashes followed by a list of the literals to the listing file. (The dashed lines separate the literals from the previous code.) 3. (if this is pass 4): a. Creates a pseudo-name for each literal's location and value in the form: Lnnnn = absolute address of the literal Vmmmm = absolute value of the literal b. Appends a plus sign (+) to those literal names that represent a value to be relocated by LINK. c. Sends the names to the KREF file so that the literals can be cross referenced both by name and by value. 2.9.9 CMNMOV The subroutine CMNMOV obtains the next literal value from either the Current Page Literal Table or the Page 0 Literal Table, depending on the value of INK. It returns the value in the AC. INK = -1 if purging current page literals = 1 if purging Page 0 literals KIND = 0 if purging current page literals = 1 if purging Page 0 literals 2-46 DESCRIPTIONS OF THE MODULES 2.10 MACMAC (Overlays 26, 27, and 30) The module MACMAC consists of three overlays that contain the routines to implement the macro directives. Overlay 26 processes the header of the macro definition. Overlay 27 processes the body of the macro definition and the .REPT directive. Overlay 30 processes macro calls. 2.10.1 $MACRO The routine $MACRO processes the header of a macro definition. It obtains the macro name and stores the formal (dummy) arguments in the Formal Argument Table (FT). This table contains groups of 3-word entries. Each entry consists of up to 6 characters packed in MACREL 6-bit code and stored in complemented (negated) form. A word of zeros terminates the table. Figure 2-2 shows the format of an entry. 0 5 6 11 word --------------------------- 1 | char 1 | char 2 | |------------|------------| 2 | char 3 | char 4 | |------------|------------| 3 | char 5 | char 6 | --------------------------- ML-030 80 Figure 2-2 Formal Argument Table Entry Format 2.10.2 PART2 The routine PART2 stores the macro body in macro space and is a continuation of $MACRO. 2.10.3 $REPT The routine $REPT implements the .REPT directive. It performs the following tasks: 1. Parses the expression that follows the directive to obtain the repeat count and the text of the repeat. 2. Saves the repeat count and text in macro storage space so that the macro can be repeated. 3. Reacts to the appearance of the .ENDR directive at the end of the repeat range, it: 2-47 DESCRIPTIONS OF THE MODULES a. Switches the input stream to RGET (MACIO) to obtain input from macro storage space. b. Passes control to BYEB (MAC24) to process the repeat range. 2.10.4 MC The code MC implements a call to a macro by performing the following tasks: 1. Reads the actual arguments and stores each one, via STORMS (MACRO), in the argument space (which is the same as macro space). 2. Accepts arguments that are enclosed either in double quotes ("text") or in angle brackets (). 3. Accepts an argument that begins with a backslash (\). In this case, it loads the EXPOVR auxiliary overlay and calls BACKL with a pointer to STORMS. This stores the numeric value of the argument that follows the backslash in macro space according to the radix interpretation currently in effect. 2.10.5 $MEXIT The routine $MEXIT implements the .MEXIT directive. If MGET is not the current stream input routine, it returns an error. If MGET is the current input routine, it stores the address of MGT4 (MACIO) in MRET. This causes the macro processor to detect an end to the current string in macro space the next time MGET is called. 2.11 MACOPN (Overlay 33) The overlay MACOPN contains routines that open MACREL's output files. This is an extension to the FIN0 overlay. 2.11.1 OPEN The routine OPEN sets up an output file for either binary or ASCII data, depending on the pass currently in effect. 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 the number of blocks in the Loader 2-48 DESCRIPTIONS OF THE MODULES Symbol Dictionary (LSD) area of the binary file. This offset allows OPEN to skip over the file's LSD area. 2.11.2 OPENTC The routine OPENTC sets up the output file to receive the table of contents. 2.11.3 OFETCH The routine OFETCH loads an output device handler. There is also a copy of this routine in MACIO. 2.12 MACORG (Overlay 7) MACORG is a small module that is an extension of MAC24. It contains part of the code that controls MACREL's current location counter or program counter (PC). ORIGI, the only entry point in this module, is called from ORPTCH in MAC24. It performs the following tasks: 1. Sets up LITPAG to the value of the new PC. 2. Zeros EXTPC to indicate that the expected new PC is not external. 3. Passes control to BYEP (MAC24) if the new PC value is absolute or is relative to the current program section. 4. Generates an error message in response to the error that occurs if the new PC value is relative to another program section; attempts to recover from the error by generating an external PC. 5. (if the new PC value is complex relocatable) a. Generates loader codes that will tell LINK to calculate the new PC value at LINK execution time. b. Sets EXTPC to 1 to indicate that the PC is external. 2.13 MACRO The module MACRO contains Field 0 resident subroutines that are used by the macro processor overlays and the Actual (macro) Argument Table (AT). A complete and detailed description of the macro processor is provided in the comments column of the source listing for this module. 2-49 DESCRIPTIONS OF THE MODULES Table 2-13 contains brief descriptions of the functions of the major routines. Table 2-13 Summary of Routines in the MACRO Module ---------------------------------------------------------------------- | Routine | Function | |--------------|-----------------------------------------------------| | | | | CREATE | Fetches a new chunk from FREESPACE to be used for | | | macro space. | | | | | DELETE | Deletes a string of characters from macro space. | | | | | DELITE | Deletes the old macro definition upon | | | redefinition. | | | | | FINMS | Terminates storage in macro space. | | | | | INITMP | Initializes the macro processor at the start of | | | each pass. | | | | | INITMS | Initializes a new chunk for storage. | | | | | MATCH | Tests a symbol just obtained for a match with a | | | given keyword list. | | | | | MS | Stores a word in the current location in macro | | | space. | | | | | RENEW | Resets character scan to beginning-of-line. | | | | | SKSEP | Skips past a sequence of spaces and/or tabs. | | | | | STORMS | Stores the AC in macro space. | | | | | TSTEOL | Tests for end-of-line. | | | | | TSTQUOTE | Tests for a double quotation mark ("). | | | | | TSTTERM | Tests for a terminator (backslash (\), semicolon | | | (;), or end-of-line). | ---------------------------------------------------------------------- The Actual (macro) Argument Table (AT) contains 15-bit pointers to the argument strings (lists) that reside in macro storage space. This table is used recursively during the expansion of macro arguments. The arguments are stored in hierarchical order by nesting level as shown in Figure 2-3. 2-50 DESCRIPTIONS OF THE MODULES -------------------------- Level 1 arg 1 | first cell pointer | |------------------------| arg 1 | last cell pointer | |------------------------| arg 2 | first cell pointer | . |------------------------| . arg 2 | last cell pointer | . |------------------------| . | . | . | . | . | . | |------------------------| Level 2 arg 1 | first cell pointer | |------------------------| . . | . | . . | . | . . | . | |------------------------| Level n arg m | last cell pointer | -------------------------- ML-031-80 Figure 2-3 Actual (macro) Argument Table Layout 2.14 MACRTH (Overlay 6) The overlay MACRTH is an extension to the resident expression processor MACEXP. It contains the routines that request LINK to perform global arithmetic for expression constructs that MACREL cannot solve. Table 2-14 describes the function of each routine. Table 2-14 Descriptions of MACRTH Routines ---------------------------------------------------------------------- | Routine | Function | |--------------|-----------------------------------------------------| | | | | HARDY | Obtains an expression, operator, and term | | | combination from EXPR (MACEX) determines the | | | appropriate LINK codes and sends this information | | | to the binary file. | | | | | STKPUT | Used by HARDY to send the codes to LINK that | | | insert a term on its stack. | ---------------------------------------------------------------------- (continued on next page) 2-51 DESCRIPTIONS OF THE MODULES Table 2-14 (Cont.) Descriptions of MACRTH Routines ---------------------------------------------------------------------- | Routine | Function | |--------------|-----------------------------------------------------| | | | | HRDTRM | Used by TERM (MACEXP) to send the codes that | | | request LINK to negate a term whose absolute value | | | cannot be determined by MACREL. | | | | | PUT | Sends a 12-bit value and associated flag field | | | (value = 3) to the binary file. | | | | | FLDYX | Processes the .FLD directive in response to a call | | | from the $FLD (MACEXP) routine. | | | | | XXEDF | Processes the XEDF directive in response to a call | | | from $XEDF (MACEXP) routine. | | | | | CM | Clears TRMABS and TRMREL and sets TRMCOD to a -1 | | | to indicate the term is on the top of LINK's | | | stack. | | | | | LEVXX | Processes the .LEVEL directive in response to a | | | call from the $LEVEL (MACEXP) routine. | ---------------------------------------------------------------------- 2.15 MACTBL The module MACTBL is a one-page character branch table. A number of routines in MAC24 use this table (instead of calling BRANCH) to perform a branch-on-matching character. The table consists of 200(octal) entries, one for each ASCII character code. The ordinal position of each entry in the table is the code for an ASCII character. The entries are bit-encoded, as shown in Table 2-15. Each bit specifies an attribute that may be associated with a character. For example, the 101st entry in the table is the entry for uppercase A. Its entry is 0400 (bit 3 set) to specify that the character is a letter. 2.16 MAC2 The module MAC2 contains the resident code that forms the pass 2 root of MACREL. The following sections describe the major routines. 2-52 DESCRIPTIONS OF THE MODULES Table 2-15 Character Branch Table (MACTBL) Classification Codes ---------------------------------------------------------------------- | Octal | Symbolic | Function | Characters Encoded | |-------|----------|--------------------|----------------------------| | | | | | | 4000 | EOL | End-of-line | NUL, FF, LF, CR, CTRL/Z, | | | | | | | 2000 | EOSY | End-of-statement | NUL, ; and / | | | | | | | 1000 | BLANK | Space | Space and HT(tab) | | | | | | | 0400 | LETTER | Letter | A through Z and a through z| | | | | | | 0200 | DIGIT | Digit | 0-9 | | | | | | | 0100 | OPER | Operator | HT(tab), space, !, %, &, | | | | | +, -, ^ | | | | | | | 0040 | EXTDLT | Extra Alphanumeric | . and $ | | | | | | | 0020 | COMMA | Comma | , | ---------------------------------------------------------------------- 2.16.1 PUXBIN The routine PUXBIN sends a binary entry and its flag field to the binary file. The flag field (FLG) must be set up prior to calling PUXBIN. The data word is in the AC. This routine also increments the current location counter (PC) unless it is external. LPATCH is a patch that resides in MAC24 and updates the high PC for the current program section. 2.15.2 BPUT The routine BPUT stores the current location counter (PC) in LITPAG (page of current page literals) if the PC overflows into a new page. It then calls BPUTX (PAS2) if this is Pass 2 and binary output (PUNCH) is enabled. 2.16.3 PUNBIT The routine PUNBIT is identical to PUXBIN except that it also calls OUT (MAC3R) to print the current line during pass 3. 2-53 DESCRIPTIONS OF THE MODULES 2.16.4 PUTBIT The routine PUTBIT sends a binary entry without a flag field to the binary file. 2.16.5 ORIG The routine ORIG sets up the flag word (FLG) and sends a new current location counter (PC) value to the binary file. The value of the new PC must be in the AC upon entry to this routine. To account for RELOC directives, the routine adds the contents of RELOK to the (PC) value before calling PUTBIT. 2.16.6 PUTB The routine PUTB calls PUTBT if this is pass 2 and binary output (PUNCH) is enabled. 2.16.7 PUNY The routine PUNY determines whether this is pass 2 and binary output (PUNCH) is enabled. If these conditions are in effect, it causes a "skip-on-condition" by incrementing the return address by 1 so that it passes control to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.16.8 PUTLC The routine PUTLC sends a loader code (FLG=3) to the binary file if binary output (PUNCH) is enabled and this is pass 2. 2.16.9 UNNAM The routine UNNAM creates a new unnamed .ASECT. It assigns the .ASECT a default name in the form: FLD:nn where: nn is the field of the .ASECT It sets bit 5 of the symbol's flag word in the symbol table entry to 1 to specify that this is an unnamed .ASECT (default name assigned). 2-54 DESCRIPTIONS OF THE MODULES Then it tentatively sets the initial current location counter (PC) value to 200. 2.17 MAC24 The module MAC24 contains the main body of resident code. It is often referred to in the comments to the source code as the "main module". MACREL's commonly used variables, flags and constants reside in Page 0 and extend into Page 1. The remaining pages contain the routines that form the operational core of the assembler. The following sections describe the most important routines. 2.17.1 NEX The routine NEX is the start-of-pass code. Execution for each pass begins here. 2.17.2 GETLSD The routine GETLSD obtains the Loader Symbol Dictionary (LSD) number associated with an LSD entry. Every LSD entry that is to be sent to the LSD in the binary (.RB) file is assigned a number. These numbers are consecutive, beginning at 1. They are assigned at the end of pass 1. 2.17.3 IGNORE The routine IGNORE ignores characters in the current line until it finds the end of the line. 2.17.4 CNVADR The routine CNVADR converts an encoded 15-bit pointer into a CDF instruction and a 12-bit address. Upon entry into the routine, the AC contains the 15-bit pointer. Prior to returning to the calling routine CNVADR executes a CDF instruction referencing the appropriate data field and loads the 12-bit address into the AC. (Refer to Section 2.7.5 for the format of 15-bit pointers.) 2.17.5 $PAUSE 2-55 DESCRIPTIONS OF THE MODULES The routine $PAUSE processes the PAL8 PAUSE directive by ignoring it. 2.17.6 HGHSCT The routine HGHSCT obtains the highest address used by a program section. 2.17.7 LOAD The routine LOAD is the overlay loader. It uses the OS/8 system handler to load the specified overlay. It will not load the overlay if it detects that the overlay is already resident. Thus, it checks that the value of bits 7 through 11 of the first location in the overlay area is the same as the requested overlay number. (The first location of an overlay contains the overlay number.) The calling sequence is a standard subroutine call. The overlay number (ovrnum) and the first, or lowest, address of the overlay area (addr) may be passed to the routine in the location following the call (loc), in the AC, or in combination as specified below. If they are passed together in the AC, the location following the call (loc) must be zero. The form is: JMS I (LOAD loc where: arg = (AC+ loc) is the logical argument containing the data to be passed to the routine ovrnum = (arg + 37) is the number of the overlay being loaded (see Appendix E) addr = (arg + 7740) is the first address of the overlay area NOTE MACREL can destroy an overlay area without using the formal mechanism provided by calling LOAD. For example, reading the input file may make the contents of the EXTREMITIES Overlay Area unusable if an input handler must be loaded. Further, it is good practice to zero the first location in the overlay area before calling LOAD. This eliminates the no load condition that could result if the input handler or the 2-56 DESCRIPTIONS OF THE MODULES data in the input buffer coincidentally begins with a number that is identical to the requested overlay number. 2.17.8 SETIT The routine SETIT creates a new title or subtitle from the current line. Upon entry, LINPTR contains a pointer to the first character of the new title or subtitle. The calling sequence is: JMS I (SETIT -length addr-1 where: -length is the complement of the number of characters to move addr-1 is the address (less 1) of the first word of the destination buffer 2.17.9 PRZLIT The routine PRZLIT uses PURG to load the MACLIT overlay, which purges Page 0 literals. 2.17.10 PRGLIT The routine PRGLIT uses PURG to load the MACLIT overlay, which purges the current page literals. 2.17.11 BACKSL The routine BACKSL calls BACKL (EXPOVR) to respond to a backslash encountered within a symbol. 2.17.12 ERROR The routine ERROR is the resident part of the error message processor. It accepts error calls and loads the special overlay MACERR to print the error message as follows: 1. Increments the error message counter ERKNT. 2-57 DESCRIPTIONS OF THE MODULES 2. Saves 5 blocks (12 memory pages) of resident code beginning at memory location 10400 by storing them in the swap area within MACREL.SV. The swap area begins at relative block 116 (ERRBLK+16), where ERRBLK contains the actual OS/8 block number of relative block 100 in SYS:MACREL.SV 3. Reads blocks from ERRBLK+1 of MACREL.SV into memory, beginning at location 11000. These blocks contain the MACERR code. 4. Branches to routine ERRTN in MACERR to print the error. 5. Passes control to ERROR when MACERR finishes to restore to memory the 5 blocks that it swapped out. (It is important that these 5 blocks never contain code that calls ERROR.) Refer to Section 2.5.1 for additional information about ERROR and a description of MACERR. NOTE Ignore the references to MACERR.SV in the comments in the listing of ERROR. This is a vestige from the first release of MACREL. The contents of MACERR.SV now reside in relative blocks 101 through 116 (octal) of MACREL.SV. 2.17.13 NEXTCHAR The routine NEXTCHAR obtains the next character from the current input stream coroutine. 2.17.14 GETSYM The routine GETSYM loads a copy of the symbol table information into Page 0 for a specified symbol. The symbol's 15-bit pointer is either in the AC or in SYMNUM. If the AC is nonzero, GETSYM takes its contents as a 15-bit pointer to the desired symbol table chunk. Otherwise, it takes the contents of SYMNUM as the pointer. 2.17.15 PUTSYM The routine PUTSYM inserts symbol table information about a specified symbol into the symbol table. The symbol's 15-bit pointer is either in the AC or in SYMNUM. If the AC is nonzero, GETSYM takes its 2-58 DESCRIPTIONS OF THE MODULES contents as a 15-bit pointer to the desired symbol table chunk. Otherwise, it takes the contents of SYMNUM as the pointer. 2.17.16 READLN The routine READLN reads a logical line of text from the current input stream coroutine into the input buffer (LINBUF in MACIO). It uses NEXTCHAR to fill the buffer one character at a time. READLN interprets LF (line feed), CTRL/Z, and NUL as logical end-of-line indicators with the following exceptions: 1. A CTRL/Z also signals the end-of-file. MACREL requires that all source files end with a CTRL/Z. 2. An FF (CTRL/L) signifies that a form feed must be sent before printing the line. READLN sets the form flag (FORM) to indicate this. (The form feed remains in the line.) 3. Vertical TAB is not treated specially. 4. No check is made for a line that is too long. 5. RETURN is ignored. READLN signals the end of the logical line by inserting a 0 in the input line buffer. Calling sequence: JMS READLN end-of-file return NOTE Ignore the comments describing the stream input routines on page 35 of the assembly listing for MAC24; they are incorrect. 2.17.17 $FIXMRI The routine $FIXMRI implements the FIXMRI directive. If the symbol name argument to the directive is a memory reference instruction (MRI), it sets bit l in MRISAV to a 1. In any case, execution proceeds into the adjacent direct assignment statement code (EQL). At the end of the EQL routine, it checks bit l of MRISAV and, if set, causes EQL to set bit l of the symbol's flag word in the symbol table entry. 2-59 DESCRIPTIONS OF THE MODULES 2.17.18 EQL The routine EQL implements the direct assignment statement. It parses the expression to the right of the equal sign and stores the value that results in the value field (word 4) of the symbol table entry of the symbol to the left of the equal sign. 2.17.19 GETCHR The routine GETCHR obtains a character from the input buffer. It stores the character in CHAR, obtains the type code from the character branch table (MACTBL), and places it in BITS. 2.17.20 SCAN The routine SCAN skips over a sequence of spaces and tabs (HT) in the input stream. 2.17.21 GET The routine GET uses GETCHR to retrieve a character from the input buffer and passes control to the caller with the character in the AC. 2.17.22 CTRLC If the routine CTRLC determines that a CTRL/C was typed at the terminal keyboard it aborts the assembly by returning control to the OS/8 monitor at location 7605. 2.17.23 FINI The routine FINI loads Overlay 22 (OVRR) to prepare for the end-of-pass operations and updates the device handler memory residency table. 2.17.24 BACKUP The routine BACKUP moves the input buffer pointer (LINPTR) back one position, so that the next call to GETCHR will return the same value that it returned before. 2-60 DESCRIPTIONS OF THE MODULES 2.17.25 BRAN The routine BRAN implements an indexed branch. It takes the contents of the AC, adds it to the return address to create an index into a table of addresses, then branches to the selected address. The table of addresses must immediately follow the call. 2.17.26 NUMLCL The routine NUMLCL processes numeric local labels as follows: 1. Parses a numeric string and evaluates it in decimal radix. 2. Passes control to B2 (MAC24) to process the local symbol if a dollar sign ($) follows the string. 3. Passes control to GETEX2 (MAC24), if there is no dollar sign after the string, to reparse the numeric string in the current radix and treat it as an expression. 2.17.27 BRANCH The routine BRANCH implements a branch-on-matching-character function. It searches a character/address table for the character or range of characters that match the specified search character. The search character must be either in the AC or in CHAR (if the AC is 0). When it finds a matching character, it branches to the address in the table associated with that character. A character/address table must immediately follow the call to BRANCH. Each entry consists of either two or three fields delimited by semicolons (;). If the search object is a single character, the first field contains the complement of the character's 6-bit code and the second field contains the branch address. If the search object is a consecutive ascending range of characters, the entry consists of three fields. The first field contains the code for the character that begins the range (positive). The second field is a negative value that specifies the character range. The third field contains the branch address. NOTE This routine is used infrequently because the calling sequence slows MACREL's execution. 2-61 DESCRIPTIONS OF THE MODULES 2.17.28 ASEMBL ASEMBL is the controlling subroutine that assembles a line. It decides upon the general format of the line and calls the appropriate routine to perform the actual parsing. 2.17.29 GETEX The routine GETEX processes the asterisk (*) directive, the right angle bracket (>) end-of-expression operator, numeric local symbols, and lines that contain expressions. 2.17.30 ASEMLV ASEMLV sends the currently assembled statement to the binary file via OUTDATA. It detects extraneous characters found after the end of the current statement and then continues assembly with the next statement on the line. 2.17.31 OUTDATA The routine OUTDATA sends the binary data assembled by the mainline code and its 2-bit flag field to the binary file. 2.17.32 TAGCOM The routine TAGCOM processes a tag ending with a comma. 2.17.33 TAGCOL The routine TAGCOL processes a tag that ends with a colon (:), but it does not terminate the current local symbol block. The 15-bit pointer to the symbol table entry for the tag that begins the current local symbol block resides in location TAGLOC. 2.17.34 ORIGIN The routine ORIGIN processes the asterisk (*) directive. 2-62 DESCRIPTIONS OF THE MODULES 2.17.35 LETTER The subroutine LETTER effects a "skip-on-condition" if the current character (CHAR) is an upper-case or lower-case letter, a period (.), or a dollar sign ($). This means that it increments the return address by 1 so that it passes control to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.17.36 TSTMAC The routine TSTMAC determines that the first symbol on a line is a macro call, it loads MACMAC (Overlay 30) to expand the macro. Upon completion, it passes control to ASEMLV (via AS3) to assemble the next line. Otherwise, it simply returns control to the caller. 2.17.37 DIGIT DIGIT determines that the current character (CHAR) is a digit, if it effects a "skip-on-condition" by incrementing the return address by 1. It therefore passes control to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.17.38 ROTL6 The subroutine ROTL6 shifts the contents of the AC and the link six bits to the left. 2.17.39 PARSYM PARSYM is the symbol parsing routine. It performs the following tasks: 1. Parses an identifier from the line beginning with the current character. 2. Converts the identifier's characters from 6-bit ASCII to MACREL 6-bit representation (see Appendix A). 3. Inserts the first six characters of the identifier into NAME1 through NAME3 of the symbol table work area and discards any extra characters. 4. Sets the QUAL word to 0 if the symbol does not end with a dollar sign ($). 2-63 DESCRIPTIONS OF THE MODULES 5. Sets QUAL to the value of TAGLOC (15-bit pointer to the current local symbol block) if the symbol is a local symbol and ends with a dollar sign ($). 6. Assumes that it is going to parse a file name if the AC is nonzero on entry to PARSYM. It inserts the file name into NAME1 through NAME3 and the extension in NAME4 of the symbol table work area (MAC24). It ignores any characters in the file name and the extension that exceed the limits (six characters for file names and two for extensions). 2.17.40 EOS The routine EOS determines whether the current character (BITS) is a statement delimiter. It checks for forward slash (/), semicolon (;), and end-of-line (NUL, LF, FF, RETURN and CTRL/Z) characters. If it does not find one of these characters, it effects a "skip-on-condition" by incrementing the return address by 1 so that it passes control to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.17.41 LOOP The routine LOOP forms the main control loop of the assembler. It calls READLN, and ASEMBL repetitively to read and assemble source lines until it encounters the end of the input file, It calls CTRLC to determine if the user typed a CTRL/C at the terminal to abort MACREL operation. 2.17.42 CALLIT The routine CALLIT allows routines that reside in fields other than Field 0 to call routines that reside in Field 0. The calling sequence is: CDF CIF 0 TAD (arg JMS CALLIT address return 1 return 2 return 3 where: arg is the argument to be passed in AC 2-64 DESCRIPTIONS OF THE MODULES address is the field 0 address of the routine to be called This routine has from one to three returns immediately following address argument, depending on the conventions of the routine beginning at address. 2.17.43 GETKAR The routine GETKAR retrieves a character from the input buffer. It returns to the caller with the character in the AC. If this is the end-of-line (AC=0), it increments the return address by 1 so that control passes to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.17.44 PUSH The routine PUSH places (pushes) the contents of the AC on the expression stack (EXPSTK in MACIO). 2.17.45 POP The routine POP removes (pops) a value from the expression stack and leaves it in the AC. 2.17.46 LOOKUP The routine LOOKUP searches the symbol table for the name contained in NAME1 through NAME3 of the symbol table work area (MAC24). If it does not find the name, control passes to the calling address plus 1 (ready to call ENTER). If it does find the name, it passes control to the calling address plus 2 with auto-index register XR0 set to point to word 3 (SYMVAL) of the symbol table entry with the data field set to Field 0. 2.17.47 CREF The routine CREF sends the symbol name and line number information to the cross-reference (KREF) file. The name resides in NAME1 through NAME3 of the symbol table work area, and the line number resides in LINENO and LINEN2. 2-65 DESCRIPTIONS OF THE MODULES 2.17.48 ENTER The routine ENTER enters the symbol name that resides in NAME1 through NAME3 of the symbol table work area into the symbol table. ENTER is ordinarily called after a symbol table search (LOOKUP) fails. 2.17.49 KLU4 The routine KLU4 obtains the lowest address used by an .ASECT and stores it in HGHTMP. 2.18 MAC30 (Overlay 15) The overlay MAC30 contains the pass 1 and pass 3 specific code. 2.18.1 PRINTY The routine PRINTY sends the current location counter (PC) value, binary data, and symbol qualifiers that are printed at the left of the assembly listing to the print routine ((QQ)LISTER). The symbol qualifiers are defined in Table 2-16. 2.18.2 PRLINO (MAC2) The routine PRLINO prints the line number at the left margin of the assembly listing. Table 2-16 Assembly Listing Symbol Name Qualifiers -------------------------------------------- | Qualifier | Meaning | |----------------------|-------------------| | | | | ' (apostrophe) | Link generated | | | | | blank | Type 0 relocation | | | | | + | Type 1 relocation | | | | | - | Type 2 relocation | | | | | * | Type 3 relocation | -------------------------------------------- 2-66 DESCRIPTIONS OF THE MODULES 2.18.3 SETT The routine SETT sets a new title from the current line by calling SETIT with the appropriate parameters. 2.18.4 DPRINT The routine DPRINT sends the decimal number in the AC to the number-printing routine NPRINT. 2.18.5 OPRINT The routine OPRINT sends the octal number in the AC to the number-printing routine NPRINT. 2.18.6 NPRINT The routine NPRINT sends the number obtained from DPRINT and OPRINT to the actual print routine ((QQ)LISTER). It performs the following tasks: 1. Examines the link bit to determine how to pad unused character positions in the number being printed. 2. Pads the number (4 places) with leading zeros if the link is set. 3. Pads the number with the character contained in PAD if the link is not set. Examples: a. If PAD contains a space character, the number is printed with leading spaces. b. If PAD contains a zero, the number is printed with no leading spaces. 2.18.7 CRLF The routine CRLF sends a RETURN/LF sequence to ((QQ)LISTER) for printing. 2-67 DESCRIPTIONS OF THE MODULES 2.18.8 LIST The routine LIST prints an entire line (or sequence of ASCII characters). The calling sequence is: JMS LIST pointer to ASCII line The ASCII line must reside in Field 1. The line consists of ASCII characters (one character per word, terminated by a word of zeros). If the AC is zero on entry to the routine, the routine automatically prints a RETURN/LF sequence after the string of characters. If the AC is nonzero on entry, the routine terminates operation and returns to the caller without sending the RETURN/LF sequence. 2.18.9 PRNDSH The routine PRNDSH sends five dashes to ((QQ)LISTER to the listing. They separate the assembled code from the literals that are printed at the end of each memory page of assembly listing. 2.18.10 PRNBIN The routine PRNBIN sends the assembled code (octal) to the print routine ((QQ)LISTER) for printing at the left of its source line in the listing. If FLG is negative, the current expression is complex relocatable, and it sends four asterisks (****) instead of the assembled value. 2.18.11 TAB The routine TAB sends an HT (horizontal tab) character to the listing file and increments the tab stop count (COLCNT). 2.19 MAC3R This module contains the resident portion of the Pass 1 and Pass 3 specific code. 2.19.1 OUT The routine OUT sends a line to the listing file. It performs the following tasks: 2-68 DESCRIPTIONS OF THE MODULES 1. Calls NEWPAG to start a new listing page if the form flag (FORM) is nonzero. 2. Returns control to the caller if this is not pass 3, or if the listing flag is off. 3. Returns control to the caller if there is no line to print and the binary extension flag (BNFLAG) is not set. 2.19.2 NEWPAG The routine NEWPAG sets up a new listing page for printing. It accepts an optional argument in the AC that specifies a sub-page number. If the AC is zero, there is no sub-page number. If the AC is nonzero, it takes this value as the new sub-page number to be printed. (The sub-page number is incremented whenever a logical memory page of code crosses a physical page boundary.) NEWPAG performs the following tasks: 1. Returns to the caller immediately if this is not pass 3. NOTE Whether or not it is pass 3, OUT must perform a minimal amount of processing to maintain line and page number accuracy. For example, the cross-reference (KREF) pass requires the line number count, and pass 1 uses the page number count to create the table-of-contents. 2. Checks NEWTIT to see if a new title was specified. If NEWTIT is nonzero, NEWPAG obtains the new title line by calling SETT, which moves a new title into the heading area from the beginning of the current source line. 3. Prints: a. the heading (TITLE), starting with an FF (form feed) as the first character b. the page number with no leading zeros c. a hyphen (-) followed by the sub-page number (if this is not sub-page 0) 4. Sets the form feed flag (FORM) to 0. 2-69 DESCRIPTIONS OF THE MODULES 5. Prints a RETURN/LF sequence followed by the subtitle and another RETURN/LF. 6. Resets the line count to the negated value of PGLINS and returns to the caller. 2.19.3 LISTER LISTER is the primary routine for printing characters during passes 1 and 3. This routine calls LISTOR (MACIO) in Field 1. The calling sequence is: TAD (char JMS I [LISTER or TAD (char JMS QQLISTER 2.19.4 OVRLIN The routine OVRLIN allows lines in the listing to continue onto a continuation page. It performs the following tasks: 1. Resets the column count (COLCNT) to the standard page width (-WIDTH). 2. Increments the line count (LINCNT). 3. Increments the sub-page number (SUBPAG) if this is the end of the page; calls NEWPAG to create a new page; and sets the line count (LINCNT) to 1. 2.19.5 PASS3 If the routine PASS3 determines that a pass is pass 3, it effects a "skip-on-condition" by incrementing the return address by 1. It therefore passes control to the calling address plus 2. Otherwise, it passes control to the calling address plus 1 (standard subroutine return). 2.20 OVRA (Overlay 1) The overlay OVRA contains the routines that implement the PAGE, ZBLOCK, and TEXT directives. 2-70 DESCRIPTIONS OF THE MODULES 2.20.1 $PAGE The routine $PAGE implements the PAGE directive. Since it can change the value of the current location counter (PC), it uses the current value of the PC when calling HGHSCT to compute the current high PC. (This allows for the rare case when a PAGE directive resets the current location counter to a value that is lower than the current PC.) If an argument follows, the keyword, $PAGE parses it as an expression that specifies a new page number. This must be an absolute expression in the range 0-37. If there is no argument, $PAGE assumes that it is the next page. $PAGE sets up the new PC and if different from the page of the current page literals (LITPAG), it calls PRGLIT to purge the previous current page literals. Paging to the current page, though of no logical value, will not cause the literal pool to be purged. Then it calls ORIG to set up the new PC. 2.20.2 $ZBLOCK The routine $ZBLOCK implements the ZBLOCK directive. It performs the following tasks: 1. Parses the first expression that follows the directive to find the length of the block. A length of zero causes control to return to PSEUDB (MAC24) and ignore the directive. Otherwise, it temporarily stops printing binary extensions in order not to list multiple duplicate binary values. 2. Parses the optional second expression if it finds a comma. This is the value to be inserted into each word in the block. If there was no comma, the default value is zero. It calls PUNBIT repetitively to send out this value. 2.20.3 $TEXT The routine $TEXT implements the TEXT directive. It performs the following tasks: 1. Interrogates ENABWD to determine what character packing options the user specified. 2. Parses the characters that remain in the source line. 3. Calls one of the coroutines listed in Table 2-17 to pack each character that it finds (if necessary) and send it to the binary output file. 4. Sends NULs to the appropriate coroutines to complete the 2-71 DESCRIPTIONS OF THE MODULES operation and to guarantee that the text string is terminated by a full word of zeros. 5. Sends one additional NUL if the user specified zero fill. Table 2-17 TEXT Directive Coroutines ---------------------------------------------------------------------- | Name |NULs| Description | |---------|----|-----------------------------------------------------| | | | | | ASCTXT | 0 | Packs text in 8-bit ASCII format (1 character per | | | | word). | | | | | | SIXTXT | 1 | Packs text in 6-bit ASCII format (2 characters per | | | | word). | | | | | | OS8TXT | 2 | Packs text in OS/8 format (3 characters per 2 | | | | words). | | | | | | USRTXT | 1 | User-defined text routine. This currently generates | | | | two 6-bit characters per word according to the | | | | "excess 237" encoding scheme. Refer to the COS-310 | _______ | | | User's Manual. | _____________ ---------------------------------------------------------------------- NOTE The USRTXT entry point allows you to define and implement your own text-packing scheme within MACREL. To do this, merely patch the location USRTXT to contain a JMP to your special text-packing coroutine. 2.21 OVRB (Overlay 2) The overlay OVRB contains the routines that implement the conditional assembly directives: IFNZRO, IFZERO, IFDEF, IFNDEF, and .IF. 2.21.1 $IFNZRO The routine $IFNZRO implements the IFNZRO directive. It uses the same code as the .IF NE directive (see Section 2.21.5). 2-72 DESCRIPTIONS OF THE MODULES 2.21.2 $IFZERO The routine $IFZERO implements the IFZERO directive. It uses the same code as the .IF EQ directive (see Section 2.21.5). 2.21.3 $IFDEF The routine $IFDEF implements the IFDEF directive. It uses the same code as the .IF DF directive (see Section 2.21.5). 2.21.4 $IFNDEF The routine $IFNDEF implements the IFNDEF directive. It uses the same code as the .IF ND directive (see Section 2.21.5). 2.21.5 $IF The routine $IF implements the .IF directive. It performs the following tasks: 1. Examines the condition keyword that follows the directive keyword and branches to the routine associated with that keyword to determine if the condition is true or false (see Table 2-18). 2. Passes control to CONDOK if the condition is true. CONDOK: a. Scans to the right angle bracket (>). b. Increments CONCNT to maintain a count of the conditional nesting level. 3. Passes control to SKIP if the condition is false. SKIP: a. Skips the range of the conditional by scanning for the right angle bracket (>) that terminates the condition. b. Prints the lines of source code in the condition range unless /J option was selected. It uses ANGCNT to count the levels of inner nesting of angle brackets. 2-73 DESCRIPTIONS OF THE MODULES Table 2-18 .IF Directive Conditions ------------------------------------------- | Argument * | Condition When True | |-------------|---------------------------| | | | | EQ | expression=0 | | | | | NE | expression not equal 0 | | | | | LT | expression < 0 | | | | | GE | expression >= 0 | | | | | GT | expression > 0 | | | | | LE | expression <= 0 | | | | | DF | symbol defined | | | | | NDf | symbol not defined | | | | | B | string empty (blank) | | | | | NB | string non-empty | | | | | IDn | pair of strings identical | | | | | DIf | pair of strings different | | | | | REf | symbol referenced | | | | | NRef | symbol not referenced | | | | | ABs | expression absolute | | | | | REl | expression relocatable | ------------------------------------------- * Lowercase characters in keywords are optional. 2.22 OVRC (Overlay 3) The overlay OVRC implements the .TASK, OCTAL, DECIMAL, .RADIX, FILENAME, DEVICE, and .ENABLE directives. 2.22.1 TASKY The routine TASKY implements the obsolete .TASK directive and is 2-74 DESCRIPTIONS OF THE MODULES included as comments for historical purposes. The directive no longer appears in the permanent symbol table. 2.22.2 $OCTAL The routine $OCTAL implements the OCTAL directive. It sets the radix to 8 instead of 10 and continues into the code that implements the DECIMAL directive. 2.22.3 $DECIMA The routine $DECIMA implements the DECIMAL directive. It sets the radix to 10 (decimal). 2.22.4 $RADIX The routine $RADIX implements the .RADIX directive. It temporarily sets the radix (RADXWD) to decimal (default), then parses the expression that follows. If the value of the expression is 0, 1, negative, greater than 10, or nonabsolute, then an error message is generated. Otherwise, it accepts the value of the expression as the new radix. 2.22.5 $FILENA The routine $FILENA implements the FILENAME directive. It performs the following tasks: 1. Scans past leading spaces, then calls PARSYM with a 1 in the AC. (The 1 sets PARSYM to scan for file names by rejecting a symbol that contains a dollar sign and by accepting a symbol that contains the period that signals a file name extension.) PARSYM sets up the name in NAME1 through NAME 4 of the symbol table work area. 2. Calls PUNBIT, which generates the binary code if this is logical pass 2. 3. Calls PSEUDB, which sends it to the listing file if this is logical pass 3. 2-75 DESCRIPTIONS OF THE MODULES 2.22.6 $DEVICE The routine $DEVICE implements the DEVICE directive and shares code with the $FILENAME routine. It performs the following tasks: 1. Scans past leading spaces, then calls PARSYM with a 1 in the AC. (The 1 sets PARSYM to scan for file names by rejecting a symbol that contains a dollar sign and by accepting a symbol that contains the period that signals a file name extension.) PARSYM sets up the name in NAME1 through NAME 4 of the symbol table work area. 2. Checks NAME3 and NAME4, when control returns from PARSYM, to determine that there were not more than four characters in the device name and that there were no periods. If this is not true, it generates an error message. 3. Calls PUNBIT, which generates the binary code if this is logical pass 2. 4. Calls PSEUDB, which sends it to the listing file if this is logical pass 3. 2.22.7 $ENABLE The routine $ENABLE implements the .ENABLE directive. It begins by parsing the symbol that represents the enable condition keyword. It then passes control to one of the routines listed in Table 2-19 to set the correct bits in the ENABWD variable. Only the first two characters of the keyword are significant. (Refer to the MACREL/LINK ___________ User's Manual for the bit significance of .ENABWD.) _____________ Table 2-19 $ENABLE Condition Options ------------------------------- | Keyword* | Routine | |-------------------|---------| | | | | 7Bit | BIT7 | | | | | 8Bit | BIT8 | | | | | AScii | ASCII | | | | | COs | COS | | | | | EXpunge | EXPUN | ------------------------------- (Continued on next page) 2-76 DESCRIPTIONS OF THE MODULES Table 2-19 (Cont.) $ENABLE Condition Options ------------------------------- | Keyword* | Routine | |-------------------|---------| | | | | FIll | FILL | | | | | NO** | NO | | | | | OR | ORR | | | | | OS8 | OS8 | | | | | PEerm | PERMY | | | | | PUnch | PUNCH | | | | | SHift | SHIFT | | | | | SIxbit | SIXBIT | ------------------------------- * Lowercase characters in keywords are optional. ** The NO routine takes the remainder of the keyword (in NAME2)and branches into the routine that implements the .DISABLE directive. The NOFILL, NOEXPUNGE, NOPERM, NOLSB and NOPUNCH conditions behave this way. For example, .ENABLE NOFILL is treated as .DISABLE FILL. 2.22.8 $DISABL The routine $DISABL implements the .DISABLE directive. It begins by parsing the symbol that represents the disable condition keyword. It then passes control to one of the routines listed in Table 2-20 to set the correct bits in the ENABWD variable (MAC24). Only the first two characters of the keyword are significant. (Refer to the MACREL/LINK ___________ User's Manual for the bit significance of .ENABWD.) _____________ 2.23 OVRD (Overlays 4 and 35) The module OVRD consists of two overlays. Overlay 4 implements the .SECT directive and all its variants. Overlay 35 is an extension to Overlay 4 that processes the overlay control arguments to the .SECT directive. Table 2-21 shows the entry points in Overlay 4 and the current program section type (CST) values associated with each. 2-77 DESCRIPTIONS OF THE MODULES Table 2-20 $DISABL Condition Options --------------------------- | Keyword | Routine | |---------------|---------| | | | | FIll | NOFILL | | | | | EXpunge | NEXPUN | | | | | PErm | NOPERM | | | | | PUnch | NOPUN | | | | | LS | NOLSB | --------------------------- Table 2-21 OVRD Entry Points and CST Values ------------------------------ | Entry Point | CST Value | |----------------|-----------| | | | | $XSECT | 10 | | | | | $ZSECT | 20 | | | | | $DSECT | 30 | | | | | $FSECT | 40 | | | | | $RSECT | 50 | | | | | $ASECT | 60 | ------------------------------ Overlay 4 performs the following tasks: 1. Sets up CST, depending on the entry point ($XSECT through $ASECT), to contain the value of the current program section type. In the case of an entry via $SECT, it parses the argument that specifies the directive type to set up CST. 2. Stores the 15-bit pointer to the previous program section in PRVSCT in case a .SECT* directive had been specified. 3. Stores the 15-bit pointer to the current program section in OLDSCT. 2-78 DESCRIPTIONS OF THE MODULES 4. Computes a new high current location counter (PC) for the old program section. 5. Purges all literal pools and cancels any RELOC directive currently in effect. 6. Obtains the new program section name and sends it to the cross-reference (KREF) file. 7. Searches the symbol table for the name of the program section to obtain more information about the symbol. If the symbol is not defined, it defines the symbol. 8. Starts a new local symbol block (LSB) by clearing TAGLOC. 9. Initializes itself to continue loading into this program section. 10. Loads Overlay 35, if the argument list continues, to process the PAGE, LOCATION, CONCATENATE, OVERLAY, LEVEL, NOPURGE and ROOT overlay control keywords. If Overlay 35 finds any of these keywords, it parses the expression that follows and inserts the information into locations in the program section's symbol table entry. 2.24 OVRE (Overlay 5) The overlay OVRE implements the .CHAIN, .INCLUDE, .ENTRY, .EXTERNAL, .ZTERNAL, .GLOBAL, and .SECREF directives. 2.24.1 $CHAIN The routine $CHAIN implements the .CHAIN directive. It sets CHNFLG to 1 and proceeds with the routine that processes the .INCLUDE directive (which sets CHNFLG to 0). 2.24.2 $INCLUD The routine $INCLUD implements the .INCLUDE directive. It performs the following tasks: 1. Parses the device and file name. 2. Fetches the handler, then calls CHAINI (MACIO in Field 1) to complete the task. 3. Sets up: 2-79 DESCRIPTIONS OF THE MODULES a. the new input device handler entry point b. the new input record number c. the new input file length (INLEN) 4. Returns through BYEB to the ASEMLV routine (MAC24), which begins parsing the new input file. 2.24.3 $ENTRY The routine $ENTRY computes the global type code (4) for the .ENTRY directive by performing address arithmetic and deposits it in GLBTYP. Execution then proceeds with the general global processing routine GLOB2 (described in Section 2.24.7). 2.24.4 $EXTERN The routine $EXTERN computes the global type code (6) for the .EXTERNAL directive by performing address arithmetic and deposits it in GLBTYP. Execution then proceeds with the general global processing routine GLOB2 (described in Section 2.24.7). 2.24.5 $ZTRNA The routine $ZTRNA computes the global type code (7) for the .ZTERNAL directive by performing address arithmetic and deposits it in GLBTYP. Execution then proceeds with the general global processing routine GLOB2 (described in Section 2.24.7). 2.24.6 $GLOBAL The routine $GLOBAL deposits the global type code (5) for the .GLOBAL directive and deposits it in GLBTYP. Execution then proceeds with the general global processing routine GLOB2 (described in Section 2.24.7). 2.24.7 GLOB2 The GLOB2 is the general global processing routine for all the directives contained in this overlay. Execution control passes to it from the $ENTRY, $EXTERNAL, $ZTERNAL, $GLOBAL, and $SECREF routines once GLBTYP is set to the global type code. It performs the following tasks: 2-80 DESCRIPTIONS OF THE MODULES 1. Parses a sequence of identifiers separated by commas. 2. Performs a symbol table look-up for each identifier, and enters in the symbol table those identifiers not already entered. 3. Enters each identifier in the cross-reference (KREF) listing file. 4. Sets the appropriate bit in the symbol table's flag word. 2.25 OVRQ (Overlays 21 and 34) The module OVRQ consists of two overlays. Overlay 21 contains the block letter printing routines. Overlay 34 contains the routines that print the macrel fish caricature, the version code, and the number of errors. Both of these overlays are a logical part of the OPEN3 routine in the FIN0 overlay. 2.25.1 BLKLET The routine BLKLET sets up the block letter printer (OUTBLK) to print the block letters header on the assembly listing. It performs the following tasks: 1. Stores the contents of the AC (width of the basic letter block) in GROUP. 2. Sets up the word pointer (BLKPTR) to point to the first word of the listing file name. 3. Calls OUTBLK twice: once with an argument of -3 to print the 3 words (6 characters) of block letters of the listing file name and once with an argument of -1 to print the 2 block letters of the listing file name extension. 2.25.2 OUTBLK The routine OUTBLK converts a sequence of 6-bit characters into a sequence of block letters and prints them on the listing device. For each 6-bit character, it finds a matching entry in one of two bit tables that contain the coordinates of the associated block letter or digit. Before OUTBLK is called: 1. GROUP must contain the number of characters (negative value) that comprise the width of the basic letter block for the heading being printed (see Section 2.2.4). 2-81 DESCRIPTIONS OF THE MODULES 2. BLKPTR must point to the first word of the name being printed. The name consists of a group of words containing characters that are packed in 6-bit ASCII. OUTBLK's calling sequence is: JMS OUTBLK nchars where: nchars is the two's complement of the number of characters to print 2.25.3 BINFO The routine BINFO prints on the listing header, the macrel fish caricature, MACREL's version code, and the number of assembly errors found during assembly. If there were no errors, it prints a smiling fish. Otherwise, it prints a scowling fish. 2.26 OVRR (Overlay 22) The overlay OVRR contains the routines that implement the XLIST, NOPUNCH, ENPUNCH, .JSW, .VERSION, .START, .LIST, and .NOLIST directives. 2.26.1 $XLIST The routine $XLIST implements the XLIST directive by complementing bit 0 in LISTWD. 2.26.2 PREFIN The routine PREFIN is called by FINI (MAC24) at the end of each pass prior to loading the FIN overlays. It performs the following initialization tasks: 1. Marks the FIN overlay area as being empty. 2. Sets up the device handlers for the correct pass. 3. Purges the literal pools that remain. 2-82 DESCRIPTIONS OF THE MODULES 4. Loads Overlay 12 if this is pass 1,2 or 4. Otherwise it loads Overlay 13. 2.26.3 $NOPUNC The routine $NOPUNC implements the NOPUNCH directive by setting PUNFLG to 1. 2.26.4 $ENPUNC The routine $ENPUNC implements the ENPUNCH directive by setting PUNFLG to 0. 2.26.5 $JSW, $VERSIO, and $START The three labels $JSW, $VERSIO, and $START are entry points to a single routine that implements the .JSW, .VERSION, and .START directives. It performs the following tasks: 1. Sets LOC to point to START, START+l, or START+2, depending on the directive. These are once-only-code locations in MAC24 that are zeroed. (The contents of LOC added to 4, is the address of the word that is zeroed.) This indicates which of the three directives was specified. 2. Parses the expression that is the argument to each directive and stores it in the proper constant location. 3. Checks for a starting field and a starting address if this is a .START directive. (The address may be relocatable.) It stores the relocatable portion of the starting address in STARTR. The field number must be less than 10 (octal). It also is stored in STARTR because being less than 10 makes it distinguishable from a 15-bit pointer. 2.26.6 $NOLIST and $LIST The two labels $NOLIST and $LIST are entry points to a single routine that implements the .NOLIST and .LIST directives. The only operational difference in processing the directives is that $NOLIST sets LSTCOD to 4000 while $LIST sets LSTCOD to 0. Since setting a bit to 1 means no condition (NO) in LISTWD, LSTCOD is used to force a specific bit to 1 or to 0 in the LISTWD variable. The routine scans the argument list for the allowable conditions and sets the appropriate location in LISTWD. The internal codes for the bits in LISTWD are described in the MACREL/LINK User's Manual. _________________________ 2-83 DESCRIPTIONS OF THE MODULES 2.27 OVRS (Overlay 23) The overlay OVRS contains the routines that implement the FIXTAB and EXPUNGE directives. 2.27.1 $FIXTAB The routine $FIXTAB implements the FIXTAB directive. It parses the list of names that follows the directive. It then searches the symbol table for each name and sets bit 2 of the its flag word to 1. If there is no argument list, it sets this bit for every entry in the symbol table. 2.27.2 $EXPUNGE The routine $EXPUNGE implements the EXPUNGE directive. It is identical to $FIXTAB, except that instead of setting a bit, it unlinks the chunk from the symbol table that contains the symbol and returns it to freespace. 2.28 OVRT (Overlay 24) The overlay OVRT contains the routines that (1) cause MACREL to chain to the KREF and LINK programs and (2) implement the FIELD directive. 2.28.1 LNKCHN Control passes to the routine LNKCHN when MACREL has completed assembly and one or more of the C, L or G command string options were selected. It performs the following tasks: 1. Transfers control to KRFCHN if the /C option was selected, to chain to KREF. Otherwise, it scans for the /L or /G option and chains to LINK.SV. 2. (when chaining to LINK) a. Sets the altmode bit in the command decoder area. b. Deletes all options except LINK's G, H, S, V, W, and 0-9 options. (This includes the equal sign (=) option.) c. Requests LINK to produce a .SV and a .MP file from the .RB file and the USR to load and run SYS:LINK.SV. 2-84 DESCRIPTIONS OF THE MODULES 2.28.2 KRFCHN The routine KRFCHN chains to SYS:KREF.SV and passes the cross-reference (.KF) file created by MACREL to the KREF program. KREF assigns the output file that it creates a .LT file name extension rather than the standard .LS OS/8 listing file name extension. This is necessary to prevent the KREF output file from overwriting the regular listing file. 2.28.3 $FIELD The routine $FIELD implements the FIELD directive. It performs the following tasks: 1. Parses the expression following the FIELD keyword. 2. Closes the current program section, if it is unnamed, and begins another unnamed program section with a name of the form: FLD:nn where: nn is the absolute part of the expression 2.29 OVRU (Overlay 25) The overlay OVRU contains the routines that implement the .SBTTL, .TITLE, EJECT, RELOC, .PUSH and .POP directives. 2.29.1 $SBTTL The routine $SBTTL implements the .SBTTL directive. It calls SETIT (MAC24) to obtain a new title from the text that follows the directive and to insert it in SUBTL. If this is pass 1, it sends this subtitle along with the current page and line number to the table-of-contents file. Otherwise, it ignores the directive and returns through BYEB to the ASEMLV routine (MAC24), which continues parsing the source file. 2.29.2 $EJECT The routine $EJECT implements the EJECT directive. It uses the same code as the .TITLE directive, except that it sets FORM to 1, so that the listing continues on a new page. 2-85 DESCRIPTIONS OF THE MODULES 2.29.3 $TITLE The routine $TITLE implements the .TITLE directive. It calls SETIT (MAC24) to obtain a new title from the text that follows the directive and to insert it in HEADING. 2.29.4 $RELOC The routine $RELOC implements the RELOC directive. It performs the following tasks: 1. (if no expression follows the directive keyword -- that is, a simple RELOC directive) a. Alters the current location counter (PC) to the value PC+RELOK. 2. (if an expression follows the directive keyword--that is, a complex RELOC directive) a. Parses the expression and returns an error message if it is not an absolute expression. b. Stores the value of the expression in the current location counter (PC). c. Sets RELOK to the value of the old current location counter minus this new value. d. Stores the current location counter in BINARY so that this new current location counter value will be printed in the binary column of the assembly listing. 2.29.5 $PUSH and $POP The two labels $PUSH and $POP are entry points to a single routine that implements the .PUSH and .POP directives. Entry through $PUSH causes the routine to set PSHTYP to a 1. Entry through $POP causes the routine to set PSHTYP to a 0 (value of AC on entry). It then parses a sequence of symbols and their values from the argument list and defines them if they are undefined. It places (pushes) them on or removes (pops) them from the user stack (USRSTK (MACIO)) depending on the value of PSHTYP. The routine generates an error if it detects an attempt to .PUSH or .POP a program section name. 2.30 PAS2 (Overlay 16) The overlay PAS2 contains the pass 2 and pass 4 specific code. It 2-86 DESCRIPTIONS OF THE MODULES consists of the PUTBN, CHKFUL, PUTBT, GETFLG, BPUTX, CREFX, and MORCRF routines. 2.30.1 PUTBN The routine PUTBN sends a new binary entry, together with its 2-bit flag word to the binary output buffer. It automatically starts a new flag word when necessary. 2.30.2 CHKFUL The routine CHKFUL checks to see if the binary output buffer is full. If the buffer is full, CHKFUL performs the following tasks: 1. Requests QPUT (MACIO) to send the buffer of binary data to the .RB file. 2. Resets the flag word mechanism so that the next 2 bits of flag information start at the beginning of a new flag word. (It ignores unused fields in the previous flag word.) 3. Sets up the first (header) word of the binary output buffer (0 for Loader Symbol Dictionary (LSD) blocks and 4000 for text blocks). If the output buffer is not full, CHKFUL returns control to the calling routine. 2.30.3 PUTBT The routine PUTBT inserts a word into the binary output buffer without updating the current flag word. It is used for complicated constructs that require more than one word per flag entry. These constructs all have an LSD flag field code of 3 (see the discussion of the LSD in the MACREL/LINK User's Manual). _________________________ NOTE The first word of binary data is always sent via a call to PUTBN so that FLG is not set up. Subsequent words of binary data are inserted using PUTBT. 2-87 DESCRIPTIONS OF THE MODULES 2.30.4 GETFLG The routine GETFLG obtains a new flag word location and sets bit 11 to 1. (This will signify that the flag word is full when the successive left rotate instructions performed by CHKFUL cause this bit to set the link.) The flag word contains six 2-bit flags as described in the MACREL/LINK User's Manual. _________________________ 2.30.5 BPUTX The routine BPUTX sends a new binary entry, together with its 2-bit flag field to the binary output buffer. It automatically starts a new flag word when necessary. It performs the same task as PUTBN except that it ignores bit 0 of FLG, which (occasionally) is set when a literal value of 4003 (octal) is stored in FLG by OUTDATA (MAC24). 2.30.6 CREFX The routine CREFX creates the cross-reference listing (KREF) file and sends it to the output device during pass 4. 2.30.7 MORCRF The routine MORCRF sends cross-reference information about literals to the cross-reference (KREF) file. Literals are assigned internal names that begin with the 6-bit code 76. The second character is either L or V, indicating a KREF by location or by value respectively. The second word of the literal name (characters 3 and 4) is the location or value, and character 6 is a plus (+) if the literal is relocatable (or its location is relocatable). 2-88 PART II LINK CHAPTER 3 INTRODUCTION 3.1 INTRODUCTION LINK is the companion program to MACREL. It converts the relocatable binary object modules created by MACREL into an executable memory image file. LINK makes two passes over the user-specified input modules. During the first pass, it creates the global symbol table (GST). The GST contains all program section names and global symbols used by the input modules. During the second pass, it reads the object modules and performs the following tasks: o Adjusts all address-dependent locations to correspond to the relocation of program sections. o Resolves all global references within object modules. o Searches user-specified libraries for unresolved globals. o Creates an overlay structure, including the necessary overlay handler, according to the user's specifications. o Creates a memory image file load module in OS/8 save image format. This file contains a core control block (CCB) followed by the linked and relocated object code. 3.2 SYSTEM LAYOUT LINK consists of nine MACREL source modules. The LNKCAL and LNKMAN modules contain two resident program sections. The remaining modules (LNKALL, LNKBN1, LNKBN2, LNKCD, LNKMAP, LNKLSD, and LNKMSG) contain the program sections that operate as a system of MACREL overlays as described in the MACREL/LINK Reference Manual. (This is in contrast ____________________________ to the overlay system that is internal to MACREL. 3.3 IMPLEMENTATION LANGUAGE LINK is written in MACREL assembly language and is capable of linking itself. 3.4 LABEL AND SYMBOL CONVENTIONS 3-1 INTRODUCTION Whenever possible, labels and symbols have been used that describe the function being performed or data being represented. LINK does not use local labels or local symbols. 3.5 ROUTINE CALLING CONVENTIONS Routines call subroutines using a JMS instruction and, with rare exceptions, pass the appropriate parameters either in the AC at the time of the call, or in the memory locations that follow the JMS, or both. 3.6 DATA FORMATS AND REPRESENTATIONS LINK stores data in memory, using one of the following data formats: o 12-bit value o 15-bit pointer (see Section 1.6.2) o MACREL 6-bit characters (see Appendix A) o 6-bit ASCII characters (see Appendix A) o OS/8 Command Decoder format (refer to the OS/8 Software ______________ Support Manual) ______________ o Tables, as described in Section 3.7 3.7 TABLES This section contains detailed descriptions of LINK's internal tables. 3.7.1 Global Symbol Table (GST) The global symbol table consists of eight-word entries. Each entry contains the information about one global symbol. The table varies in length depending on the number of global symbols and the amount of memory available. Since LINK places entries in the table as it encounters them, it must perform a sequential search to retrieve a particular symbol. Table 3-1 shows the format of an entry, and Table 3-2 shows the type codes. 3-2 INTRODUCTION Table 3-1 Global Symbol Table Entry Format ---------------------------------------------------------------------- | Word | Use | |------|-------------------------------------------------------------| | | | | 0 | char 0 / char 1 char = character of symbol name | | 1 | char 2 / char 3 in MACREL 6-bit code | | 2 | char 4 / char 5 | | | | | 3 | PC if the symbol is not declared .ENTRY, or transfer vector | | | count (TRNCNT) if symbol is declared .ENTRY | | | | | 4 | bit | | | 0 field flag | | | 0 = word 5 does not contain an absolute field* | | | 1 = word 5 contains an absolute field* | | | 1 address flag | | | 0 = word 6 does not contain an absolute address* | | | 1 = word 6 contains an absolute address* | | | 2 field reference pointer flag | | | 0 = field reference pointer OK | | | 1 = field reference pointer in error (same page | | | restriction)* | | | 3 address reference pointer flag | | | 0 = address reference pointer flag | | | 1 = address reference pointer in error | | | 4 definition flag | | | 0 = symbol is defined | | | 1 = symbol is undefined | | | 5-7 unused | | | | | | 8-11 type code (see Table 3-2) | | | | | 5 | field or pointer to GST (see word 4 bit 0) | | | | | 6 | address or offset (see word 4 bit 1) | | | | | 7 | bit | | | 0 transfer vector flag | | | 0 = no transfer vector needed | | | 1 = transfer vector needed | | | 1-4 unused | | | 5-7 level | | | 8-11 overlay | ---------------------------------------------------------------------- * Relates to program section symbols only. 3-3 INTRODUCTION Table 3-2 Global Symbol Table Symbol Type Codes --------------------------------------------------- | Code | Symbol Type | |--------|----------------------------------------| | | | | 0 | FIELD | | 1 | .SECREF | | 2 | .ASECT | | 3 | .RSECT | | 4 | .FSECT | | 5 | .DSECT | | 6-7 | unused | | 10 | .XSECT | | 11 | .ZSECT | | 12-13 | unused | | 14 | .ENTRY | | 15 | .GLOBAL | | 16 | .EXTERNAL (stored as undefined global) | | 17 | .ZTERNAL | --------------------------------------------------- 3.7.2 Binary Buffer Table (LDBUFS) The binary buffer table establishes the correspondence between the binary buffers and the relative block addresses of the loader image file. It begins at location 12000 and consists of one to thirty-two one-word entries. The number of entries in the table is proportional to the amount of memory fields available (see Table 3-3). Each entry is position-dependent and contains a loader image file block number. For example, the first entry corresponds to the first buffer, the second entry corresponds to the second buffer, and so forth. The binary buffers function as windows into the loader image file through which the loaded program is written to the output file. Each binary buffer is two pages (one OS/8 block) long. The binary buffers start at location 20000 except in 8K-word memory environments where they start at location 07000. LINK optimizes input/output operations by keeping a record of the last time each buffer was referenced. When the buffer is to be loaded with new data, LINK uses the buffer that was least recently used. This allows data that is frequently referenced to reside in memory. 3-4 INTRODUCTION Table 3-3 Number of Binary Buffers as a Function of Memory Size ----------------------------- | Memory | Number of | | Size | Buffers | |---------------|-----------| | | | | 8K | 1 | | 12K | 8 | | 16K | 16 | | 20K | 24 | | 24K | 32 | | 28K | 32 | | 32K | 32 | ----------------------------- 3.7.3 Pointer Table (PTRTAB) The pointer table establishes the correspondence between the local LSD reference numbers used in the LSD text, and the address of that symbol in the GST. It contains 256 (decimal) one-word entries. The nth entry in PTRTAB contains the GST entry number of LSD symbol n. Bit 0 is set to a 1 if the entry is a reference that is inaccurate. This means that the program section name has an erroneous field or address value. 3.7.4 Module Descriptor Table (MODTAB) The module descriptor table contains the file and overlay information for each module that the user specifies. It consists of 1 to 128 (decimal) three-word entries. Each entry contains the data for one input module. The entries appear in ascending order both by level and by overlay within the level. Library module entries reside at the end of table, because they are processed last and can only appear in the main level. Table 3-4 shows the format of the table. 3.7.5 .SECT Table (SECTAB) The .SECT table contains entries that describe the program sections found in the global symbol table (GST). The table is used during memory allocation. Each entry is six words long as described in Table 3-5. 3-5 INTRODUCTION Table 3-4 Module Descriptor Table Format ---------------------------------------------------------------------- | Word | Use | |------------|-------------------------------------------------------| | | | | 0 | bits | | | 0-7 block length | | | 8-11 device number | | | | | 1 | starting block number | | | | | 2 | bit | | | 0 library module flag | | | 0 = entry is not for a library module | | | 1 = entry is for a library module | | | | | | 1-4 unused | | | 5-7 level number | | | 8-11 overlay number | ---------------------------------------------------------------------- Table 3-5 .SECT Table Format ---------------------------------------------------------------------- | Word | Use | |-------|------------------------------------------------------------| | | | | 0 | bit | | | 0 memory allocation flag | | | 0 = no memory allocated for this program section | | | 1 = memory allocated for this program section | | | | | | 1-11 global symbol table entry number | | | | | 1 | bit | | | 0 field flag | | | 0 = GST entry number of field restriction | | | in word 2 | | | 1 = absolute field value in word 2 | | | | | | 1 address flag | | | 0 = GST entry number of address restriction | | | in word 3 | | | 1 = absolute address in word 3 | ---------------------------------------------------------------------- (continued on next page) 3-6 INTRODUCTION Table 3-5 (Cont.) .SECT Table Format ---------------------------------------------------------------------- | Word | Use | |-------|------------------------------------------------------------| | | | | | 2 field restriction flag | | | 0 = no field restriction | | | 1 = same field restriction | | | | | | 3 page restriction flag | | | 0 = no page restriction | | | 1 = same page restriction | | | | | | 4-10 unused | | | | | | 11 load flag | | | 0 = program section loaded | | | 1 = program section failed to load | | | | | 2 | GST entry number of field restriction (word 1, bit 0 = 0) | | | | | | bit | | | 0 field flag | | | 0 = field word is not in global symbol table | | | 1 = field word is in global symbol table | | | | | | 1-11 GST entry number of field restriction | | | | | | absolute field (word 1, bit 0 = 1) | | | | | | bit | | | 0-6 unused | | | | | | 7-11 field | | | | | 3 | GST entry number of address restriction (word 1, bit 1 = 0)| | | | | | bit | | | 0 address flag | | | 0 = address is not in the global symbol table | | | 1 = address is in the global symbol table | | | | | | 1-11 GST entry number of address restriction | | | | | | absolute address (word 1, bit 1 = 1) | | | | | | bit | | | 0-11 absolute address | ---------------------------------------------------------------------- (continued on next page) 3-7 INTRODUCTION Table 3-5 (Cont.) .SECT Table Format ---------------------------------------------------------------------- | Word | Use | |-------|------------------------------------------------------------| | | | | 4 | bit | | | 0-2 (TYPE-2)& 7 (octal) | | | 3-4 unused | | | 5-7 level | | | 8-11 overlay | | | | | 5 | length of program section | ---------------------------------------------------------------------- 3.7.6 Core Image Table (CIMAG, CIMAG1, CIMAG2, and CIMAGE) The core image table describes the available memory segments. LINK maintains three versions of the table: CIMAG, CIMAG1, and CIMAG2 (see Section 4.1). They are used during memory allocation and are updated in the CIMAGE buffer area. They consist of three-word entries in the form shown in Table 3-6. Table 3-6 Core Image Table Format ---------------------------------------- | Word | Use | |-------|------------------------------| | | | | 0 | bits | | | 0-6 unused | | | 7-11 field | | | | | 1 | starting address | | | | | 2 | length of the memory segment | ---------------------------------------- 3.7.7 Overlay Transfer Vector (TRANVC) An overlay transfer vector contains the information required to load the overlay and start execution of the specified routine. An overlay transfer vector is four words long. Table 3-7 shows the format of an overlay transfer vector. 3-8 INTRODUCTION Table 3-7 Overlay Transfer Vector Format ----------------------------------------------------------- | Word | Use | |-------|-------------------------------------------------| | | | | 0 | ISZ XFERV | | | | | 1 | JMS I XFERV+1 | | | | | 2 | bit | | | 0-1 field number (most significant bits) | | | 2-4 level number | | | 5-8 overlay number | | | 9-11 field number (least significant bits) | | | | | 3 | address of entry point | ----------------------------------------------------------- NOTES 1. XFERV is a flag word that the overlay handler uses to determine whether execution control will pass to the newly loaded overlay using a JMP or a JMS instruction. XFERV will contain a 0, if a JMS instruction is to be used. It will contain a 1 (because of the ISZ XFERV instruction) if a JMP instruction is to be used. 2. XFERV+1 contains the address of the overlay handler's entry point. 3. The version 2A of OVRDRV.MA does not manage overlays in fields higher than field 7 and so does not use bits 0-1 of word 2. 3.7.8 User Overlay Level Data Table (QUSRLV) The user overlay level data table (QUSRLV) provides the information to create the overlay storage information table (OST) that resides in the core control block (CCB). It consists of 4-word entries as defined in Table 3-8. NOTE The OST is used by the OS/8 file utility program FUTIL. Neither MACREL nor LINK uses this table. 3-9 INTRODUCTION Table 3-8 Overlay Level Data Table Format --------------------------------------------- | Word | Use | |-------|-----------------------------------| | | | | 0 | number of overlays in this level | | | | | 1 | bit | | | 0-4 address of overlay area | | | 5-6 unused | | | 7-11 field | | | | | 2 | relative starting block number | | | | | 3 | length of overlay (in pages) | --------------------------------------------- 3.7.9 Overlay Level Information Table (LHDR) The overlay level information table contains the information that LINK uses to build the swap table (SWPTAB) that the overlay driver (OVRDRV.MA) allocates. LHDR contains eight four-word entries. Each entry corresponds to one of the eight possible overlay levels (0 through 7). Table 3-9 shows the format of an entry. Table 3-9 Overlay Information Table Entry Format ---------------------------------------------------------------------- | Word | Use | |-------|------------------------------------------------------------| | | | | 0 | bit | | | 0-6 unused | | | 7-11 field of level | | | | | 1 | address of level | | | | | 2 | relative block number of first overlay in level | | | | | 3 | length (in pages) of the overlay (All overlays in a level | | | are the same length.) | ---------------------------------------------------------------------- 3.7.10 Main Binary Section Table (MBST) The main binary section table contains the program's memory allocation 3-10 INTRODUCTION data and is constructed from the memory image file's core control block. It consists of a number of 2-word and 4-word entries, as shown in Figure 3-1. The table begins with a number of 2-word entries; one for each memory field occupied by the user's program. These are followed by a number of 4-word entries. The 2-word entries are organized in descending order by field number. Each entry series as a header for one or more of the 4-word entries. 2-word entries ---------------------------------------- | | number of 4-word entries for field n | | |--------------------------------------| | | pointer to first entry for field n |--------- | |--------------------------------------| | V | counter for field n-1 | | | |--------------------------------------| | | pointer for field n-1 |----- | |--------------------------------------| | | | . | | | | . | | | | . | | | |--------------------------------------| V | | | counter for field 0 | | | |--------------------------------------| | | | pointer for field 0 | | | 4-word entries |--------------------------------------| | V | | | field of this section (bits 7-11) |<---- | | |--------------------------------------| | | | starting address | | | |--------------------------------------| | V | relative block of the image file | | | |--------------------------------------| | | number of records (pages) | | |--------------------------------------| | | . | | | . | | | . | | |--------------------------------------| | | field of this section (bits 7-11) |<-------- |--------------------------------------| | starting address | |--------------------------------------| | relative block of the image file | |--------------------------------------| | number of records | |--------------------------------------| | . | | . | | . | ---------------------------------------- ML-032-80 Figure 3-1 Main Binary Section Table Layout 3-11 INTRODUCTION 3.7.11 Memory Segment Control Double Words Table 3-10 shows the format of the memory segment control word pairs contained in the core control block. Table 3-10 Memory Segment Control Double Word Entry Format ----------------------------------------------------- | Word | Use | |--------|------------------------------------------| | | | | 0 | starting address of segment | | | | | 1 | bit | | | 0 unused | | | 1-5 number of pages in this segment | | | 6-10 5-bit field number of the form: | | | | | | abcde | | | | | | encoded as: | | | | | | bit 6 10 | ----------------------------------------------------- 3.7.12 Library Table (LIBTB) The library table is a table of bit flags that specifies which modules (LSDs) in the user-specified library files are to be included in the load image file (see Figure 3-2). Each LSD in a file is assigned a bit in LIBTB. The order of bit assignment is that specified by the user to the Command Decoder (stored in MODTAB). The bit flags for each file begin on a word boundary starting with the least significant bit (bit 11). The bits are assigned from least significant to most significant within a word in increasing word addresses. For example, the first LSD in the first library file is assigned to bit 11 of the first word in LIBTB. Each bit that is set to a 1 indicates an LSD to be included in the memory image. 3.8 DEFAULT CONDITIONS The following rules define LINK's default operating conditions: 1. Unless otherwise specified by the software memory size, all of memory not occupied by LINK and OS/8 code is available for tables and buffers. 3-12 INTRODUCTION bit bit 0 11 ------------------------- LIBTB (06000) | | | | | | | | | | | | | first 12 LSDs \ |-----------------------| \ | | | | | | | | | | | | | next 12 LSDs \ |-----------------------| \ first | . | / library | . | / file | . | / |-----------------------| / | | | | | | | | | | | | | first 12 LSDs \ |-----------------------| \ | . | \ second | . | / library | . | / file |-----------------------| / LIBTB+177 | | | | | | | | | | | | | ------------------------- ML-033-30 Figure 3-2 Library Table Layout 2. Unless otherwise specified in a Command Decoder input line or in an input module: a. The size of memory for the object program is the same as the size of memory available for use by LINK. b. The object program will not load into locations 7600 through 7777 of any memory field. c. The object program will contain no overlays. d. The empty memory of the object program will be initialized to contain zeros. e. No library other than LNKLIB.RB (if it exists on SYS:) will be scanned to resolve undefined symbols. f. The default starting address is 00200 for the object program. g. The job status word will be created by the loader for the object program. h. Locations 0-1777 of field 0 and field 1 will be allocated to the object program. i. Every memory field that can be allocated to the object program shall be (if necessary) allocated. 3-13 INTRODUCTION 3.9 LINK ERROR AND EXCEPTION REPORTING LINK sends error messages to the console terminal as it creates the memory image file. Except where indicated in the MACREL/LINK User's __________________ Manual, the errors are fatal. When LINK encounters a fatal error, it ______ returns control to the OS/8 Monitor. 3-14 CHAPTER 4 DESCRIPTIONS OF THE MODULES This chapter describes the major operations performed by each of LINK's modules. They are presented in alphabetical order by module name. 4.1 LNKALL The LNKALL overlay allocates memory to the user's program, builds any specified overlay structures and sets up the following three memory image tables: o CIMAG contains the master memory image and resides on the system device (blocks 40 and 41 (octal)). It is accessed by the WRICIM and RDCIM routines. o CIMAG1 contains the current overlay's memory image and is the primary working image used for allocating memory to the user's program. It resides in location 10000 to 10777 and is accessed by the WRCIM1 and RDCIM1 routines. o CIMAG2 contains the current overlay level's memory image. It resides in locations 11000 to 11777 and is accessed by the WRCIM2 and RDCIM2 routines. During memory allocation, these tables are read into and written from the buffer CIMAGE (locations 06600 to 07577). They are updated as the memory image table changes. LNKALL attempts to fit all program sections into available memory. If it cannot fit a program section into the memory that remains, it attempts to optimize the memory layout by: o Deallocating memory from all program sections in the current overlay. o Reordering the allocation list so that the name of the program section that did not fit is at the top of the list. o Reallocating memory to the program sections according to the reordered list. When done, LNKALL passes control to LNKCAL to call the LNKMAP overlay. LNKALL performs the following tasks: 4-1 DESCRIPTIONS OF THE MODULES 1. Sets up the memory image table (CIMAG) to include memory fields 0 and 1. 2. Allocates memory to the user's program as follows: a. Initializes relevant pointers and counters and the user overlay level data table (QUSRLV). b. Writes the current contents of CIMAGE to CIMAG and to CIMAG2. c. Obtains the highest unallocated program section from SECTAB. If this program section is not part of the current level or overlay, LNKALL saves current level or overlay information: (1) If an overlay is being changed, LNKALL reads a copy of CIMAG2 into CIMAGE for use as CIMAG1. (2) If a level is being changed, LNKALL checks that the old level: o Resides in one memory field if it is not the main level. o Has no intervening program section from a lower level. o Starts at an address that is a multiple of 400 (octal). If the conditions (above) are true, LNKALL updates QUSRLV and copies CIMAGE to CIMAG and CIMAG2. If any of these conditions are not true, LNKALL updates the contents of CIMAGE, copies it to CIMAG2 and attempts to allocate memory for that level again. d. Resolves any field restrictions that apply to this program section. If this is not possible, processing continues with Step i (below). e. Resolves any address restrictions that apply to this program section. If this is not possible, processing continues with Step i (below). f. Allocates memory to the program section. If the section does not fit, it: (1) Deallocates memory for all previously allocated sections. (2) Inserts the section that did not fit at the top of SECTAB. 4-2 DESCRIPTIONS OF THE MODULES (3) Reinitializes the pointers to SECTAB. (4) Continues processing with Step c (above). g. Flags the program section as being allocated and updates CIMAG1 to reflect the successful allocation of the program section. h. Allocates memory to all program sections that are restricted to depend on this program section (Steps e through g). (It ignores program sections that cannot be allocated because of unallocated restrictions.) i. Advances necessary pointers and counters. If there are any program sections left to allocate, it continues processing with Step c (above). If there are no more program sections to allocate, processing continues with Step 3. 3. Resolves all entry point and global symbol addresses in the GST if the user did not request a memory load map. Otherwise, it passes control back to LNKCAL to start creating the load map. 4.2 LNKBN1 AND LNKBN2 The overlays LNKBN1 and LNKBN2 create a memory image of the object program (if requested) and starts the program if the G option is specified. LNKALL calls LNKBN1 after LNKMAP generates the memory load map. When LNKBN1 completes its tasks, it calls LNKBN2. The overlays perform the following tasks: 1. Build the memory control block for the user's program. 2. Modify the user overlay level data table (QUSRLV) to determine the starting block in the file that begins each overlay level. 3. Send the memory control block data (from Step 1) and the user overlay level data (from Step 2) to the output (.SV) file. 4. Create the main binary section table (MBST) from the core control block (CCB). 5. Create the load image relative block number table (LHDR) for the main level (level 0) and overlay levels 1 through 7. 6. Build a transfer vector table if the user is creating an overlay structure. (The overlay driver routine (OVRDRV.MA) must be specified in the command line.) 4-3 DESCRIPTIONS OF THE MODULES 7. Perform the following steps, processing the input modules for the second time (pass 2) to create the program's memory image: a. Read a bufferful of data from an input module into the input buffer. b. Perform Step d (below) if this module is not in a library file. c. Use LIBTB to determine if the current piece of this library is required. If it is not required, the current LSD and text is discarded and this step is repeated. If the piece is required, processing continues with the next step. When it has scanned the library file completely, processing continues with Step f (below). d. Initialize the pointer table, then process the LSD for the current module (or piece of a library) to equate LSD numbers to GST numbers. e. Produce the corresponding part (Step d) of the memory image file (.SV file) from the relocatable part of the relocatable binary (.RB) input module or library piece. f. (LNKBN2) advances its pointers to the next piece if this module is a library file and processing continues with Step c (below). If the module is not a library file or if the library file has been fully processed, LNKBN2 advances all module pointers to the next input module. If there is another module to read, processing continues with Step a. Otherwise, processing continues with the next step. g. Close the output file. h. Chain to the OS/8 absolute loader (ABSLDR.SV) to load and start the program if the user specified the G option. Otherwise it exits to the OS/8 Monitor. 4.3 LNKCAL The module LNKCAL consists of two program sections. The first section is the master overlay caller. It consists of a series of jumps to LINK's various overlays. The second program section is the overlay driver. This is the code that reads the appropriate overlay into memory and transfers control to it. It is the standard overlay driver found in OVRDRV.MA. 4-4 DESCRIPTIONS OF THE MODULES 4.4 LNKCD The LNKCD overlay accomplishes all interfacing between the program and the OS/8 Command Decoder. It obtains the I/O specifications and options, and determines the amount of memory available. When done, LNKCD passes control to LNKCAL to call the LNKLSD overlay. It performs the following tasks: 1. Clears the temporary map file (MFILE) information and temporary output file (OFILE) information tables, determines the size of available memory, and initializes the pointers to MTAB and NLTAB. (These are temporary working copies of MODTAB and NULTAB respectively.) 2. Calls the Command Decoder to obtain the I/O and control specifications. 3. Verifies and saves the memory image file and memory load map file specifications if they were specified. 4. Obtains the Command Decoder options, verifies them, and passes control to the routines that perform the setup for each option. 5. Places the input module specifications in the module table. 6. Processes the C, D, and V options if specified. 7. Processes the G option and the ESC terminator. If it finds either, it continues processing with Step 8 (below). Otherwise, it continues processing with Step 2 (above). 8. Includes the contents of the library file LNKLIB.RB in the module table if the file resides on the system (SYS:) device. 9. Determines the size of the binary buffer table, section table, and global symbol table. 10. Checks for the T option and processes it if BATCH is running. 11. Returns control to the LNKCAL module to start pass 1. 4.5 LNKMAN LNKMAN is a module that contains two resident program sections, LNKMAN and PAGED. They contain the commonly used subroutines described in Table 4-1 and the page 0 variables. 4-5 DESCRIPTIONS OF THE MODULES Table 4-1 Routines in LNKMAN ---------------------------------------------------------------------- | Routine | Description | |---------------|----------------------------------------------------| | | | | TTYHAN | Sends messages to the terminal. | | | | | TTYO | Sends a character to the terminal. | | | | | CRLF | Sends a RETURN/LF combination to the terminal. | | | | | OS8ER | Sends system errors to the terminal. | | | | | EROUT | Sends fatal error messages to the terminal during | | | pass 1. | | | | | FERR | Sends fatal error messages to the terminal. | | | | | NFERR | Sends non-fatal error messages to the terminal. | | | | | IPTRTB | Initializes the pointer table that equates LSD | | | numbers to GST numbers. | | | | | IOHAN | Interfaces I/O device handlers. It can: | | | o Fetch a handler. | | | o Check for end of file. | | | o Issue a call to a handler. | | | | | GETREF | Retrieves a GST entry number from the pointer | | | table. | | | | | PROBOT | Processes both the LSD preface and the LSD of an | | | input module. | | | | | INQIRE | Determines if a specified device handler is in | | | memory. | | | | | REMOD | Reads in four blocks of data from an input module. | | | | | IMPT | Initializes the input module table pointer and | | | counter. | | | | | ADVPTR | Advances the module table pointer to the next | | | input module. | | | | | PUTGST | Inserts the contents of the AC into the global | | | symbol table. | | | | | NXTBLK | Scans a library file for the next group of LSD | | | block(s) of an input file. | ---------------------------------------------------------------------- (continued on next page) 4-6 DESCRIPTIONS OF THE MODULES Table 4-1 (Cont.) Routines in LNKMAN ---------------------------------------------------------------------- | Routine | Description | |---------------|----------------------------------------------------| | | | | TSTEND | Tests for the end of an input file. | | | | | SKPLIB | Skips over a piece of a library. | | | | | CGSTA | Calculates the address of an entry in the global | | | symbol table, using the GST entry number in the | | | AC. | | | | | PROLSD | Processes the contents of an LSD. | | | | | GETLSD | Obtains a word from an LSD. | | | | | ILSDP | Advances the LSD pickup pointer used in GETLSD to | | | the next entry in the LSD. | | | | | INCPTR | Advances a pointer into the global symbol table to | | | the next entry in the table. | | | | | PROHDR | Processes the LSD header, by passing the LSD | | | preface. | | | | | SEARCH | Searches the GST for a symbol. | | | | | LOOK | Performs the actual symbol table search for the | | | SEARCH subroutine (above). | | | | | TSTBOT | Tests for the bottom (end) of the global symbol | | | table. | | | | | GETGST | Obtains a word from the global symbol table. | | | | | OPRINT | Sends the contents of the AC (in octal) to the | | | terminal. | | | | | PUTPTR | Inserts a GST entry index into the pointer table | | | (PTRTAB). | | | | | SSEC | Searches the section table (SECTAB) for the data | | | in the AC. | | | | | KEYBRD | Implements the CTRL/O, CTRL/C, CTRL/Q, and CTRL/S | | | sequences for the TTYO subroutine. | | | | | FIXCHR | Converts a backslash (\) to a period (.) and a | | | left square bracket ([) to a dollar ($) sign for | | | printing in the symbol table listing. | ---------------------------------------------------------------------- 4-7 DESCRIPTIONS OF THE MODULES 4.6 LNKLSD The overlay LNKLSD creates the global symbol table (GST) and program section table (SECTAB) from the loader symbol dictionaries (LSDs) of the input modules. It begins by processing all nonliterary modules. Thereafter, it searches the user specified libraries (and LNKLIB.RB if it exists) to resolve any undefined symbols. LNKLSD is called by LNKCAL after all input modules have been specified to LNKCD. When done, LNKLSD passes control to LNKCAL to call the LNKALL overlay. It performs the following tasks: 1. Initializes various pointers and counters. 2. Obtains an input module descriptor from the module table (MODTAB) and continues processing with Step 3 (below). If this is a library module, it ignores it and continues processing with Step 6 (below). 3. Processes the LSD header: a. Checks that the file is a relocatable binary (.RB) file. b. Checks the RB specification level (LSD preface code 4). c. Obtains the starting address and job status word (JSW). 4. Processes the LSD text: a. Obtains a symbol from the LSD. b. Searches the GST for the symbol. If it does not find the symbol, it enters the symbol in the GST. If it finds the symbol, it enters the program section in SECTAB and checks for a conflict between this definition and previous definitions. If there is no conflict, processing continues with Step c. Otherwise, the conflict will eventually cause a duplicate definition error. c. Places an index to the GST entry in the pointer table. d. Processes the next LSD entry beginning at Step a (above). Otherwise, it continues processing with Step 5. 5. Resolves all forward references in the GST. 6. Advances the pointers into the module table. If another module exists, processing continues with Step 2 (above). Otherwise, processing continues with the next step. 7. Scans the library modules as follows: 4-8 DESCRIPTIONS OF THE MODULES a. Initializes necessary pointers and counters. b. Obtains an input module descriptor from the module table. If it is a library module, it continues processing with Step c. Otherwise, it continues processing with Step j (below). c. Checks the appropriate library table (LIBTB) word to determine if this piece of the library resides in the GST. If it does, it ignores this module and continues processing with Step g (below). Otherwise processing continues with the next step. d. Reads the LSD for this piece of the library, checking the LSD header's .RB specification level (LSD preface code 4). e. Scans the LSD checking that each symbol resolves a previously undefined symbol. If it cannot resolve a symbol, processing continues with Step g (below). Otherwise processing continues with the next step. f. Processes the LSD using Steps 4 and 5 (above). g. Advances all necessary pointers to process the next piece of the library (Step c above). If there is no more library input, processing continues with the next step. h. Processes undefined symbols that remain (the next step). If there are no more symbols to define, it continues processing with Step 8 (below). i. Determines if any symbol was resolved during the current pass over this library. If this is true, processing continues with Step c (above). Otherwise, processing continues with the next step. j. Advances all necessary pointers and counters. If there is another input module, processing continues with Step b (above). Otherwise, it displays all undefined symbols on the terminal and continues processing with the next step. 8. Adjusts all pointers in SECTAB to point forward to the GST word that contains the program section restriction (if any). 9. Sorts independent program sections that restrict other program sections so they reside at the top of their overlay. 10. Sorts the null table (NULTAB) by field and page so that the first entry contains the lowest field and page. 11. Returns control to LNKCAL to start the allocating memory to the user's program. 4-9 DESCRIPTIONS OF THE MODULES 4.7 LNKMSG The overlay LNKMSG contains the error reporting routines for most of the fatal errors that LINK encounters. It also contains the error message text. 4.8 LNKMAP The overlay LNKMAP creates a load map of the program (if requested) while resolving entry point and global symbol addresses in the GST. It obtains the starting address, job status word, and memory load map file I/O specifications from the Command Decoder. LNKMAP is called by LNKCAL after LNKALL has allocated memory for all program sections. When done, LNKMAP passes control to LNKCAL to call the LNKBN1 overlay. It performs the following tasks: 1. Sets up the user-provided starting address if the S option was specified. 2. Sets up the user-provided job status word (JSW) if the W option was specified. 3. Produces a memory load map, if the user provided an appropriate file specification. LNKMAP performs the following steps: a. Sorts the program section table (SECTAB) by address, field, and overlay level. b. Sends all undefined and absolute global symbols to the memory load map file. c. Obtains a SECTAB pointer into the GST. d. Sends the program section's name, value, and length to the memory load map file. e. Resolves the program section's entry point and global symbol addresses in the GST and sends the names and values to the memory load map file. f. Performs Steps c through e for all entries in SECTAB. g. Sends the user-provided starting address and job status word to the memory load map file. 4. Passes control back to LNKCAL to start generating the program's memory image. 4-10 APPENDIX A CHARACTER SETS Table A-1 shows the special 6-bit character set used by MACREL for most symbol table storage. Table A-2 shows the standard 6-bit and 7-bit ASCII character set used by both MACREL and LINK for all other operations. Table A-1 MACREL Special 6-bit Character Codes ---------------------------------------------------------------------- | Code | Meaning | |-------------------|------------------------------------------------| | | | | 0 | padding | | 1-32 | A through Z | | 33 | $ (dollar sign) | | 34 | . (period) | | 35 | reserved | | 36 or 76 | extended symbol name definition | | 37 | reserved | | 40 | reserved | | 41-72 | $A through $Z (if first character in symbol) | | 60-71 | 0 through 9 (if not first character in symbol) | ---------------------------------------------------------------------- Table A-2 ASCII Character Set ---------------------------------------------------------------------- | 7-Bit | 6-Bit | Character/ | Remarks | | Octal | Octal | Control Code | | |--------|-------|--------------|------------------------------------| | | | | | | 000 | | NUL | Fill character - ignored on input | | 001 | | SOH | | | 002 | | STX | | | 003 | | ETX | CTRL/C - Return control to monitor | | 004 | | EOT | | | 005 | | ENQ | | | 006 | | ACK | | | 007 | | BEL | CTRL/G - Sound audible signal | | 010 | | BS | | ---------------------------------------------------------------------- (continued on next page) A-1 CHARACTER SETS Table A-2 (Cont.) ASCII Character Set ---------------------------------------------------------------------- | 7-Bit | 6-Bit | Character/ | Remarks | | Octal | Octal | Control Code | | |--------|-------|--------------|------------------------------------| | | | | | | 011 | | HT | CTRL/I - HT (horizontal tab) | | 012 | | LF | CTRL/J - LF (new line) | | 013 | | VT | CTRL/K - VT (vertical tab) | | 014 | | FF | CTRL/L - FF (form feed) | | 015 | | CR | CTRL/M - CR (cursor or carriage | | | | | return) | | 016 | | SO | | | 017 | | SI | CTRL/O - Abort current terminal | | | | | output | | 020 | | DLE | | | 021 | | DC1 | CTRL/Q - Disable terminal output | | 022 | | DC2 | | | 023 | | DC3 | CTRL/S - Enable terminal output | | 024 | | DC4 | CTRL/T - Display job status | | 025 | | NAK | CTRL/U - Delete current input line | | 026 | | SYN | CTRL/V | | 027 | | ETB | CTRL/W | | 030 | | CAN | CTRL/X | | 031 | | EM | CTRL/Y | | 032 | | SUB | CTRL/Z - End of file | | 033 | | ESC | ALTMODE | | 034 | | FS | | | 035 | | GS | | | 036 | | RS | | | 037 | | US | | | 040 | 40 | SP | Space | | 041 | 41 | ! | Exclamation point | | 042 | 42 | " | Quotation mark | | 043 | 43 | # | | | 044 | 44 | $ | Dollar sign | | 045 | 45 | % | Percent sign | | 046 | 46 | & | Ampersand | | 047 | 47 | ' | Apostrophe | | 050 | 50 | ( | Left parenthesis | | 051 | 51 | ) | Right parenthesis | | 052 | 52 | * | Asterisk | | 053 | 53 | + | Plus sign | | 054 | 54 | , | Comma | | 055 | 55 | _ | Hyphen or minus sign | | 056 | 56 | . | Period | | 057 | 57 | / | Slash (right) | | 060 | 60 | 0 | | | 061 | 61 | 1 | | | 062 | 62 | 2 | | ---------------------------------------------------------------------- (continued on next page) A-2 CHARACTER SETS Table A-2 (Cont.) ASCII Character Set ---------------------------------------------------------------------- | 7-Bit | 6-Bit | Character/ | Remarks | | Octal | Octal | Control Code | | |--------|-------|--------------|------------------------------------| | | | | | | 063 | 63 | 3 | | | 064 | 64 | 4 | | | 065 | 65 | 5 | | | 066 | 66 | 6 | | | 067 | 67 | 7 | | | 070 | 70 | 8 | | | 071 | 71 | 9 | | | 072 | 72 | : | Colon | | 073 | 73 | ; | Semicolon | | 074 | 74 | < | Left angle bracket or less than | | | | | sign | | 075 | 75 | = | Equals sign | | 076 | 76 | > | Right angle bracket or greater | | | | | than sign | | 077 | 77 | ? | Question mark | | 100 | 00 | @ | At sign (null in 6-bit) | | 101 | 01 | A | | | 102 | 02 | B | | | 103 | 03 | C | | | 104 | 04 | D | | | 105 | 05 | E | | | 106 | 06 | F | | | 107 | 07 | G | | | 110 | 10 | H | | | 111 | 11 | I | | | 112 | 12 | J | | | 113 | 13 | K | | | 114 | 14 | L | | | 115 | 15 | M | | | 116 | 16 | N | | | 117 | 17 | O | | | 120 | 20 | P | | | 121 | 21 | Q | | | 122 | 22 | R | | | 123 | 23 | S | | | 124 | 24 | T | | | 125 | 25 | U | | | 126 | 26 | V | | | 127 | 27 | W | | | 130 | 30 | X | | | 131 | 31 | Y | | | 132 | 32 | Z | | | 133 | 33 | [ | Left square bracket | | 134 | 34 | \ | Backslash | ---------------------------------------------------------------------- (continued on next page) A-3 CHARACTER SETS Table A-2 (Cont.) ASCII Character Set ---------------------------------------------------------------------- | 7-Bit | 6-Bit | Character/ | Remarks | | Octal | Octal | Control Code | | |--------|-------|--------------|------------------------------------| | | | | | | 135 | 35 | ] | Right square bracket | | 136 | 36 | ^ | Circumflex | | 137 | 37 | _ | | | 140 | 40 | ` | Grave accent | | 141 | 41 | a | | | 142 | 42 | b | | | 143 | 43 | c | | | 144 | 44 | d | | | 145 | 45 | e | | | 146 | 46 | f | | | 147 | 47 | g | | | 150 | 50 | h | | | 151 | 51 | i | | | 152 | 52 | j | | | 153 | 53 | k | | | 154 | 54 | l | | | 155 | 55 | m | | | 156 | 56 | n | | | 157 | 57 | o | | | 160 | 60 | P | | | 161 | 61 | q | | | 162 | 62 | r | | | 163 | 63 | s | | | 164 | 64 | t | | | 165 | 65 | u | | | 166 | 66 | v | | | 167 | 67 | w | | | 170 | 70 | x | | | 171 | 71 | Y | | | 172 | 72 | z | | | 173 | 73 | { | | | 174 | 74 | | | | | 175 | 75 | } | | | 176 | 76 | ~ | Tilde | | 177 | 77 | DEL | RUBOUT | ---------------------------------------------------------------------- A-4 APPENDIX B MACREL MAINTENANCE PROCEDURES This appendix provides you with some general guidelines for maintenance and for diagnosing problems with MACREL. One general technique is to use the DUMP: handler as the binary output file during assembly. This allows you to obtain a listing of the assembled binary. The OS/8 System Reference Manual provides more information about DUMP:. Another useful diagnostic tool is to obtain a memory dump of the parts of MACREL that are currently in memory. This procedure is especially useful when checking the integrity of the symbol table. By examining the symbol table and the bucket pointers you can easily follow the chunk chains through memory, since each chunk begins with a pointer to the next chunk. To do this, restart OS/8 at location 7600 and save memory as follows: .SAVE SYS CORDMP 16000-17577,20000-27577,nnnnn-mmmmm,... where: mmmmm-nnnnn represents other areas of memory that you wish to dump You can print the CORDMP.SV file on the line printer, using PIP and the DUMP: handler. If MACREL halts, it is important to determine which overlays are in memory. You can do this easily by examining the first word in each overlay region (See Table E-1). Bits 7 through 11 of this word specify the number of the overlay that is currently resident in that region. You can determine the line currently being processed by examining the input buffer located LINBUF (MACIO). You can determine the input coroutine currently being used by examining NEXTCHAR (MAC24). B-1 APPENDIX C SUMMARY OF MACREL'S MAJOR MODULES Name Overlay Description AINIT FIN5 Sets the initial values at the start of each pass. ASEMBL MAC24 Controls the parsing of input lines. ASEMLV MAC24 Sends the currently assembled statement to OUTDATA. BACKL EXPOVR Processes backslashes (\) and forward slashes (/). BACKSL MAC24 Processes a backslash (\) in a symbol. BACKUP MAC24 Moves the line buffer pointer back to the previous character. BINFO OVRQ Sends the macrel fish caricature to the listing file. BLKLET OVRQ Sets up the block letter printer. BPUT MAC2 Stores the PC in the current page. BPUTX PAS2 Sends the binary word and flag field to the binary buffer and starts a new flag word if necessary. BRAN MAC24 Performs a branch-on-condition. BRANCH MAC24 Performs a branch-on-matching-character. CALLIT MAC24 Implements cross-field subroutine calls. CHKFUL PAS2 Sends the binary buffer, when full, to the binary file. CHKKBD MACERR Checks to see if a CTRL/C, CTRL/S, CTRL/O, E, F, or L was typed. (continued on next page) C-1 SUMMARY OF MACREL'S MAJOR MODULES Name Overlay Description CMNMOV MACLIT Obtains the next literal value from either the Current Page Literal Table or the Page 0 Literal Table. CNVADR MAC24 Converts a 15-bit pointer into a CDF instruction and a 12-bit address. CONV MACIO Converts a 15-bit pointer into a CDF instruction and a 12-bit address. CORE MACINI Determines the real physical memory size. CPYTOC FIN5 Copies the table-of-contents to the listing file. CREATE MACRO Fetches a new chunk from FREESPACE to be used for macro space. CREF MAC24 Sends a symbol name and its line number to the cross-reference file. CREFX PAS2 Creates a cross-reference listing file. CRLF MAC30 Sends a RETURN and LF to the listing file. CRLFF MACERR Sends a RETURN and LF to OUTDEY. CTRLC MAC24 Implements CTRL/C exit to the OS/8 Monitor. DATE MACINI Obtains the current OS/8 system date. DELETE MACIO Deletes characters from macro space. DELITE MACRO Deletes the old macro definition upon redefinition. DIGIT MAC24 Determines if a character is a digit. DPRINT MAC30 Sends a decimal number to NPRINT. ENTER MAC24 Enters a symbol into the symbol table. EOS MAC24 Determines if the current character is a statement delimiter. EQL MAC24 Implements the direct assignment (=) operator. ERROR MAC24 Processes calls to print error messages. (continued on next page) C-2 SUMMARY OF MACREL'S MAJOR MODULES Name Overlay Description EXPOVR OVRZ Implements the uparrow (^), backslash (\), single quote ('), and percentage (%) symbols in expressions. EXPSTK MACIO Expression stack. FIN2 FIN2 Performs end of passes 1, 2, and 4 processing. FIN3 FIN3 Prepares the symbol table for printing. FINI MAC24 Loads overlay 22 (OVRR) for end-of-pass processing. FINMS MACRO Terminates storage into macro space. FINIO MACIO Initializes the binary output file for the Loader Symbol Dictionary (LSD). FSCHEK MAC24 Checks the current value for .FSECT relocatability. GENUN MACLIT Creates Page 0 literals for unnamed .ASECTs. GET MAC24 Obtains a character from the line buffer. GETCHR MAC24 Obtains a character and its type code from the line buffer. GETEX MAC24 Parses a single expression. GETFLG PAS2 Starts a new flag word. GETLSD MAC24 Obtains the LSD number of a specified entry. GETKAR MAC24 Obtains a character from the line buffer. GETOS MACIO Gets characters from the stream input buffer. GETSYM MAC24 Obtains a symbol table entry from the symbol table. GLOB2 OVRE Processes globals (general global processing). HGHSCT MAC24 Obtains the highest address used by a program section. (continued on next page) C-3 SUMMARY OF MACREL'S MAJOR MODULES IDIV EXPOVR Performs division. IGNORE MAC24 Ignores the current input line up to the end-of-line. IMUL EXPOVR Performs multiplication. INITMP MACRO Initializes the macro processor at the start of each pass. INITMS MACRO Initializes a new chunk for storage. IOINIT MACIO Initializes the input coroutines and their switching mechanism. IONIT2 MACIO Initializes variables to prepare for first input file. KLU4 MAC24 Obtains the lowest address used by an .ASECT. KLU10 MACLIT Patch to PURGEL. KRFCHN OVRT Chains to KREF after assembly is complete. LETTER MAC24 Determines if the current character is a letter or a symbol. LIMSET MACINI Sets up the memory limit table. LIST MAC30 Sends the entire line to LISTER. LISTER MAC3R Sends characters to the listing file. LOAD MAC24 Loads MACREL's internal overlays. LOCPOP MACIO Removes (pops) coroutine local variables from the stream stack. LOCPSH MACIO Places (pushes) coroutine local variables on the stream stack. LOOKU MACIO Searches a device for a file. LOOKUP MAC24 Searches the symbol table for symbol. LOOP MAC24 Controls the entire assembly process (main loop routine). LNKCHN OVRT Chains to LINK and KREF (if requested) after assembly is complete. LPATCH MAC24 (continued on next page) C-4 SUMMARY OF MACREL'S MAJOR MODULES LSDINI FIN2 Sends the Loader Symbol Dictionary preface to the binary file. LSDOUT FIN2 Sends the Loader Symbol Dictionary entry to the binary file. LSTRET MACIO Obtains a character to be sent to the listing file. MACTBL (MACORG) Character branch table. MATCH MACRO Checks the current symbol for a match against a keyword list. MC MACMAC Implements a .MACRO call. MGET MACIO Obtains text from .MACRO and .MACRO argument space. MORCRF PAS2 Sends cross-reference information about literals to the cross-reference file (KREF). MS MACRO Stores a word in the current location in macro space. NEWPAG MAC3R Sets up a new listing page for printing. NEX MAC24 Controls start of all passes. NEXTCHAR MAC24 Obtains next character from current input stream NEXTT FIN0 Performs beginning of pass initialization. NUMLCL MAC24 Processes numeric local labels. OFETCH MACOPN Loads the output device handler. (MACIO) OFIX MACIO Refetches a device handler for OGET. OGET MACIO Gets a character from the stream input buffer. ONCE MACINI Initializes the assembler during initial startup. OPEN MACOPN Opens an output file. OPEN1 FIN0 Opens the table-of-contents file (pass 1). OPEN2 FIN0 Opens the binary output file (pass 2). (continued on next page) C-5 SUMMARY OF MACREL'S MAJOR MODULES OPEN3 FIN0 Opens the listing file (pass 3). OPEN4 FIN0 Opens the cross-reference listing file (pass 4). OPENTC MACOPN Sets up the listing file to receive the table of contents. OPRINT MAC30 Sends an octal number to NPRINT. ORIG MAC2 Sets up the flag word and sends the PC to the binary output file. ORIGI MACORG Sets the current location (program) counter (PC) OUT MAC3R Sends a line to the listing file. OUTBLK OVRQ Sends the block letter heading to the listing file. OUTDATA MAC24 Sends binary data to the binary file. OUTDEY MACERR Contains the name of the current output device (either PR or LPUT). OUTLST MACIO Packs the output buffer with characters. OVRLIN MAC3R Allows listing file page overflow. PART2 MACMAC Stores the body of a macro in macro space. PASS3 MAC3R Tests if this is pass 3. PARSYM MAC24 Parses a symbol. POP MAC24 Removes a character from expression stack. PR MACERR Sends a character to the BATCH 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. PR2 MACERR Sends two 6-bit ASCII characters to PR. PR6 MACERR Prints one 6-bit ASCII character using PR. PR6A MACERR Prints a 6-bit ASCII character on the output device. PR12 MACERR Prints one 12-bit number as 4 octal digits, using PR. (continued on next page) C-6 SUMMARY OF MACREL'S MAJOR MODULES PRCHR MACERR Prints single characters on the output device. PREFIN OVRR Performs pre-end-of-pass tasks. PREFORM MACINI Formats unused memory into chunks of FREESPACE. PRINTY MAC30 Sends PC, binary data, and its qualifiers to the print routine. PRLINO MAC2 Prints the line number on the assembly listing. PRGLIT MAC24 Uses PURG to load MACLIT overlay to purge current page literals. PRGSPL MACLIT Purges the Page 0 literals in an unnamed .ASECT. PRN FIN3 Sends a symbol name to the listing file. PRNAM MACERR Sends a 6-character name to the output device. PRNBIN MAC30 Sends binary code to listing file. PRNDSH MAC30 Sends five dashes (-) to listing file. PRNT2 FIN3 Sends two packed 6-bit characters to the listing file. PRNT6 FIN3 Sends one 6-bit character to the listing file. PRZLIT MAC24 Uses PURG to load MACLIT overlay to purge Page 0 literals. PUNBIT MAC2 Sends a binary word and its flag field to the binary output file. PUNY MAC2 Determines whether this is pass 2 and whether binary output is enabled. PURGEL MACLIT Purges literals from a literal pool. PUSH MAC24 Saves a character on the expression stack. PUTB MAC2 Calls PUTBT if this is pass 2 and if binary output is enabled. (continued on next page) C-7 SUMMARY OF MACREL'S MAJOR MODULES PUTBIT MAC2 Sends a binary entry without a flag field to the binary file. PUTBN PAS2 Sends a binary word and its flag field to the binary buffer. PUTBT PAS2 Sends a binary word to the binary buffer. PUTBUF MACIO Sends a bufferful of characters to the listing device. PUTLC MAC2 Sends a loader code to the binary file if this is pass 2 and binary output is enabled. PUTSYM MAC24 Inserts symbol table information into the symbol table. PUXBIN MAC2 Sends a binary word and its flag field to the binary output file. READLN MAC24 Reads a line of text from the current stream into the input buffer. READOS MACIO Reads characters from the input file into the input buffer. REIT FIN5 Completes a return after opening an output file. RENEW MACRO Resets the character scan to the beginning of the line. RGET MACIO Obtains text from .REPEAT storage space. ROTL6 MAC24 Performs a six-bit, left-shift operation. SCAN MAC24 Skips over spaces and tabs. SETIT MAC24 Creates a new title or subtitle from the current line. SETNAM MACERR Sets up a name to be printed by PRNAM. SETT MAC30 Sets up a new title from current line. SKSEP MACRO Skips past a sequence of spaces and/or tabs. SNGLQQ EXPOVR Processes single quotation marks ('). SPOP MACIO Removes (pops) arguments from any stack. SPUSH MACIO Places (pushes) arguments on any stack. (continued on next page) C-8 SUMMARY OF MACREL'S MAJOR MODULES STNAM MACERR Sets up a symbol table name for printing. STORMS MACRO Stores the AC in macro space. STPRNT FIN3 Sends a physical page of symbol table information to the listing file. STRSTK MACIO Pushdown stack for input coroutine switching. SWBACK MACIO Controls switching of the input stream coroutines back to the previous stream. SWITCH MACIO Controls switching of the input stream coroutines. SYMINI MACINI Builds the run-time symbol table. TAB MAC30 Sends a tab character to the listing file. TAGCOL MAC24 Processes a tag ending with a colon (:). TAGCOM MAC24 Processes a tag ending with a comma(,). TASKY OVRC Implements the obsolete .TASK directive. TP MACERR Sends a character (unconditionally) to the terminal. TPUT MACERR Sends a character (unconditionally) to the BATCH log device. TSTEOL MACRO Tests an end-of-line character. TSTMAC MAC24 Checks whether a symbol is a macro call. TSTQUOTE MACRO Tests for a double quotation mark ("). TSTTERM MACRO Tests for a terminator (slash, semicolon, or end-of-line). TYPE MACERR Prints a 6-bit character or RETURN/LF (if NUL character) on OUTDEY. TYPERR MACERR Sends an error message to the error log (TTY or BATCH log file.). UNNAM MAC2 Creates and names an unnamed .ASECT. UPAROQ EXPOVR Processes the temporary radix operators (^B, ^D, and ^0). USRSTK MACIO .PUSH and .POP directive stack (OVRU). (continued on next page) C-9 SUMMARY OF MACREL'S MAJOR MODULES XPRINT FIN3 Sends a symbol's binary value to the listing file. ZGET MACIO Sends CTRL/Zs to the input stream. ZINIT MACIO Initializes the .MACRO processor. ZL MACLIT Dumps the Page 0 literal pool. ZLIT MACLIT Purges the Page 0 literal pool. ZPAD FIN2 Pads the binary buffer with CTRL/Zs. ZSECTG MACLIT Creates Page 0 literals. $ASECT OVRD Implements the .ASECT directive. $CDF MACEXP Implements the CDF special operator. $CHAIN OVRE Implements the .CHAIN directive. $CIF MACEXP Implements the CIF special operator. $DECIMA OVRC Implements the DECIMAL directive. $DEVICE OVRC Implements the DEVICE directive. $DISABL OVRC Implements the .DISABLE directive. $DOT MACEXP Implements the period (.) special operator. $DSECT OVRD Implements the .DSECT directive. $EDF MACEXP Implements the EDF special operator. $EJECT OVRU Implements the EJECT directive. $ENABLE OVRC Implements the .ENABLE directive. $ENPUNC OVRR Implements the ENPUNCH directive. $ENTRY OVRE Implements the .ENTRY directive. $EXPNG OVRS Implements the EXPUNGE directive. $EXTERN OVRE Implements the .EXTERNAL directive. $FIELD OVRT Implements the FIELD directive. $FILENA OVRC Implements the FILENAME directive. $FIXMRI MAC24 Implements the FIXMRI directive. (continued on next page) C-10 SUMMARY OF MACREL'S MAJOR MODULES $FIXTAB OVRS Implements the FIXTAB directive. $FLD MACEXP Implements the .FLD special operator. $FSECT OVRD Implements the .FSECT directive. $GLOBAL OVRE Implements the .GLOBAL directive. $I MACEXP Implements the I special operator. $IF OVRB Implements IF directive. $IFDEF OVRB Implements the IFDEF directive. $IFNDEF OVRB Implements the IFNDEF directive. $IFNZRO OVRB Implements the IFNZRO directive. $IFZERO OVRB Implements the IFZERO directive. $INCLUD OVRE Implements the .INCLUDE directive. $JSW OVRR Implements the .JSW directive. $LEVEL MACEXP Implements the LEVEL keyword. $LIST OVRR Implements the .LIST directive. $MACRO MACMAC Processes the header of a .MACRO definition. $MEXIT MACMAC Implements the .MEXIT directive. $NARGS MACMAC Implements the .NARGS special operator. $NCHARS MACEXP Implements the .NCHARS special operator. $NOLIST OVRR Implements the .NOLIST directive. $NOPUNC OVRR Implements the NOPUNCH directive. $OCTAL OVRC Implements the OCTAL directive. $PAGE OVRA Implements the PAGE directive. $PAUSE MAC24 Ignores PAL8 PAUSE directives. $POP OVRU Implements the .POP directive. $PUSH OVRU Implements the .PUSH directive. $RADIX OVRC Implements the RADIX directive. (continued on next page) C-11 SUMMARY OF MACREL'S MAJOR MODULES $RELOC OVRU Implements the RELOC directive. $REPT MACMAC Implements the the .REPT directive. $RSECT OVRD Implements the .RSECT directive. $SBTTL OVRU Implements the .SBTTL directive. $SECREF OVRE Implements the .SECREF directive. $SECT OVRD Implements the .SECT directive. $START OVRR Implements the .START directive. $TEXT OVRA Implements the TEXT directive. $TITLE OVRU Implements the .TITLE directive. $VERSIO OVRR Implements the .VERSION directive. $XEDF MACEXP Implements the XEDF special operator. $XLIST OVRR Implements the XLIST directive. $XSECT OVRD Implements the .XSECT directive. $Z MACEXP Implements the Z special operator. $ZBLOCK OVRA Implements the ZBLOCK directive. $ZSECT OVRD Implements the .ZSECT directive. $ZTRNA OVRE Implements the .ETERNAL directive. C-12 APPENDIX D BATCH FILES FOR ASSEMBLING AND LINKING MACREL, LINK, AND KREF This appendix shows you the basic sequence of steps necessary to build the MACREL, LINK, and KREF source modules into executable files. It consists of a listing example of an OS/8 BATCH command file (Figure D-1) that assembles and links MACREL, LINK, and KREF. The file also includes previously unpublished binary patches that update MACREL to version V2C and LINK to version V2AG. You will find more binary patches published in the issues of the Digital Software News (DSN) beginning June/July 1979. The output files that result from this process are the MACREL.SV, LINK.SV, and KREF,SV files and the LINK map listings for MACREL, LINK, and KREF. If you wish to obtain assembly and cross-reference (KREF) listings, you must modify each command line that invokes MACREL to include the appropriate command string options and listing file specification (refer to the MACREL/LINK User's Manual). For example, _________________________ the following command lines send the listing for PAS2 to the line printer. .R MACREL *DEV:PAS2,LPT: FREESPACE (see note below) | | 50000-57767 | | | | | | 60000-67767 | | | | | | 70000-77767 | | | / | ---------------------------------------------------------------------| NOTE 1. If OS/8 BATCH is running and the Z option is not specified, locations higher than 5000 in the field where BATCH resides will not be used. 2. If the system device handler is a 2-page handler, the high page in field 2 will not be used. 3. If there is more than 12K words of memory and the Y option is not specified, locations lower than 4000 will not be used. E-3 MEMORY UTILIZATION AND MODULE SUMMARY 4. The number of memory fields available to MACREL depends on both the hardware and the software memory size. Table E-2 Overlay Module Data Summary ---------------------------------------------------------------------- | | Overlay | | Module|------------------------------------------------------------| | Name |Name| No.|Address| Area | Description | |-------|----|----|-------|------------|-----------------------------| | | | | | | | | OVRA |OVRA| 01 | 2000 | Directives | PAGE, ZBLOCK, TEXT | | | | | | | | | OVRB |OVRB| 02 | 2000 | Directives | .IF, .IFDEF, .IFNDEF, | | | | | | | .IFZERO, .IFNZRO | | | | | | | | | OVRC |OVRC| 03 | 2000 | Directives | Radix control, FILENAME, | | | | | | | DEVICE, .ENABLE, .DISABLE | | | | | | | | | OVRD |OVRD| 04 | 2000 | Directives | .SECT, .ASECT, .RSECT, | | | | | | | .FSECT, .DSECT, .XSECT, | | | | | | | .ZSECT | | | | | | | | | OVRE |OVRE| 05 | 2000 | Directives | .INCLUDE, .CHAIN | | | | | | | | | MACRTH|OVRF| 06 | 2400 | Auxiliary | Global arithmetic | | | | | | | | | MACORG|OVRG| 07 | 2400 | Directives | Origin | | | | | | | | | FIN0 |OVRH| 10 | 6400 | Extremities| Pass initialization | | | | | | | | | FIN3 |OVRI| 11 | 2000 | Directives | Symbol table extension | | | | | | | | | FIN2 |OVRJ| 12 | 6400 | Extremities| Pass 1,2,4 FIN code | | | | | | | | | FIN3 |OVRK| 13 | 6400 | Extremities| Pass 3 FIN code | | | | | | | | | FIN2 |OVRL| 14 | 2000 | Directives | Passes 2,4 FIN code | | | | | | | extension | | | | | | | | | MAC30 |OVRM| 15 | 1400 | Pass- | Pass 1 and 3 specific code | | | | | | specific | | | | | | | | | | PAS2 |OVRN| 16 | 1400 | Pass- | Pass 2 _4 specific code | | | | | | specific | | | | | | | | | | ---------- | 17 | ---------------- | Patch area ------------- | | | | | | | | | ---------- | 20 | ---------------- | Unused ----------------- | ---------------------------------------------------------------------- (continued on next page) E-4 MEMORY UTILIZATION AND MODULE SUMMARY Table E-2 (Cont.) Overlay Module Data Summary ---------------------------------------------------------------------- | | Overlay | | Module|------------------------------------------------------------| | Name |Name| No.|Address| Area | Description | |-------|----|----|-------|------------|-----------------------------| | | | | | | | | OVRQ |OVRQ| 21 | 2000 | Directives | Block-letter printer | | | | | | | | | OVRR |OVRR| 22 | 2000 | Directives | Listing directives pre-FIN | | | | | | | overlay .START, .JSW, | | | | | | | .VERSION, NOPUNCH, ENPUNCH | | | | | | | | | OVRS |OVRS| 23 | 2000 | Directives | FIXTAB, EXPUNGE | | | | | | | | | OVRT |OVRT| 24 | 2000 | Directives | Block letter printer, chain | | | | | | | to LINK | | | | | | | | | OVRU |OVRU| 25 | 2000 | Directives | TITLE, SBTITLE, RELOC, | | | | | | | .PUSH, .POP | | | | | | | | | MACMAC|OVRV| 26 | 2000 | Directives | Macro definition header | | | | | | | | | MACMAC|OVRW| 27 | 2000 | Directives | Macro definition body .REPT | | | | | | | | | MACMAC|OVRX| 30 | 2000 | Directives | Macro invocation | | | | | | | | | MACLIT|OVRY| 31 | 2400 | Auxiliary | Literal purger | | | | | | | | | EXPOVR|OVRZ| 32 | 2400 | Auxiliary | Implements ^, \, ', % | | | | | | | in expressions | | | | | | | | | MACOPN| | 33 | 2000 | Directives | FIN0 extension | | | | | | | | | OVRQ | | 34 | 2000 | Auxiliary | Block-letter data | | | | | | | | | OVRD | | 35 | 2400 | Auxiliary | OVRD extension for .SECT | | | | | | | overlay control arguments | ---------------------------------------------------------------------- E-5 APPENDIX F MACREL COMMAND DECODER OPTIONS Option Function /A Deletes PDP-8/E symbols /B Prints listing file name in block letters /C Chains to KREF /E Enables error if links are generated /F Sends fast (brief) TTY error messages /G Chains to LINK after assembly and begins program execution /H Passed to LINK /J Does not list unsatisfied conditional code /L Chains to LINK after assembly /M Includes the permanent symbols in the KREF output file /N Lists symbol table only /O Eliminates macro generation capability /P Resets line numbers to 0 for each page in the listing /Q Adds MQ (EAE) symbols /R Eliminates PAL8 symbols /S Omits symbol table from listing /V Passed to LINK /W Passed to LINK /X Sends extended TTY error messages /Y Cancels resident overlays /Z Eliminates BATCH /0-7 Passed to LINK /8 Passed to LINK /9 Passed to LINK /=N Adjusts listing width F-1 APPENDIX G DISCUSSION OF SELECTED ROUTINES IN LINK G.1 ADJPTR (LNKLSD) The routine ADJPTR adjusts SECTAB reference pointers to be forward pointers. It also adjusts chained reference pointers to point to the first reference. For example, it would change the condition: B references A and C references B to: B references A and C references A. G.2 ALLOC (LNKALL) The subroutine ALLOC uses SECTAB and the buffer (CIMAGE) to allocate memory to each program section. Beginning with the first entry in SECTAB, it performs the following steps: 1. Searches CIMAGE for the smallest available memory segment that meets the field, PC, and length requirements of the current program section. 2. Allocates memory to that section. 3. Updates CIMAGE. 4. Scans the remainder of SECTAB for entries that reference the current entry and allocates memory to them at this time. If a program section does not fit into memory, its entry in SECTAB is flagged by ALLOC and the allocation process is restarted with the scan by SECTAB. G.3 BULDTV (LNKBN2) BULDTV generates the overlay transfer vectors. It creates a transfer vector for each symbol in an overlay that is declared to be an entry (.ENTRY). The vector provides the information needed to load the overlay containing the referenced routine. G-1 DISCUSSION OF SELECTED ROUTINES IN LINK G.4 CPIC (LNKALL) The subroutine CPIC creates the memory image tables in the CIMAGE buffer area according to the user-specified Command Decoder options. The argument in the routine's calling sequence specifies the largest field in the memory picture. It exits through the error return when the argument exceeds the number of the highest available memory field. The calling sequence is shown below: (AC = 0) JMS CPIC arg error return where: arg is the number of the highest field to be included in memory allocation error is the error return address return is the normal return address G.5 NEWBB (LNKBN2) The subroutine NEWBB is called whenever a new binary output buffer is needed during loader image file construction. NEWBB scans the list of available buffers and dumps the contents of the least recently accessed buffer to make room for a new buffer. G.6 NEWORG (LNKBN2) NEWORG is called whenever it finds a reference to the current location counter in an input module. It maps the referenced location into a block of the loader image file. It calls NEWBB when a new binary buffer is needed. G.7 PUTBIN (LNKBN2) PUTBIN inserts words, sequentially, into the current binary buffer. When the buffer is full, it calls NEWBB to send the buffer's contents to the memory image file and to supply a new buffer. G-2 DISCUSSION OF SELECTED ROUTINES IN LINK G.8 RELOCA (LNKBN2) RELOCA relocates an entire input module, executing calls to NEWORG and PUTBIN. G.9 SEARCH (LNKMAN) The routine SEARCH searches the GST for a symbol. (During pass 1, undefined symbols are added to the table.) If a symbol is not a defined symbol, the GST entry is flagged as undefined and the count of undefined symbols is incremented. If the symbol was found and this is defined, the definition is put in the GST and the count of undefined symbols is decremented. An attempt to redefine a symbol will cause an error. During pass 2 an unsuccessful search results in an error return. A successful search returns with the symbol's GST entry number in the AC. The calling sequence is: JMS SEARCH pass number error return normal return (AC=0 in pass 1) (AC=PTR in pass 2) G.10 SSORT (LNKALL, LNKLSD, and LNKMAP) SSORT performs an all-purpose bubble sort. Its calling sequence is: JMS SSORT argl - the address of the table to be sorted arg2 - length of table arg3 - length of table entry arg4 - the word to sort arg5 - word mask (for example, 7600) arg6 - type of comparison (for example, SNA) return address G-3 INDEX A D ADJPTR, G-1 DATE, 2-33 AINIT, 2-11 $DECIMA, 2-75 ALLOC, G-1 DELETE, 2-42 .ASECT symbol table entry $DEVICE, 2-76 format, 1-13 DIGIT, 2-63 ASEMBL, 2-62 $DISABL, 2-77 ASEMLV, 2-62 DPRINT, 2-67 Auxiliary symbol table chunk .DSECT symbol table entry entry format, 1-15 format, 1-14 B E BACKL, 2-2 $EJECT, 2-85 BACKSL, 2-57 $ENABLE, 2-76 BACKUP, 2-60 $ENPUNC, 2-83 Binary buffer table (LDBUFS), 3-4 ENTER, 2-66 BINFO, 2-82 $ENTRY, 2-80 BLKLET, 2-81 EOS, 2-64 BPUT, 2-53 EQL, 2-60 BPUTX, 2-88 ERROR, 2-57 BRAN, 2-61 Error Typeout Routines, 2-26 BRANCH, 2-61 EXPOVR, 2-2 BULDTV, G-1 EXPR, 2-29 $EXPUNGE, 2-84 $EXTERN, 2-80 C .EXTERNAL symbol table entry format, 1-13 CALLIT, 2-64 $CHAIN, 2-79 F CHKFUL, 2-87 CMNMOV, 2-46 CNVADR, 2-55 $FIELD, 2-85 CONV, 2-42 $FILENA, 2-75 CORE, 2-34 FIN0, 2-7 Core image table (CIMAG, CIMAG1, FIN2, 2-14 CIMAG2, CIMAGE), 3-8 FIN3, 2-20 CPIC, G-2 FIN5, 2-10 CPYTOC, 2-12 FINI, 2-60 CREF, 2-65 FINIO, 2-19, 2-37 CREFX, 2-88 $FIXMRI, 2-59 CRLF, 2-67 $FIXTAB, 2-84 CTRLC, 2-60 .FSECT symbol table entry format, 1-15 Index-1 INDEX (CONT.) G L GENUN, 2-44 LETTER, 2-63 GET, 2-60 Library table (LIBTB), 3-12 GETCHR, 2-60 LIMSET, 2-34 GETEX, 2-62 LIST, 2-68 GETFLG, 2-88 $LIST, 2-83 GETKAR, 2-65 LISTER, 2-70 GETLSD, 2-55 LISTOR, 2-42 GETOS, 2-39 LNKALL, 4-1, G-1, G-2, G-3 GETSYM, 2-58 LNKBN1, 4-3 Global symbol definition file LNKBN2, 4-3, G-1, G-2 (MGLOB.MA), 1-3 LNKCAL, 4-4 Global symbol table (GST), 3-2 LNKCD, 4-5 GLOB2, 2-80 LNKCHN, 2-84 $GLOBAL, 2-80 LNKLSD, 4-8, G-1, G-3 LNKMAN, 4-5, G-3 LNKMAP, 4-10, G-3 H LNKMSG, 4-10 LOAD, 2-56 LOCPOP, 2-42 HGHSCT, 2-56 LOCPSH, 2-42 LOOKU, 2-43 LOOKUP, 2-65 I LOOP, 2-64 LSDINI, 2-18 LSDOUT, 2-16 IDIV, 2-4 LSTRET, 2-42 $IFDEF, 2-73 $IFNDEF, 2-73 $IFNZRO, 2-72 M $IFZERO, 2-73 IGNORE, 2-55 IMUL, 2-4 MAC2, 2-52 $INCLUD, 2-79 MAC24, 2-55 IOINIT, 2-13, 2-37 MAC30, 2-66 IONIT2, 2-14, 2-37 MAC3R, 2-68 MACERR, 2-25 MACEXP, 2-29 J MACINI, 2-33 MACIO, 2-36 MACLIT, 2-43 $JSW, 2-83 MACMAC, 2-47 MACOPN, 2-48 MACORG, 2-49 K MACRO, 2-49 $MACRO, 2-47 format, 1-12 KLU4, 2-66 MACRTH, 2-51 KLU10, 2-45 MACTBL, 2-52 Main binary section table (MBST), 3-10 Index-2 INDEX (CONT.) MC, 2-28 OVRLIN, 2-70 Memory segment control double OVRR, 2-82 words, 3-12 OVRS, 2-84 $MEXIT, 2-48 OVRU, 2-85 MGET, 2-40 Module descriptor table (MODTAB), 3-5 P MORCRF, 2-88 $PAGE, 2-71 N PARSYM, 2-63 PART2, 2-47 PAS2, 2-86 NEWBB, G-2 PASS3, 2-70 NEWORG, G-2 $PAUSE, 2-55 NEWPAG, 2-69 Pointer table (PRTAB), 3-5 NEX, 2-55 POP, 2-65 NEXTCHAR, 2-58 $POP, 2-86 NEXTT, 2-7 PREFIN, 2-82 $NOLIST, 2-83 PREFORM, 2-35 $NOPUNC, 2-83 PRGLIT, 2-57 NPRINT, 2-67 PRGSPL, 2-45 NUMLCL, 2-61 PRINTY, 2-66 PRLINO, 2-66 PRN, 2-23 O PRNBIN, 2-68 PRNDSH, 2-68 PRNT2, 2-23 $OCTAL, 2-75 PRNT6, 2-25 OFETCH, 2-42, 2-49 PRZLIT, 2-57 OFIX, 2-40 Pseudo-macro symbol table ONCE, 2-34 entry format, 1-12 OPEN, 2-48 Pseudo-operator table OPEN1, 2-8 entry format, 1-13 OPEN2, 2-8 PUNBIT, 2-53 OPEN3, 2-8 PUNY, 2-54 OPEN4, 2-10 PURGEL, 2-45 OPENTC, 2-49 PUSH, 2-65 OPRINT, 2-67 $PUSH, 2-86 ORET, 2-39 PUTB, 2-54 ORIG, 2-54 PUTBIN, G-2 ORIGIN, 2-62 PUTBIT, 2-54 OUT, 2-68 PUTBN, 2-87 OUTBLK, 2-81 PUTBT, 2-87 OUTDATA, 2-62 PUTBUF, 2-42 OUTLIT, 2-45 PUTLC, 2-54 OUTLST, 2-42 PUTSYM, 2-58 Overlay level information PUXBIN, 2-53 table (LNDR), 3-10 Overlay transfer vector (TRANVC), 3-8 OVRA, 2-70 OVRB, 2-72 OVRD, 2-77 Index-3 INDEX (CONT.) R U $RADIX, 2-75 UNNAM, 2-54 REIT, 2-13 UPAROQ, 2-5 $RELOC, 2-86 User overlay level data RELOCA, G-3 table (QUSRLV), 3-9 ROTL6, 2-63 .RSECT symbol table entry format, 1-14 V S $VERSIO, 2-83 $SBTTL, 2-85 X SCAN, 2-60 SEARCH, G-3 .SECT table, 3-5 SETIT, 2-57 XPRINT, 2-23 SETT, 2-67 .XSECT symbol table entry SNGLQQ, 2-5 format, 1-15 SPOP, 2-41 SPUSH, 2-40 SSORT, G-3 Z $START, 2-83 STPRNT, 2-22 SWBACK, 2-39 $ZBLOCK, 2-71 SWITCH, 2-38 ZGET, 2-40 SYMINI, 2-35 ZINIT, 2-43 ZL, 2-44 ZLIT, 2-44 T ZPAD, 2-18 .ZSECT symbol table entry TAB, 2-68 format 1-15 TAGCOL, 2-62 ZSECTG, 2-43 TAGCOM, 2-62 $ZTRNA, 2-80 TASKY, 2-74 TERM, 2-31 $TEXT, 2-71 $TITLE, 2-86 TSTMAC, 2-63 Index-4 : MACREL/LINK : Software Support Manual : AA-J073A-TA : : : READER'S COMMENTS : : : : NOTE: This form is for document comments only. DIGITAL will : use comments submitted on this form at the company's : discretion. If you require a written reply and are : eligible to receive one under Software Performance : Report (SPR) service, submit your comments on an SPR : form. : : : Did you find this manual understandable, usable, and well-organized? : Please make suggestions for improvement. : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : : Did you find errors in this manual? If so, specify the error and the : page number. : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : ___________________________________________________________________ : : Please indicate the type of reader that you most nearly represent. : : [] Assembly language programmer : [] Higher-level language programmer : [] Occasional programmer (experienced) : [] User with little programming experience : [] Student programmer : [] Other (please specify)___________________________________ : : : Name____________________________________ Date______________________ : : Organization_______________________________________________________ : : Street_____________________________________________________________ : : City_________________________ State__________ Zip Code_____________ : or : Country - - - Do Not Tear - Fold Here and Tape - - - - - - - - - - - - - - - - +-+-+-+-+-+-+-+ +---------------+ |d|i|g|i|t|a|l| | FIRST CLASS | +-+-+-+-+-+-+-+ | PERMlT NO. 33 | | MAYNARD. MASS.| +---------------+ ======== ======== ------------------------------------------ ======== | BUSINESS REPLY MAIL | ======== | FIRST CLASS PERMIT NO.33 MAYNARD MASS. | ======== ------------------------------------------ ======== ======== POSTAGE WILL BE PAID BY ADDRESSEE ======== ======== ======== ======== BSSG SOFTWARE PUBLICATIONS ML 5-5/E45 ======== DIGITAL EQUIPMNT CORPORATION ======== 146 MAIN STREET ======== MAYNARD, MASSACHUSETTS 01754 ======== -----------------Do Not Tear - Fold Here and Staple-------------------