@Style[LeftMargin 10 chars, RightMargin 10 chars, Spacing 1 line, Justification no, TabWidth 8 chars] @Pageheading[center "@b(* Infocom, Inc., Company Confidential Document *)"] @Blankspace[10 lines] @verbatim[ ZZZZZ A PPPP Z A A P P Z A A P P Z AAAAA PPPP Z A A P Z A A P ZZZZZ A A P ] @Blankspace[10 lines] @Center[ ZAP: Z-language Assembly Program Joel M. Berez INFOCOM INTERNAL DOCUMENT - NOT FOR DISTRIBUTION ] @Chapter[Introduction] ZAP is a two (or three) pass absolute assembler for Z-code. The intention is for ZAP to provide relatively low-level support for all features available in ZIP (Z-language Interpreter Program). A ZAP program consists of a single file containing line-oriented statements. A statement may produce code and/or data or may simply direct the assembly process. During the first pass, the assembler checks statement syntax, calculates code/data locations, and attempts to resolve symbolic references. During the second pass, code is generated, any error messages are displayed, and an optional listing is produced. Due to the nature of this two-pass process, certain symbol definition restrictions exist that will be explained in the appropriate sections. An optional prepass may be invoked to build the frequently used word table by omitting the table (FWORDS) from the input file. This is a table of substrings that may be inserted into larger strings in an abbreviated form. The assembler will identify any such substrings (defined by .FSTR) in strings that it assembles and use the proper format. This optional prepass will search all regular strings, find 32 good choices for substrings, and define them with .FSTRs in the FWORDS table. See the ZIP manual for further details concerning the string format. Code that is generated by the assembler is directly executable by ZIP as long as the program follows all necessary conventions for the interpretor. ZAP will to a large extent insure that required data structures are defined, ZIP pointers are initialized, etc. However it cannot be responsible for such implementation dependent restrictions as maximum table sizes. @Chapter[Language Syntax] @Section[Character Set] Except within strings or comments, only the following characters are allowed in a Z program: @Verbatim[ A-Z Symbol constituents 0-9,- Symbol or number constituents ?,#,. Symbol constituents , Ignored except as initial operand prefix , Ignored End-of-line character , General operand prefix > Return value operand prefix / Branch (on success) operand prefix \ Branch (on failure) operand prefix = Value operand prefix (for assignments) + Addend operand prefix (addition of constants) " String delimiter ; Comment prefix ] @Section[Symbols] Symbols are used to represent values of various types. Because the assembler associates a type with each symbol along with its value when it is defined, no special method is required to specify the type when the symbol is used. However, certain naming conventions are suggested for the convenience of the programmer. A symbol contains any positive number of characters from the set {A-Z,0-9,?,#,.,-}. By convention pseudo-ops, and only pseudo-ops, begin with a period. Other conventions are left to the discretion of the programmer. Symbols may be global or local depending upon the type of value that is assigned to them. The range of a global symbol is the entire program, while the range of a local symbol is restricted to the function in which it is defined. While local symbols may be reused from one function to another, only constants (always global) may be truly redefined. The global symbols include two predefined sets. Operators are the "hardware" Z-machine instructions and use the same mnemonics shown in the ZIP documentation. Pseudo-ops are used somewhat like operators, but are simply assembler directives that may or may not generate code/data. They are explained later in this manual. Global labels can refer to either global data or to functions. (In fact data, strings and tables, must be defined globally.) These are defined either through the colon-colon construct, by a pseudo-op, or by assignment to another global label. A few special globals are predefined by the assembler (e.g@. VOCAB refers to the vocabulary table). Constants refer to arbitrary user-specified values. These are defined by a direct assignment or by a pseudo-op. Unlike other symbols, constants may be redefined at any time. Global variables are defined by the .GVAR pseudo-op within the GLOBAL table. They may be used interchangeably with local variables, including the special STACK variable, and represent unique data locations within the program. Local symbols come in two varieties. Local variables are defined by the .FUNCT pseudo-op, which defines a function and allocates storage for its arguments and other local variables. These variables are allocated on the stack when the function is called and are for each such call assigned the initial values specified. Local labels are the targets of branching instructions and are defined by the colon construct or by assignment to another local label. @Section[Statement Syntax] A statement consists of the following four fields, all of which are optional: