Digital PDFs
Documents
Guest
Register
Log In
AA-D032C-TE
March 1980
187 pages
Original
6.7MB
view
download
Document:
VAX-11 MACRO Language Reference Manual
Order Number:
AA-D032C-TE
Revision:
000
Pages:
187
Original Filename:
OCR Text
VAX-11 MACRO Language Reference Manual Order No. AA-D032C-TE March 1980 This document describes the assembly language supported by VAX/VMS. All symbols, expressions, addressing modes, and directives are detailed. No prior knowledge of the VAX-11 MACRO assembler is assumed. VAX-11 MACRO Language Reference Manual Order No. AA-D032C-TE SUPERSESSION/UPDATE INFORMATION: This revised document supersedes the VAX-11 MACRO Language Reference Manual (Order No. AA-D032B-TE) OPERATING SYSTEM AND VERSION: VAX/VMS V02 SOFTWARE VERSION: VAX-11 MACRO V02 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, August 1978 Revised, February 1979 Revised, March 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 @ 1978, 1979, 1980 by Digital Equipment Corporation. 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: DIGITAL DEC PDP DEC US UNIBUS COMPUTER LABS CO MT EX DDT DEC COMM ASSIST-11 VAX DECnet DATATRIEVE DECsystem-10 DECtape DIBOL EDU SYSTEM FLIP CHIP FOCAL IND AC LAB-8 DECSYSTEM-20 RTS-8 VMS IAS TRAX MASSBUS OMNIBUS OS/8 PHA RSTS RSX TYPESET-8 TYPESET-11 TMS-11 ITPS-10 SB! PDT CONTENTS Page vii PREFACE CHAPTER 1 INTRODUCTION 1-1 CHAPTER 2 MACRO SOURCE STATEMENT FORMAT 2-1 2.1 2.2 2.3 2.4 LABEL FIELD OPERATOR FIELD OPERAND FIELD COMMENT FIELD 2-2 2-3 2-3 2-4 3 THE COMPONENTS OF MACRO SOURCE STATEMENTS 3-1 3.1 3.2 3.2.1 3.2.2 3.2.3 3.3 3.3.1 3.3.2 3.3.3 3.4 3.5 3.6 3-1 3-3 3-3 3.7 3.7.1 3.7.2 3.7.3 3.7.4 3.8 3.9 CHARACTER SET NUMBERS Integers Floating-Point Numbers Packed Decimal Strings SYMBOLS Permanent Symbols User-defined Symbols and Macro Names Determining Symbol Values LOCAL LABELS TERMS AND EXPRESSIONS UNARY OPERATORS Radix Control Operators Textual Operators ASCII Operator Register Mask Operator Numeric Control Operators Floating-Point Operator Complement Operator BINARY OPERATORS Arithmetic Shift Operator Logical AND Operator Logical Inclusive OR Operator Logical Exclusive OR Operator DIRECT ASSIGNMENT STATEMENTS CURRENT LOCATION COUNTER 4 ADDRESSING MODES 4-1 4.1 GENERAL REGISTER MODES Register Mode Register Deferred Mode Autoincrement Mode Autoincrement Deferred Mode Autodecrement Mode Displacement Mode Displacement Deferred Mode Literal Mode 4-1 CHAPTER 3.6.1 3.6.2 3.6.2.1 3.6.2.2 3.6.3 3.6.3.1 3.6.3.2 CHAPTER 4 .1.1 4.1.2 4 .1. 3 4 .1. 4 4.1.5 4 .1. 6 4 .1. 7 4 .1.8 iii 3-4 3-5 3-5 3-5 3-'1 3-'1 3-7 3-9 3-11 3-12 3-13 3-13 3-13 3-14 3-14 3-15 3-15 3-lh 3-lh 3-17 3-17 3-17 3-18 4-4 4-4 4-5 4-5 4-'1 4-6 4-8 4-9 CONTENTS Page CHAPTER 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.3 4.4 PROGRAM COUNTER MODES INDEX MODE BRANCH MODE 4-10 4-10 4-11 4-12 4-12 4-13 4-14 4-17 5 GENERAL ASSEMBLER DIRECTIVES 5-1 .ADDRESS .ALIGN .ASCix .ASCII .ASCIC .ASCID .ASCIZ .BLKx .BYTE .CROSS .NOCROSS .DEBUG .DEFAULT .D FLOATING .DOUBLE .DISABLE .ENABLE .END .ENDC .ENTRY .ERROR .EVEN .EXTERNAL .F FLOATING .FLOAT .G-FLOATING .GLOBAL .H FLOATING .!DENT .IF .IF x 5-3 5-4 5-6 5-7 5-7 5-8 5-8 5-9 5-11 5-12 5-14 5-15 5-16 5-17 5-17 5-20 5-20 5-21 5-23 5-24 5-24 5-25 5-26 5-27 5-28 5-29 5-30 5-33 5-36 5-37 5-38 5-39 5-39 5-40 5-40 5-41 5-41 5-42 5-44 5-44 5-45 5-46 5-51 5-52 5-53 5-54 5-55 Relative Mode Relative Deferred Mode Absolute Mode Immediate Mode General Mode .IIF .LIST .LONG .MASK .NLIST .NOCROSS .NOSHOW .OCTA .ODD .OPDEF .PACKED .PAGE • PRINT .PSECT .QUAD .REFn .RESTORE PSECT .SAVE PSECT .SHOW- .NOSHOW iv CONTENTS Page CHAPTER 6 .SIGNED BYTE .SIGNED-WORD .SUBTITLE .TITLE .TRANSFER .WARN .WEAK .WORD 5-57 5-58 5-60 5-61 5-fi2 5-fi5 5-66 5-67 MACROS 6-1 6.1 6-2 6 .1.1 6 .1. 2 6 .1. 3 6 .1.4 0 .1. 5 ARGUMENTS IN MACROS Default Values Keyword Arguments String Arguments Argument Concatenation Passing Numeric Values of Symbols 6.1.6 Created Local Labels Macro String Operators 6.1.7 6.1.7.1 %LENGTH Operator 6.1.7.2 %LOCATE Operator %EXTRACT Operator 6.1.7.3 6.2 MACRO DIRECTIVES .ENDM .ENDR • IRP • IRPC • LIBRARY .MACRO .MCALL .MDELETE .MEXIT .NARG .NCHR .NTYPE .REPEAT fi-3 fi-3 6-22 6-23 fi-24 6-25 fi-26 6-28 APPENDIX A ASCII CHARACTER SET A-1 APPENDIX B VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY B-1 n-7 6-7 n-8 6-9 n-10 6-11 6-13 n-13 6-13 n-14 fi-16 6-18 6-19 ~-21 B.4 ASSEMBLER DIRECTIVES SPECIAL CHARACTERS OPERATORS Unary Operators Binary Operators Macro String Operators ADDRESSING MODES C PERMANENT SYMBOL TABLE C-1 C.l C.2 OPCODES (ALPHABETIC ORDER) OPCODES (NUMERIC ORDER) C-1 C-8 B.l B.2 B.3 B.3.1 B.3.2 B.3.3 APPENDIX 6-4 6-6 v B-1 B-7 B-9 B-9 B-10 B-10 B-11 CONTENTS Page APPENDIX D HEXADECIMAL/DECIMAL CONVERSION D-1 D.l HEXADECIMAL TO DECIMAL DECIMAL TO HEXADECIMAL POWERS OF 2 AND 16 D-1 D-1 D.2 D.3 INDEX D-2 Index-1 FIGURES FIGURE 5-1 Using Transfer vectors 5-63 TABLES TABLE 3-1 3-2 3-3 3-4 4-1 4-2 4-3 5-1 5-2 5-3 5-4 5-5 5-6 5-7 6-1 A-1 B-1 B-2 B-3 B-4 B-5 B-6 D-1 Special Characters Used in VAX-11 MACRO Statements Separating Characters in VAX-11 MACRO Statements Unary Operators Binary Operators Addressing Modes Floating Point Short Literals Index Mode Addressing Summary of General Assembler Directives .ENABLE and .DISABLE Symbolic Arguments Condition Tests for Conditional Assembly Directives Operand Descriptors Program Section Attributes Default Program Section Attributes .SHOW and .NOSHOW Symbolic Arguments Summary of Macro Directives Hexadecimal/ASCII Conversion Assembler Directives Special Characters Used in VAX-11 MACRO Statements Unary Operators Binary Operators Macro String Operators Addressing Modes Hexadecimal/Decimal Conversion vi 3-1 3-3 3-11 3-15 4-2 4-9 4-16 5-1 5-18 5-31 5-43 5-48 5-49 5-Sn 6-2 A-1 B-1 B-7 B-9 B-10 B-10 B-11 D-3 PREFACE MANUAL OBJECTIVES It includes the This manual describes the VAX-11 MACRO language. format and function of each feature of the language. The VAX-11 MACRO User's Guide describes how to use VAX-11 MACRO. INTENDED AUDIENCE This manual is intended for all programmers writing VAX-11 MACRO programs. Programmers should be familiar with assembly language programming, the VAX-11 instruction set, and the VAX/VMS operating system before reading this manual. The VAX-11 MACRO User's Guide provides a brief introduction to the assembler and describes the commands necessary to use VAX-11 MACRO. The VAX-11 Architecture Handbook describes the VAX-11 instruction set. All programmers should read these manuals before using this language reference manual. STRUCTURE OF THIS DOCUMENT This manual is organized into six chapters follows: introduces the and appendixes, as the VAX-11 MACRO VAX-11 MACRO source • Chapter 1 language. • Chapter 2 describes the format used statements. • Chapter 3 describes the components of VAX-11 MACRO source statements: the character set; numbers; symbols; local labels; terms and expressions; unary and binary operators; direct assignment statements; and the current location counter. • Chapter 4 summarizes and gives examples VAX-11 MACRO addressing modes. • Chapter 5 describes directives. the features four VAX-11 vii of in MACRO of the general use of the assembler • Chapter 6 describes expanding macros. the directives used in defining • Appendix A lists the ASCII character set that can be VAX-11 MACRO programs. • Appendix B summarizes the general assembler and macro directives {in alphabetical order), special characters, unary operators, binary operators, and addressing modes. • Appendix C lists alphabetically and by opcode the permanent symbols {instruction set) defined for use with VAX-11 MACRO. • Appendix D gives rules for hexadecimal/decimal conversion. used and in ASSOCIATED DOCUMENTS The following documents are relevant to VAX-11 MACRO programming: • VAX-11 Archi tectur~_!!~Ddl::>oo_~ • VAX-11 MACRO User's Guide • VAX-11 Linker Reference Manual • VAX-11 Symbolic Debugger Reference Manual For a complete list of all VAX-11 documents, including a brief description of each, see the VAX-11 Information Directory and Index. CONVENTIONS USED IN THIS DOCUMENT The following conventions are observed in this manual, as in the other VAX-11 documents: Convention Meaning Uppercase words and letters Uppercase words and letters, examples, indicate that you should word or letter exactly as shown. Lowercase words and letters Lowercase words and letters, used in format examples, indicate that you are to substitute a word or value of your choice. Square brackets indicate item is optional. that the used in type the enclosed A horizontal ellipsis indicates that the preceding item{s) can be repeated one or more times. A vertical ellipsis indicates that not all of the statements in an example or figure are shown. viii SUMMARY OF TECHNICAL CHANGES This manual documents VAX-11 MACRO V2.0, as released with Release 2.0 of VAX/VMS. This section summarizes the technical changes from the last version, released with Release 1.5 of VAX/VMS. Changes affecting directives: There is a new data type, the octaword, which stores 128 bits (lo bytes) of binary data. The octaword storage directive is .OCTA. A new block storage directive, .BLKO, reserves octawords for data. A new operand generation directive, .REF16, generates an octaword operand. However, DIGITAL recommends using the opcode definition directive, .OPDEF, instead of .REF; there are new operand descriptors for use with .OPDEF which describe octaword operators. Two new floating-point directives provide additional flexibility and capacity for floating-point numbers. The .G FLOATING directive generates 64-bit data (quadwords) of which one bit- is the sign, 11 bits are exponent, and 52 bits are fraction. The .H FLOATING directive generates 128-bit data (octawords) with one bit for-sign, 15 bits for exponent, and 112 bits for fraction. There are new block storage directives, .BLKG and .BLKH, which reserve G floating quadwords and H floating octawords, respectively. There- are new operand descriptors for use with .OPDEF which describe G floating and H floating operands. (Note: not all VAX-11 processors support the G=floating and H_floating data types.) To bring the formats of the floating-point data types and directives into a consistent format, there are new alternate forms of the .FLOAT directive - .F FLOATING - and the .DOUBLE directive .D FLOATING. The terms F floating and n floating are used in this manual-to denote single-precision and 64-bit-double precision data. A new program section attribute, VEC, has been added for use with the .PSECT directive. It shows that a program section contains information to be used in a privileged shareable image. The new directives, attributes, and operand descriptors listed are all described under the directive names in Chapter 5. above New opcodes have been added to the VAX-11 instruction set to make use of octaword, G floating, and H floating data. These opcodes, and the mnemonics that represent them in source code, are listed in Appendix c. Miscellaneous changes: • User-define~ • The ASCII string used with the ASCII operator (~A) may now be up to 16 characters long, depending on the data type of the operand. • Source statements used within macros may now characters long. symbols may now be up to 31 characters long. ix be up to 1000 CHAPTER 1 INTRODUCTION The VAX-11 MACRO programming language is an assembly language for programming VAX-11 computers under the VAX/VMS operating system. Source programs written in the VAX-11 MACRO programming language are translated into object (or binary) code by the VAX-11 MACRO assembler, which produces an object module and, optionally, a listing file. These functions of the assembler are described in the VAX-11 MACRO User's Guide. The features of the language itself are introduced in this chapter. VAX-11 MACRO source programs consist of a sequence of source statements. These source statements may be any of the following: • VAX-11 native-mode instructions • Direct assignment statements • Assembler directives Instructions manipulate data. They perform' such functions as addition, data conversion, and transfer of control. Instructions are usually followed in the source statement by operands, which can be any kind of data needed for the operation of the instruction. The VAX-11 instruction set is summarized in Appendix C of this volume and is described in detail in the VAX-11 Architecture Handbook. Direct assignment statements equate symbols to values. Assembler directives guide the assembly process and provide tools for using the instructions. There are two classes of assembler directives: general assembler directives and macro directives. General assembler directives can be used to perform the following: • Store data or reserve memory for data storage • Control the alignment in memory of parts of the program • Specify the methods of accessing the which the program will be stored. • Specify the entry point of the program program • Specify the way in which will be referenced • Specify that a part of the program is under certain conditions ~ymbols 1-1 sections or to of be of memory part in of the assembled only INTRODUCTION • Control the format and content of the listing file • Display informational messages • Control the assembler options that are used to source program • Define new opcodes Macro directives are used to define macros and allow programmers to do the following: sequences repeat • Repeat identical or similar throughout a program • Use string operators to manipulate and test source statements Use of macros and repeat blocks halps to and to speed the debugging process. 1-2 of minimize interpret the blocks. They source the statements contents programmer of errors CHAPTER 2 MACRO SOURCE STATEMENT FORMAT A source program consists of a sequence of source statements, which the assembler interprets and processes, one by one, generating object code or performing a specific assembly-time process. A source statement can occupy one source line or can extend onto several source lines. Each source line can be up to 132 characters long; however, no line should exceed 80 characters to ensure that the source line fits (with its binary expansion) on one line in the listing file. MACRO statements can consist of up to four fields: • Label field -- symbolically defines a location in a program • Operator field -- specifies the action to be performed by the statement; this field can be an instruction, an assembler directive, or a macro call • Operand field -- contains the instruction operand(s) or assembler directive argument(s) or the macro argument(s) • Comment field -- contains a comment that explains the of the statement; this field does not affect execution the meaning program The label field and the comment field are optional. The label field ends with a colon (:) and the comment field starts with a semicolon (;). The operand field must conform to the format of the instruction, directive, or macro specified in the operator field. Although statement fields can be separated by either a space or a tab (see Table 3-2), formatting statements with the tab character is recommended for consistency and clarity. By DIGITAL convention, tab characters are used to separate the statement fields as follows: Field Begins in Column Tab Characters to Reach Column Label 1 0 Operator 9 1 Operand 17 2 Comment 41 5 For example: LABT: LAB2: .TITLE .ENTRY CLRL SUBL3 BRB ROUTl START,O RO #10,4(AP)R2 CONT BEGINNING OF ROUTINE CLEAR REGISTER SUBTRACT 10 BRANCH TO ANOTHER ROUTINE 2-1 MACRO SOURCE STATEMENT FORMAT A single statement can be continued on several lines by using a hyphen (-) as the last nonblank character before the comment field or at the end of line (when there is no comment). For example: LABl: MOVAL VECTOR,RPB$L_IOVEC (R7) W~BOO$AL SAVE ADDRESS OF BOOT DEVICE DRIVER. VAX-11 MACRO treats the above statement as equivalent to the following statement: LABl: MOVAL W~BOO$AL_VECTOR,RPB$L_IOVEC(R7) ; SAVE BOOT DRIVER A statement can be continued at any point. User-defined and permanent symbol names; however, should not be continued on two lines. If a symbol name is continued and the first character on the second line is a tab or a blank, the symbol name will be terminated at that character. (Section 3.3 describes symbols in detail.) Note that when a statement occurs in a macro definition {see 6), the statement cannot contain more than 1000 characters. Chapter Blank lines, although legal, have no significance program except that they terminate a continued line. source The following sections detail. 2.1 describe each of the in the statement fields in LABEL FIELD A label is a user-defined symbol that identifies a location in the program. The symbol is assigned a value equal to the location counter at the location in the program section in which the label occurs (see the VAX-11 MACRO User's Guide for information on program sections). The user-defined symboY-name-can be up to 31 characters long and can contain any alphanumeric character and the underline( ), dollar sign ($), and period (.) characters. Section 3.3 describes the rules for forming user-defined symbol names in more detail. If a statement contains a label, the label must be in the first on the line. field A label is terminated by a colon (:) or a double colon (::). A single colon indicates that the label is defined only for the current module (an internal symbol). A double colon indicates that the label is globally defined; that is, the label can be referenced by other object modules (see Section 3.3.2). Once a label is defined, it cannot be redefined during the source program. If a label is defined more than once, VAX-11 MACRO displays an error message when the label is defined and again when it is referenced. If a label extends past column 7, it should be placed on itself so that the operator field can start in column 9. 2-2 . a line by MACRO SOURCE STATEMENT FORMAT For example: EVAL: CLRL ERROR IN ARG: INCL TEST:: MOVO TESTl: EXP: DATA:: BRW .BLKL .BLKW ROUTINE EVALUATES EXPRESSIONS THE ARG-LIST CONTAINS AN ERROR INCREMENT ERROR COUNT THIS TESTS ROUTINE REFERENCED EXTERNALLY GO TO EXIT ROUTINE TABLE STORES EXPECTED VALUES DATA TABLE ACCESSED BY STORE ROUTINE IN ALGO MODULE RO RO EXP,Rl EXIT ROU 50 25 The label field is also used for the symbol statement (see Section 3.8). in a direct The operator field specifies the action to statement. This field can contain either assembler directive, or a macro call. be an performed by the instruction, or an 2.2 assignment OPERATOR FIELD When the operator is an instruction, VAX-11 MACRO generates the binary code for that instruction in the object module. The binary codes are listed in Appendix C of this manual; the instruction set is described in the VAX-11 Architecture Handbook. When the operator is a directive, VAX-11 MACRO performs certain control actions or processing operations during source program assembly; the assembler directives are described in Chapters 5 and 6 of this manual. When the operator is a macro call, VAX-11 MACRO expands the macro; macro calls are described in Chapter 6. Either a space or a tab character may terminate the operator however, the tab is the recommended terminating character. 2.3 field; OPERAND FIELD The operand field can contain operands for instructions for assembler directives or macro calls. or arguments Operands for instructions identify the memory locations or the registers that are used by the machine operation. These operands specify the addressing mode for the instruction, as described in Chapter 4 of this manual. The operand field fo~ a specific instruction must contain the number of operands required by that instruction. See the VAX-11 Architecture Handbook for descriptions of the instructions and their operands. Arguments for a directive must meet the format requirements of the directive. Chapters 5 and 6 describe the directives and the format of their arguments. Operands for a macro must meet the requirements specified in the macro definition. See the description of the .MACRO directive in Chapter n. If two or more operands are specified, they should be separated by commas. VAX-11 MACRO also allows a space or tab to be used as a separator for arguments to any directive that does not accept expressions (see Section 3.5). However, a comma is required to separate operands for instructions and for directives that accept expressions as arguments. 2-3 MACRO SOURCE STATEMENT FORMAT The semicolon that starts the comment field terminates the operand field. If a line does not have a comment field, the operand field is terminated by the end of the line. 2.4 COMMENT FIELD The comment field contains text that explains the function of the statement. Every line of code should have a comment. Comments do not affect assembly processing or program execution except for messages displayed during assembly by the .ERROR, .PRINT, and .WARN directives (see descriptions in Chapter 5). The comment field must be preceded by a semicolon and is terminated by the end of the line. The comment field can contain any printable ASCII character (see Appendix A). If a comment does not fit on one line, it can be continued on the next, but the continuation must be preceded by another semicolon. A comment can appear on a line by itself. The text of a comment normally conveys the meaning rather than the action of the statement. The instruction MOVAL BUF PTR l,R7, for instance, should have a comment such as "GET POINTER TO FIRST BUFFER" not "MOVE ADDRESS OF BUF PTR l TO R7." For example: MOVAL STRING_DES_l,RO MOVZWL MOVL (RO) , Rl 4(RO) ,RO GET ADDRESS OF STRING DESCRIPTOR GET LENGTH OF STRING GET ADDRESS OF STRING 2-4 CHAPTER 3 THE COMPONENTS OF MACRO SOURCE STATEMENTS MACRO source This chapter describes the components of VAX-11 statements. These components consist of the character set; numbers; unary and binary symbols; local labels; terms and expressions; operators; direct assignment statements; and the current location counter. 3.1 CHARACTER SET The following statements: characters can be used in VAX-11 MACRO source • Both uppercase and lowercase letters (A through Z, a through z) are accepted. However, the assembler considers lowercase letters equivalent to uppercase except when they appear in ASCII strings. • The digits 0 through 9. • The special characters listed in Table 3-1. Table 3-1 Special Characters Used in VAX-11 MACRO Statements Character Character Name Function Underline Character in symbol names $ Dollar sign Charaqter in symbol names . Period Character in symbol names, current location counter, and decimal point : Colon Label terminator = EquaJ. sign Direct assignment operator and macro keyword argument terminator Tab Field terminator Space Field terminator - (continued on next line) 3-1 THE COMPONENTS OF MACRO SOURCE STATEMENTS Table 3-1 (Cont.) Special Characters Used in VAX-11 MACRO Statements Character Character Name Function # Number sign Immediate addressing mode indicator @ At sign Def erred addressing mode indicator and arithmetic shift operator Comma Field, operand, and item separator Semicolon Comment field indicator Plus sign Autoincrement addressing mode indicator, unary plus operator, and arithmetic addition operator Minus sign or hyphen Autodecrement addressing mode indicator, unary minus operator, arithmetic subtraction operator, and line continuation indicator * Asterisk Arithmetic multiplication operator I Slash Arithmetic division operator & Ampersand Logical AND operator ! Exclamation point Logical inclusive OR operator \ Backslash Logical exclusive OR and numeric conversion indicator in macro arguments Circumflex Unary operators and macro argument delimiter [] Square brackets Index addressing mode and repeat count indicators () Parentheses Register def erred addressing mode indicators <> Angle brackets Argument or expression grouping delimiters ? Question mark Created label indicator in macro arguments I Apostrophe Macro argument concatenation indicator % Percent sign Macro string operators + ,. -- '--·-~----···-··------ ----------------------------·--------- 3-2 THE COMPONENTS OF MACRO SOURCE STATEMENTS Table 3-2 defines the separating characters used in VAX-11 MACRO. Table 3-2 Separating Characters in VAX-11 MACRO Statements Character 3.2 Character Name Usage Space or tab Separator between statement fields. Spaces within expressions (see Section 3. 5) are ignored. Comma Separator between symbolic arguments within the operand field. Multiple expressions in the operand field must be separated by commas. NUMBERS Numbers can be integers, floating-point strings. numbers, or packed decimal Integers 3.2.1 Integers can be used in any expression including expressions in operands and in direct assignment statements (Section 3.5 describes expressions). Format snn s An optional sign: plus sign (+) for positive default) or minus sign (-) for negative numbers. numbers A string of numeric characters that are radix. the (the nn legal for current VAX-11 MACRO interprets all integers in the source program as decimal unless the number is preceded by a radix control operator (see Section 3.6.1). Integers must be in the range of -2147483648 through 2147483647 for signed data or in the range of 0 through 4294967295 for unsigned data. Negative numbers must be preceded by a minus sign; translates such numbers into 2's complement form. numbers, the plus sign is optional. 3-3 VAX-11 MACRO In positive THE COMPONENTS OF MACRO SOURCE STATEMENTS 3.2.2 Floating-Point Numbers A floating-point number can be used in the .F FLOATING (.FLOAT), .D FLOATING, (.DOUBLE) .G FLOATING, and .H FLOATING directives (described in Chapter 5) as an operand Tn a floating-point instruction. A floating-point number cannot be used in an expression or with a unary or binary operator except the unary plus, unary minus, and unary floating-point operator (~F). Sections 3.6 and 3.7 describe unary and binary operators. or A floating-point number can be specified with or without an exponent. Formats Floating-point number without exponent: snn snn.nn snn. Floating-point number with exponent: snnEsnn snn.nnEsnn snn.Esnn s An optional sign. nn A string of decimal digits in the range of O through 9. The decimal point can appear anywhere to the right of the first digit. However, note that a floating-point number cannot start with a decimal point because VAX-11 MACRO will treat the number as a user-defined symbol (see Section 3.3.2). Floating-point numbers can be single-precision (32-bit), double-precision (64-bit), or extended-precision (128-bit) quantities. The degree of precision is 7 digits for single-precision numbers, l~ digits for double-precision numbers, and 33 digits for extended precision numbers. The magnitude of a nonzero floating-point number cannot be smaller than approximately 0.29E-38 or greater than approximately l.7E38. Single-precision floating-point numbers can be rounded (by default) or truncated. The .ENABLE and .DISABLE directives (described in Chapter 5) control whether single-precision floating-point numbers are rounded or truncated. Double-precision and extended-precision floating point numbers are always rounded. The VAX-11 Architecture Handbook floating-point numbers. describes 3-4 the internal format of THE COMPONENTS OF MACRO SOURCE STATEMENTS 3.2.3 Packed Decimal Strings A packed decimal string can be used (described in Chapter 5). only in the .PACKED directive Format snn s An optional sign. nn A string of from 1 to 31 decimal digits in the range of 0 through 9. A packed decimal string cannot have a decimal point or an exponent. The VAX-11 Architecture Handbook packed decimal strings. 3.3 describes the internal format of SYMBOLS Three types of symbols can be used in VAX-11 MACRO source permanent symbols, user-defined symbols, and macro names. 3.3.1 programs: Permanent Symbols Permanent symbols consist of instruction mnemonics (see Appendix C), VAX-11 MACRO directives (see Chapters 5 and 6), and register names. Instruction mnemonics and directives need not be defined before being used in the operator field of a VAX-11 MACRO source statement. Register names need not be defined before being used in the addressing modes (see Chapter 4). Register names cannot be redefined; that is, no user-defined symbol can have one of the register names listed below. The 16 general registers of the VAX-11 processor can be expressed in a source program only as follows: Register Name Processor Register RO General register 0 Rl General register 1 R2 General register 2 Rll General register 11 Rl2 or AP General register 12 or argument pointer. If Rl2 is used as an argument pointer, the name AP is recommended; if Rl2 is used as a general register, the name Rl2 is recommended. 3-5 THE COMPONENTS OF MACRO SOURCE STATEMENTS Register Name Processor Register FP Frame pointer SP Stack pointer PC Program counter 3.3.2 User-defined Symbols and Macro Names User-defined symbols can be used as labels or can be equated to specific value by a direct assignment statement (see Section 3.8). User-defined symbols also can be used in any expression (see a Section 3.5). The following rules govern the creation of user-defined symbols: • User-defined symbols can be composed of alphanumeric characters, underlines (),dollar signs ($),and periods (.). Any other character terminates the symbol. • The first character of a symbol must not be a number. • The symbol must be no more than 31 unique. character~ long and must be In addition, by DIGITAL convention: • The dollar sign ($) is reserved for names defined by DIGITAL. This convention ensures that a user-defined name (which does not have a dollar sign) will not conflict with a DIGITAL-defined name (which does have a dollar sign). • The period (.) should not be used in any global symbol name (see Section 3.3.3) because other languages, such as FORTRAN, do not allow periods in symbol names. Macro names follow the same rules and conventions as user-defined symbols (see the description of the .MACRO directive in Chapter 6 for more information on macro names). User-defined symbols and macro names do not conflict; that is, the same name can be used for a user-defined symbol and a macro. However, to avoid confusion, user-defined symbols and macros should be given different names. 3.3.3 Determining Symbol Values The value of a symbol depends on its use in the program. VAX-11 MACRO uses a different method to determine the values of symbols in the operator field than it uses to determine the values of symbols in the operand field. A symbol in the operator field can be either a permanent symbol or a macro name. VAX-11 MACRO searches for a symbol definition in the following order: • Previously defined macro names • User-defined opcode (see the .OPDEF description in Chapter 5) 3-6 THE COMPONENTS OF MACRO SOURCE STATEMENTS • Permanent symbols (instructions and directives) • Macro libraries This search order allows permanent symbols to be redefined as macro names. If a symbol in the operator field is not defined as a macro or a permanent symbol, the assembler displays an error message. A symbol in the operand field must be either a user-defined symbol a register name. or User-defined symbols can be either local (internal) symbols or global (external) symbols. Whether symbols are loc~l or global depends on their use in the source program. A local symbol can be referenced only in the module in which it is defined. If local symbols .with the same names are defined in different modules, the symbols are completely independent. A global symbol's definition, however, can be referenced from any module in the program. Normally, VAX-11 MACRO treats all user-defined symbols as local when they are defined. However, a symbol definition can be explicitly declared to be global by any one of the following three methods: • Use of the double colon (::) in defining a label (see Section 2.1) • Use of the double equal sign statement (see Section 3.8) • Use of the .GLOBAL, .ENTRY, or .WEAK directive (see Chapter 5) (==) in a direct assignment When a symbol is referenced within the module in which it is defined, VAX-11 MACRO considers the reference an internal reference. When a symbol is referenc~d within a module in which it is not defined, VAX-11 MACRO considers the reference an external reference (that is, the symbol is defined in another module). The .DISABLE directive can be used to make references to symbols not defined in the current module illegal. In this case, the .EXTERNAL directive must be used to specify that the reference is an external reference. See Chapter 5 for descriptions of the .DISABLE and .EXTERNAL directives. 3.4 LOCAL LABELS Local labels are used to identify addresses within a block code. of source user-defined symbol • Local labels cannot be referenced outside the block of code in which they appear. source • Local labels can be reused in another block of source code. Format nn$ nn A decimal integer in the range of 1 through 65535. Local labels can be used in the same way labels, but with the following differences: 3-7 as THE COMPONENTS OF MACRO SOURCE STATEMENTS • Local labels do not appear in the symbol cannot be accessed by the debugger. tables and, • Local labels cannot be used in .END (see Chapter 5). thus, By convention, local labels are positioned like statement labels: left-justified in the source text. Although local labels can appear in the program in any order, by convention, the local labels in any block of source code should be in numeric order. Local labels are useful as branch addresses when the address is used only within the block. Local labels can be used to distinguish between addresses that are referenced only in a small block of code and addresses that are referenced elsewhere in the module. A disadvantage of local labels is that their numeric names cannot provide any indication of their purpose. Consequently, local labels should not be used to label sequences of statements that are logically unrelated; user-defined symbols should be used instead. DIGITAL recommends that users create local labels only in the range of 1$ to 29999$ because the assembler automatically creates local labels in the range of 30000$ to 65535$ for use in macros (see Section 6.1.6). The local label block in which a local label is valid is delimited the following statements: by • A user-defined label • A .PSECT directive (see Chapter 5) • The .ENABLE and .DISABLE directives (see Chapter 5) which can extend a local label block beyond user-defined labels and .PSECT directives A local label block is usually delimited by two user-defined labels. However, the .ENABLE LOCAL BLOCK directive starts a local block that is terminated only by one of-the following: e A second .ENABLE LOCAL BLOCK directive e A .DISABLE LOCAL BLOCK directive followed label or a .PSECT directive by a user-defined Although local label blocks can extend from one program section to another, DIGITAL recommends that local labels in one program section not be referenced from another program section. User-defined symbols should be used instead. Local labels can be preserved for future reference with the context of the program section in which they are defined; see the descriptions of the .SAVE PSECT [LOCAL BLOCK] directive and the .RESTORE PSECT directive in-Chapter 5. An example showing the use of local labels follows. 3-8 THE COMPONENTS OF MACRO SOURCE STATEMENTS RPSUB: 10$: MOVL SUBL2 BGTR ADDL2 MOVL CLRL CMPL BGTR SUBL INCL BRB MOVL BRW AMOUNT,RO DELTA,RO 10$ DELTA,RO MAX,Rl R2 RO,Rl 20$ INCR,RO R2 10$ R2,COUNT TEST .ENABLE POPR ADDL3 BRB LOCAL BLOCK #AM<RO,Rl,R2> RO,Rl,R3 10$ ENTR2: SUBL2 R2,R3 10$: SUBL2 BGTR INCL BRB R2,R3 20$ RO NEXT 20$: DECL RO .DISABLE LOCAL BLOCK CLRL R4 COMP: 10$: 20$: ENTRl: NEXT: 3.5 STARTS LOCAL LABEL BLOCK DEFINE LOCAL LABEL 10$ CONDITIONAL BRANCH TO LOCAL LABEL EXECUTED WHEN RO NOT > 0 ENDS PREVIOUS LOCAL LABEL BLOCK AND STARTS NEW ONE DEFINE NEW LOCAL LABEL 10$ CONDITIONAL BRANCH TO LOCAL LABEL EXECUTED WHEN RO NOT > Rl I • UNCONDITIONAL BRANCH TO LOCAL LABEL DEFINE LOCAL LABEL UNCONDITIONAL BRANCH TO USER-DEFINED LABEL START LOCAL LABEL BLOCK THAT WILL NOT BE TERMINATED BY A USER-DEFINED LABEL BRANCH TO LOCAL LABEL THAT IS AFTER A USER-DEFINED LABEL DOES NOT START A NEW LOCAL LABEL BLOCK DEFINE LOCAL LABEL CONDITIONAL BRANCH TO LOCAL LABEL EXECUTED WHEN R2 NOT > R3 UNCONDITIONAL BRANCH TO USER-DEFINED LABEL DEFINE LOCAL LABEL DIRECTIVE FOLLOWED BY USER-DEFINED LABEL TERMINATES LOCAL LABEL BLOCK TERMS AND EXPRESSIONS A term can be any one of the following: • A number • A symbol • The current location counter {see Section 3.9) • A textual operator followed by text (see Section 3.~.2) • Any of the above preceded by a 3.6) {see unary operator Section VAX-11 MACRO evaluates terms as longword {4-byte) values. If an undefined symbol is used as a term, the linker determines the term's value. The current location counter (.) has the value of the location counter at the start of the current operand. Expressions are combinations of terms joined by binary operators (see Section 3.7) and evaluated as longword (4-byte) values. VAX-11 MACRO evaluates expressions from left to right with no operator precedence rules. However, angle brackets (<>) can be used to change the order of evaluation. Any part of an expression that is enclosed in angle brackets is first evaluated to a single value, which is then used in evaluating the complete expression. For example, the expressions A*B+C and A*<B+C> are different. Angle brackets can also be used to apply a unary operator to an entire expression, such as -<A+B>. Note that unary operators are considered part of a term; thus, VAX-11 MACRO performs the aGtion indicated by a unary operator before it performs the action indicated by any binary operator. 3-9 THE COMPONENTS OF MACRO SOURCE STATEMENTS Expressions fall into three categories: external (global). • relocatable, absolute, and An expression is relocatable if its value is fixed relative to the start of the program section in which it appears. The current location counter is relocatable in a relocatable program section. expression is absolute if its value is an assembly-time • An constant. An expression whose terms are all numbers is absolute. An expression that consists of a relocatable term minus another relocatable term from the same program section an is absolute, because such an expression reduces to assembly-time constant. • An expression is external if it contains one or that are not defined in the current module. Any type of expression can be used in most macro restrictions are placed on expressions used in: more symbols statements, • .ALIGN alignment directive • .BLKx storage allocation directives • .IF and .!IF conditional assembly block directives • .REPEAT repeat block directive • .OPDEF opcode definition directive • .ENTRY entry point directive e .BYTE, .LONG, .WORD, .SIGNED_BYTE, and .SIGNED WORD repetition factors • Direct assignment statements (see Section 3.8) but directive See Chapter 5 for descriptions of the directives listed above, except .REPEAT which is described in Chapter n. Expressions used in these directives and in direct assignment statements can only contain symbols that have been previously defined in the current module. They cannot contain either external symbols or symbols defined later in the current module. In addition, the expressions in these directives must be absolute. Expressions in direct assignment statements can be relocatable. An example showing the use of expressions follows. A = 2*100 .BLKB LAB: HALF .BLKW A LAB+<A/2> LAB2: .BLKB LAB2-LAB .WORD LAB3-LAB2 .WORD TST+LAB+2 LAB3: 2*100 IS AN ABSOLUTE EXPRESSION A+SO IS AN ABSOLUTE EXPRESSION AND CONTAINS NO UNDEFINED SYMBOLS LAB IS RELOCATABLE LAB+<A/2> IS A RELOCATABLE EXPRESSION AND CONTAINS NO UNDEFINED SYMBOLS LAB2-LAB IS AN ABSOLUTE EXPRESSION AND CONTAINS NO UNDEFINED SYMBOLS LAB3-LAB2 IS AN ABSOLUTE EXPRESSIO BUT CONTAINS THE SYMBOL LAB3 THAT IS DEFINED LATER IN THIS MODU TST+LAB+2 IS AN EXTERNAL EXPRESSIO BECAUSE TST IS AN EXTER~AL SYMBOL A+SO 3-10 THE COMPONENTS OF MACRO SOURCE STATEMENTS 3.6 UNARY OPERATORS A unary operator modifies a term or an expression, and indicates an action to be performed on that term or expression. Expressions modified by unary operators must be enclosed in angle brackets. Unary operators can be used to indicate whether a term or expression is positive or negatlve (if unary plus or minus is not specified, the value is assumed to be plus, by default). In addition, unary operators perform radix conversion, textual conversion (including ASCII conversion), and numeric control operations, as described in Sections 3.6.1 through 3.6.3. Table 3-3 summarizes the unary operators. Table 3-3 Unary Operators Unary Operator Operator Name Example Operation Plus sign +A Results in the positive value of A Minus sign -A Results in the negative (2's complement) value of A "B Binary "BllOOOlll Specifies that 11000111 is a binary number "o Decimal "'0127 Specifies that 127 is a decimal number "o Octal "034 Specifies that 34 is an octal number "x Hexadecimal "XFCF9 Specifies that FCF9 is a hexadecimal number "A ASCII "A/ABC/ Produces an ASCII string; the characters between the matching delimiters are converted to ASCII representation Register mask #"M<R3,R4,R5> Specifies the registers R3, R4, and R5 in the register mask Floating point "F3.0 Specifies that 3.0 is a floating-point number Complement "C24 Produces the l's complement value of 24 (decimal) + "c 3-11 THE COMPONENTS OF MACRO SOURCE STATEMENTS More than one unary operator can be applied to a single term or to expression enclosed in angle brackets. For example: an -+-A This construct is equivalent to: -<+<-A» 3.6.1 Radix Control Operators VAX-11 MACRO accepts terms or expressions in four different radixes: binary, decimal, octal, and hexadecimal. The default radix is decimal. Expressions modified by radix control operators must be enclosed in angle brackets. Formats ""Bnn "'Dnn "'onn "'Xnn nn A string of characters that are legal in the specified The legal characters for each radix are listed below. Format Radix Name Legal Characters "'Bnn Binary 0 and 1 "'Dnn Decimal 0 through 9 "'Onn Octal 0 through 7 ""Xnn Hexadecimal 0 through 9 and A through F radix. Radix control operators can be included in the source program anywhere a numeric value is legal. A radix control operator affects only the term or expression immediately following it, causing that term or expression to be evaluated in the specified radix. For example: .WORD .WORD .WORD .WORD .LONG BINARY RADIX DECIMAL RADIX (DEFAULT) OCTAL RADIX 13 IS IN OCTAL RADIX ALL NUMBERS IN EXPRESSION ARE IN HEXADECIMAL RADIX ""BOOOOllOl ""Dl23 "'047 <A+""Ol3> ""X<FlC3+FFFFF-20> The circumflex cannot be separated from the B, D, O, or X that follows it, but the entire radix control operator can be separated by spaces and tabs from the term or expression that is to be evaluated in that radix. The decimal operator, the default, is needed only within an expression that has another radix control operator. In the following example, the 16 would be interpreted as an octal number if the ""D operator did not precede it: .LONG ""0<10000 + 100 + ""Dl6> 3-12 THE COMPONENTS OF MACRO SOURCE STATEMENTS 3.6.2 Textual Operators The textual operators are the ASCII operator mask operator (AM). (AA) and the register 3.6.2.l ASCII Operator - The ASCII operator converts a string of printable characters to their 8-bit ASCII values and stores them one character to a byte. The string of characters must be enclosed in a pair of matching delimiters. The delimiters can be any printable character except the space, tab, or semicolon (;). Although alphanumeric characters can be used as delimiters, nonalphanumeric characters should be used to avoid confusion. Format AAstring string A delimited ASCII string from 1 through 16 characters long. The delimited ASCII string must not be larger than the data type of the operand. For example, if the AA operator occurs in an operand in a MOVW instruction (the data type is a word), the delimited string cannot be more than two characters. For example: MOVL MOVES CHARACTERS A,B,C,D INTO RO RIGHT JUSTIFIED WITH "A" IN LOW-ORDER BYTE AND "D" IN HIGH-ORDER BYTE COMPARES X AND Y AS ASCII CHARACTERS WITH CONTENTS OF LOW ORDER 2 BYTES OF RO GENERATES 8 BYTES OF ASCII DATA MOVE ASCII CHARACTERS AB INTO RO; "A" IN LOW-ORDER BYTE; "B" IN NEXT; AND ZERO THE 2 HIGHORDER BYTES CMPW .QUAD MOVL AA%1234/678% #AA/AB/,RO 3.6.2.2 Register Mask Operator - The register mask operator converts a register name or a list of register names enclosed in angle brackets into a 1- or 2-byte register mask. The register mask is used by the PUSHR and POPR instructions and the .ENTRY and .MASK directives (see Chapter 5). Formats AM reg-name AM< reg-name-list> reg-name One of the register names or the DV or IV arithmetic trap specifiers. reg-name-list A list of register names and/or the DV and enable specifiers, separated by commas. 3-13 IV arithmetic enable trap THE COMPONENTS OF MACRO SOURCE STATEMENTS The register mask operator sets a bit in the register mask for every register name or arithmetic trap enable specified in the list. The bits corresponding to each register name and arithmetic trap enable specifier are listed below. Register Name Arithmetic Trap Enable Bits RO through Rll 0 through 11 (respectively) Rl2 or AP 12 FP 13 SP IV 14 DV 15 When the register mask operator is used in a POPR or PUSHR instruction, RO through Rll, Rl2 or AP, FP, and SP can be specified. The PC register name and the IV and DV arithmetic trap enable specifiers cannot be specified. When the register mask operator is used in the .ENTRY or .MASK directives, R2 through Rll and the IV and DV arithmetic trap enable specifiers can be specified. However, RO, Rl, FP, SP, and PC cannot be specified. IV sets the integer overflow trap, and DV sets the decimal string overflow trap. See the VAX-11 Architecture Handbook for more information on masks and arithmetic trap enable specifiers. register For example: 3.6.3 .ENTRY RT1,AM<R3,R4,R5,R6,IV> PUSHR #AM<RO,Rl,R2,R3> POPR #AM<RO,Rl,R2,R3> SAVE REGISTERS R3,R4 RS, AND R6 AND SET THE INTEGER OVERFLOW TRAP SAVE REGISTERS RO,Rl, R2, AND R3 RESTORE RO,Rl,R2, AND R3 Numeric Control Operators The numeric control operators are the floating-point operator (AF) and the complement operator (AC). 3.6.3.1 Floating-Point Operator - The floating-point operator accepts a floating-point number and converts it to its internal representation (a 4-byte value). This value can be used in any expression. VAX-11 MACRO does not perform floating-point expression evaluation. Format ~Fliteral literal A floating-point number (see Section 3.2.2). The floating-point operator is useful because it allows floating-point number in an instruction that accepts integers. 3-14 a THE COMPONENTS OF MACRO SOURCE STATEMENTS For example: MOVL #"'F3.7,RO MOVF #3.7,RO NOTE THE RECOMMENDED INSTRUCTION TO MOVE THIS FLOATING-POINT NUMBER IS THE MOVF INSTRUCTION 3.6.3.2 Complement Operator - The complement l's complement of the specified value. operator produces the Format ""cterm term Any term or expression. If an expression is specified, be enclosed in angle brackets. it must VAX-11 MACRO evaluates the term or expression as a 4-byte value before complementing it. For example: .LONG .LONG 3.7 ""c""XFF ""c25 PRODUCES FFFFFFOO (HEX) PRODUCES COMPLEMENT OF 25 (DEC) WHICH IS FFFFFFE6 (HEX) BINARY OPERATORS In contrast to unary operators, binary operators specify actions to be performed on two terms or expressions. Expressions must be enclosed in angle brackets. Table 3-4 summarizes the binary operators. Table 3-4 Binary Operators Binary Operator Operator Name Example Operation Plus sign A+B Addition Minus sign A-B Subtraction * Asterisk A*B Multiplication I Slash A/B Division At sign A@B Arithmetic shift Ampersand A&B Logical AND Exclamation p oint A!B Logical inclusive OR Backslash A\B Logical exclusive OR + & \ 3-15 THE COMPONENTS OF MACRO SOURCE STATEMENTS All binary operators have equal priority. Terms or expressions can be grouped for evaluation by enclosing them in angle brackets. The enclosed terms and expressions are then evaluated first, and remaining operations are performed from left to right. For example: .LONG .LONG 1+2*3 1+<2*3> ; EQUALS 9 ; EQUALS 7 Note that a 4-byte result is returned from all binary operations. If a 1-byte or 2-byte operand is used, the result is the low-order byte(s) of the 4-byte result. VAX-11 MACRO displays an error message if the truncation causes a loss of significance. The· following sections describe the arithmetic shift, logical AND, logical inclusive OR, and logical exclusive OR operators in more detail. 3.7.1 Arithmetic Shift Operator The arithmetic shift operator (@) is used to perform left and right arithmetic shift of arithmetic quantities. The first argument is shifted left or right the number of bit positions specified by the second argument. If the second argument is positive, the first argument is shifted left; if the second argument is negative, the first argument is shifted right. When the first argument is shifted left, the low-order bits are set to O; and when the first argument is shifted right, the high-order bits are set to the value of the original high-order bit (the sign bit). For example: A .LONG .LONG MOVL AB101@4 1@2 #<AB1100000@-5>,RO YIELDS 1010000 (BINARY) YIELDS 100 (BINARY) YIELDS 11 (BINARY) .LONG .LONG l@A AX1234@-A YIELDS 10000 (BINARY) YIELDS 123(HEX) 4 3.7.2 Logical AND Operator The logical AND operator (&) takes the logical AND of two operands. For example: A B AB1010 ABllOO .LONG A&B YIELDS 1000 (BINARY) 3-16 THE COMPONENTS OF MACRO SOURCE STATEMENTS Logical Inclusive OR Operator 3.7.3 The logical inclusive OR operator (!) takes the logical of two operands. inclusive OR For example: A ~81010 B ~81100 .LONG YIELDS 1110 (BINARY) A!B Logical Exclusive OR Operator 3.7.4 The logical exclusive OR operator (\) takes the logical of two arguments. exclusive OR For example: A B ~81010 ~81100 .LONG 3.8 A\B YIELDS 0110 (BINARY) DIRECT ASSIGNMENT STATEMENTS A direct assignment statement equates a symbol to a specific value. Unlike a symbol that is used as a label, a symbol defined with a direct assignment statement can be redefined as many times as desired. Formats symbol=expression symbol==expression symbol A user-defined symbol. expression An expression that does not contain any Section 3.5). undefined symbols (see The format with a single equal sign {=) defines a local symbol and the format with a double equal sign {==) defines a global symbol. See Section 3.3.3 for more information about local and global symbols. The following statements: three syntactic rules apply to direct assignment • An equal sign {=) or double equal sign {==) must separate the symbol from the expression defining the symbol's value. Spaces preceding and/or following the direct assignment operators have no significance in the resulting value. • Only one symbol can be defined in a single statement. • A direct assignment comment field. statement 3-17 can be direct followed assignment only by a THE COMPONENTS OF MACRO SOURCE STATEMENTS In addition, by DIGITAL convention, the symbol in a direct statement is placed in the label field. assignment For example: A = 1 B A@5 THE SYMBOL 'A' IS GLOBALLY EQUATED TO THE VALUE 1 THE SYMBOL 'B' IS EQUATED TO 1@5 OR 20(HEX) THE SYMBOL 'C' IS EQUATED TO 1270(DEC) THE SYMBOL 'D' IS EQUATED TO lO(HEX) c = 127*10 D = "'XlOO/""XlO 3.9 CURRENT LOCATION COUNTER The period (.), the symbol for the current location counter, always has the value of the address of the current byte. VAX-11 MACRO sets the current location counter to 0 at the beginning of the assembly and at the beginning of each new program section. Every VAX-11 MACRO source statement that allocates memory in the object module increments the value of the current location counter by the number of bytes allocated. For example, the directive .LONG 0 increments the current location counter by 4. However, a direct assignment statement, except the special form described below, does not increase the current location counter because no memory is allocated. The current location counter can be explicitly set by a special form of the direct assignment statement. The location counter can be either incremented or decremented. Explicitly. setting the location counter is often useful when defining data structures. Data storage areas should not be reserved by explicitly setting the location counter; the .BLKx directives should be used instead (see Chapter 5). Format .=expression expression An expression that does not contain any Section 3.5). undefined symbols (see In a relocatable program section, the expression must be relocatable; that is, the expression must be relative to an address in the current program section. It can be relative to the current location counter. For example: MOVES LOCATION COUNTER FORWARD = .+40 When a program section previously defined in the current module is continued, the current location counter is set to the last value of the current location counter in that program section. When the current location counter is used in the operand field of an instruction, the current location counter has the value of the address of that operand--it does not have the value of the address of the beginning of the instruction. For this reason, the current location counter is not normally used as a part of the operand specifiar. 3-18 CHAPTER 4 ADDRESSING MODES This chapter summarizes the VAX-11 addressing modes and contains examples of VAX-11 MACRO statements that use these addressing modes. The VAX-11 Architecture Handbook describes the addressing modes in detail. There are four types of addressing modes: • General Register • Program Counter • Index • Branch Although index mode is a general register mode, it is considered a separate type of mode because it can be used only in combination with another type of mode. Table 4-1 summarizes the addressing modes. 4.1 GENERAL REGISTER MODES The general register modes use registers RO through Rl2, AP {the as Rl2)' FP, and SP. There are eight general register modes: • Register • Register Deferred • Autoincrement • Autoincrement Def erred • Autodecrement • Displacement • Displacement Deferred • Literal 4-1 same ADDRESSING MODES Table 4-1 Addressing Modes --- Type Addressing Mode Format* --+------ ______ Hexadecimal Value Description Indexable? -----·----·----------------· ~,, ----i Register Rn 5 Register contains the operand No Register Deferred (Rn) 6 Register contains the address of the operand Yes Auto increment (Rn)+ 8 Register contains the address of the operand; the processor increments the register contents by the size of the operand data type Yes Auto increment Def erred @(Rn)+ 9 Register contains the address of the operand address; the processor increments the register contents by 4 Yes Autodecrement -(Rn) 7 The processor decrements the register contents by the size of the operand data type; the register then contains the address of the operand Yes Displacement dis(Rn) B"dis(Rn) W"dis(Rn) L"dis(Rn) The sum of the contents of the register and the displacement is the address of the operand; B", w",and L" indicate byte, word, and longword displacement, respectively Yes A Displacement Deferred @dis(Rn) @B"dis(Rn) @W"dis(Rn) @L"dis(Rn) The sum of the contents of the register and the displacement is the address of the operand address; B", w", and L" indicate byte, word, and longword displacement, respectively Yes B D F General Register (Cont.) Literal tliteral S"tliteral The literal specified is the the operand; the literal is stored as a short literal No 0-3 Program Counter Relative General Register c E address B"address W"address L"address A Relative Deferred @address @B"address @W"address @L"address B D F Absolute @taddress 9 Immediate tliteral I"tli teral 8 G"address - General c E The address specified is the Yes address of the operandi the address specified is stored as a d~splacement from PC; B", W", and L" indicate byte, word, and longword displacement, respectively The address specified is the address of the operand address; the address specified is stored as a displacement from PC; B", W", and L" indicate byte, word, and longword displacement, respectively Yes The address specified is the address of the operand; the address specified is stored as an absolute virtual address (not as a displacement) Yes The literal specified is the operand; the literal is stored as a byte, word, longword, or quadword No The address specified is the address of the operand;[ if the address is defined as relocatable, the linker stores the address as a displacement from PC; if the address is defined as an absolute virtual address, the linker stores the address as an absolute value Yes ---·---------- L..-. (continued on next page) 4-2 ADDRESSING MODES Table 4-1 (Cont.) Addressing Modes _,...__,, Type Addressing Mode Format* Hexadecimal Value Indexable? Description Index Index base-mode [Rx] 4 The base-mode specifies the base address and the register specifies the index; the sum of the base address and the product of the contents of Rx and the size of the operand data type is the address of the operand; base-mode can be any addressing mode except register, immediate, literal, index, or branch No Branch Branch address - The address specified is the operand; this address is stored as a displacement to PC; branch mode can only be used with the branch instructions No . ---'-···-·· * ____ -·--·~·-· ,,.-;~~ - ·--·· Key: Rn Any general register RO through Rl2. Note that the AP, FP, or SP register can be used in place of Rn. Rx Any general register RO through Rl2. Note that the AP, FP, or SP register can be used in place of Rx. Rx cannot be the same as the Rn specified in the base-mode for certain base modes(see Section4.3). dis An expression specifying a displacement. address An expression specifying an address. literal An expression, an integer constant, or a floating-point constant. 4-3 ADDRESSING MODES 4.1.1 Register Mode In register mode, the operand is the register, except in the following cases: contents of the specified • For quadword, D floating, G floating or variable-bit field operands, the- operand Ts the contents of register n concatenated with the contents of register n+l. • For octaword and H floating operands, contents of register n concatenated registers n+l, n+2, and n+3. the operand is the with the contents of In each of these cases, the least significant bytes of the operand are in register n and the most significant bytes are in the highest register used, either n+l or n+3. The results of the operation are unpredictable if PC is used in register mode or if the use of a large data type extends the operand into the PC. Formats Rn AP FP SP n A number in the range of 0 through 12. Example CLRB CLRQ TSTW INCL 4.1.2 RO Rl RlO R4 CLEAR LOWEST BYTE OF RO CLEAR Rl AND R2 TEST LOWER WORD OF RlO ADD 1 TO R4 Register Deferred Mode In register deferred mode, the register contains the address of the operand. Register deferred mode can be used with index mode (see Section 4.3). Formats (Rn) (AP) (FP) (SP) n A number in the range of 0 through 12. Example 10$: MOVAL CMPL BEQL CLRL MOVL MOVZBL LDATA,R3 (R3) ,RO 10$ (R3) (SP) ,Rl (AP) ,R4 MOVE ADDRESS OF LDATA TO R3 COMPARE VALUE AT LDATA TO RO IF THEY ARE THE SAME, IGNORE CLEAR LONGWORD AT LDATA COPY TOP ITEM OF STACK INTO Rl GET NUMBER OF ARGUMENTS IN CALL 4-4 ADDRESSING MODES Autoincrement Mode 4.1.3 In autoincrement mode, the register contains the address of the operand. After evaluating the operand address contained in the register, -the processor increments that address by the size of the operand data type. The processor increments the contents of the register by 1, 2, 4, 8, or 16 for a byte, word, longword, quadword, or octaword operand, respectively. Autoincrement mode can be used with index mode (see Section 4.3), but the index register cannot be the same as the register specified in autoincrement mode. Formats (Rn)+ (AP)+ (FP)+ (SP)+ n A number in the range of 0 through 12. Example MOVAL CLRQ CLRL MOVAB INCB INCB XORL3 TABLE,Rl (Rl)+ (Rl)+ GET ADDRESS OF TABLE CLEAR FIRST AND SECOND LONGWORDS AND THIRD LONGWORD IN TABLE LEAVE Rl POINTING TO TABLE +12 BYTARR,R2 GET ADDRESS OF BYTARR (R2)+ INCREMENT FIRST BYTE OF BYTARR AND SECOND (R2)+ (R3)+,(R4)+,(RS)+ ; EXCLUSIVE-OR THE TWO LONGWORDS WHOSE ADDRESSES ARE STORED IN R3 AND R4 AND STORE RESULT IN ADDRESS CONTAINED IN RS, THEN ADD 4 TO R3, R4, AND RS Autoincrement Deferred Mode 4.1.4 In autoincrement deferred mode, the register contains an address that is the address of the operand address (a pointer to the operand). After evaluating the operand address, the processor increments the contents of the register by 4 (the size in bytes of an address). Autoincrement deferred mode can be used with index mode (see Section 4.3), but the index register cannot be the same as the register specified in autoincrement deferred mode. Formats @(Rn)+ @(AP)+ @(FP)+ @(SP)+ n A number in the range of O through 12. 4-5 ADDRESSING MODES Example MOVAL CLRQ PNTLIS,R2 @(R2)+ CLRB @(R2)+ MOVL RlO,@(RO)+ GET ADDRESS OF POINTER LIST CLEAR QUADWORD POINTED TO BY FIRST ABSOLUTE ADDRESS IN PNTLIS THEN ADD 4 TO R2 CLEAR BYTE POINTED TO BY SECOND ABSOLUTE ADDRESS IN PNTLIS THEN ADD 4 TO R2 MOVE RlO TO LOCATION WHOSE ADDRESS IS POINTED TO BY RO; THEN ADD 4 TO RO Autodecrement Mode 4.1.5 In autodecrement mode, the processor decrements the contents of the register by the size of the operand data type; then the register contains the address of the operand. The processor decrements the register by 1, 2, 4, 8, or 16 for byte, word, longword, quadword, or octaword operands, respectively. Autodecrement mode can be used with index mode (see Section 4.3), but the index register cannot be the same as the register specified in autodecrement mode. Formats - (Rn) -(AP) -(FP) - (SP) n A number in the range of 0 through 12. Example 4.1.6 CLRO -(Rl) MOVZBL R3,-(SP) CMPB Rl,-(RO) SUBTRACT 8 FROM Rl AND ZERO THE OCTAWORD WHOSE ADDRESS IS THEN IN Rl PUSH THE ZERO-EXTENDED LOW BYTE OF R3 ONTO THE STACK AS A LONGWORD ONTO THE STACK SUBTRACT 1 FROM RO AND COMPARE LOW BYTE OF Rl WITH BYTE WHOSE ADDRESS IS NOW IN RO Displacement Mode In displacement mode, the sum of the contents of the register and the displacement (sign extended to a longword) is the address of the operand. Displacement mode can be used with index mode 4-6 (see Section 4.3). ADDRESSING MODES Formats dis (Rn) dis(AP) dis(FP) dis(SP) n A number in the range of 0 through 12. dis An expression specifying a displacement; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement. Displacement Length Specifier B"' w"' L .... Meaning Displacement requires 1 byte Displacement requires 1 word (2 bytes) Displacement requires 1 longword (4 bytes) If no displacement length specified precedes the expression and the value of the expression is known, the assembler chooses the smallest number of bytes (1, 2, or 4) needed to store the displacement. If no length specifier precedes the expression and the value of the expression is unknown, the assembler reserves 1 word (2 bytes) for the displacement. Note that if the displacement is either relocatable or defined later in the source program, the assembler considers it unknown. If the actual displacement does not fit in the memory reserved, the linker displays an error message. Example MOVAB MOVB MOVB CLRW MOVL TSTB MOVAB KEYWORDS,R3 B"'IO(R3) ,R4 GET ADDRESS OF KEYWORDS GET BYTE WHOSE ADDRESS IS IO PLUS ADDRESS OF KEYWORDS i THE DISPLACEMENT IS STORED AS A BYTE B"'ACCOUNT(R3) ,RS; GET BYTE WHOSE ADDRESS IS ACCOUNT PLUS ADDRESS OF KEYWORDS THE DISPLACEMENT IS STORED AS A BYTE L"'STA (Rl) CLEAR WORD WHOSE ADDRESS IS STA PLUS CONTENTS OF Rl THE DISPLACEMENT IS STORED AS A LONGWORD MOVE RO TO ADDRESS THAT IS -2 R0,-2(R2) PLUS THE CONTENTS OF R2 THE DISPLACEMENT IS STORED AS A BYTE TEST THE BYTE WHOSE ADDRESS EXTRN(R3) IS EXTRN PLUS THE ADDRESS OF KEYWORDS THE DISPLACEMENT IS STORED AS A WORD SINCE EXTRN IS UNDEFINED 2(RS),RO MOVE <CONTENTS OF RS> + 2 TO RO Note If the value of the displacement is O and no displacement length is specified, the assembler uses register deferred mode rather than displacement mode. 4-7 ADDRESSING MODES 4.1.7 Displacement Deferred Mode In displacement deferred mode, the sum of the contents of the register and the displacement (sign extended to a longword) is the address of the operand address (a pointer to the operand). Displacement deferred mode can be used with index mode (see Section 4. 3) • Formats @dis(Rn) @dis(AP) @dis(FP) @dis(SP) n A number in the range of 0 through 12. dis An expression specifying a displacement; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement. Displacement Length Specifier B"' w"' L ... Meaning Displacement requires 1 byte Displacement requires 1 word (2 bytes) Displacement requires 1 longword (4 bytes) If no displacement length specifier precedes the expression and the value of the expression is known, the assembler chooses the smallest number of bytes (1, 2, or 4) needed to store the displacement. If no length specifier precedes the expression and the value of the expression is unknown, the assembler reserves 1 word (2 bytes) for the displacement. Note that if the displacement is either relocatable or defined later in the source program, the assembler considers it unknown. If the actual displacement does not fit in the memory reserved, the linker displays an error message. Example MOVAL CLRL MOVL CLRW ARRPOINT,R6 @16(R6) GET ADDRESS OF ARRAY OF POINTERS CLEAR LONGWORD POINTED TO BY LONGWORD WHOSE ADDRESS IS 16 PLUS THE ADDRESS OF ARRPOINT ; THE DISPLACEMENT IS STORED AS A BYTE @B"'OFFS(R6),@RSOFF(R6) ; MOVE THE LONGWORD POINTED TO BY LONGWORD WHOSE ADDRESS IS OFFS PLUS THE ADDRESS OF ARRPOINT TO THE ADDRESS POINTED TO BY LONGWORD WHOSE ADDRESS IS RSOFFS PLUS THE ADDRESS OF ARRPOINT THE FIRST DISPLACEMENT IS STORED AS A BYTE THE SECOND DISPLACEMENT IS STORED AS A WOF @84(R2) CLEAR THE WORD THAT IS POINTED TO BY LONGWORD AT 84 PLUS THE CONTENTS OF R2--THE ASSEMBLER USES BYTE DISPLACEMENT AUTOMATICALLY 4-8 ADDRESSING MODES Literal Mode 4.1.8 In literal mode, the value of the literal is stored in the mode byte itself. addressing Formats #literal S""#literal literal An expression, an integer constant, or a floating-point constant. The literal must fit in the short literal form. That is, integers must be in the range of O through 63 and floating-point constants must be one of the· 64 values listed in Table 4-2. Floating-point short literals are stored with a 3-bit exponent and a 3-bit fraction. Table 4-2 also shows the value of the exponent and the fraction for each literal. See the VAX-11 Architecture Handbook for information on the format of short literals. Table 4-2 Floating Point Short Literals ~ 0 1 0 1 2 3 4 5 6 7 0.5 1.0 2.0 4.0 8.0 16.0 32.0 64.0 0.5625 1.125 2.25 4.5 9.0 18.0 3fl.O 72.0 2 3 4 5 0.625 1. 25 2.5 5.0 10.0 20.0 40.0 80.0 0.6875 1.37 2.75 5.5 11.0 22.0 44.0 88.0 0.75 1.5 3.0 0.8125 l .fi25 3.25 fi 7 0.875 1. 75 3.5 7.0 14.0 28.0 56.0 112.0 0.9375 1.875 3.75 7.5 15.0 30.0 t fi .o 12.0 24.0 48.0 96.0 fi .5 13.0 26.0 52.0 104.0 fiO .O 120.0 Example MOVL #1,RO MOVB S""#CR,Rl MOVF #0.625,Rn RO IS SET TO l; THE 1 IS STORED IN THE INSTRUCTION AS A SHORT LITERAL THE LOW BYTE OF Rl IS SET TO THE VALUE CR CR IS STORED IN THE INSTRUCTION AS A SHORT LITERAL IF CR IS NOT IN RANGE 0-n3, THE LINKER PRODUCES A TRUNCATION ERROR R6 IS SET TO THE FLOATING POINT VALUE 0.625; IT IS STORED IN THE FLOATING POINT SHORT LITERAL FORM 4-9 ADDRESSING MODES Notes 1. When the #literal format is used, the assembler chooses whether to use literal mode or immediate mode (see Section 4.2.4). The assembler uses immediate mode if any of the following conditions are met: • The value of the literal does not fit in the short literal form • The literal is a relocatable or external Section 3.5) • The literal symbols is an expression that expression contains (see undefined The difference between immediate mode and literal mode is the amount of storage that it takes to store the literal in the instruction. 2. 4.2 The SA#literal format forces the mode. assembler to use literal PROGRAM COUNTER MODES The program counter modes use PC for a general register. There are five program counter modes: • Relative • Relative Def erred • Absolute • Immediate • General 4.2.1 Relative Mode In relative mode, the address specified is the address of the operand. The assembler stores the address as a displacement from PC. Relative mode can be used with index mode (see Section 4.3). Format address address An expression specifying an address; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement. 4-10 ADDRESSING MODES Displacement Length Specifier Meaning Displacement requires 1 byte Displacement requires 1 word (2 bytes) Displacement requires 1 longword (4 bytes) If no displacement length specifier precedes the address expression and the value of the expression is known, the assembler chooses the smallest number of .bytes (1, 2, or 4) needed to store the displacement. If no length specifier precedes the address expression and the value of the expression is unknown, the assembler uses the default displacement length (see the description of .DEFAULT in Chapter 5). If the addreas expression is either defined later in the program or defined in another program section, the assembler considers the value unknown. Example MOVL GET LONGWORD AT LABEL; THE ASSEMBLER USES DEFAULT DISPLACEMENT UNLESS LABEL PREVIOUSLY DEFINED IN THIS SECTION COMPARE RlO WITH LONGWORD AT ADDRESS DATA+4; THE ASSEMBLER USES A WORD DISPLACEMENT LABEL,Rl CMPL Relative Deferred Mode 4.2.2 In relative deferred mode, the address specified is the address of the operand address (a pointer to the operand). The assembler stores the address specified as a displacement from PC. Relative deferred mode can be used with index mode (see Section 4.3). Format @address address An expression specifying an address; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement. Displacement Length Specifier Meaning Displacement requires 1 byte Displacement requires 1 word (2 bytes) Displacement requires 1 longword (4 bytes) If no displacement length specifier precedes the address expression and the value of the expression is known, the assembler chooses the smallest number of bytes (1, 2, or 4) needed to store the displacement. If no length specifier precedes the address expression and the value of the expression is unknown, the assembler uses the default displacement length (see the description of .DEFAULT in Chapter 5). If the address expression is either defined later in the program or defined in another program section, the assembler considers the value unknown. 4-11 ADDRESSING MODES Example CLRL @W .. PNTR INCB @L .. COUNTS+4 CLEAR LONGWORD POINTED TO BY LONGWORD AT PNTR; THE ASSEMBLER USES A WORD DISPLACEMENT INCREMENT BYTE POINTED TO BY LONGWORD AT COUNTS+4; ASSEMBLER USES A LONGWORD DISPLACEMENT Absolute Mode 4.2.3 In absolute moqe, the address specified is the address of the operand. The address is stored as an absolute virtual address (compare relative mode, where the address is stored as a displacement from PC). Absolute mode can be used with index mode (see Section 4.3). Format @#address address An expression specifying an address. Example CLRL CLRB @#"XllOO @#ACCOUNT CALLS #3,@#SYS$FAO CLEAR THE CONTENTS OF LOCATION llOO(HEX) CLEAR THE CONTENTS OF LOCATION ACCOUNT; THE ADDRESS IS STORED ABSOLUTELY, NOT AS A DISPLACEMENT CALL THE PROCEDURE SYS$FAO WITH THREE ARGUMENTS ON THE STACK Immediate Mode 4.2.4 In immediate mode, the literal specified is the operand. Formats #literal I .. #literal literal An expression, an integer constant, or a floating-point constant. Example MOVL #1000 ,RO MOVB #BAR,Rl MOVF #O.l,R6 ADDL2 I .. #5,RO RO IS SET TO 1000; THE OPERAND 1000 IS STORED IN A LONGWORD THE LOW BYTE OF Rl IS SET TO THE VALUE OF BAR R6 IS SET TO THE FLOATING POINT VALUE 0.1; IT IS STORED AS A 4-BYTE FLOATING POINT VALUE (IT CAN NOT BE REPRESENTED AS A SHORT LITERAL) THE 5 IS STORED IN A LONGWORD BECAUSE THE I .. FORCES THE ASSEMBLER TO USE IMMEDIATE MODE; 4-12 ADDRESSING MODES Notes 1. When the #literal format is used, the assembler chooses whether to use literal mode (Section 4.1.8) or immediate mode. If the literal is an integer from 0 through 63 or a floating-point constant that fits in the short literal form, the assembler uses literal mode. If the literal is an expression, the assembler uses literal mode if all the following conditions are met: • The expression is absolute • The expression contains no undefined symbols • The value of the expression fits in the short literal form In all other cases, the assembler uses immediate mode. The difference between immediate mode and literal mode is the amount of storage required to store the literal in the instruction. The assembler stores an immediate mode literal in a byte, word, or longword depending on the operand data type. 2. 4.2.5 The IA#literal format forces the assembler to mode. use immediate General Mode In general mode, the address specified is the address of the operand. The linker converts the addressing mode to either relative or absolute mode. If the address is relocatable, the linker converts general mode to relative mode. If the address is absolute, the linker converts general mode to absolute mode. General mode is used to write position-independent code when the programmer does not know whether the address is relocatable or absolute. A general addressing mode operand requires 5 bytes of storage. General mode can be used with index mode (see Section 4.3). Format address An expression specifying an address. Example CLRL CALLS GALABEL 1 CLEARS THE LONGWORD AT LABEL 1 IF LABEL 1 IS DEFINED AS ABSOLUTE THEN THIS IS CONVERTED TO ABSOLUTE MODE; IF IT IS DEFINED AS RELOCATABLE, THEN THIS IS CONVERTED ; TO RELATIVE MODE #5,GASYS$SERVICE ; CALLS PROCEDURE SYS$SERVICE ; WITH 5 ARGUMENTS ON STACK 4-13 ADDRESSING MODES 4.3 INDEX MODE Index mode is a general register mode that can be used only in combination with another mode, called the base mode. The base mode can be any addressing mode except register, immediate, literal, index, or branch. The assembler first evaluates the base mode to get the base address. Then the assembler adds the base address to the product of the contents of the index register and the number of bytes of the operand data type. This sum is the operand address. Combining index mode with the following addressing modes: other • Register Deferred Index • Autoincrement Index • Autoincrement Def erred Index • Autodecrement Index • Displacement Index • Displacement Def erred Index • Relative Index • Relative Deferred Index • Absolute Index • General Index addressing modes The process of first evaluating the base mode and index register is the same for each of these modes. produces the adding the then Formats base-mode[Rx] base-mode[AP) base-mode[FP] base-mode[SPJ base-mode Any addressing mode except register, immediate, or branch, specifying the base address. literal, index, x A number in register. the range O through 12, specifying Table 4-3 lists the formats of index mode addressing. 4-14 the index ADDRESSING MODES Examples ; ; REGISTER DEFERRED INDEX MODE ; DEFINE OFFS GET ADDRESS OF BLIST SET UP INDEX REGISTER CLEAR BYTE WHOSE ADDRESS IS THE ADDRESS OF BLIST PLUS 20*1 CLEAR QUADWORD WHOSE ADDRESS IS THE ADDRESS OF BLIST PLUS 20*8 CLEAR OCTAWORD WHOSE ADDRESS IS THE ADDRESS OF BLIST PLUS 20*16 OFFS=20 MOVAB MOVL CLRB BLIST,R9 #OFFS,Rl (R9) [Rl] CLRQ (R9) [Rl] CLRO (R9) [Rl] AUTOINCREMENT INDEX MODE CLRW (R9)+[Rl] CLEAR WORD WHOSE ADDRESS IS ADDRESS OF BLIST PLUS 20*2; R9 NOW CONTAINS ADDRESS OF BLIST+2 AUTOINCREMENT DEFERRED INDEX MODE MOVAL MOVL CLRW POINT ,R8 #30,R2 @(R8)+[R2] GET ADDRESS OF POINT SET UP INDEX REGISTER CLEAR WORD WHOSE ADDRESS IS 30*2 PLUS THE ADDRESS STORED IN POINT; RB NOW CONTAINS 4 PLUS ADDRESS OF POINT DISPLACEMENT DEFERRED INDEX MODE MOVAL MOVL TSTF ADDARR,R9 #100 ,Rl @40 (R9) [Rl] GET ADDRESS OF ADDRESS ARRAY SET UP INDEX REGISTER TEST FLOATING POINT VALUE WHOSE ADDRESS IS 100*4 PLUS THE ADDRESS STORED AT (ADDARR+40) 4-15 ADDRESSING MODES Table 4-3 Index Mode Addressing Mode Format* Register Deferred Index (Rn) [Rx] Auto increment Index (Rn)+[Rx] Auto increment Deferred Index @(Rn)+[Rx] Autodecrement Index - (Rn) [Rx] Displacement Index dis (Rn) [Rx] Displacement Deferred Index @dis(Rn) [Rx] Relative Index address[Rx] Relative Def erred Index @.address[Rx] Absolute Index @#address[Rx] General Index G"'address[Rx] * Key: Rn Any general register RO through Rl2 or the AP, FP, register. or SP Rx Any general register RO through Rl2 or the AP, FP, or SP register. Rx cannot be the same register as Rn in the autoincrement index, autoincrement deferred index, and decrement index addressing modes. dis An expression specifying a displacement. address An expression specifying an address. Notes 1. If the base mode alters the contents of its register (autoincrement, autoincrement deferred, and autodecrement), the index mode cannot specify the same register. 2. The index register is added to the address after the base mode is completely evaluated. For example, in autoincrement deferred index mode, the base register contains the address of the operand address. The index register (times the length of the operand data type) is added to the operand address rather than to the address stored in the base register. 4-16 ADDRESSING MODES 4.4 BRANCH MODE In branch mode, the address is stored as an implied displacement from PC. This mode can only be used in branch instructions. The displacement for conditional branch instructions and the BRB instruction is stored in a byte. The displacement for the BRW instruction is stored in a word (2 bytes). A byte displacement allows a range of 127 bytes forward and 128 bytes backward. A word displacement allows a range of 32767 bytes forward and 32768 bytes backward. The displacement is relative to the updated PC, the byte past the byte or word where the displacement is stored. See the VAX-11 Architecture Handbook for more information on the branch instructions. Format address address An expression that represents an address. Example ADDL3 (Rl)+,RO,TOTAL BLEQ LABELl BRW LABEL TOTAL VALUES AND SET CONDITION CODES BRANCH TO LABELl IF RESULT IS LESS THAN OR EQUAL TO 0 BRANCH UNCONDITIONALLY TO LABEL 4-17 CHAPTER 5 GENERAL ASSEMBLER DIRECTIVES The general assembler directives provide facilities for performing eleven types of functions. Table 5-1 lists these types of functions and the directives that fall under them. The remainder of this chapter describes the directives in detail, showing their formats and giving examples of their use. For ease of reference, the directives are presented in alphabetical order in this chapter. In addition, Appendix B contains a summary of all assembler directives. Table 5-1 Summary of General Assembler Directives Directivesl Category Listing Control Directives (.LIST) .SHOW ( .NLIST) .NOS HOW .TITLE .SUBTITLE (. SBTTL) • IDENT .PAGE Message Display Directives .PRINT .WARN .ERROR Assembler Option· Directives .ENABLE (.ENABL) .DISABLE (.DSABL) .DEFAULT Data Storage Directives .BYTE .WORD .LONG .ADDRESS .QUAD .OCTA .PACKED .ASCII .ASCIC .ASCID .ASCIZ • F FLOATING (.FLOAT) .D-FLOATING (.DOUBLE) .G FLOATING • H-FLOATING .SIGNED BYTE .SIGNED-WORD 1. The alternate form, if any, is given in parentheses. (continued on next page) 5-1 GENERAL ASSEMBLER DIRECTIVES Table 5-1 (Cont.) Summary of General Assembler Directives Category Directives 1 Location Control Directives .ALIGN .EVEN .ODD .BLKA .BLKB .BLKD .BLKF .BLKG .BLKH .BLKL .BLKO .BLKQ .BLKW .END Program Sectioning Directives .PSECT .SAVE PSECT (.SAVE) .RESTORE PSECT (.RESTORE) Symbol Control Directives Directives .GLOBAL ( .GLOBL) .EXTERNAL (.EXTRN) .DEBUG .WEAK Routine Entry Point Definition Directives .ENTRY .TRANSFER .MASK Conditional and Subconditional Assembly Block Directives .IF .ENDC (.!FF) .IF FALSE • IF-TRUE (.!FT) • IF-TRUE FALSE (. IFTF) .IIF - Cross-Reference Directives .CROSS .NOCROSS Instruction Generation Directives .OPDEF .REFl .REF2 .REF4 .REFS .REF16 1. The alternate form, if any, is given in parentheses. 5-2 GENERAL ASSEMBLER DIRECTIVES .ADDRESS .ADDRESS -- ADDRESS STORAGE DIRECTIVE .ADDRESS stores successive longwords containing addresses in the object module. DIGITAL recommends that .ADDRESS rather than .LONG be used for storing address data to provide additional information to the linker. In shareable images, addresses specified with .ADDRESS produce position-independent code. See the VAX-11 MACRO User's Guide for a discussion of specifying addresses in position-independent code. Format .ADDRESS address-list Parameter address-list A list of symbols or expressions, separated by commas, that VAX-11 MACRO interprets as addresses. Repetition factors are not allowed. Example TABLE: .ADDRESS LAB_4,LAB_3,ROUTTERM 5-3 REFERENCE TABLE GENERAL ASSEMBLER DIRECTIVES .ALIGN .ALIGN LOCATION COUNTER ALIGNMENT DIRECTIVE .ALIGN aligns the location counter to the boundary specified by either an integer or a keyword. Formats .ALIGN integer[,expression] .ALIGN keyword[,expression] Parameters integer An integer in the range of 0 through 9. The location counter is aligned at an address that is the value of 2 raised to the power of the integer. keyword One of five keywords that specify the alignment boundary. The location counter is aligned to an address that is the next multiple of the values listed below. Keyword Size (in Bytes) BYTE WORD LONG QUAD PAGE 2"0 1 2"1 = 2 2"2 = 4 2"3 8 2"9 512 expression Specifies the fill value to be stored in each byte. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). Example .ALIGN .ALIGN .ALIGN .ALIGN BYTE,O WORD 3,"A/ I PAGE BYTE ALIGNMENT-FILL WITH NULL WORD ALIGNMENT QUAD ALIGNMENT-FILL WITH BLANKS PAGE ALIGNMENT Notes 1. The alignment specified in .ALIGN cannot exceed the alignment of the program section in which the alignment is attempted (see the description of .PSECT). For example, if the default program section alignment (BYTE) is being used and .ALIGN is specified with a WORD or larger alignment, the assembler displays an error message. 2. If the optional expression is supplied, the bytes skipped by the location counter (if any) are filled with the value of that expression. Otherwise, the bytes are zero filled. 5-4 GENERAL ASSEMBLER DIRECTIVES 3. Although most instructions do not require any data alignment other than byte alignment, execution speed is improved by the following alignments: Data Length Alignment Word Longword Quadword Word Longword Quadword 5-5 GENERAL ASSEMBLER DIRECTIVES .ASClx .ASCix -- ASCII CHARACTER STORAGE DIRECTIVES VAX-11 MACRO has four ASCII character storage directives: Directive Function ASCII ASCIC ASCID ASCIZ ASCII string storage Counted ASCII string storage String-descriptor ASCII string storage Zero-terminated ASCII string storage Each directive is followed by a string of characters enclosed in a pair of matching delimiters. The delimiters can be any printable character except the space, tab, equal sign (=), semicolon (;), or left angle bracket {<). The character used as the delimiter cannot appear in the string itself. Alphanumeric characters can be used as delimiters; however, nonalphanumeric characters should be used to avoid confusion. Any character except the null, carriage return, and form feed characters can appear within the string. The assembler does not convert lowercase alphabetic characters to uppercase. ASCII character storage directives convert the characters to their 8-bit ASCII value (see Appendix A) and store them one character to a byte. Any character, including the null, carriage return, and form feed characters, can also be represented by an expression enclosed in angle brackets outside of the delimiters. You must define the ASCII values of null, carriage return, and form feed with a direct assignment statement. The ASCII character storage directives store the 8-bit binary value specified by the expression. ASCII strings can be continued over several lines but the string on each line must be delimited at both ends; however, a different pair of delimiters can be used for each line. For example: CR=l3 LF=lO .ASCII .ASCIZ .ASCIC .ASCII .ASCII .ASCII .ASCII /ABC DEFG/ @Any character can be delimiter@ ? lowercase is not converted to UPPER? ? this is a test!?<CR><LF>!Isn't it?! \ Angle Brackets <are part <of> this> string \ I This string is continued I \ on the next line \ <CR><LF>! this string includes an expression! - <128+CR>? whose value is a 13 plus 128? The following sections describe each of the four ASCII character storage directives, giving the formats and examples of each. 5-6 GENERAL ASSEMBLER DIRECTIVES .ASCII .ASCII -- ASCII STRING STORAGE DIRECTIVE .ASCII stores in the next available byte the ASCII value of each character in the ASCII string or the value of each byte expression. Format .ASCII string Parameter string A delimited ASCII string. Example CR=l3 LF=lO .ASCII .ASCII "DATE: 17-NOV-1979" /EOF/<CR><LF> DIRECT ASSIGNMENT STATEMENTS DEFINE CR AND LF DELIMITER IS " DELIMITER IS / .ASCIC .ASCIC -- COUNTED ASCII STRING STORAGE DIRECTIVE .ASCIC performs the same function as .ASCII, except that .ASCIC inserts a count byte before the string data. The count byte contains the length of the string in bytes. The length given includes any bytes of nonprintable characters outside the delimited string but excludes the count byte • • ASCIC is useful in copying text length of the text to be copied. because the count indicates the Format .ASCIC string Parameter string A delimited ASCII string. Example CR=l3 DIRECT ASSIGNMENT STATEMENT DEFINES CR .ASCIC #HELLO#<CR> .BYTE .ASCII 6 #HELLO#<CR> THIS COUNTED ASCII STRING IS EQUIVALENT TO THE COUNT FOLLOWED BY THE ASCII STRING 5-7 GENERAL ASSEMBLER DIRECTIVES .ASCID .ASCID -- STRING-DESCRIPTOR ASCII STRING STORAGE DIRECTIVE .ASCID performs the same function as ASCII, except that .ASCID inserts a string descriptor before the string data. The string descriptor consists of 1) two bytes that specify the length of the string, 2) two bytes of descriptor information, and 3) a longword containing a position-independent pointer to the string. String descriptors are used in calling procedures (see Appendix C of the VAX-11 Architecture Handbook). Position-independence is discussed in the VAX-11 MACRO User's Guide. Format .ASCID string Parameter string A delimited ASCII string. Example DESCRl: .ASCID DESCR2: .ASCID PUS HAL PUS HAL CALLS /ARGUMENT FOR CALL/ /SECOND ARGUMENT/ STRING DESCRIPTOR ANOTHER ONE DESCRl DESCR2 #2,STRNG_PROC PUT ADDRESS OF DESCRIPTORS ON THE STACK CALL PROCEDURE .ASCIZ .ASCIZ -- ZERO-TERMINATED ASCII STRING STORAGE DIRECTIVE .ASCIZ performs the same function as .ASCII, except that .ASCIZ appends a null byte as the final character of the string. Thus, when a list or text string is created with an .ASCIZ directive, the user need only perform a search for the null character in the last byte to determine the end of the string. Format .ASCIZ string Parameter string A delimited ASCII string. Example DEFINE FF FF=l2 .ASCIZ /ABCDEF/ .ASCIZ /A/<FF>/B/ 6 CHARACTERS IN STRING 7 BYTES OF DATA 3 CHARACTERS IN STRINGS 4 BYTES OF DATA 5-8 GENERAL ASSEMBLER DIRECTIVES .BLKx .BLKx -- BLOCK STORAGE ALLOCATION DIRECTIVES VAX-11 MACRO has ten block storage directives: Directive Function .BLKA Reserves storage for addresses (longwords) .BLKB Reserves storage for byte data .BLKD Reserves storage for double-precision, floating-point data (quadwords) .BLKF Reserves storage for single-precision, floating-point data (longwords) .BLKG Reserves storage for G floating data (quadwords) .BLKH Reserves storage for H floating data (octawords) .BLKL Reserves storage for longword data .BLKO Reserves storage for octaword data .BLKQ Reserves storage for quadword data .BLKW Reserves storage for word data - - Each directive reserves storage for a different data type. The value of the expression determines the number of data items for which VAX-11 MACRO reserves storage. For example, .BLKL 4 reserves storage for 4 longwords of data and .BLKB 2 reserves storage for 2 bytes of data. The total number of bytes reserved is equal to the length of the type times the value of the expression as follows: Directive Number of Bytes Allocated .BLKB Value of expression .BLKW 2 * value of expression .BLKA .BLKF .BLKL 4 * value of expression .BLKD .BLKG .BLKQ 8 * value of expression .BLKH .BLKO 16 * value of expression 5-9 data GENERAL ASSEMBLER DIRECTIVES Formats .BLKA expression .BLKB expression .BLKD expression .BLKF expression .BLKG expression .BLKH expression .BLKL expression .BLKO expression .BLKQ expression .BLKW expression Parameter expression An expression specifying the amount of storage to be allocated. All the symbols in the expression must be defined and the expression must be an absolute expression (see Section 3.5). If the expression is omitted, a default value of 1 is assumed. Example .BLKB .BLKO .BLKL .BLKF SPACE FOR 15 BYTES SPACE FOR 3 OCTAWORDS (48 BYTES) SPACE FOR 1 LONGWORD (4 BYTES) SPACE FOR 12 SINGLE PRECISION FLOATING-POINT VALUES (48 BYTES) 15 3 1 <3*4> 5-10 GENERAL ASSEMBLER DIRECTIVES .BYTE .BYTE -- BYTE STORAGE DIRECTIVE .BYTE generates successive bytes of binary data in the object module. Format .BYTE expression-list Parameter expression-list One or more expressions separated by commas. Each expression is first evaluated as a longword expression. Then the value of each expression is truncated to 1 byte. The value of each expression should be in the range of O through 255 for unsigned data or in the range of -128 through +127 for signed data. Each expression optionally can be followed by a repetition factor delimited by square brackets. An expression followed by a repetition factor has the format: expressionl[expression2] expressionl An expression that specifies the value to be stored. [expression2] An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required. Example .BYTE .BYTE .BYTE .BYTE .<1024-1000>*2 AXA,FIF,10,65-<21*3> 0 X,X+3 [5*4] ,z STORES A VALUE OF 48 STORES 4 BYTES OF DATA STORES 1 BYTE OF DATA STORES 22 BYTES OF DATA Notes 1. The assembler displays an error message if the high-order 3 bytes of the longword expression has a value other than 0 or AXFFFFFF. 2. At link time, a relocatable expression can result in a value that exceeds 1 byte. In this case, the VAX-11 Linker issues a truncation diagnostic message for the object module in question. For example: A: 3. .BYTE RELOCATABLE VALUE 'A' WILL CAUSE VAX-11 LINKER TRUNCATION DIAGNOSTIC IF THE STATEMENT HAS A VIRTUAL ADDRESS OF 256 OR ABOVE A The .SIGNED BYTE directive is the same as .BYTE except the assembler displays a diagnostic message if a value in the range from 128 to 255 is specified. See the description of .SIGNED BYTE for more information. 5-11 GENERAL ASSEMBLER DIRECTIVES .CROSS .NOCROSS .CROSS AND .NOCROSS -- CROSS-REFERENCE DIRECTIVES VAX-11 MACRO produces a cross-reference listing when the CROSS qualifier is specified in the MACRO command. The .CROSS and .NOCROSS directives control which symbols are included in the cross-reference listing. The .CROSS and .NOCROSS directives have an effect only if /CROSS REFERENCE was specified in the MACRO command (see the VAX-11 MACRO User's Guide). By default, the cross-reference listing includes the definition and all the references to every symbol in the module. The cross-reference listing can be disabled for all symbols or for a specified list of symbols • • NOCROSS without a symbol list disables the cross-reference listing of all symbols. .CROSS without a symbol list reenables the cross-reference listing. Any symbol definition or reference that appears after .NOCROSS without a symbol list and before the next .CROSS with no argument list is excluded from the cross reference listing • • NOCROSS with a symbol list disables the cross-reference listing the listed symbols. .CROSS with a symbol list reenables cross-reference listing of the listed symbols. for the Formats .CROSS .CROSS symbol-list .NOCROSS .NOCROSS symbol-list Parameter symbol-list A list of legal symbol names separated by commas. Examples LABl: .NOCROSS MOVL .CROSS LOC1,LOC2 STOP CROSS REFERENCE COPY DATA REENABLE CROSS REFERENCE The definition of LABl and the references to LOCl included in the cross reference listing. LAB2: .NOCROSS MOVL .CROSS LOCl LOC1,LOC2 LOCl and LOC2 are not DO NOT CROSS REFERENCE LOCl COPY DATA REENABLE CROSS REFERENCE OF LOCl The definition of LAB2 and the reference to LOC2 are included in the cross reference, but the reference to LOCl is not included in the cross reference. 5-12 GENERAL ASSEMBLER DIRECTIVES Notes 1. not reenable the .CROSS without a symbol list will cross-reference listing of a symbol specified in ~NOCROSS with a symbol list. 2. If the cross-reference listing of all symbols is disabled, .CROSS with a symbol list will have no effect until the cross-reference listing is reenabled by .CROSS without a symbol list. 5-13 GENERAL ASSEMBLER DIRECTIVES .DEBUG .DEBUG -- DEBUG SYMBOL ATTRIBUTE DIRECTIVE .DEBUG specifies that the symbols in the list are made known to the debugger. During an interactive debugging session, these symbols can be used to refer to memory locations or to examine the values assigned to the symbols. Format .DEBUG symbol-list Parameter symbol-list A list of legal symbols separated by commas. Example .DEBUG INPUT,OUTPUT,LAB_30,LAB_40 MAKE THESE SYMBOLS KNOWN TO THE DEBUGGER Note The assembler adds the symbols in the symbol list to the symbol table in the object module. The programmer need not specify global symbols in the .DEBUG directive because global symbols automatically are put in the object moduule's symbol table. See the description of .ENABLE for information on making information about all symbols available to the debugger. 5-14 GENERAL ASSEMBLER DIRECTIVES .DEFAULT .DEFAULT -- DEFAULT CONTROL DIRECTIVE .DEFAULT determines the default displacement length for the relative and relative deferred addressing modes (see Sections 4.2.1 and 4.2.2). Format .DEFAULT DISPLACEMENT, keyword Parameter keyword One of three keywords--BYTE, WORD, LONG--indicating displacement length. the default Example .DEFAULT DISPLACEMENT,WORD MOVL LABEL,Rl .DEFAULT DISPLACEMENT,LONG INCB @COUNTS+4 WORD IS DEFAULT ASSEMBLER USES WORD DISPLACEMENT UNLESS LABEL HAS BEEN DEFINED LONG IS DEFAULT ASSEMBLER USES LONGWORD DISPLACEMENT UNLESS COUNTS HAS BEEN DEFINED Notes 1. .DEFAULT has no effect on the default displacement for displacement and displacement deferred addressing modes (see Sections 4.1.6 and 4.1.7). 2. If there is no .DEFAULT in a source module, the default displacement length for the relative and relative deferred addressing modes is a longword. 5-15 GENERAL ASSEMBLER DIRECTIVES .D_FLOATING .DOUBLE .D FLOATING -- FLOATING POINT STORAGE DIRECTIVE .D FLOATING evaluates the specified floating-point constants and stores the results in the object module. .D FLOATING generates 64-bit, double-precision, floating-point data (1 bit of sign, 8 bits of exponent, and 55 bits of fraction). See the description of .F FLOATING for information on storing single precision floating point numbers and the descriptions of .G FLOATING and .H FLOATING for descriptions of other floating point numbers. Format .D FLOATING literal-list .DOUBLE literal-list Parameter literal-list A list of floating-point constants (see Section 3.2.2). The constants cannot contain any unary or binary operators except unary plus or unary minus. Example .D FLOATING 1000,l.OE3,l.OOOOOOOE-9 .DOUBLE 3.1415928, 1.107153423828 .D FLOATING 5, 10, 15, 0, 0.5 CONSTANT LIST Notes 1. Double precision floating point numbers are always They are not affected by .ENABLE TRUNCATION. 2. The floating point constants in the literal list must not preceded by the floating point operator (AF). 5-Hi rounded. be GENERAL ASSEMBLER DIRECTIVES .DISABLE .DISABLE -- FUNCTION CONTROL DIRECTIVE .DISABLE disables, or inhibits, the specified assembler See the description of .ENABLE for more information. functions. Format .DISABLE argument-list Parameter argument-list One or more of the symbolic arguments listed in Table 5-2 in the description of .ENABLE. Either the long form or the short form of the symbolic arguments can be used. If multiple arguments are specified, they must be separated by commas, spaces, or tabs. Note The alternate form of .DISABLE is .DSABL. .ENABLE .ENABLE -- FUNCTION CONTROL DIRECTIVE .ENABLE enables the specified assembly function. .ENABLE and its negative form, .DISABLE, control the following assembler functions. • Creating local label blocks. • Making all local symbols available enabling the traceback feature. • Specifying that references. undefined symbol • Truncating numbers. or rounding single-precision • Suppressing the listing of symbols that are referenced. • Specifying that all PC references are absolute not relative. to the references debugger are and external floating-point defined but not Format .ENABLE argument-list Parameter argument-list One or more of the symbolic arguments listed in Table 5-2. Either the long form or the short form of the symbolic arguments can be used. If multiple arguments are specified, they must commas, spaces, or tabs. 5-17 be separated by GENERAL ASSEMBLER DIRECTIVES Table 5-2 .ENABLE and .DISABLE Symbolic Arguments Long Form Short Form Default Condition Function --------------------------+--"-'"''"___________,__________ ABSOLUTE AMA Disabled When ABSOLUTE is enabled, all PC relative addressing modes are assembled as absolute addressing modes. DEBUG DBG Disabled When DEBUG is enabled, all local symbols are included in the object module's symbol table for use by the debugger. GLOBAL GBL Enabled When GLOBAL is enabled, all undefined symbols are considered external symbols. When GLOBAL is disabled, any undefined symbol that is not listed in a .EXTERNAL directive causes an assembly error. LOCAL BLOCK LSB Disabled When LOCAL BLOCK is enabled, the current local label block is ended and a new one is started. When LOCAL BLOCK is disabled, the current local label block is ended. See Section 3.4 for a complete description of local label blocks. SUPPRESSION SUP Disabled When SUPPRESSION is enabled, all symbols that are defined but not referred to are not listed in the symbol table. When SUPPRESSION is disabled, all symbols that are defined are listed in the symbol table. TRACEBACK TBK Enabled When TRACEBACK is enabled, the program section names and lengths, module names, and routine names are included in the object module for use by the debugger. When TRACEBACK is disabled, VAX-11 MACRO excludes this information and, in addition, does not make any local symbol information available to the debugger. (continued on next page) 5-18 GENERAL ASSEMBLER DIRECTIVES Table 5-2 (Cont.) .ENABLE and .DISABLE Symbolic Arguments Long Form Short Form Default Condition TRUNCATION FPT Disabled Function When TRUNCATION is enabled, single-precision floating-point numbers are truncated. When TRUNCATION is disabled, single-precision floating-point numbers are rounded. D floating, G floating,-and H floating numbers are not affected by .ENABLE TRUNCATION; they are always rounded. Example .ENABLE ABSOLUTE, GLOBAL ASSEMBLE RELATIVE ADDRESS MODE AS ABSOLUTE ADDRESS MODE. UNDEFINED REFERENCES ARE GLOBAL • DISABLE TRUNCATION,TRACEBACK ROUND FLOATING-POINT NUMBERS • DO NOT PUT ANY DEBUGGING INFORMATION INTO OBJECT MODULE Note The alternate form of .ENABLE is .ENABL. 5-19 GENERAL ASSEMBLER DIRECTIVES .END .END -- ASSEMBLY TERMINATION DIRECTIVE .END terminates the source program. No additional text should occur beyond this point in the current source file or in any additional source files specified in the command line for this assembly. If any additional text does occur, the assembler ignores the text. The additional text does not appear in either the listing file or the object file. Format .END [symbol] Parameter symbol The address (called the execution is to begin. transfer address) at which program Example .ENTRY START,O .END START ENTRY MASK MAIN PROGRAM Notes 1. The transfer address must be in a program section the EXE attribute (see the description of .PSECT). that has 2. When an executable image consisting of several object modules is linked, only one object module should be terminated by an .END directive that specifies a transfer address. All other object modules should be terminated by .END directives that do not specify a transfer address. If an executable image either contains no transfer address or contains more than one transfer address, the VAX-11 Linker displays an error message. 3. If the source program contains an unterminated conditional code block when the .END directive is specified, the assembler displays an error message • . ENDC .ENDC -- END CONDITIONAL DIRECTIVE .ENDC terminates the conditional range started by the .IF directive. See the description of .IF for more information and examples. Format .ENDC 5-20 GENERAL ASSEMBLER DIRECTIVES .ENTRY .ENTRY -- ENTRY DIRECTIVE .ENTRY defines a symbolic name for an entry point and stores a register save mask (2 bytes) at that location. The symbol is defined as a global symbol with a value equal to the value of the location counter at the .ENTRY directive. The entry point can be used as the transfer address of the program. The register save mask is used to determine which registers are saved before the procedure is called. These saved registers are automatically restored when the procedure returns control to the calling program. See the description of the procedure call instructions in the VAX-11 Architecture Handbook. Format .ENTRY symbol,expression Parameter symbol The symbolic name for the entry point. expression The register save mask for the entry point. The expression must be an absolute expression and must not contain any undefined symbols. Example .ENTRY CALC,"M<R2,R3,R7> PROCEDURE STARTS HERE. REGISTERS 2,3,7 ARE PRESERVED BY CALL AND RET INSTRUCTIONS Notes 1. The. register mask operator ("M) is convenient to use for setting the bits in the register save mask (see Section 3.6.2.2). 2. An assembly error occurs if the expression has bits O, 1, 12, or 13 set. These bits correspond to the registers RO, Rl, AP, and FP and are reserved for the CALL interface. 3. DIGITAL recommends that .ENTRY be used to define all callable entry points including the transfer address of the program. Although the following construct also defines an entry point, its use is discouraged: symbo 1 : : • WORD expression Although a procedure starting with this construct can be called, the entry mask 1s not checked for any illegal registers and the symbol cannot be used in a .MASK directive. 5-21 GENERAL ASSEMBLER DIRECTIVES 4. .ENTRY should be used only for procedures that will be called by the CALLS or CALLG instruction. A routine that is entered by the BSB or JSB instruction should not use .ENTRY because these instructions do not expect a register save mask. These routines should begin in the following format: symbol:: first instruction The first instruction of the routine immediately follows symbol. 5-22 the GENERAL ASSEMBLER DIRECTIVES .ERROR .ERROR -- ERROR DIRECTIVE .ERROR causes the assembler to display an error message on the terminal or batch log file and in the listing file (if there is one). Format .ERROR [expression] comment Parameters expression An expression whose value is displayed when .ERROR is encountered during assembly. comment A comment that is displayed when .ERROR is encountered assembly. The comment must be preceded by a semicolon. during Example • IF DEFINED .IF GREATER .ERROR 25 .ENDC .ENDC LONG MESS lOoo=woRK AREA ; NEED LARGER WORK AREA If the symbol LONG MESS is defined and if the symbol WORK AREA has value of 1000 or less, the following error message is displayed: %MACRO-E-GENERR, Generated ERROR: a 25 NEED LARGER WORK AREA Notes 1. .ERROR, .WARN, and .PRINT are called the message display directives. They can be used to display information indicating that a macro call contains an error or an illegal set of conditions (see Chapter n for more information on macro calls). 2. When the assembly is finished, the assembler displays the total number of errors, warnings, and information messages, and the sequence numbers of the lines causing the errors or warnings on the terminal. See the VAX-11 MACRO User's Guide for more information on errors and warnings. 3. If .ERROR is included in a macro library (see the VAX-11 MACRO User's Guide), the comment should end with an additional semicolon. Otherwise, the librarian will strip the comment from the directive and it will not be displayed when the macro is called. 4. The line containing the .ERROR directive is not the listing file. included in 5. If the expression has a value of O, it is the error message. displayed in 5-23 not GENERAL ASSEMBLER DIRECTIVES .EVEN .EVEN -- EVEN LOCATION COUNTER ALIGNMENT DIRECTIVE .EVEN ensures that the current value of the location counter is even by adding 1 if the current value is odd. If the current value is already even, no action is taken. Format .EVEN .EXTERNAL .EXTERNAL -- EXTERNAL SYMBOL ATTRIBUTE DIRECTIVE .EXTERNAL indicates that specified symbols are external; that is, the symbols are defined in another object module and cannot be defined until link time (see Section 3.3.3). Format .EXTERNAL symbol-list Parameter symbol-list A list of legal symbols separated by commas. Example .EXTERNAL .EXTERNAL SIN,TAN,COS SINH,COSH,TANH THESE SYMBOLS ARE DEFINED IN EXTERNALLY ASSEMBLED MODULES Notes 1. If the GLOBAL argument is enabled (see Table 5-2 in the description of .ENABLE), all unresolved references will be marked as global and external. Thus, if GLOBAL is enabled, the programmer need not specify .EXTERNAL. However, if GLOBAL is disabled, the programmer must explicitly specify .EXTERNAL to declare any symbols that are defined externally but referred to in the current module. 2. If GLOBAL is disabled and the assembler finds symbols that are not defined in the current module and are not listed in a .EXTERNAL directive, the assembler displays an error message. 3. The alternate form of .EXTERNAL is .EXTRN. 5-24 GENERAL ASSEMBLER DIRECTIVES .f_FLOATING .FLOAT .F FLOATING (.FLOAT) -- FLOATING-POINT STORAGE DIRECTIVE .F FLOATING evaluates the specified floating-point constants and stores the results in the object module. .F FLOATING generates 32-bit, single-precision, floating-point data {l bit of sign, 8 bits of exponent, and 23 bits of fractional significance). See the description of .D FLOATING for information on storing double-precision floating-point numbers and the descriptions of .G FLOATING and .H FLOATING for descriptions of other floating point numbers. Format .F FLOATING literal-list .FLOAT literal-list Parameter literal-list A list of floating-point constants {see Section 3.2.2). The constants cannot contain any unary or binary operators except unary plus and unary minus. Example • F FLOATING • F-FLOATING • F-FLOATING .FLOAT 134.5782,74218.34E20 134.2,0.1342E3,1342E-l -0.75,1E38,-l.OE-37 0,25,50 SINGLE PRECISION THESE ALL GENERATE 134.2 DATA LIST Notes 1. See the description of .ENABLE for information on floating-point rounding or truncation. 2. The floating point constants in the literal list must not preceded by the floating point unary operator {AF). 5-25 specifying be GENERAL ASSEMBLER DIRECTIVES .G_FLOATING .G FLOATING -- G FLOATING POINT STORAGE DIRECTIVE G FLOATING evaluates the specified floating-point constants and stores tne results in the object module. .G FLOATING generates n4-bit data ( 1 bi t of s i g n , 11 bi ts- of ex pone n t , and 5 2 bi ts of f r action ) • Format .G FLOATING literal-list Parameters literal-list A list of G floating point constants (see Section 3.2.2). The constants cannot contain any unary or binary operators except unary plus or unary minus. Example .G FLOATING 1000, l.OE3, l.OOOOOOOE-9 ;constant list Notes 1. G floating point numbers are always rounded. affected by the .ENABLE TRUNCATION directive. are not 2. The floating point constants in the literal list must not preceded by the floating point operator (AF). be 5-26 They GENERAL ASSEMBLER DIRECTIVES .GLOBAL .GLOBAL -- GLOBAL SYMBOL ATTRIBUTE DIRECTIVE .GLOBAL indicates that specified symbol names are either globally defined in the current module or externally defined in another module (see Section 3.3.3). Format .GLOBAL symbol-list Parameter symbol-list A list of legal symbol names separated by commas. Example .GLOBAL LAB_40,LAB_30 MAKE THESE SYMBOL NAMES GLOBALLY KNOWN TO ALL LINKED MODULES .GLOBAL UKN 13 Notes 1. .GLOBAL is provided for MACR0-11 compatibility only. DIGITAL recommends that global definitions be specified by a double colon or double equals sign (see Section 2.2.1 and 3.8) and that external references be specified by .EXTERNAL (when necessary). 2. The alternate form of .GLOBAL is .GLOBL. 5-27 GENERAL ASSEMBLER DIRECTIVES .H_FLOATING .H FLOATING -- H FLOATING POINT STORAGE DIRECTIVE - - H FLOATING evaluates the specified floating-point constants and stores the results in the object module. .H FLOATING generates 128-bit data (1 bit of sign, 15 bits of exponent, and 112 bits of fraction). Format .H FLOATING literal-list Parameters literal-list A list of H floating point constants (see Section 3.2.2). The constants cannot contain any unary or binary operators exc~pt unary plus or unary minus. Example ;constant list .H FLOATING 1. H floating point numbers are always rounded. affected by the .ENABLE TRUNCATION directive. are not 2. The floating point constants in the literal list must not preceded by the floating point operator (~F). be 36912, 15.0E18, l.OOOOOOOE-9 Notes 5-28 They GENERAL ASSEMBLER DIRECTIVES .IDENT .!DENT -- IDENTIFICATION DIRECTIVE .!DENT provides a means of identifying the object module. This identification is in addition to the name assigned to the object module with .TITLE. A character string can be specified in .!DENT to label the object module. This string is printed in the header of the listing file as well as appearing in the object module. Format .!DENT string Parameter string A 1- to 31-character string that identifies the module, such as a string that specifies a version number. The string must be delimited. The delimiters can be any paired printing characters, other than the left angle bracket (<) or the semicolon (;), as long as the delimiting character is not contained in the text string itself. Example • !DENT /3-47 I ; VERSION AND EDIT NUMBERS The character string 3-47 is included in the object module. Notes 1. If one source module contains more than one .!DENT, the last directive given establishes the character string that forms part of the object module identification. 2. If the delimiting characters do not match, or if an illegal delimiting character is used, the assembler displays an error message. 5-29 GENERAL ASSEMBLER DIRECTIVES .IF .IF -- CONDITIONAL ASSEMBLY BLOCK DIRECTIVES A conditional assembly block is a series of source statements that is assembled only if a certain condition is met. .IF starts the conditional block and .ENDC ends the conditional block. Each .IF must have a corresponding .ENDC. The .IF directive contains a condition test and one or two arguments. The condition test specified is applied to the argument(s). If the test is met, all MACRO statements between .IF and .ENDC are assembled. If the test is not met, the statements are not assembled. An exception to this occurs when subconditional directives are used (see the description of .IF x directive). Conditional blocks can be nested, that is a conditional block can be inside of another conditional block. In this case the statements in the inner conditional block are assembled only if the condition is met for both the outer and inner block. Format .IF condition argument(s) range .ENDC Parameters condition A specified condition that must be met if the block is to be included in the assembly. Table 5-3 lists the conditions that can be tested by the conditional assembly directives. The condition must be separated from the argument(s) by a comma, space, or tab. argument(s) The symbolic argument(s) or expression{s) of the specified conditional test. If the argument is an expression, it cannot contain any undefined symbols and must be an absolute expression (see Section 3.5). range The block of source code that is conditionally assembly. 5-30 included in the GENERAL ASSEMBLER DIRECTIVES Table 5-3 Condition Tests for Conditional Assembly Directives Complement Condition Test Long Form Short Form Long Form Short Form EQUAL EQ NOT_EQUAL NE Expression 1 Expression is equal to O /not equal to O GREATER GT LESS_EQUAL LE Expression 1 Expression is greater than O /less than or equal to 0 LESS THAN LT GREATER_EQUAL GE Expression 1 Expression is less than O /greater than or equal to 0 DEFINED DF NOT DEFINED NDF Symbolic 1 Symbol is defined /not defined BLANK 1 B NOT BLANK 1 NB Macro 1 Argument is blank /nonblank IDENTICAL l IDN DIFFERENT l DIF Macro 2 Arguments are identical /different Argument Type Number of Arguments Condition that Assembles Block Condition Test 1. The BLANK, NOT BLANK, IDENTICAL, and DIFFERENT conditions are only useful in macro definitions. Chapter n describes macro directives in detail. Examples 1. An example of a conditional assembly directive is: .IF EQUAL ALPHA+l ASSEMBLE BLOCK IF ALPHA+l=O DO NOT ASSEMBLE IF ALPHA+l NOT=O .ENDC 2. Nested conditional directives take the form: .IF .IF condition,argument(s) condition,argument(s) .ENDC .ENDC 5-31 GENERAL ASSEMBLER DIRECTIVES 3. The following conditional assembly is to occur: .IF DEFINED .IF DEFINED directives can govern whether SY Ml SYM2 .ENDC .ENDC In this example, if the outermost condition is not satisfied, no deeper level of evaluation of nested conditional statements within the program occurs. Therefore, both SYMl and SYM2 must be defined for the code to be assembled. Notes 1. If .ENDC occurs outside a conditional assembler displays an error message. 2. VAX-11 MACRO permits a nesting depth of 31 conditional assembly levels. If a statement attempts to exceed this nesting level depth, the assembler displays an error message. 3. The assembler displays an error message if .IF specifies any of the following: a condition test other than those in Table 5-3, an illegal argument, or a null argument specified in an .IF directive. 4. The .SHOW and .NOSHOW directives control whether condition blocks that are not assembled are included in the listing file. 5-32 assembly block, the GENERAL ASSEMBLER DIRECTIVES .IF_x .IF x -- SUBCONDITIONAL ASSEMBLY BLOCK DIRECTIVES VAX-11 MACRO has three subconditional assembly block directives: Directive Function .IF FALSE If the condition of the assembly block tests false, the program is to include the source code following the .IF FALSE directive and continuing up to the next subconditional directive or to the end of the conditional assembly block. .IF TRUE If the condition of the assembly block tests true, the program is to include the source code following the .IF TRUE directive and continuing up to the next subconditional directive or to the end of the conditional assembly block • • IF TRUE FALSE Always include the source code fo)lowing the .IF TRUE FALSE directive and continuing up to the next subconditional directive or to the end of the conditional assembly block. This source code is included regardless of whether the condition of the assembly block tests true or false. The implied argument of a subconditional directive is the condition test specified when the conditional assembly block was entered. A conditional or subconditional directive in a nested conditional assembly block is not evaluated if the preceding (or outer) condition in the block is not satisfied (see examples 3 and 4 below). A conditional block with a subconditional directive is different than a nested conditional block. If the condition in the .IF is not met, the inner conditional block(s) are not assembled, but a subconditional directive can cause a block to be assembled. Formats .IF FALSE • IF-TRUE .IF-TRUE FALSE 5-33 GENERAL ASSEMBLER DIRECTIVES Examples 1. Assume that symbol SYM is defined: • IF DEFINED SYM TESTS TRUE SINCE SYM IS DEFINED. ASSEMBLES THE FOLLOWING CODE. .IF FALSE TESTS FALSE SINCE PREVIOUS .IF WAS TRUE. DO NOT ASSEMBLE THE FOLLOWING CODE. • IF TRUE TESTS TRUE. SYM IS DEFINED • ASSEMBLES THE FOLLOWING CODE • • IF TRUE FALSE ASSEMBLES FOLLOWING CODE UNCONDITIONALLY • • IF. TRUE TESTS TRUE. SYM IS DEFINED. ASSEMBLES REMAINDER OF CONDITIONAL ASSEMBLY BLOCK • • ENDC 2. Assume that symbol • IF DEFINED .IF DEFINED x is defined and that symbol Y is not defined: x TESTS TRUE. SYMBOL X IS DEFINED • TESTS FALSE. SYMBOL Y IS NOT DEFINED. TESTS TRUE. SYMBOL Y IS NOT DEFINED. ASSEMBLES THE FOLLOWING CODE. y .IF FALSE TESTS FALSE. SYMBOL Y IS NOT DEFINED. DOES NOT ASSEMBLE THE FOLLOWING CODE • .IF TRUE • ENDC .ENDC 3. Assume that symbol A is defined and that symbol B is not defined: .IF DEFINED TESTS TRUE. A IS DEFINED. ASSEMBLES THE FOLLOWING CODE. A .IF FALSE TESTS FALSE. A IS DEFINED. DOES NOT ASSEMBLE THE FOLLOWING CODE. .IF NOT DEFINED B NESTED CONDITIONAL DIRECTIVE IS NOT EVALUATED • • ENDC .ENDC 5-34 GENERAL ASSEMBLER DIRECTIVES 4. Assume that symbol X is not defined but symbol Y is defined: • IF DEFINED X • IF DEFINED Y TESTS FALSE. SYMBOL X IS NOT DEFINED. DOES NOT ASSEMBLE THE FOLLOWING CODE. NESTED CONDITIONAL DIRECTIVE IS NOT EVALUATED. • IF FALSE NESTED SUBCONDITIONAL DIRECTIVE IS NOT EVALUATED • • IF TRUE NESTED SUBCONDITIONAL DIRECTIVE IS NOT EVALUATED • • ENDC .ENDC Notes 1. If a subconditional directive appears outside a conditional assembly block, the assembler displays an error message. 2. The alternate forms of .IF FALSE, .IF TRUE FALSE are .!FF, .!FT, and-.IFTF. 5-35 • IF_TRUE,, and GENERAL ASSEMBLER DIRECTIVES .llF' .IIF IMMEDIATE CONDITIONAL ASSEMBLY BLOCK DIRECTIVE .IIF provides a means of writing a one-line conditional assembly block. The condition to be tested and the conditional assembly block are expressed completely within the line containing the .IIF directive; no terminating .ENDC statement is required. Format .IIF condition argument(s), statement Parameters condition One of the legal condition tests defined for conditional assembly blocks in Table 5-3 (See the description of .IF). The condition must be separated from the argument(s) by a comma, space, or tab. argument(s) The argument associated with the immediate conditional directive; that is, an expression or symbolic argument (described in Table 5-3). If the argument is an expression, it cannot contain any undefined symbols and must be an absolute expression (see Section 3.3.3). The argument(s) must be separated from the statement by a comma. statement The statement to be assembled if the condition is satisfied. Example Condition Argument Statement .IIF DEFINED EXAM, BEQL ALPHA This directive generates the following code defined within the source program: BEQL if the symbol EXAM is ALPHA Note The assembler displays an error message if .IIF specifies any of the following: a condition test other than those listed in Table 5-3, an illegal argument, or a null argument. 5-36 GENERAL ASSEMBLER DIRECTIVES .LIST .LIST LISTING DIRECTIVE .LIST is equivalent to the .SHOW. more information. See the description of .SHOW for Formats .LIST .LIST argument-list Parameter argument-list One or more of the symbolic argument defined in Table 5-7 in the description of .SHOW. Either the long form or the short form of the arguments can be used. If multiple arguments are specified, they must be separated by commas, spaces, or tabs. 5-37 GENERAL ASSEMBLER DIRECTIVES .LONG .LONG -- LONGWORD STORAGE DIRECTIVE .LONG generates successive longwords (4 bytes) of data in module. the object Format .LONG expression-list Parameters expression-list One or more expressions separated by commas. Each expression optionally can be followed by a repetition factor delimited by square brackets. An expression followed by a repetition factor has the format: expressionl[expression2] expressionl An expression that specifies the value to be stored. [expression2] An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required. Example LAB 3: .LONG .LONG .LONG LAB 3,AX7FFFFFFF,AA'ABCD' AXF@4 0[22] 3 LONGWORDS OF DATA 1 LONGWORD OF DATA 22 LONGWORDS OF DATA Note Each expression in the list represented in 32 bits. must 5-38 have a value that can be GENERAL ASSEMBLER DIRECTIVES .MASK .MASK -- MASK DIRECTIVE .MASK reserves a word for a register save mask for a transfer vector. See the description of .TRANSFER for more information and for an example of .MASK. Format .MASK symbol[,expression] Parameters symbol A symbol defined in an .ENTRY directive. expression A register save mask. Notes 1. If .MASK does not contain an expression, the assembler directs the linker to copy the register save mask specified in .ENTRY to the word reserved by .MASK. 2. If .MASK contains an expression, the assembler directs the linker to combine this expression with the register save mask specified in .ENTRY and store the result in the word reserved by .MASK. The linker performs an inclusive OR operation to combine the mask in the entry point and the value of the expression. Consequently, a register specified in either .ENTRY or .MASK will be included in the combined mask. See the description of .ENTRY for more information on entry masks. .NLIST .NLIST LISTING DIRECTIVE .NLIST is equivalent to .NOSHOW. more information. See the description of .SHOW for Formats .NLIST .NLIST argument-list Parameter argument-list One or more of the symbolic arguments listed in Table 5-7 in the description of .SHOW. Either the long form or the short form of the arguments can be used. If multiple arguments are specified, they must be separated by commas, spaces, or tabs. 5-39 GENERAL ASSEMBLER DIRECTIVES .NOCROSS .NOCROSS -- CROSS REFERENCE DIRECTIVE VAX-11 MACRO produces a cross-reference listing when the CROSS qualifier is specified in the MACRO command. The .CROSS and .NOCROSS directives control which symbols are included in the cross-reference listing. The description of .NOCROSS is included with the description of .CROSS. Formats .NOCROSS .NOCROSS symbol-list Parameter symbol-list A list of legal symbol names separated by commas • . NOSHOW .NOSHOW -- LISTING DIRECTIVE .NOSHOW specifies listing control options. .SHOW for more information. See the description of Formats .NOSHOW .NOSHOW argument-list Parameter argument-list One or more of the symbolic arguments listed in Table 5-7 in the description of .SHOW. Either the long form or the short form of the arguments can be used. If multiple arguments are specified, they must be separated by commas, spaces, or tabs. 5-40 GENERAL ASSEMBLER DIRECTIVES .OCTA .OCTA -- OCTAWORD STORAGE DIRECTIVE .OCTA generates 128 bits (16 bytes) of binary data. Format .OCTA literal .OCTA symbol Parameters literal Any constant value. This value can be preceded by Ao, AB, AX, or AD to specify the radix as octal, binary, hexadecimal, or decimal, respectively; or it can be preceded by AA to specify ASCII text. Decimal is the default radix. symbol A symbol defined elsewhere in the program. This symbol results in a sign-extended, 32-bit value being stored in an octaword. Example .OCTA AA"FEDCBA987654321" .OCTA .OCTA .OCTA 0 EACH ASCII CHARACTER IS STORED IN A BYTE OCTA 0 OCTA HEX VALUE SPECIFIED VINTERVAL HAS A 32 BIT VALUE SIGN EXTENDED AX01234ABCD5678F9 VINTERVAL Note .OCTA is like .QUAD and unlike other data storage directives (.BYTE, .WORD, and .LONG) in that it does not evaluate expressions and that it accepts only one value. It does not accept a list. .ODD .ODD -- ODD LOCATION COUNTER ALIGNMENT DIRECTIVE .ODD ensures that the current value of the location counter is odd by adding 1 if the current value is even. If the current value is already odd, no action is taken. Format .ODD 5-41 GENERAL ASSEMBLER DIRECTIVES .OPDEF .OPDEF -- OPCODE DEFINITION DIRECTIVE .OPDEF defines an opcode, which it inserts into a user-defined opcode table. The assembler searches this table before it searches the permanent symbol table. This directive can redefine an existing opcode name or create a new one. Format .OPDEF opcode value,operand-descriptor-list Parameters opcode An ASCII string specifying the name of the opcode. The string can be up to 31 characters long and can contain the letters A through z; the digits 0 through 9; and the special characters underline { ) , dollar sign {$), and period (.). The string should not start with a digit and should not be surrounded by delimiters. value An expression that specifies the value of the opcode. The expression must not contain any undefined values and must be an absolute expression {see - Section 3.5). The value of the expression must be in the range of 0 through decimal 65535 {hexadecimal FFFF), but the values 252 through 255 cannot be used. The expression is represented as follows: if 0 < expression < 251 i f expression expression is a one-byte opcode. expression bits 15:8 are the first byte of the opcode and expression bits 7:0 are the second byte of the opcode. > 255 Values 252 through 255 cannot be used because the architecture specifies these as the start of a two-byte opcode. Note that this representation does not correspond to the representation of these numbers in memory. operand-descriptor-list A list of operand descriptors that specifies the number of operands and the type of each. Up to lfi operand descriptors are allowed in the list. Table 5-4 lists the operand descriptors. 5-42 GENERAL ASSEMBLER DIRECTIVES Table 5-4 Operand Descriptors ---------------- ---------. Data Type Access Type Byte Word Longword AB AW AL Read-only RB RW Modify MB MW Write-only WB WW Field VB vw Branch BB BW ---- - Address Flo a ting Double Floating Po in t Point ··-· G floating Point H floating Point Quadword Octaword -+-·----- AF AD AG AH AQ AO RL RF RD RG RH RQ RO ML MF MD MG MH MQ MO WL WF ~ ~ ~ ~ ~ VL VF - --- '-------------'----- Examples .OPDEF MOVL3 .OPDEF .OPDEF .OPDEF DIVF2 MOVC5 CALL ; DEFINES AN INSTRUCTION, MOVL3, WHICH USES THE RESERVED OPCODE FF. ~X46,RF,MF ; REDEFINES THE DIVF2 AND ~X2C,RW,AB,AB,RW,AB ; MOVC5 INSTRUCTIONS. ~XlO,BB ; EQUIVALENT TO A BSBB ~XFFA9,RL,ML,WL Notes 1. A macro can also be used to redefine an opcode (see the description of .MACRO in Chapter 6). Note that the macro name table is searched before the user-defined opcode table. 2. .OPDEF is useful in creating "custom" instructions that execute us~r-written microcode. This directive is supplied to allow programmers to execute their microcode in a MACRO program. 3. The operand descriptors are specified in a format similar to the operand specifier notation described in the VAX-11 Architecture Handbook. The first character specifies the operand access type and the second character specifies the operand data type. 5-43 GENERAL ASSEMBLER DIRECTIVES .PACKED .PACKED -- PACKED DECIMAL STRING STORAGE DIRECTIVE .PACKED generates packed decimal data, 2 digits per byte. Packed decimal data is useful in calculations requiring exact accuracy. Packed decimal data is operated on by the decimal string instructions. See the VAX-11 Architecture Handbook for more information on the format of packed decimal data. Format .PACKED decimal-string[,symbol] Parameters decimal-string A decimal number from 0 through 31 digits long with an optional sign. Each digit can be in the range of 0 through 9 (see Section 3.2.3). symbol An optional symbol that is assigned a value equivalent to the number of decimal digits in the string. The sign is not counted as a digit. Example .PACKED -12,PACK SIZE .PACKED +500 .PACKED 0 .PACKED -0,SUM_SIZE PACK SIZE GETS VALUE OF 2 SUM SIZE GETS VALUE OF 1 .PAGE .PAGE -- PAGE EJECTION DIRECTIVE .PAGE forces a new page in the listing; printed in the listing. the directive itself VAX-11 MACRO ignores .PAGE in a macro definition. operation is performed only during macro expansion. describes macro directives and facilities in detail. Format .PAGE 5-44 is not The paging Chapter 6 GENERAL ASSEMBLER DIRECTIVES .PRINT .PRINT -- ASSEMBLY MESSAGE DIRECTIVE .PRINT causes the assembler to display an informational message. The message consists of the value of the expression and the comment specified in the .PRINT directive. The message is displayed on the terminal for interactive jobs and in the log file for batch jobs. The message produced by .PRINT is not considered an error or warning message. Format .PRINT [expression] ;comment Parameters expression An expression whose value is displayed when .PRINT is encountered during assembly. comment A comment that is displayed when .PRINT is encountered assembly. The comment must be preceded by a semicolon. during Example .PRINT 2 THE SINE ROUTINE HAS BEEN CHANGED Notes 1. .PRINT, .ERROR, and .WARN are called the message display directives. They can be used to display information indicating that a macro call contains an error or an illegal set of conditions (See Chapter 6 for more information on macro calls) • 2. If .PRINT is included in a macro library (see the VAX-11 MACRO User's Guide), the comment should end with an additional semicolon. Otherwise, the comment will be stripped from the directive and will not be displayed when the macro is called. 3. If the expression has a value of the message. 5-45 o, it is not displayed with GENERAL ASSEMBLER DIRECTIVES .PSECT .PSECT -- PROGRAM SECTIONING DIRECTIVE .PSECT defines a program section and its attributes and program section once it is defined. refers to a Program sections can be used to: • Develop modular programs • Separate instructions from data • Allow different modules to access the same data • Protect read-only data and instructions from being modified • Identify sections of the object module to the debugger • Control the order in which virtual memory See the VAX-11 MACRO program sections. User's program Guide for sections more are information stored on in using The assembler automatically defines two program sections: the absolute program section and the unnamed (or blank) program section. Any symbol definitions that appear before any instruction, data, or .PSECT directive are placed in the absolute program section. Any instructions or data that appear before the first named program section is defined are placed in the unnamed program section. Any .PSECT directive that does not include a program section name specifies the unnamed program section. A maximum of 254 user-defined, named program sections can be defined. When the assembler encounters a .PSECT directive that specifies a new program section name, it creates a new program section and stores the name, attributes, and alignment of the program section. The assembler includes all data and instructions that follow the .PSECT directive in that program section until it encounters another .PSECT directive. The assembler starts all program sections at a location counter of 0 which is relocatable. If the assembler encounters a .PSECT directive that specifies the name of a previously defined progr~m section, it stores the new data or instructions after the last entry in the previously defined program section. The location counter is set to the value of the location counter at the end of the previously defined program section. The programmer need not list the attributes when continuing a program section but any attributes that are listed must be the same as those previously in effect for the program section. A continuation of a program section cannot contain attributes conflicting with those specified in the original .PSECT directive. The attributes listed in the .PSECT directive only describe the contents of the program section. The assembler does not check to ensure that the contents of the program section actually include the attributes listed. 5-46 GENERAL ASSEMBLER DIRECTIVES However, the assembler and the linker do check that all program sections with the same name have exactly the same attributes. The assembler and linker display an error message if the program section attributes are not consistent. Program section names are independent of local symbol, global symbol, and macro names. Thus, the same symbolic name can be used for a program section and for a local symbol, global symbol, or macro name. Formats .PSECT .PSECT program section-name[,argument-list] Parameters program-section-name The name of the program section. This name can be up to 31 characters long and can contain any alphanumeric character and the underline ( ) , dollar sign ($), and period (.) characters. However, the first character must not be a digit. argument-list A list containing the program section attributes and the program section alignment. Table 5-5 lists the attributes and their functions. Table 5-6 lists the default attributes and their opposites. Program sections are aligned when an integer in the range of 0 through 9 is specified or when one of the five keywords listed below is specified. If an integer is specified, the program section is linked to begin at the next virtual address that is a multiple of 2 raised to the power of the integer. If a keyword is specified, the program section is linked to begin at the next virtual address that is a multiple of the values listed below: Keyword Size (in Bytes) BYTE WORD LONG QUAD PAGE 2"'0 1 2"'1 = 2 2"'2 4 2"'3 8 2"'9 512 BYTE is the default. 5-47 GENERAL ASSEMBLER DIRECTIVES Table 5-5 Program Section Attributes Attribute Name Function -------+---·----·-·--··-------··--------------------~ ABS Absolute--The linker assigns the program section an absolute address. The contents of the program section can be only symbol definitions (usually definitions of symbolic offsets to data structures that are used by the routines being assembled). An absolute program section contributes no binary code to the image, so its byte allocation request to the linker is O. The size of the data structure being defined is the size of the absolute program section printed in the "program section synopsis" at the end of the listing. Compare this attribute with its opposite, REL. CON Concatenate--Program sections with the same name attributes (including CON) are merged into program section. Their contents are merged in order in which the linker acquires them. allocated virtual address space is the sum of individual requested allocations. EXE Executable--The program section contains instructions. This attribute provides the capability of separating instructions from read-only and read/write data. The linker uses this attribute in gathering program sections and in verifying that the transfer address is in an executable program section. GBL Global--Program sections that have the same name and attributes, including GBL and OVR, will have the same relocatable address in memory even when the program sections are in different clusters (see the VAX-11 Linker Reference Manual for more information on clusters). This attribute is specified for FORTRAN COMMON block program sections (see the VAX-11 FORTRAN User's Guide). Compare this attribute with its opposite, LCL. LCL Local--The program section is restricted to its cluster. Compare this attribute with its opposite, GBL. LIB Library Segment--Reserved for future use. NO EXE Not Executable--The program section contains only; it does not contain instructions. NOP IC Non-Position-Independent Content--The program section is assigned to a fixed location in virtual memory (when it is in a shareable image). NORD Nonreadable--Reserved for future use. NOS HR No Share--The program section is reserved for private use at execution time by the initiating process. and one the The the data (continued on next page} 5-48 GENERAL ASSEMBLER DIRECTIVES Table 5-5 (Cont.) Program Section Attributes Attribute Name Function NOWRT Nonwritable--The program section's contents cannot be altered (written into) at execution time. OVR Overlay--Program sections with the same name and attributes, including OVR, have the same relocatable base address in memory. The allocated virtual address space is the requested allocation of the largest overlaying program section. Compare this attribute with its opposite, CON. PIC Position-Independent Content--The program section can be relocated; that is, it can be assigned to any memory area {when it is in a shareable image). RD Readable--Reserved for future use. REL Relocatable--The linker assigns the program section a relocatable base address. The contents of the program section can be code or data. Compare this attribute with its opposite, ABS. SHR Share--The program section can be shared at execution time by multiple processes. This attribute is assigned to a program section that can be linked into a shareable image. USR User Segment--Reserved for future use. VEC vector-Containing--The program section contains a change mode vector indicating a privileged shareable image. The SHR attribute must be used with VEC. ~T Write--The program section's contents can be (written into) at execution time. Table 5-6 Default Program Section Attributes Default Attribute Opposite Attribute CON EXE LCL NOP IC NOS HR RD REL WRT NOV EC OVR NO EXE GBL PIC SHR NORD ABS NOWRT VEC 5-49 altered GENERAL ASSEMBLER DIRECTIVES Examples .PSECT CODE,NOWRT,EXE,LONG .PSECT RWDATA,WRT,NOEXE,QUAD PROGRAM SECTION TO CONTAIN EXECUTABLE CODE PROGRAM SECTION TO CONTAIN MODIFIABLE DATA Notes 1. The .ALIGN directive cannot specify an alignment greater than that of the current program section; consequently, .PSECT should specify the largest alignment needed in the program section. For efficiency of execution, an alignment of longword or larger is recommended for all program sections that have longword data. 2. The attributes of the def a ult absolute and the default unnamed program sections are listed below. Note that the program section names include the periods and enclosed spaces. Program Section Name ABS • BLANK • Attributes and Alignment NOPIC,USR,CON,ABS,LCL,NOSHR,NOEXE,NORD,NOWRT,NOVEC,BYTE NOPIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,NOVEC,BYTE 5-50 GENERAL ASSEMBLER DIRECTIVES .QUAD .QUAD -- QUADWORD STORAGE DIRECTIVE .QUAD generates 64 bits (8 bytes) of binary data. Format .QUAD literal .QUAD symbol Parameters literal Any constant value. This value can be preceded by Ao, AB, AX, or AD to specify the radix as octal, binary, hexadecimal, or decimal, respectively; or it can be preceded by AA to specify the ASCII text operator. Decimal is the default radix. symbol A symbol defined elsewhere in the program. This symbol results in a sign-extended, 32-bit value being stored in a quadword. Example .QUAD AA I • • ASK? •• I .QUAD .QUAD .QUAD .QUAD 0 AX0123456789ABCDEF AB1111000111001101 LABEL EACH ASCII CHARACTER IS STORED IN A BYTE QUAD 0 QUAD HEX VALUE SPECIFIED QUAD BINARY VALUE SPECIFIED LABEL HAS A 32 BIT VALUE ZERO EXTENDED. Note .QUAD is like .OCTA and different from other data storage directives (.BYTE, .WORD, and .LONG) in that it does not evaluate expressions and that it accepts only one value. It does not accept a list. 5-51 GENERAL ASSEMBLER DIRECTIVES .REFn .REFn -- OPERAND GENERATION DIRECTIVES VAX-11 MACRO has five operand generation (see Chapter 6) to define new opcodes: directives Directive Function .REFl Generates a byte operand .REF2 Generates a word operand .REF4 Generates a longword operand .REF8 Generates a quadword operand .REF16 Generates an octaword operand used in macros The .REFn directives are provided for compatibility with VAX-11 MACRO Vl.O. The .OPDEF directive provides greater functionality and is easier to use than .REFn; consequently, .OPDEF should be used instead of .REFn. Formats .RE·Fl .REF2 .REF4 .REF8 .REF16 operand operand operand operand operand Parameter operand An operand of byte, context, respectively. word, longword, quadword, or octaword Example .MACRO .BYTE .REF4 .REF4 .REF4 .ENDM MOVL3 A,B,C "XFF,"XA9 MOVL3 RO,@LAB-l,(R7)+[Rl0] A B c THIS OPERAND HAS LONGWORD CONTEXT THIS OPERAND HAS LONGWORD CONTEXT THIS OPERAND HAS LONGWORD CONTEXT MOVL3 This example uses .REF4 to create a new instruction, MOVL3, which uses the reserved opcode FF. See the example in .OPDEF for a preferred method to create a new instruction. GENERAL ASSEMBLER DIRECTIVES . RESTORE_PSECT .RESTORE PSECT -- RESTORE PREVIOUS PROGRAM SECTION CONTEXT DIRECTIVE .RESTORE PSECT retrieves the program section from the top of the program section context stack, an internal stack in the assembler. If the stack is empty when .RESTORE PSECT is issued, the assembler displays an error message. When-.RESTORE PSECT retrieves a program section, it restores the current location counter to the value it had when the program section was saved. The local label block is also restored if it was saved when the program section was saved. See the descriptipn of .SAVE_PSECT. Format .RESTORE PSECT Example .RESTORE PSECT and .SAVE PSECT are especially useful in macros that define program sections (see Chapter 6). The macro definition below saves the current program section context and defines new program sections. Then, it restores the saved program section. If the macro did not save and restore the program section context each time the macro was invoked, the program section would change • • MACRO INITD INITIALIZE SYMBOLS AND DATA AREAS SAVE THE CURRENT PSECT DEFINE NEW PSECT DEFINE SYMBOLS .SAVE PSECT .PSECT SYMBOLS,ABS HELP LEV=2 MAXNUM=lOO RATE1=16 RATE2=4 .PSECT DATA,NOEXE,LONG TABL: .BLKL 100 TEMP: .BLKB 16 .RESTORE PSECT DEFINE ANOTHER PSECT 100 LONGWORDS IN TABL MORE STORAGE RESTORE THE PSECT IN EFFECT WHEN MACRO IS INVOKED .ENDM Note The alternate form of .RESTORE PSECT is .RESTORE. 5-53 GENERAL ASSEMBLER DIRECTIVES .SAVE_PSECT .SAVE PSECT -- SAVE CURRENT PROGRAM SECTION CONTEXT DIRECTIVE .SAVE PSECT stores the current program section context on the top of the program section context stack, an internal assembler stack, while leaving the current program section context in effect. The program section context stack can hold 31 entries. Each entry includes the value of the current location counter and the maximum value assigned to the location center in the current program section. If the stack is full when .SAVE_PSECT is encountered, an error occurs • • SAVE PSECT and .RESTORE PSECT are especially useful in macros that define program sections (s~e Chapter fi). See the description of .RESTORE PSECT for another example of using .SAVE PSECT. Format .SAVE PSECT [LOCAL_BLOCK] Parameter LOCAL BLOCK An optional keyword that specifies that the current is to be saved with the program section context. local label Example MACRO DEFINITION: .MACRO ERR_MESSAGE, TEXT ; SET UP LISTS OF MESSAGES AND ; POINTERS .IIF NOT DEFINED MESSAGE INDEX, MESSAGE INDEX=O .SAVE PSECT LOCAL BLOCK KEEP LOCAL LABELS .PSECT MESSAGE TEXT LIST OF ERROR MESSAGES MESSAGE:: .ASCIC /TEXT/ADDRESSES OF ERROR MESSAGES .PSECT MESSAGE POINTERS STORE ONE POINTER .ADDRESS -MESSAGE GET BACK LOCAL LABELS .RESTORE PSECT PUSHL #MESSAGE INDEX PRINT MESSAGE CALLS #1, PRINT_MESS MESSAGE INDEX=MESSAGE INDEX+l .ENDM ERR MESSAGE MACRO CALL: RESETS: CLRL R4 BLBC RO, 30$ ; <STRING TOO SHORT> ADD "STRING TOO SHORT" ERR MESSAGE ; TO LIST OF ERROR MESSAGES 30$: RSB The use of .SAVE PSECT LOCAL BLOCK here means that the local label 30$ is defined in tne same locaT label block as the reference to 30$. If a local label is not defined in the block in which it is referenced, the assembler produces the following error message: %MACRO-E-UNDEFSYM, Undefined Symbol Note 1. The alternate form of .SAVE PSECT is .SAVE. 5-54 GENERAL ASSEMBLER DIRECTIVES .SHOW .NOSHOW .SHOW AND .NOSHOW -- LISTING DIRECTIVES .SHOW and .NOSHOW specify listing control options in the source text of a program. .SHOW and .NOSHOW can be used with or without an argument 1 ist. When used with an argument list, .SHOW causes certain types of lines to be included in the listing file and .NOSHOW causes certain types of lines to be excluded. .SHOW and .NOSHOW control the listing of the source lines that are in conditional assembly blocks (see the description of .IF}, macros, and repeat blocks (see Chapter n}. When used without arguments, these directives alter the listing level count. The listing level count is initialized to o. Each time .SHOW appears in a program, the listing level count is incremented; each time .NOSHOW appears in a program, the listing level count is decremented. When the listing level count is negative, the listing is suppressed (unless the line contains an error}. Conversely, when the listing level count is positive, the listing is generated. When the count is O, the line is either listed or suppressed, depending on the value of the listing control symbolic arguments. Formats .SHOW .SHOW argument-list .NOSHOW .NOSHOW argument-list Parameter argument-list One or more of the optional symbolic arguments, defined in Table 5-7. Either the long form or the short form of the arguments can be used. Each argument can be used alone or in combination with other arguments. If multiple arguments are specified, they must be separated by commas, tabs, or spaces. If any argument is not specifically included in a listing control statement, its default value (Show or Noshow} is assumed throughout the source program. 5-55 GENERAL ASSEMBLER DIRECTIVES Table 5-7 .SHOW and .NOSHOW Symbolic Arguments ... ~--~·-·-----.--·------·----~.------------r--------------- Long Form Short Form Default Function BINARY MEB No show Lists macro expansions and repeat block expansions that generate binary code. BINARY is a subset of EXPANSIONS. CALLS MC Show Lists macro calls and repeat block specifiers. CONDITIONALS CND Show Lists unsatisfied conditional code associated with the conditional assembly directives. DEFINITIONS MD Show Lists macro and repeat range definitions that appear in an. input source file. EXPANSIONS ME No show Lists macro and repeat range expansions. '-------~-"--··-----·------- '---·-·-- ___ ..___··--·~-------~~---~--J Example .MACRO XX .SHOW LIST NEXT LINE. .NOS HOW DO NOT LIST REMAINDER OF MACRO EXPANSION • X=. • ENDM DO NOT LIST MACRO EXPANSIONS • • NOSHOW EXPANSIONS xx X=. Notes 1. The listing level count allows macros to be listed selectively; a macro definition can specify .NOSHOW at the beginning to decrement the listing count and can specify .SHOW at the end to restore the listing count to its original value. 2. The alternate forms .NLIST. of .SHOW 5-56 and .NOSHOW are .LIST and GENERAL ASSEMBLER DIRECTIVES .SIGNED_BVTE .SIGNED BYTE -- SIGNED BYTE DATA DIRECTIVE .SIGNED BYTE is equivalent to .BYTE, except that VAX-11 MACRO indicates that the data is signed in the object module. The linker uses this information to test for overflow conditions. Format .SIGNED BYTE expression-list Parameters expression-list An expression or list of expressions separated by commas. Each expression optionally can be followed by a repetition factor delimited by square brackets. An expression followed by a repetition factor has the format: expressionl[expression2] expressionl An expression that specifies the value to be stored. must be in the range -128 to +127. The value [expression2] An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required. Example .SIGNED BYTE .SIGNED-BYTE LABEL1-LABEL2 ALPHA [ 20] DATA MUST FIT IN BYTE Note Specifying .SIGNED BYTE allows the linker to detect overflow conditions when the value of the expression is in the range of 128 through 255. Values in this range can be stored as unsigned data but cannot be stored as signed data in a byte. 5-57 GENERAL ASSEMBLER DIRECTIVES .SIGNED_WORD .SIGNED_WORD -- SIGNED WORD STORAGE DIRECTIVE .SIGNED WORD is equivalent to .WORD except that the assembler indicates that the data is signed in the object module. The linker uses this information to test for overflow conditions. .SIGNED WORD is useful after the case instruction to ensure that the displacement fits in a word. Format .SIGNED WORD expression-list Parameters expression-list An expression or list of expressions separated by commas. Each expression optionally can be followed by a repetition factor delimited by square brackets. An expression followed by a repetition factor has the format: expressionl[expression2] expression! An expression that specifies the value to be stored. must be in the range -32768 to +32767. The value [expression2] An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required. Example .MACRO CASE,SRC,DISPLIST,TYPE=W,LIMIT=#O,NMODE=SA#,?BASE,?MAX MACRO TO USE CASE INSTRUCTION SRC IS SELECTOR, DISPLIST IS LIST OF DISPLACEMENTS, TYPE IS B-BYTE W-WORD, L-LONG, LIMIT IS THE BASE ; VALUE OF SELECTOR CASE'TYPE SRC,LIMIT,NMODE'<<MAX-BASE>/2>-1 CASE INSTRUCTION BASE: LOCAL LABEL SPECIFYING BASE .IRP EP,<DISPLIST> TO SET UP OFFSET LIST .SIGNED WORD EP-BASE OFFSET LIST .ENDR MAX: LOCAL LABEL USED TO COUNT ARGS CASE .ENDM CASE CASEW IVAR <ERR PROC,SORT,REV SORT> IVAR,#0,SA#<(30001$-30000$)/2>-l 5-58 IF IVAR=O, ERROR; GENERAL ASSEMBLER DIRECTIVES 30000$: .SIGNED WORD .SIGNED-WORD .SIGNED-WORD 30001$: ERR PROC-30000$ SORT-30000$ REV SORT-30000$ LOCAL LABEL SPECIFYING BASE ; OFFSET LIST ; -OFFSET LIST ; OFFSET LIST LOCAL LABEL USED TO COUNT ARGS =l, FOWARD SORT; =2,BACKWARD SORT CASE CASEL TEST <TEST1,TEST2,TEST3>,L,#l TEST,#l,SA#<<30003$-30002$>/2>-l ; LOCAL LABEL SPECIFYING BASE 30002: ; OFFSET LIST .SIGNED WORD TESTl-30002$ .SIGNED-WORD TEST2-30002$ ; OFFSET LIST .SIGNED-WORD ; OFFSET LIST TEST3-30002$ LOCAL LABEL USED TO COUNT ARGS 30003$: VALUE OF TEST CAN BE 1,2, OR 3 In this example, the CASE macro 'uses .SIGNED WORD to create a CASEB, CASEW, or CASEL instruction. See Chapter 6 for a description of the directives used to define the macro. Note Specifying .SIGNED WORD allows the linker to detect overflow conditions when the value of the expression is in the range of 32768 through 65535. Values in this range can be stored as unsigned data but cannot be stored as signed data in a word. 5-59 GENERAL ASSEMBLER DIRECTIVES .SUBTITLE .SUBTITLE -- SUBTITLE DIRECTIVE .SUBTITLE causes the assembler to print a line of text in the table of contents that is produced immediately before the assembly listing. The assembler also prints the line of text as the subtitle on the second line of each assembly listing page. This subtitle text is printed on each page until altered by a subsequent .SUBTITLE directive in the program. Format .SUBTITLE comment-string Parameter comment-string An ASCII string from 1 to 40 characters long; excess characters are truncated. This string represents the line of text to be printed in the table of contents and as the subtitle in the assembly listing. Example 1. .SUBTITLE CONDITIONAL ASSEMBLY This directive causes the assembler to print text as the subtitle of the assembly listing: the following CONDITIONAL ASSEMBLY It also causes the text to be printed out in the listing's table of contents, along with the source page number and the line sequence number of the source statement where .SUBTITLE was specified. The table of contents would have the following format: 2. TABLE OF CONTENTS (1) (2) (2) (3) (4) (4) (5) 5000 ASSEMBLER DIRECTIVES 300 MACRO DEFINITIONS 2300 DATA TABLES AND INITIALIZATION 4800 MAIN ROUTINE 2800 CALCULATIONS 5000 I/O ROUTINES 1300 CONDITIONAL ASSEMBLY Note The alternate form of .SUBTITLE is .SBTTL. 5-60 GENERAL ASSEMBLER DIRECTIVES .TITLE .TITLE -- TITLE DIRECTIVE .TITLE assigns a name to the object module. This name is the first 31 or fewer nQnblank characters following the directive. Format .TITLE module-name comment-string Parameters module-name An identifier from 1 to 31 characters long. comment-string An ASCII string from 1 to 40 characters long; are truncated. excess characters Example .TITLE EVAL EVALUATES EXPRESSIONS Notes 1. The module name specified with .TITLE bears no relationship to the file specification of the object module, as specified in the VAX-11 MACRO command line. Rather, the object module name appears in the linker load map, and is also the module name that the debugger and librarian recognize. 2. If .TITLE is not specified, MACRO assigns the default name .MAIN. to the object module. If more than one .TITLE directive is specified in the source program, the last .TITLE directive encountered establishes the name for the entire object module. 3. When evaluating the module-name, MACRO ignores all spaces and/or tabs up to the first nonspace/nontab character after .TITLE. 5-61 GENERAL ASSEMBLER DIRECTIVES .TRANSFER .TRANSFER -- TRANSFER DIRECTIVE .TRANSFER redefines a global symbol for use in a shareable image. The linker redefines the symbol as the value of the location counter at the .TRANSFER directive after a shareable image is linked. Whenever possible, programs should not need to be relinked when the shareable images to which they are linked change. This can only be achieved if: • the total size of the shareable image does not change • the entry points in the shareable image do not change their addresses when the shareable code is changed and the image is relinked. To avoid changing the size of the shareable image, reserve extra space when first creating the image. To insure that the entry points do not change, create an object module that contains a transfer vector for each entry point and does not change the order of the transfer vectors. Link this object module at the beginning of the shareable image and the addresses will remain fixed even if source code for a routine is changed. After each .TRANSFER directive, a register save mask (for procedures only) and a branch to the first instruction of the routine should appear. The .TRANSFER directive does not cause any memory to be allocated and does not generate any binary code. It merely generates instructions to the linker to redefine the symbol when a shareable image is being created • • TRANSFER can be used with procedures entered by the CALLS or CALLG instruction. In this case, .TRANSFER is used with the .ENTRY and .MASK directives. The branch to the actual routine must be a branch to the entry point plus 2. Adding 2 to the address is necessary to bypass the 2-byte register save mask. Figure 5-1 illustrates the use of transfer vectors. 5-62 GENERAL ASSEMBLER DIRECTIVES Linked with Object Modules Linked with Shareable Image Program Calling Procedure Transfer Vector Module .. . CALLS .. Program Calling Procedure ROUTB . .TRANSFER .MASK BRW .TRANSFER .MASK BRW . CALLS ROUTB--- ROUT A ROUT A ROUTA+2 ROUTB~ ROUTB ROUTB+2-+- Shareable Image Other Object Modules ROUTB,O .ENTRY ; START OF ROUTINE..._1- .. ENTRY ROUTB,O ............... ; START OF ROUTINE . RET RET Figure 5-1 Object Modules Using Transfer Vectors 5-n3 GENERAL ASSEMBLER DIRECTIVES Format .TRANSFER symbol Parameter symbol A global symbol that is an entry point in a procedure or routine. Example .TRANSFER ROUTINE A .MASK ROUTINE=A,AM<R4,R5> BRW ROUTINE A+2 .ENTRY ROUTINE_A,AM<R2,R3> COPY ENTRY MASK AND ADD REGISTERS 4 AND 5 BRANCH TO ROUTINE (PAST ENTRY MASK) ENTRY POINT, SAVE REGISTERS 2 AND 3 RET In this example, .MASK copies a routine's entry mask to the new entry address specified by .TRANSFER. If the routine is placed in a shareable image and then called, registers 2, 3, 4, and 5 will be saved. 5-64 GENERAL ASSEMBLER DIRECTIVES .WARN .WARN -- WARNING DIRECTIVE .WARN causes the assembler to display a warning message on the terminal or batch log file and in the listing file (if there is one). Format .WARN [expression] ;comment Parameters expression An expression whose value is displayed when .WARN is during assembly. encountered ;comment A comment that is displayed when .WARN comment must be preceded by a semicolon. is encountered. The Example • IF DEFINED • IF DEFINED .WARN .ENDC .ENDC FULL DOUBLE PREC ; THIS-COMBINATION NOT TESTED If the symbols FULL and DOUBLE PREC are both warning message is displayed. %MACRO-W-GENWRN, Generated WARNING: defined, the following THIS COMBINATION NOT TESTED Notes 1. .WARN, .ERROR, and .PRINT are called the message display directives. They can be used to display information indicating that a macro call contains an error or an illegal set of conditions (see Chapter n for more information on macro calls) • 2. When the assembly is finished, the assembler displays the total number of errors, warnings, and information messages, and the page numbers and line numbers of the lines causing the errors or warning on the terminal (or in the batch log file). See the VAX-11 MACRO User's Guide for more information on errors and warnings. 3. If .WARN is included in a macro ~ibrary (see the VAX-11 MACRO User's Guide), the comment should end with an additional semicolon. Otherwise, the comment will be stripped from the directive and will not be displayed when the macro is called. 4. The line containing the .WARN directive is not included the listing file. If the expression has a value of O, it is not displayed the warning message. 5. 5-65 in in GENERAL ASSEMBLER DIRECTIVES .WEAK .WEAK -- WEAK SYMBOL ATTRIBUTE DIRECTIVE .WEAK specifies symbols that are either defined externally in another module or defined globally in the current module. .WEAK suppresses any object library search for the symbol. When .WEAK specifies a symbol that is not defined in the current module, the symbol is externally defined. If the linker finds the symbol's definition in another module, it uses that definition. If the linker does not find an external definition, the symbol has a value of 0 and the linker does not report an error. The linker does not search a library for the symbol, but if a module brought in from a library for another reason contains the symbol definition, the linker uses it. When .WEAK specifies a symbol that is defined in the current module, the symbol is considered to be globally defined. However, if this module is inserted in an object library, this symbol is not inserted in the library's symbol table. Consequently, searching the library at link time to resolve this symbol does not cause the module to be included. Format .WEAK symbol-list Parameter symbol-list A list of legal symbols separated by commas. Example .WEAK IOCAR,LAB_3 5-66 GENERAL ASSEMBLER DIRECTIVES .WORD .WORD -- WORD STORAGE DIRECTIVE .WORD generates successive words (2 module. bytes) of data in the object Format .WORD expression-list Parameter expression-list One or more expressions separated by commas. Each expression optionally can be followed by a repetition factor delimited by square brackets. An expression followed by a repetition factor has the format: expressionl[expression2] expressionl An expression that specifies the value to be stored. [expression2] An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required. Example .WORD "X3F,FIVE[3] ,32 Notes 1. The expression is first evaluated as a longword, then truncated to a word. The value of the expression should be in the range of -32768 through 32767 for signed data or O through 65535 for unsigned data. The assembler displays an error if the high-order 2 bytes of the longword expression have a value other than O or "XFFFF. 2. The .SIGNED WORD directive is the same as .WORD except that the assembler displays a diagnostic message if a value is in the range from 32768 to 65535. 5-67 CHAPTER 6 MACROS By using macros, a programmer can use a sequence of source lines into a program. single line to insert a A macro definition contains the source lines of the macro. The macro definition can optionally have formal arguments. These formal arguments can be used throughout the sequence of source lines. Later, the formal arguments are replaced by the actual arguments in the macro call. The macro call consists of the macro name optionally followed by actual arguments. The assembler replaces the line containing the macro call with the source lines in the macro definition. It replaces any occurrences of formal arguments in the macro definition with the actual arguments specified in the macro call. This process is called the macro expansion. By default, macro expansions are not printed in the assembly listing. They are printed only when the .SHOW directive (see description in Chapter 5), or the /SHOW qualifier, described in the VAX-11 MACRO User's Guide, specifies the EXPANSIONS argument. In the examples in this chapter, the macro expansions are listed as they would appear if .SHOW EXPANSIONS was specified in the source file or /SHOW EXPANSIONS was specified in the MACRO command string. The macro directives provide facilities for performing eight categories of functions. Table 6-1 lists these categories and the directives that fall under them. Section 6.1 describes macro arguments. Section 6.2 describes the directives in detail. For ease of reference, the directives are presented in alphabetical order. 6-1 MACROS Table 6-1 Summary of Macro Directives Directives 1 Category Macro Definition Directives .MACRO .ENDM Macro Library Directives • LIBRARY .MCALL Macro Deletion Directive .MDELETE Macro Exit Directive .MEXIT Argument Attribute Directives .NARG .NCHR .NTYPE Indefinite Repeat Block Directives .IRP • IRPC Repeat Block Directives .REPEAT (.REPT) End Range Directive .ENDR '-----------~----''----"·-~-·-··· ·----·----- 1. The alternate form, if any, is given in parentheses. 6.1 ARGUMENTS IN MACROS Macros have two types of arguments: actual and formal. Actual arguments are the strings given in the macro call after the name of the macro. Formal arguments are specified by name in the macro definition: that is, after the macro name in the .MACRO directive. Actual arguments in macro calls and formal arguments in macro definitions can be separated by commas, tabs, or spaces. The number of actual arguments in the macro call can be less than or equal to the number of formal arguments in the macro definition. But if the number of actual arguments is greater than the number of formal arguments, the assembler displays an error message. Formal and actual arguments normally maintain a strict positional relationship. That is, the first actual argument in a macro call replaces all occurrences of the first formal argument in the macro definition. However, this strict positional relationship can be overridden by the use of keyword arguments (see Section 6.1.2). An example of a macro definition using formal arguments follows: .MACRO .LONG .WORD .BYTE .ENDM STORE ARGl ARG3 ARG2 STORE ARG1,ARG2,ARG3 ARGl IS FIRST ARGUMENT ARG3 IS THIRD ARGUMENT ARG2 IS SECOND ARGUMENT 6-2 MACROS The following two examples show possible calls and expansions macro defined above. of 1. STORE .LONG .WORD .BYTE 3,2,1 3 1 2 MACRO CALL 3 IS FIRST ARGUMENT 1 IS THIRD ARGUMENT 2 IS SECOND ARGUMENT 2. STORE .LONG .WORD .BYTE X,X-Y,Z MACRO CALL X IS FIRST ARGUMENT Z IS THIRD ARGUMENT X-Y IS SECOND ARGUMENT 6.1.1 x z X-Y the Default Values Default values are values that are defined in the macro definition. They are used when no value is specified in the macro call for a formal argument. Default values are specified in the .MACRO directive as follows: formal-argument-name = default-value An example of a macro definition specifying default values follows: .MACRO .LONG .WORD .BYTE .ENDM STORE ARGl ARG3 ARG2 STORE ARG1=12,ARG2=0,ARG3=1000 The following three examples show possible calls and expansions of the macro defined above. 1. 2. STORE .LONG .WORD .BYTE NO ARGUMENTS SUPPLIED 12 1000 0 STORE .LONG .WORD .BYTE x 3. STORE .LONG .WORD .BYTE 1 1 1000 0 6.1.2 Keyword Arguments ,5,X 12 LAST TWO ARGUMENTS SUPPLIED 5 FIRST ARGUMENT SUPPLIED Keyword arguments allow a macro call to specify the arguments in any order; however, the macro call must specify the same formal argument names that appear in the macro definition. Keyword arguments are useful when a macro definition has many formal arguments, only some of which need to be specified in the call. In any one macro call the arguments should be either all positional arguments or all keyword arguments. When positional and keyword arguments are combined in a macro, only the positional arguments 6-3 MACROS correspond by position to the formal arguments; the keyword arguments are not used. If a formal argument corresponds to both a positional argument and a keyword argument, the argument that appears last in the macro call overrides any other argument definition for the same argument. For example, the following macro definition specifies three arguments: .MACRO .LONG .WORD .BYTE .ENDM STORE ARGl ARG3 ARG2 STORE ARGl ,ARG2 ,ARG3 The following macro call specifies keyword arguments: STORE .LONG .WORD .BYTF ARG3=27+5/4,ARG2=5,ARGl=SYMBL SYMBL 27+5/4 5 Because the keywords are specified in the macro call, the arguments in the macro call need not be given in the order they were listed in the macro definition. 6.1.3 String Arguments If an actual argument is a string containing characters that the assembler interprets as separators (such as a tab, space, or comma), the string must be enclosed by delimiters. String delimiters are usually paired angle brackets (<>). However, the assembler also interprets any character after an initial circumflex (A) as a delimiter. Thus, to pass an angle bracket as part of a string, the programmer can use the circumflex form of the delimiter. The following are examples of delimited macro arguments: <HAVE THE SUPPLIES RUN OUT?> <LAST NAME, FIRST NAME> <LAB: CLRL R4> A%ARGUMENT rs <LAST,FIRST> FOR CALL% A?EXPRESSION IS <5+3>*<4+2>? In the last two examples the initial circumflex indicates that the percent sign (%) and question mark (?), respectively, are the delimiters. Note that only the left hand delimiter is preceded by a circumflex. The assembler interprets a string argument enclosed by delimiters as one actual argument and associates it with one formal argument. If a string argument that contains separator characters is not enclosed by delimiters, the assembler interprets it as successive actual arguments and associates it with successive formal arguments. For example, the following macro call has one formal argument. .MACRO .ASCII .ASCII .ENDM REPEAT STRNG /STRNG/ /STRNG/ REPEAT 'i-4 MACROS The following two macro calls demonstrate actual without delimiters. 1. 2. REPEAT .ASCII .ASCII arguments with and <A B C D E> /A B C D E/ /A B C D E/ REPEAT A B C D E %MACRO-E-TOOMNYARGS, Too many arguments in MACRO call Note that the assembler interpreted the second macro call as having five actual arguments instead of one actual argument with spaces. When a macro is called, the assembler removes present) around a string before associating arguments. the delimiters (if it with the formal If a string contains a semicolon, the string must be enclosed by delimiters, or the semicolon will mark the start of the comment field. To pass a number containing a radix or unary operator (for example, "XF19), the entire argument must be enclosed by delimiters, or the assembler will interpret the radix operator as a delimiter. The following are macro arguments that are enclosed in delimiters because they contain radix operators: <"XF19> <"'BOllOOOll> <"'Fl.5> Macros can be nested, that is a macro definition can contain a call to another macro. If within a macro definition, another macro is called and passed a string argument, the programmer must delimit the argument so that the entire string is passed to the second macro as one argument. The following macro definition contains a call defined in an earlier example: LABl: to the REPEAT .MACRO .BYTE CNTRPT LAB1,LAB2,STR ARG LAB2-LAB1-l LENGTH OF 2+STRING REPEAT <STR ARG> .ENDM CNTRPT macro CALL REPEAT MACRO LAB2: Note that the argument in the call to REPEAT is enclosed in angle brackets even though the actual argument does not contain any separator characters. This is done because the actual argument in the call to REPEAT is a formal argument in the macro definition and will be replaced with an actual argument that may contain separator characters. The following example calls the macro CNTRPT which in turn macro REPEAT: ST: CNTRPT .BYTE REPEAT .ASCII .ASCII ST,FIN,<LEARN YOUR ABC'S> FIN-ST-1 LENGTH OF 2*STRING CALL REPEAT MACRO <LEARN YOUR ABC'S> /LEARN YOUR ABC'S/ /LEARN YOUR ABC'S/ FIN: 6-5 calls the MACROS An alternative method to pass string arguments in nested macros is to enclose the macro argument in nested delimiters. In this case the macro calls in the macro definitions should not have delimiters. Each time the delimited argument is used in a macro call, the assembler removes the outermost pair of delimiters before associating it with the formal argument. This method is not recommended because it requires that the programmer know how deeply a macro is nested. The following macro definition also contains macro: LABl: a call to the .MACRO .BYTE CNTRPT2 LAB1,LAB2,STR ARG LAB2-LAB1-l LENGTH OF 2*STRING REPEAT STR ARG .ENDM CNTRPT2 repeat CALL REPEAT MACRO LAB2: Note that the argument in the call to REPEAT is not enclosed in brackets. angle The following example calls the macro CNTRPT2: BEG: CNTRPT2 BEG,TERM,<<MIND YOUR P'S AND Q'S>> LENGTH OF 2*STRING .BYTE TERM-BEG-1 REPEAT <MIND YOUR P'S AND Q'S> ; CALL REPEAT MACRO .ASCII /MIND YOUR P'S AND Q'S/ .ASCII /MIND YOUR P'S AND Q'S/ TERM: Note that even though the call to REPEAT in the macro definition is not enclosed in delimiters, the call in the expansion is enclosed in delimiters because the call to CNTRPT2 contains nested delimiters around the string argument. 6.1.4 Argument Concatenation The argument concatenation operator, the apostrophe ('), concatenates a macro argument with some constant text. Apostrophes can either precede or follow a formal argument name in the macro source. If an apostrophe precedes the argument name, the text before the apostrophe is concatenated with the actual argument when the macro is expanded. For example, if ARGl is a formal argument associated with the actual argument TEST, ABCDE'ARGl is expanded to ABCDETEST. If an apostrophe follows the formal argument name, the actual argument is concatenated with the text that follows the apostrophe when the macro is expanded. For example, if ARG2 is a formal argument associated with the actual argument MOV, ARG2'L is expanded to MOVL. Note that expansion. the apostrophe itself does not appear in the macro To concatenate two arguments, separate the two formal arguments with two successive apostrophes. Two apostrophes are needed because each concatenation operation discards an apostrophe from the expansion. 6-6 MACROS An example of a macro definition that uses concatenation follows: .MACRO CONCAT INST,SIZE,NUM TEST'NUM': INST''SIZE RO,R'NUM TEST'NUM'X: .ENDM CONCAT Note that two successive apostrophes are used when two formal arguments INST and SIZE. concatenating the An example of a macro call and expansion follows: CON CAT TESTS: MOVL TESTSX: 6.1.5 MOV,L,5 RO,RS Passing Numeric Values of Symbols When a symbol is specified as an actual argument, the name of the symbol, not the numeric value of the symbol, is passed to the macro. However, the value of the symbol can be passed by inserting a backslash before the symbol in the macro call. The assembler then passes the characters representing the decimal value of the symbol to the macro. For example, if the symbol COUNT has a value of 2 and the actual argument specified is \COUNT, the assembler passes the string "2" to the macro; it does not pass the name of the symbol, "COUNT". Passing numeric values of symbols is especially useful with apostrophe (') concatenation operator for creating new symbols. the An example of a macro definition for passing numeric values of symbols follows: .MACRO .ENTRY .ENDM TESTDEF,TESTNO,ENTRYMASK=A?AM<>? TEST'TESTNO,ENTRYMASK ; USES ARG CONCATENATION TESTDEF The following example shows a possible call and expansion of the macro defined above: COUNT = 2 TESTDEF \COUNT .ENTRY TEST2,AM<> COUNT COUNT + 1 TESTDEF \COUNT,A?AM<R3,R4>? .ENTRY TEST3,AM<R3,R4> 6.1.6 Created Local Labels Local labels are often very useful in macros. Although the programmer can specify local labels in the macro definition, these local labels might be duplicated elsewhere in the local label block and might thus cause errors. However, the programmer can use the assembler to create local labels in the macro expansion which will not conflict with other local labels. These labels are called created local labels. Created local labels range from 30000$ through 65535$. Each time the assembler creates a new local label, it increments the numeric part of the label name by 1. Consequently, no user-defined local labels should be in the range of 30000$ through 65535$. 6-7 MACROS The programmer specifies a created local label by a question mark (?) placed in front of the formal argument name. When the macro is expanded, the assembler creates a new local label if the corresponding actual argument is blank. If the corresponding actual argument is specified, the assembler substitutes the actual argument for the formal argument. Created local symbols can be used only in the first 31 formal arguments specified in the .MACRO directive. Created local labels can be associated only with positional actual arguments; created local labels cannot be associated with keyword actual arguments. The following example is a macro definition specifying a created local label: .MACRO TSTL BGEQ MN EGL .ENDM Ll: POSITIVE ARGl L"l ARGl ,ARGl POSITIVE ARGl, ?Ll The following three calls and expansions of the macro defined above show both created local labels and a user-specified local label: 1. POSITIVE TSTL RO BGEQ 30000$ MNEGL RO,RO RO 30000$: 2. POSITIVE COUNT TSTL COUNT BGEQ 30001$ MNEGL COUNT,COUNT 30001$: 3. POSITIVE VALUE,10$ TSTL VALUE BGEQ 10$ MNEGL VALUE,VALUE 10$: Macro String Operators 6.1.7 The three macro string operators are: • %LENGTH • %LOCATE e %EXTRACT These operators perform string manipulations on macro arguments and ASCII strings. They can be used only in macros and repeat blocks. The following sections describe these operators and give their formats and examples of their use. 6-8 MACROS 0 /oLENGTH 6.1.7.1 %LENGTH Operator - The %LENGTH operator returns the length of a string. For example, the value of %LENGTH(<ABCDE>) is 5. Format %LENGTH(string) Parameters string A macro argument or a delimited string. The delimited by angle brackets or a character circumflex (see Section 6.1.3). string can be preceded by a Examples Macro definition: .MACRO CHK'SIZE ARGl ; MACRO CHECKS IF ARGl .IF GREATER-EQUAL %LENGTH(ARG1)-3 ; IS BETWEEN 3 AND .IF LESS THAN 6-%LENGTH(ARG1) ; 6 CHARACTERS LONG .ERROR ARGUMENT ARGl IS GREATER THAN 6 CHARACTERS ; IF MORE THAN 6 .ENDC ; IF LESS THAN 3 .IF FALSE ARGUMENT ARGl IS LESS THAN 3 CHARACTERS .ERROR ; OTHERWISE DO .ENDC ; NOTHING .ENDM CHK SIZE Macro calls and expansions of the macro defined above: ; SHOULD BE TOO SHORT CHK SIZE A .IF-GREATER EQUAL 1-3 ; IS BETWEEN 3 AND 6-1 ; 6 CHARACTERS LONG .IF LESS THAN ARGUMENT A IS GREATER THAN 6 CHARACTERS .ERROR ; IF MORE THAN 6 .ENDC .IF FALSE ; IF LESS THAN 3 %MACRO-E-GENERR, Generated ERROR: ARGUMENT A IS LESS THAN 3 CHARACTERS 1. .ENDC 2. ; OTHERWISE DO CHK SIZE ABC ; SHOULD BE OK .IF-GREATER EQUAL 3-3 ; IS BETWEEN 3 AND .IF LESS THAN 6-3 ; 6 CHARACTERS LONG .ERROR ARGUMENT ABC IS GREATER THAN 6 CHARACTERS .ENDC ; IF MORE THAN 6 .IF FALSE ; IF LESS THAN 3 .ERROR ARGUMENT ABC IS LESS THAN 3 CHARACTERS .ENDC ; OTHERWISE DO 6-9 MACROS %LOCATE 6.1.7.2 %LOCATE Operator - The %LOCATE operator locates a substring within a string. If %LOCATE finds a match of the substring, it returns the character position of the first character of the match in the string. For example, the value of %LOCATE(<D>,<ABCDEF>) is 3. Note that the first character position of a string is o. If %LOCATE does not find a match, it returns a value equal to the length of the string. For example, the value of %LOCATE(<Z>,<ABCDEF>) is 6. The %LOCATE operator returns a numeric value that can be used expression. in any Format %LOCATE(stringl,string2 [,symbol] ) Parameters stringl A string that specifies the substring. The substring can be either a macro argument or a delimited string. The delimiters can be either angle brackets or a character preceded by a circumflex. string2 The string that is searched for the substring. The string can be either a macro argument or a delimited string. The delimiters can be either angle brackets or a character preceded by a circumflex. symbol An optional symbol or decimal number that specifies the position in string2 at which the assembler should start the search. If this argument is omitted, the assembler starts the search at position 0 (the beginning of the string). A symbol must be an absolute symbol that has been previously defined and a number must be an unsigned decimal number. Expressions and radix operators are not allowed. Example Macro definition: .MACRO BIT NAME ARGl ; CHECKS IF ARGl IS IN LIST %LOCATE(ARG1,<DELDFWDLTDMOESC>)-15 .IF EQUAL ; IF IT IS NOT PRINT ERROR .ERROR ARGl IS AN INVALID BIT NAME ; IF IT IS DO .ENDC BIT NAME ; NOTHING .ENDM 6-10 MACROS Macro calls and expansions of the macro defined above: 1. 2. IS IN LIST BIT NAME .IF-EQUAL ESC 12-15 .ERROR .ENDC IF IT IS NOT PRINT ERROR ; ESC IS AN INVALID BIT NAME IF IT IS DO BIT NAME • IF-EQUAL FOO 15-15 %MACRO-E-GENERR, Generated ERROR: NOT IN LIST IF IT IS NOT PRINT ERROR FOO IS AN INVALID BIT NAME .ENDC ; IF IT IS DO Note If the optional symbol is specified, the search begins at the character position of string2 specified by the symbol. For example, the value of %LOCATE(<ACE>,<SPACE HOLDER>,5) is 12 because there is no match after the 5th character position. 6.1.7.3 %EXTRACT Operator - The %EXTRACT operator extracts a substring from a string. It returns the substring that begins at the specified position and is the specified length. For example, the value of %EXTRACT(2,3,<ABCDEF>) is CDE. Note that the first character in a string is in position o. Format %EXTRACT(symboll,symbol2,string) Parameters symboll A symbol or rlecimal number that specifies the starting position of the substring. A symbol must be an absolute symbol that has been previously defined and a number must be an unsigned decimal number. Expressions and radix operators are not allowed. symbol2 A symbol or decimal number that specifies the length of the substring. A symbol must be an absolute symbol that has been previously defined and a number must be an unsigned decimal number. Expressions and radix operators are not allowed. string A macro argument or a delimited string. The delimited by angle brackets or a character circumflex. 6-11 string can be preceded by a MACROS Example Macro definition: XX .MACRO RESERVE ARGl %LOCATE(<=>,ARG1) .IF EQUAL XX-%LENGTH(ARG1) .WARN ; INCORRECT FORMAT FOR MACRO CALL - ARGl .MEX IT .ENDC %EXTRACT(O,XX,ARG1) :: XX = XX+l .BLKB %EXTRACT(XX,3,ARG1) .ENDM RESERVE Macro calls and expansions of the macro defined above: 1. xx = 6 RESERVE FOOBAR .IF EQUAL XX-6 %MACRO-W-GENWRN, Generated WARNING: INCORRECT FORMAT FOR MACRO CALL - FOOBA .MEXIT 2. xx RESERVE LOCATION=l2 8 • IF EQUAL XX-11 .WARN INCORRECT FORMAT FOR MACRO CALL - LOCATION=l2 .MEX IT .ENDC LOCATION:: XX = XX+l .BLKB 12 Notes If the starting position specified is greater than or equal to the length of the string, %EXTRACT returns a null string (a string of O characters). If the length specified is o, %EXTRACT returns a null string. 6-12 6.2 MACRO DIRECTIVES The remainder of this chapter describes the macro directives in detail, showing their formats and giving examples of their use. The directives are presented in alphabetical order. .ENDM .ENDM--END DEFINITION DIRECTIVE .ENDM terminates the macro definition. for an example of the use of .ENDM. See the description of .MACRO Format .ENDM [macro-name] Parameter macro-name The The name of the macro whose definition is to be terminated. macro name is optional; but, if specified, it must match the The macro name name defined in the matching .MACRO directive. should be specified so that the assembler can detect any improperly nested macro definitions. Note If .ENDM is encountered outside a macro definition, the assembler displays an error message. .ENDR .ENDR--END RANGE DIRECTIVE .ENDR indicates the end of a repeat range. It must be the final statement of every indefinite repeat block directive (.IRP and .IRPC) and every repeat block directive (.REPEAT). See the description of these directives for examples of the use of .ENDR. Format .ENDR 6-13 MACROS .IRP .IRP--INDEFINITE REPEAT ARGUMENT DIRECTIVE .IRP replaces a formal argument with successive actual arguments specified in an argument list. This replacement process occurs during the expansion of the indefinite repeat block range. The .ENDR directive specifies the end of the range • • IRP is analogous to a macro definition with only one formal argument. At each expansion of the repeat block, this formal argument is replaced with successive elements from the argument list. The directive and its range are coded inline within the source program. This type of macro definition and its range do not require calling the macro by name, as do other macros described in this chapter • • IRP can appear either within or outside another macro definition, indefinite repeat block, or repeat block (see the description of .REPEAT). The rules for specifying .IRP arguments are the same as those for specifying macro arguments. Format .IRP symbol,<argument list> range .ENDR Parameters symbol A formal argument that is successively replaced with the specified actual arguments enclosed in angle brackets. If no formal argument is specified, the assembler displays an error message. <argument list> A list of actual arguments enclosed in angle brackets and used in expanding the indefinite repeat range. An actual argument can consist of one or more characters; multiple arguments must be separated by a legal separator (comma, space, or tab). If no actual arguments are specified, no action is taken. range The block of source text to be repeated once for each occurrence of an actual argument in the list. The range can contain macro definitions and repeat ranges. .MEXIT is legal within the range. 6-14 MACROS Example Macro definition: SUBR,Al,A2,A3,A4,A5,A6,A7,A8,A9,Al0 .MACRO CALL SUB .NARG COUNT .!RP ARG,<Al0,A9,A8,A7,A6,A5,A4,A3,A2,Al> .IIF NOT BLANK ARG, PUSHL ARG .ENDR CALLS ; NOTE SUBR IS COUNTED #<COUNT-1>,SUBR .ENDM CALL SUB Macro call and expansion of the macro defined above: CALL SUB TEST,INRES,INTES,UNLIS,OUTCON,#205 .NARG COUNT .IRP ARG,<,,,,,#205,0UTCON,UNLIS,INTES,INRES> .IIF NOT BLANK ARG, PUSHL ARG .ENDR • II F NOT BLANK PUSHL .IIF NOT-BLANK PUSHL .IIF NOT-BLANK PUSHL • !IF NOT-BLANK PUSHL .IIF NOT-BLANK , PUSHL .IIF NOT-BLANK #205, PUSHL #205 .IIF NOT-BLANK OUTCON, PUSHL OUTCON .IIF NOT-BLANK UNLIS, PUSHL UN LIS .IIF NOT-BLANK INTES, PUSHL INT ES .IIF NOT-BLANK INRES, PUSHL IN RES CALLS i<COUNT-1>,TEST ; NOTE TEST IS COUNTED This example uses the .NARG directive to count the arguments and the .IIF NOT_BLANK directive (see descriptions of .IF and .IIF in Chapter 5). to determine whether the actual argument is blank. If the argument is blank, no binary code is generated. ~-15 MACROS .IRPC .IRPC--INDEFINITE REPEAT CHARACTER DIRECTIVE .IRPC is similar to .IRP except that .IRPC permits single-character substitution, rather than argument substitution. On each iteration of the indefinite repeat range, the formal argument is replaced with each successive character in the specified string. The .ENDR directive specifies the end of the range • • IRPC is analogous to a macro definition with only one formal argument. At each expansion of the repeat block, this formal argument is replaced with successive characters from the actual argument string. The directive and its range are coded inline within the source program and do not require calling the macro by name, as do other macros described in this chapter • • IRPC can appear either within or outside another macro definition, indefinite repeat block, or repeat block (see description of .REPEAT). Format .IRPC symbol,<string> range .ENDR Parameters symbol A formal argument that is successively replaced with the specified characters enclosed in angle brackets. If no formal argument is specified, the assembler displays an error message. I <string> A sequence of characters enclosed in angle brackets and used in the expansion of the indefinite repeat range. Although the angle brackets are required only when the string contains separating characters, their use is recommended for legibility. range The block of source text to be repeated once for each occurrence of a character in the list. The range can contain macro definitions and repeat ranges. .MEXIT is legal within the range. 6-16 MACROS Example Macro Definition: HV .MACRO .NCHR .IRPC HV+"A?CHR? .ENDR .ENDM HASH SYM HV, <SYMBOL> CHR, <SYMBOL> SYMBOL HASH SYM Macro call and expansion of the macro defined above: HV HV HV HV HV HV HASH SYM <MOVC5> .NCHR HV,<MOVC5> .IRPC CHR,<MOVC5> HV+"A?CHR? .ENDR HV+"A?M? HV+"A?O? HV+"A?V? HV+"A?C? HV+"A?5? This example uses the .NCHR characters in actual argument. directive fi-17 to count the number of MACROS .LIBRARY .LIBRARY--MACRO LIBRARY DIRECTIVE .LIBRARY adds a name to the macro library list that is searched whenever a .MCALL or an undefined opcode is encountered. The libraries are searched in the reverse order in which they were specified to the assembler. If the programmer omits any information from the macro-library-name argument, default values are assumed. The device defaults to the user's disk; the directory defaults to the user's directory; and the file type defaults to MLB. DIGITAL recommends that libraries be specified in the MACRO command line with the /LIBRARY qualifier rather than with the .LIBRARY directive. The .LIBRARY directive makes moving files cumbersome. Format .LIBRARY macro-library-name Parameter macro-library-name A delimited string that is the library. file specification of Example .LIBRARY .LIBRARY .LIBRARY MACRO LIBRARY USERM.MLB /DBl:[TEST]USERM/ ?DBl:SYSDEF.MLB? \CURRENT.MLB\ 6-18 a macro MACROS .MACRO .MACRO--MACRO DEFINITION DIRECTIVE .MACRO begins the definition of a macro. It gives the macro name and a list of formal arguments (see Section 6.1). If the name specified is the same as the name of a previously defined macro, the previous definition is deleted and replaced with the new one. The .MACRO directive is followed by the source text to be included in the macro expansion. The .ENDM directive specifies the end of the range. Macro names do not conflict with user-defined symbols. user-defined symbol can both have the same name. A macro and a When the assembler encounters a .MACRO directive, it adds the macro name to its macro name table and stores the source text of the macro (up to the matching .ENDM directive). No other processing occurs until the macro is expanded. The symbols in the formal argument list are associated with the macro name and are limited to the scope of the definition of that macro. For this reason, the symbols that appear in the formal argument list can also appear elsewhere in the program. Format .MACRO macro-name [formal-argument-list] range .ENDM [macro name] Parameters macro-name The name of the macro to be defined; symbol up to 31 characters long. this name can be any legal formal-argument-list The symbols, separated by commas, to be replaced arguments in the macro call. by range The source text to be included in the macro expansion. n-19 the actual MACROS Example Macro definition: .MACRO .PSECT USERDEF DEFS,ABS MYSYM= 5 HIVAL= "XFFF123 LOWVAL= 0 .PSECT RWDATA,NOEXE,LONG TABLE: .BLKL 100 LIST: .BLKB 10 .MACRO USERDEF .ENDM USERDEF .ENDM USERDEF REDEFINE IT TO NULL Macro calls and expansions of the macro defined above: USERDF .PSECT 1. SHOULD EXPAND DATA DEFS,ABS MYSYM= 5 HIVAL= "XFFF123 LOWVAL= 0 .PSECT RWDATA,NOEXE,LONG TABLE: .BLKL 100 LIST: .BLKB 10 .MACRO USERDEF USERDEF .ENDM USERDF 2. REDEFINE IT TO NULL SHOULD EXPAND NOTHING In this example, when the macro is called the first time it defines some symbols and data storage areas and then redefines itself. When the macro is called a second time, the macro expansion contains no source text. Notes 1. If a macro has the same name as a VAX-11 opcode, the macro is used instead of the instruction. This feature allows a programmer to temporarily redefine an opcode. 2. If a macro has the same name as a VAX-11 opcode and is in a macro library, the .MCALL directive must be used to define the macro. Otherwise, because the symbol is already defined (as the opcode), the assembler will not search the macro libraries. 3. The programmer can redefine a macro with new source text during assembly by specifying a second .MACRO directive with the same name. Including a second .MACRO directive within the original macro definition causes the first macro call to redefine the macro. This is useful when a macro performs initialization or defines symbols; that is, when an operation is performed only once. The macro redefinition can eliminate unneeded source text in a macro or it can delete the entire macro. The .MDELETE directive provides another way to delete macros. 6-20 MACROS .MCALL .MCALL--MACRO CALL DIRECTIVE .MCALL specifies the names of the system and/or user-defined macros that are required to assemble the source program but are not defined in the source file. If any named macro is not.found upon completion of the search (that is, if the macro is not defined in any of the macro libraries), the assembler displays an error message. Format .MCALL macro-name-list Parameter macro-name-list A list of macros to be defined for this assembly. be separated by commas. The names must Example .MCALL INSQUE SUBSTITUTE MACRO IN LIBRARY FOR INSQUE INSTRUCTION Note .MCALL is provided for compatibility with MACR0-11; DIGITAL recommends that it not be used. When VAX-11 MACRO finds an unknown symbol in the opcode field, it automatically searches all macro libraries. If it finds the symbol in a library, it uses the macro definition and expands the macro reference. If VAX-11 MACRO does not find the unknown symbol in the library, it displays an error message. There is one exception for which .MCALL must be used: when a macro has the same name as an opcode (see description of .MACRO). 6-21 MACROS .MDELETE .MDELETE--MACRO DELETION DIRECTIVE .MDELETE deletes the definitions of specified macros. The number of macros actually deleted is printed in the assembly listing on the same line as the .MDELETE directive • • MDELETE completely deletes the macro, freeing memory as necessary, whereas the technique of macro redefinition explained in the description of .MACRO merely redefines the macro. Format .MDELETE macro-name-list Parameter macro-name-list A list of macros whose definitions are to be deleted. must be separated by commas. Example .MDELETE USERDEF,$SSDEF,ALTR 6-22 The names MACROS .MEXIT .MEXIT--MACRO EXIT DIRECTIVE .MEXIT terminates a macro expansion before the end of the macro. Termination is the same as if .ENDM was encountered. The directive can also be used within repeat blocks. .MEXIT is most useful in conditional expansion of macros because it bypasses the complexities of nested conditional directives and alternate assembly paths. Format .MEX IT Example .MACRO POLO • IF EQ N N,A,B START CONDITIONAL ASSEMBLY BLOCK • • MEX IT • ENDC .ENDM TERMINATE MACRO EXPANSION • END CONDITIONAL ASSEMBLY BLOCK • POLO ; NORMAL END OF MACRO. In this example, if the actual argument for the formal argument N equals O, the conditional block would be assembled, and the macro expansion would be terminated by .MEXIT. Notes 1. When .MEXIT occurs in a repeat block, the assembler terminates the current repetition of the range and suppresses further expansion of the repeat range. 2. When macros or repeat blocks are nested, .MEXIT exits to next higher level of expansion. 3. If .MEXIT occurs outside a macro definition or block, the assembler displays an error message. 6-23 a the repeat MACROS .NARG .NARG--NUMBER OF ARGUMENTS DIRECTIVE .NARG determines the number of arguments in the current macro call • • NARG counts all the positional arguments specified in the macro call, including null arguments {specified by adjacent commas). The value assigned to the specified symbol does not include either any keyword arguments or any formal arguments that have default values. Format .NARG symbol Parameter symbol A symbol that is assigned a arguments in the macro call. value equal to the number of Example Macro definition: .MACRO .NARG .WORD .ENDM CNT ARG Al,A2,A3,A4,A5,A6,A7,A8,A9=DEF9,Al0=DEF10 COUNTER ; COUNTER IS SET TO NO. OF ARGS COUNTER ; STORE VALUE OF COUNTER CNT ARG Macro calls and expansions of the macro defined above: 1. CNT ARG TEST,FIND,ANS .NARG COUNTER COUNTER .WORD COUNTER WILL = 3 COUNTER IS SET TO NO. OF ARGS STORE VALUE OF COUNTER 2. CNT ARG COUNTER .NARG COUNTER .WORD COUNTER WILL = 0 COUNTER IS SET TO NO. OF ARGS STORE VALUE OF COUNTER 3. CNT ARG TEST,A2=SYMB2,A3=SY3 .NARG COUNTER COUNTER .WORD COUNTER WILL = 1 COUNTER rs SET TO NO. OF ARGS STORE VALUE OF COUNTER KEYWORD ARGUMENTS ARE NOT CO UN TE 4. CNT ARG ,SYMBL,, .NARG COUNTER COUNTER .WORD COUNTER WILL = 3 COUNTER IS SET TO NO. OF ARGS STORE VALUE OF COUNTER NULL ARGUMENTS ARE COUNTED Note If .NARG appears outside of message. a 6-24 macro, the assembler displays an MACROS .NCHR .NCHR--NUMBER OF CHARACTERS DIRECTIVE .NCHR determines the number of characters in a specified character string. It can appear anywhere in a VAX-11 MACRO program and is useful in calculating the length of macro arguments. Format .NCHR symbol,<string> Parameters symbol A symbol that is assigned a value equal to characters in the specified character string. the number of <string> A sequence of printable characters. The character string must be delimited by angle brackets or a character preceded by a circumflex only if the specified character string contains a legal separator (comma, space, and/or tab) or a semicolon. Example Macro definition: .MACRO .NCHR .WORD .ASCII .ENDM DEFINE MACRO ASSIGN VALUE TO CHRCNT STORE VALUE STORE CHARACTERS FINISH CHAR MESS CHRCNT,<MESS> CHRCNT /MESS/ CHAR Macro calls and expansions of the macro defined above: CHRCNT WILL = 5 ASSIGN VALUE TO CHRCNT STORE VALUE STORE CHARACTERS 1. CHAR .NCHR .WORD .ASCII <HELLO> CHRCNT,<HELLO> CHRCNT /HELLO/ 2. CHAR .NCHR .WORD .ASCII <14, 75.39 4> CHRCNT,<14, 75.39 CHRCNT /14, 75.39 4/ 4> 6-25 CHRCNT WILL= 12(DEC) ASSIGN VALUE TO CHRCNT STORE VALUE STORE CHARACTERS MACROS .NTYPE .NTYPE--OPERAND TYPE DIRECTIVE .NTYPE determines the addressing mode of the specified operand. The value of the symbol is set to the specified addressing mode. In most cases, an 8-bit (1-byte) value is returned. Bits O through 3 specify the register associated with the mode, and bits 4 through 7 specify the addressing mode. To provide concise addressing information, the mode bits 4 through 7 are not exactly the same as the numeric value of the addressing mode described in Table 4-1. Specifically, literal mode is indicated by a O in bits 4 through 7 instead of the values 0 through 3 described in Table 4-1. Mode 1 indicates an immediate mode operand, mode 2 indicates an absolute mode operand, and mode 3 indicates a general mode operand. For indexed addressing mode, a 16-bit (2-byte) value is returned. The high-order byte contains the addressing mode of the base operand specifier and the low-order byte contains the addressing mode of the primary operand (the index register). See the VAX-11 Architecture Handbook and Chapter 4 of this manual more information on-addressing modes. for Format .NTYPE symbol,operand Parameter symbol Any legal VAX-11 MACRO symbol. This symbol is assigned a value equal to the 8- or 16-bit addressing mode of the operand argument that follows. operand Any legal address expression, as used argument is specified, 0 is assumed. 6-26 with an opcode. If no MACROS Example Macro Definition: THE FOLLOWING MACRO IS USED TO PUSH AN ADDRESS ON THE STACK. IT CHECKS THE OPERAND TYPE (BY USING .NTYPE) TO DETERMINE IF THE OPERAND IS AN ADDRESS AND, IF NOT, THE MACRO SIMPLY PUSHES THE ARGUMENT ON THE STACK AND GENERATES A WARNING MESSAGE • A ERR • MACRO PUSHADR ADDR .NTYPE A,ADDR A@-4&"'XF .IF IDENTICAL O,<ADDR> PUSHL #0 .MEXIT .ENDC ASSIGNS OPERAND TYPE TO A ISOLATE ADDRESSING MODE IS ARGUMENT EXACTLY 0 STACK ZERO EXIT FROM MACRO 0 .IIF LESS EQUAL A-1, ERR=l .IIF EQUAL A-5, ERR=l .IF EQUAL ERR PUSHAL ADDR .IFF PUSHL ADDR .WARN ; ADDR IS NOT AN ADDRESS .ENDC .ENDM PUSHADR ERR TELLS IF MODE IS ADDRESS ERR = 0 FOR ADDRESS, 1 WHEN NOT IS MODE NOT LITERAL OR IMMEDIATE IS MODE NOT REGISTER IS MODE ADDRESS? YES, STACK ADDRESS NO THEN STACK OPERAND & WARN Macro calls and expansions of the macro defined above: 1. PUSHADR (RO) PUS HAL (RO) VALID ARGUMENT YES, STACK ADDRESS 2. PUSHADR (Rl) [R4] PUS HAL (Rl) [R4] VALID ARGUMENT YES, STACK ADDRESS 3. PUSHADR 0 PUSHL #0 IS ZERO STACK ZERO 4. PUSHADR #1 NOT AN ADDRESS PUSHL ; THEN STACK OPERAND & WARN #1 %MACRO-W-GENWRN, Generated WARNING: #1 IS NOT AN ADDRESS 5. PUSHADR RO NOT AN ADDRESS PUSHL RO ; THEN STACK OPERAND & WARN %MACRO-W-GENWRN, Generated WARNING: RO IS NOT AN ADDRESS Note that to save space, this example is listed as it would appear if .SHOW BINARY, not .SHOW EXPANSIONS, was specified in the source program. 6-27 MACROS .REPEAT .REPEAT--REPEAT BLOCK DIRECTIVE .REPEAT repeats a block of code, a specified number of times, inline with other source code. The .ENDR directive specifies the end of the range. Format .REPEAT expression range .ENDR Parameters expression An expression whose value controls the number of times the range is to be assembled within the program. When the expression is less than or equal to O, the repeat block is not assembled. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). range The source text to be repeated the number of times specified by the value of the expression. The repeat block can contain macro definitions, indefinite repeat blocks, or other repeat blocks • • MEXIT is legal within the range. Example Macro definition: .MACRO COPIES STRING,NUM • REPEAT -NUM .ASCII /STRING/ .ENDR .BYTE 0 • ENDM COPIES Macro calls and expansions of the macro defined above: 1. COPIES <ABCDEF>,5 .REPEAT 5 .ASCII /ABCDEF/ .ENDR .ASCII /ABCDEF/ .ASCII /ABCDEF/ .ASCII /ABCDEF/ .ASCII /ABCDEF/ .ASCII /ABCDEF/ .BYTE 0 6-28 MACROS 2. VARB 3 COPIES <HOW MANY .REPEAT 3 .ASCII /HOW MANY .ENDR .ASCII /HOW MANY .ASCII /HOW MANY .ASCII /HOW MANY .BYTE 0 TIMES>,\VARB TIMES/ TIMES/ TIMES/ TIMES/ Note The alternate form of .REPEAT is .REPT. 6-29 APPENDIX A ASCII CHARACTER SET Table A-1 lists the ASCII characters each. and the hexadecimal code Table A-1 Hexadecimal/ASCII Conversion HEX Code ASCII Char. HEX Code ASCII Char. HEX Code 00 01 02 03 04 OS 06 07 08 09 OA OB NUL SOH STX ETX EQT ENQ ACK BEL BS HT LF VT FF CR 20 21 22 23 24 2S 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 3S 36 37 38 39 3A 3i3 3C 30 3E 3F SP 40 41 42 43 44 4S 46 47 48 49 4A 4B 4C 4D 4E 4F oc OD OE OF 10 11 12 13 14 lS 16 17 18 19 lA lB lC lD lE lF so SI DLE DCl DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS us ! " # $ % & I ( ) * + -' . I 0 1 2 3 4 s 6 7 8 9 : ; < = > ? A-1 ASCII Char. HEX Code ASCII Char. @ 60 \ A B 61 62 63 64 6S 66 r,7 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 7S 76 77 78 79 7A 7B 7C 7D 7E 7F a b c d e f c D E F G H I J K L M N 0 so p Sl S2 S3 54 SS S6 57 SS S9 SA SB SC SD SE SF Q R s T u v w x y z [ \ ] ,. g h i j k 1 m n 0 p q r s t u v w x y z DEL for APPENDIX B VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY B.l ASSEMBLER DIRECTIVES The following table summarizes the VAX-11 MACRO assembler directives. Table B-1 Assembler Directives Format Operation .ADDRESS address-list Stores successive longwords of address data .ALIGN keyword [,expression] Aligns the location counter to the boundary specified by the keyword .ALIGN integer [,expression] Aligns location counter to the boundary specified by (2~integer) .ASCIC string Stores the ASCII string string (enclosed in delimiters), preceded by a count byte .ASCID string Stores the ASCII (enclosed in delimiters), preceded by a string descriptor .ASCII string Stores the ASCII string (enclosed in delimiters) .ASCIZ string Stores the ASCII string (enclosed in delimiters) followed by a 0 byte. .BLKA expression Reserves longwords of address data .BLKB expression Reserves bytes for data .BLKD expression Reserves quadwords for double-precision, floating-point data (continued on next page) B-1 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Operation Format .BLKF expression Reserves longwords for single-precision, floating-point data .BLKG expression Reserves quadwords for floating-point data .BLKH expression Reserves octawords for extended-precision floating-point data .BLKL expression Reserves longwords for data .BLKO expression Reserves octawords for data .BLKQ expression Reserves quadwords for data .BLKW expression Reserves words for data .BYTE expression-list Generates successive bytes of data; each byte contains the value of the specified expression .CROSS Enables cross-referencing of all symbols .CROSS symbol-list Cross-references specified symbols .DEBUG symbol-list Makes symbol names known to the debugger .DEFAULT DISPLACEMENT, keyword Specifies the default displacement length for the relative addressing modes .D FLOATING literal-list Generates 8-byte, double-precision, floating-point data .DISABLE argument-list Disables function(s) specified in argument-Ii st .DOUBLE literal-list Equivalent to .D_FLOATING .DSABL argument-list Equivalent to .DISABLE .ENABL argument-list Equivalent to .ENABLE .ENABLE argument-list Enables function(s) specified in argument-list .END [symbol] Indicates logical end of source program; optional symbol specifies transfer address (continued on next page) B-2 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Format Operation .ENDC Indicates end of conditional assembly block .ENDM [macro-name] Indicates end of macro definition .ENDR Indicates end of repeat block .ENTRY symbol ~ERROR [,expression] [expression] ;comment Procedure entry directive Displays specified error message .EVEN Ensures that the current location counter has an even value (adds 1 if it is odd) .EXTERNAL symbol-list Indicates specified symbols are externally defined .EXTRN symbol-list Equivalent to .EXTERNAL .F FLOATING literal-list Generates 4-byte, single-precision, floating point data .FLOAT literal-list Equivalent to .F_FLOATING .G FLOATING literal-list Generates 8-byte G_floating-point data .GLOBAL symbol-list Indicates specified symbols are global symbols .GLOBL Equivalent to .GLOBAL .H FLOATING literal-list Generates 16-byte, extended precision H_floating-point data .!DENT string Provides means of labeling object module with additional data .IF condition argument(s) Begins a conditional assembly block of source code which is included in the assembly only if the stated condition is met with respect to the argument(s) specified .IFF Equivalent to .IF FALSE .IF FALSE Appears only within a conditional assembly block; begins block of code to be assembled if the original condition tests false .IFT Equivalent to .IF TRUE (continued on next page) B-3 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Format Operation .IFTF Equivalent to .IF_TRUE_FALSE .IF TRUE Appears only within a conditional assembly block; begins block of code to be assembled if the original condition tests true .IF TRUE FALSE Appears only within a conditional assembly block; begins block of code to be assembled unconditionally .IIF condition argument(s), statement Acts as a 1-line conditional assembly block where the condition is tested for the argument specified; the statement is assembled only if the condition tests true .IRP sym<argument list> Replaces a formal argument with successive actual arguments specified in an argument list .IRPC sym,<string> Replaces a formal argument with successive single characters specified in string .LIBRARY macro-library-name Specifies a macro library .LIST [argument-list] Equivalent to .SHOW .LONG expression-list Generates successive longwords of data; each longword contains the value of the specified expression • • MACRO macro-name,argument-list Begins a macro definition .MASK symbol [,expression] Reserves a word for and copies a register save mask .MCALL macro-name-list Specifies the system and/or user-defined macros in libraries that are required to assemble the source program .MDELETE macro-name-list Deletes from memory the macro definitions of the macros in the list .MEXIT Exits from the expansion of a macro before the end of the macro is encountered (continued on next page) B-4 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Format Operation .NARG symbol Determines the number of arguments in the current macro call .NCHR symbol,<string> Determines the number of characters in a specified character string .NLIST [argument-list] Equivalent to .NOSHOW .NOCROSS Disables cross-referencing of all symbols .NOCROSS symbol-list Disables cross-referencing of specified symbols .NOSHOW Decrements listing level count .NOSHOW argument-list Controls listing of macros and conditional assembly blocks .NTYPE symbol,operand Can appear only within a macro definition; equates the symbol to the addressing mode of the specified operand .OCTA literal Stores 16 bytes of data .OCTA symbol Stores 16 bytes of data .ODD Ensures that the current location counter has an odd value (adds 1 if it is even) .OPDEF opcode value, operand-descriptor-list Defines an opcode and its operand list .PACKED decimal-string [,symbol] Generates packed decimal data, 2 digits per byte .PAGE Causes the assembly listing to skip to the top of the next page, and to increment the page count .PRINT [expression] ;comment Displays the specified message .PSECT Begins or resumes the blank program section .PSECT section-name argument-list Begins or resumes a user-defined program section (continued on next page) B-5 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Format Operation • QUAD Ii teral Stores 8 bytes of data .QUAD symbol Stores 8 bytes of data .REFl operand Generates byte operand .REF2 operand Generates word operand .REF4 operand Generates longword operand .REF8 operand Generates quadword operand .REF16 operand Generates octaword operand .REPEAT expression Begins a repeat section of code .ENDR directive number of times expression .REPT Equivalent to .REPEAT .RESTORE Equivalent to .RESTORE_PSECT .RESTORE PSECT Restores program section context from the program section context stack .SAVE [LOCAL_BLOCK] Equivalent to .SAVE_PSECT .SAVE_PSECT [LOCAL_BLOCK] Saves current program section context on the program section context stack .SBTTL comment-string Equivalent to .SUBTITLE .SHOW Increments listing level count .SHOW argument-list Controls listing of macros and conditional assembly blocks .SIGNED_BYTE expression-list Stores successive bytes (8 bits) of signed data .SIGNED WORD expression-list Stores successive words (16 bits) of signed data .SUBTITLE comment-string Causes the specified string to be printed as part of the assembly listing page header; the string component of each .SUBTITLE is collected into a table of contents at the beginning of the assembly listing block; the up to the next is repeated the specified by the (continued on next page) B-6 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-1 (Cont.) Assembler Directives Format Operation .TITLE module-name comment-string Assigns the first 15 characters in the string as an object module name and causes the string to appear on each page of the assembly listing .TRANSFER symbol Directs the linker to redefine the value of the global symbol for use in a shareable image .WARN [expression] ;comment Displays specified warning message .WEAK symbol-list Indicates that each of the listed symbols has the weak attribute .WORD expression-list Generates successive words of data; each word contains the value of the corresponding specified expression SPECIAL CHARACTERS B.2 The following table summarizes the VAX-11 MACRO special characters. Table B-2 Special Characters Used in VAX-11 MACRO Statements Character Character Name Function(s) - Underline Character in symbol names $ Dollar sign Character in symbol names . Period Character in symbol names, current location counter, and decimal point : Colon Label terminator = Equal sign Direct assignment operator and macro keyword argument terminator Tab Field terminator Space Field terminator Number sign Immediate addressing mode indicator # (continued on next page) B-7 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY Table B-2 (Cont.) Special Characters Used in VAX-11 MACRO Statements Character Character Name Function(s) At sign Def erred addressing mode indicator and arithmetic shift operator Comma Field, operand, and item separator Semicolon Comment field indicator Plus sign Autoincrement addressing mode indicator, unary plus operator, and arithmetic addition operator Minus sign Autodecrement addressing mode indicator, unary minus operator, arithmetic subtraction operator, and line continuation indicator * Asterisk Arithmetic multiplication operator I Slash Arithmetic division operator & Ampersand Logi~al ! Exclamation point Logical inclusive OR operator \ Backslash Logical exclusive OR and numeric conversion indicator in macro arguments ... Circumflex Unary operator indicator and macro argument delimiter [J Square brackets Index addressing mode and repeat count indicators () Parentheses Register deferred addressing mode indicators <> Angle brackets Argument or expression grouping delimiters ? Question mark Created label indicator in macro arguments I Apostrophe Macro argument concatenation indicator % Percent sign Macro string operators @ + B-8 AND operator VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY B.3 OPERATORS B.3.1 Unary Operators The following table summarizes the VAX-11 MACRO unary operators. Table B-3 Unary Operators Unary Operator Operator Name + Plus sign +A Results in the positive value of A •(default) Minus sign -A Results in the negative (2's complement) value of A Binary "'BllOOOlll Specifies that 11000111 is a binary number "'o Decimal "'0127 Specifies that 127 is a decimal number "'o Octal "'034 Specifies that 34 is an octal number "'x Hexadecimal "'XFCF9 Specifies that FCF9 is a hexadecimal number ASCII "'A/ABC/ Produces an ASCII string; the characters between the matching delimiters are converted to ASCII representation Register mask "'M<R3,R4,R5> Specifies the registers R3, R4, and RS in the register mask Floating point "'F3 .O Specifies that 3.0 is a floating-point number Complement "'C24 Produces the l's complement value of 24 (decimal) "'c Example B-9 Effect VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY B.3.2 Binary Operators The following table summarizes the VAX-11 MACRO binary operators. Table B-4 Binary Operators ... Binary Operator Operator Name Example + Plus sign A+B Addition - Minus sign A-B Subtraction * Asterisk A*B Multiplication I Slash A/B Division @ At sign A@B Arithmetic Shift & Ampersand A&B Logical AND ! Exclamation point A!B Logical inclusive OR \ Backslash A\B Logical exclusive OR ------. B.3.3 Operation ,..,.,.._. Macro String Operators The following table summarizes the macro operators can be used only in macros. string operators. These Table B-5 Macro String Operators -·---····----------- Format -----------------Function %LENGTH(string) Returns the length of the string %LOCATE(stringl,string2[,symbol]) Locates the substring stringl within string2 starting the search at the character position specified by symbol %EXTRACT(symboll,symbol2,string) Extracts a substring from string that begins at character position specified by symboll and has a length specified by symbol2 B-10 VAX-11 MACRO ASSEMBLER DIRECTIVES AND LANGUAGE SUMMARY B.4 ADDRESSING MODES The following table summarizes the VAX-11 MACRO addressing modes. Table B-6 Addressing Modes Type Addressing Mode Hexadecimal Value Formatl General Register Indexable? Description -1 ~""- Register Rn 5 Register contains the oper and No Register Deferred (Rn) 6 Register contains the addr ess of the operand Yes Auto increment (Rn)+ 8 Register contains the addr ess of the operand; the processor increments the register co ntents by the size of the operand data type Yes Auto increment Deferred @(Rn)+ 9 Register contains the addr ess of the operand address; the processor increments the register contents by 4 Yes Autodecrement -(Rn) 7 The processor decrements t he register contents by the s lZe of the operand data type; the register then contains the address of the operand Yes Displacement dis (Rn) BAdis(Rn) WAdis(Rn) LAdis(Rn) The sum of the contents of the register and the displacem ent is the address of the operand, BA, WA 1 and LA indicate byte, word, and longword displacement, respectively Yes A The sum of the contents of the register and the displacem ent is the address of the operand address; BA, WA, and LA indicate byte, word, and longword displacement, respectively Yes The literal specified is t he the operand; the literal is stored as a short literal No The address specified is t he address of the operand; t he address specified is store d as a displacement from PC; BA, WA, and LA indicate byte, word , and longword displacement, respectively Yes The address specified is t he address of the operand address; t he address specified is stored as a displacement from PC; BA, WA, and LA indicate byte, word , and longword displacement, respectively Yes The address specified is t he address of the operand; the addre SS specified is stored as an absolute virtual address ( not as a displacement) Yes The literal specified is t he operand; the literal is s to red as a byte, word, longword, or quadword No Displacement Def erred General Register (Cont.) Literal Program Counter Relative Relative Deferred c E @dis(Rn) @BAdis(Rn) @WAdis(Rn) @LAdis(Rn) D F #literal SA#literal 0-3 B address BA address WA address LAaddress A c E @address @BA address @.WA address @.LAaddress D F Absolute @#address 9 Immediate #literal IA#literal 8 --- B -- •------ -----·~--·------·--~ (continued on next page) B-ll Table B-6 (Cont.) Addressing Modes Addressing Mode Format! General GA address Index Index base-mode[Rx] Branch Branch address Type .__, -------·"·---1 Hexadecimal Value 4 Description Indexable? The address specified is the address of the operand; if the address is defined as relocatable, the linker stores the address as a displacement from PC; if the address is defined as an absolute virtual address, the linker stores the address as an absolute value Yes The base-mode specifies the base address and the register specifies the index; the sum of the base address and the product of the contents of Rx and the size of the operand data type is the address of the operand; base-mode can be any addressing mode except register, immediate, literal, index, or branch No The address specified is the operand; this address is stored as a displacement to PC; branch mode can only be used with the branch instructions No 1. Key: Rn Any general register RO through Rl2. register can be used in place of Rn. Note that the AP, FP, or SP Rx Any general register RO through Rl2. Note that the AP, FP, or SP register can be used in place of Rx. Rx cannot be the same as the Rn specified in the base-mode for certain base modes (see Section 4.3). dis An expression specifying a displacement. address An expression specifying an address. literal An expression, an integer constant, or a floating-point constant. B-12 APPENDIX C PERMANENT SYMBOL TABLE The permanent symbol table (PST) contains the symbols that VAX-11 MACRO automatically recognizes. These symbols consist of both opcodes and assembler directives. Sections C.l and C.2 below present the opcodes (instruction set) in alphabetical and numerical order, respectively. Appendix B (in Section B.l) presents the assembler directives. The VAX-11 Architecture Handbook provides a the instruction set. C.l 9D 6F 4F 4FFD 6FFD Fl 3D 58 80 81 60 61 40 41 40FD 41FD 60FD 61FD Cl 20 21 AO Al DB F3 F2 78 F8 79 description OPCODES (ALPHABETIC ORDER) Hexadecimal Value co detailed Mnemonic Functional Name ACBB ACBD ACBF ACBG ACBH ACBL ACBW ADAWI ADDB2 ADDB3 Add compare and branch byte Add compare and branch D floating Add compare and branch F-floating Add compare and branch G-floating Add compare and branch H-floating Add compare and branch long Add compare and branch word Add aligned word interlocked Add byte 2 operand Add byte 3 operand ADDD2 ADDD3 ADDF2 ADDF3 ADDG2 ADDG3 ADDH2 ADDH3 ADDL2 ADDL3 ADDP4 ADDP6 Add D-floating 2 operand Add D-f loating 3 operand Add F floating 2 operand Add F-f loating 3 operand Add G-f loating 2 operand Add G-floating 3 operand Add H-floating 2 operand Add H-floating 3 operand Add long 2 operand Add long 3 operand Add packed 4 operand Add packed 6 operand ADDW2 ADDW3 ADWC AOBLEQ AOBLSS ASHL ASHP ASHQ Add word 2 opetand Add word 3 operand Add with carry Add one and branch on less or equal Add one and branch on less Arithmetic shift long Arithmetic shift and round packed Arithmetic shift quad C-1 of PERMANENT SYMBOL TABLE Hexadecimal Value El ES E7 E3 EO E4 E2 E6 lE IF 13 13 lB IE 14 IA BA BB CA CB 89 AA AB BB B9 CB C9 BB AB A9 93 03 83 E9 EB 15 18 19 lF 12 12 03 11 31 10 30 IC ID FA FB 8F CF AF Mnemonic Functional Name BBC BBCC BBC CI BBCS BBS BBSC BBSS BBS SI Branch on bit clear Branch on bit clear and clear Branch on bit clear and clear interlocked Branch on bit clear and set Branch on bit set Branch on bit set and clear Branch on bit set and set Branch on bit set and set interlocked BCC BCS BEQL BEQLU BGEQ BGEQU BGTR BGTRU Branch on carry clear Branch on carry set Branch on equal Branch on equal unsigned Branch on greater or equal Branch on greater or equal unsigned Branch on greater Branch on greater unsigned BICB2 BICB3 BICL2 BICL3 BICPSW BICW2 BICW3 BISB2 Bit clear byte 2 operand Bit clear byte 3 operand Bit clear long 2 operand Bit clear long 3 operand Bit clear program status word Bit clear word 2 operand Bit clear word 3 operand Bit set byte 2 operand BISB3 BISL2 BISL3 BISPSW BISW2 BISW3 BITS BITL Bit set byte 3 operand Bit set long 2 operand Bit set long 3 operand Bit set program status word Bit set word 2 operand Bit set word 3 operand Bit test byte Bit test long BITW BLBC BLBS BLEQ BLEQU BLSS BLSSU BNEQ Bit test word Branch on low bit clear Branch on low bit set Branch on less or equal Branch on less or equal unsigned Branch on less Branch on less unsigned Branch on not equal BNEQU BPT BRB BRW BSBB BSBW BVC BVS Branch on not equal unsigned Break point trap Branch with byte displacement Branch with word displacement Branch to subroutine with byte displacement Branch to subroutine with word displacement Branch on overflow clear Branch on overflow set CAL LG CALLS CASES CASEL CASEW Call with general argument list Call with stack Case byte Case long Case word C-2 PERMANENT SYMBOL TABLE Hexadecimal Value Mnemonic Functional Name BD BC BE BF 94 CHME CHMK CHMS CHMU CLRB Change mode Change mode Change mode Change mode Clear byte 7C DF 7C 7CFD D4 7CFD 7C B4 91 CLRD CLRF CLRG CLRH CLRL CLRO CLRQ CLRW CMPB Clear D floating Clear F-floating Clear G-floating Clear H-floating Clear long Clear octa Clear quad Clear word Compare byte 29 2D CMPC3 CMPC5 CMPD CMPF CMPG CMPH CMPL CMPP3 CMPP4 CMPV Compare character 3 operand Compare character 5 operand Compare D floating Compare F-floating Compare G-f loating Compare H-floating Compare long Compare packed 3 operand Compare packed 4 operand Compare field 6C 4C 4CFD 6CFD 98 99 68 CMPW CMPZV CRC CVTBD CVTBF CVTBG CVTBH CVTBL CVTBW CVTDB Compare word Compare zero-extended field Calculate cyclic redundancy check Convert byte to D floating Convert byte to F-floating Convert byte to G-f loating Convert byte to H-floating Convert byte to long Convert byte to word Convert D_floating to byte 76 32FD 6A 69 48 56 99FD 98FD 4A 49 48FD 33FD 56FD 4AFD 49FD CVTDF CVTDH CVTDL CVTDW CVTFB CVTFD CVTFG CVTFH CVTFL CVTFW CVTGB CVTGF CVTGH CVTGL CVTGW Convert D floating Convert D-floating Convert D-floating Convert D-floating Convert F-floating Convert F-floating Convert F-floating Convert F-floating Convert F-floating Convert F-f loating Convert G-floating Convert G-f loating Convert G-f loating Convert G-floating Convert G=f loating 68FD F7FD F6FD 76FD 6AFD 69FD F6 CVTHB CVTHD CVTHF CVTHG CVTHL CVTHW CVTLB Convert Convert Convert Convert Convert Convert Convert 71 51 51FD 71FD Dl 35 37 EC Bl ED OB to to to to executive kernel supervisor user to to to to to to to to to to to to to to to F floating H-floating long word byte D floating G-f loating H-floating long word byte F floating H-f loating long word H floating to H-f loating to H-floating to H-floating to H-floating to H-floating to long to byte byte D floating F-floating G-f loating long word C-3 PERMANENT SYMBOL TABLE Hexadecimal Value Mnemonic Functional Name 6E 4E 4EFD fiEFD F9 F7 36 08 24 68 CVTLD CVTLF CVTLG CVTLH CVTLP CVTLW CVTPL CVTPS CVTPT CVTRDL Convert Convert Convert Convert Convert Convert Convert Convert Convert Convert 48 CVTRFL CVTRGL CVTRHL CVTSP CVTTP CVTWB CVTWD CVTWF CVTWG CVTWH CVTWL DECB Convert rounded F floating to long Convert rounded G-floating to long Convert rounded H-floating to long Convert leading separate to packed Convert trailing to packed Convert word to byte Convert word to D floating Convert word to F-floating Convert word to G-f loating Convert word to H-floating Convert word to long Decrement byte DECL DECW DIVB2 DIVB3 DIVD2 DIVD3 DIVF2 DIVF3 DIVG2 DIVG3 DIVH2 DIVH3 DIVL2 DIVL3 DIVP DIVW2 DIVW3 EDITPC EDIV EMO DD Decrement long Decrement word Divide byte 2 operand Divide byte 3 operand Divide D floating 2 operand Divide D-floating 3 operand Divide F-floating 2 operand Divide F-floating 3 operand Divide G-floating 2 operand Divide G-floating 3 operand Divide H-floating 2 operand Divide H-floating 3 operand Divide long 2 operand Divide long 3 operand Divide packed Divide word 2 operand Divide word 3 operand Edit packed to character Extended divide Extended modulus D_floating EMODF EMODG EMO DH EMUL EXTV EXTZV FFC FFS HALT INCB Extended modulus F floating Extended modulus G-f loating Extended modulus H-floating Extended multiply Extract field Extract zero-extended field Find first clear bit Find first set bit Halt Increment byte INCL INCW INDEX Increment long Increment word Index calculation 4BFG 6BFD 09 26 33 60 40 4DFD 6DFD 32 97 D7 87 86 87 66 67 46 47 46FD 47FD 66FD 67FD C6 C7 27 A6 A7 38 78 74 54 54FD 74FD 7A EE EF EB EA 00 96 D6 86 OA long to D floating long to F-f loating long to G-f loating long to H-f loating long to packed long to word packed to long packed to leading separate packed to trailing rounded D_floating to long C-4 PERMANENT SYMBOL TABLE Hexadecimal Value Mnemonic Functional Name SC SD OE FO 17 16 06 INSQHI INSQTI INSQUE INSV JMP JSB LDPCTX Insert into queue at head, interlocked Insert into queue at tail, interlocked Insert into queue Insert field Jump Jump to subroutine Load program context 3A 39 92 D2 B2 DB 8E 72 LOCC MATCHC MCOMB MCOML MCOMW MFPR MNEGB MNEGD Locate character Match characters Move complemented byte Move complemented long Move complemented word Move from processor register Move negated byte Move negated D~floating 52 52FD 72FD CE AE 9E 7E DE 7E 7EFD DE 7EFD 7E MNEGF MNEGG MNEGH MNEGL MNEGW MOVAB MOVAD MOVAF MOVAG MOVAH MOVAL MOVAO MOVAQ Move Move Move Move Move Move Move Move Move Move Move Move Move negated F floating negated G-floating negated H-floating negated long negated word address of byte address of D floating address of F-f loating address of G-f loating address of H-floating address of long address of octa address of quad 3E 90 28 2C 70 50 50FD 70FD DO 7DFD 34 DC 7D 2E 2F BO OA 9B 3C MOVAW MOVB MOVC3 MOVC5 MOVD MOVF MOVG MOVH MOVL MOVO MOVP MOVPSL MOVQ MOVTC MOVTUC MOVW MOVZBL MOVZBW MOVZWL Move Move Move Move Move Move Move Move Move Move Move Move Move Move Move Move Move Move Move address of word byte character 3 operand character 5 operand D floating F-floating G-floating H-floating long data packed program status longword quad translated characters translated until character word zero-extended byte to long zero-extended byte to word zero-extended word to long DA 84 85 64 65 44 45 44FD 45FD MTPR MULB2 MULB3 MULD2 MULD3 MULF2 MULF3 MULG2 MULG3 Move to processor register Multiply byte 2 operand Multiply byte 3 operand Multiply D floating 2 operand Multiply D-floating 3 operand Multiply F-floating 2 operand Multiply F-floating 3 operand Multiply G-floating 2 operand Multiply G=floating 3 operand C-5 PERMANENT SYMBOL TABLE Hexadecimal Value Mnemonic Functional Name 64FD 6SFD C4 MULH2 MULH3 MULL2 Multiply H floating 2 operand Multiply H-floating 3 operand Multiply long 2 operand cs MULL3 MULP MULW2 MULW3 NOP POL YD POLYF POLYG POLYH POPR Multiply long 3 operand Multiply packed Multiply word 2 operand Multiply word 3 operand No operation Evaluate polynomial D floating Evaluate polynomial F-floating Evaluate polynomial G-floating Evaluate polynomial H=floating Pop registers PROBER PRO BEW PUSHAB PU SHAD PUSHAF PU SHAG PU SHAH PUS HAL PU SHAO PUS HAQ PUSHAW Probe read access Probe write access Push address of byte Push address of D floating Push address of F-floating Push address of G-floating Push address of H-floating Push address of long Push address of octa Push address of quad Push address of word D9 PUSHL PUS HR REI REMQHI REMQTI REMQUE RET ROTL RSB SBWC Push long Push registers Return from exception or interrupt Remove from queue at head, interlocked Remove from queue at tail, interlocked Remove from queue Return from called procedure Rotate long Return from subroutine Subtract with carry 2A 3B F4 FS 2B 82 83 62 SCANC SKPC SOBGEQ SOBGTR SPANC SUBB2 SUBB3 SUBD2 Scan for character Skip character Subtract one and branch on greater or equal Subtract one and branch on greater Span characters Subtract byte 2 operand Subtract byte 3 operand Subtract D_floating 2 operand 63 42 43 42FD 43FD 62FD 63FD C2 C3 22 23 A2 A3 SUBD3 SUBF2 SUBF3 SUBG2 SUBG3 SUBH2 SUBH3 SUBL2 SUBL3 SUBP4 SUBP6 SUBW2 SUBW3 Subtract D floating 3 operand Subtract F-floating 2 operand Subtract F-floating 3 operand Subtract G-f loating 2 operand Subtract G-floating 3 operand Subtract H-floating 2 operand Subtract H-floating 3 operand Subtract long 2 operand Subtract long 3 operand Subtract packed 4 operand Subtract packed 6 operand Subtract word 2 operand Subtract word 3 operand 2S A4 AS 01 7S SS SSFD 7SFD BA oc OD 9F 7F DF 7F 7FFD DF 7FFD 7F 3F DD BB 02 SE SF OF 04 9C OS C-6 PERMANENT SYMBOL TABLE Hexadecimal Value 07 95 73 53 53FD 73FD D5 BS FC 8C 8D cc CD AC AD Mnemonic Functional Name SVPCTX TSTB TSTD TSTF TSTG TSTH TSTL TSTW XFC Save process context Test byte Test D_floating Test F floating Test G- floating Test I-I- floating Test long Test word Extended function call XORB2 XORB3 XORL2 XORL3 XORW2 XORW3 Exclusive-OR byte Exclusive-OR byte Exclusive-OR long Exclusive-OR long Exclusive-OR word Exclusive-OR word C-7 2 operand 3 operand 2 operand 3 operand 2 operand 3 operand C.2 OPCODES (NUMERIC ORDER) HEX Value Instruction 00 01 02 03 04 OS 06 07 OS 09 OA OB HALT NOP REI BPT RET RSB LDPCTX SVPCTX CVTPS CVTSP INDEX CRC PROBER PROBEW INSQUE REMQUE BSBB BRB BNEQ, BNEQU BEQL, BEQLU BGTR B:r..EQ JSB JMP BGEQ BLSS BGTRU BLEQU BVC BVS BCC, BGEQU BCS, BLSSU ADDP4 ADDP6 SUBP4 SUBP6 CVTPT oc OD OE OF 10 11 CJ I (X) 12 13 14 lS 16 17 lS 19 lA lB lC 10 lE lF 20 21 22 23 24 2S 26 27 2S 29 2A 2B 2C 2D 2E 2F MULP CVTTP DIVP MOVC3 CMPC3 SCANC SPANC MOVCS CMPCS MOVTC MOVTUC HEX Value 30 31 32 33 34 3S 36 37 3S 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 4S 46 47 4S 49 4A 4B 4C 40 4E 4F so Sl S2 S3 S4 SS S6 S7 SS S9 SA SB SC SD SE SF Instruction HEX Value BSBW BRW CVTWL CVTWB MOVP CMPP3 CVTPL CMPP4 EDITPC MATCHC LOCC SKPC MOVZWL ACBW MOVAW PUSHAW ADDF2 ADDF3 SUBF2 SUBF3 MULF2 MULF3 DIVF2 DIVF3 CVTFB CVTFW CVTFL CVTRFL CVTBF CVTWF CVTLF ACBF MOVF CMPF MNEGF TSTF EMODF POLYP CVTFD reserved ADAWI reserved reserved reserved INSQHI INSQTI REMQHI REMQTI 60 61 62 63 64 6S 66 67 6B 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 7S 76 77 7S 79 7A 7B 7C 70 7E 7F 80 Sl S2 S3 B4 SS B6 87 BS S9 SA BB SC SD BE SF Instruction ADDD2 ADDD3 SUBD2 SUBD3 MULD2 MULD3 DIVD2 DIVD3 CVTDB CVTDW CVTDL CVTRDL CVTBD CVTWD HEX Value 90 91 92 93 94 9S 96 97 9B 99 9A 9B 9C 9D 9E 9F AO Al A2 A3 A4 AS A6 A7 AS A9 CVTLD ACBD MOVD CMPD MNEGD TSTD EMODD POL YD CVTDF reserved ASHL ASHQ EMUL AA EDIV AB CLRD, CLRQ, CLRG AC MOVQ AD MOVAD, MOVAQ, MOVAG AE PUSHAD, PUSHAQ, PU SHAG AF ADDB2 BO ADDB3 Bl SUBB2 B2 SUBB3 B3 MULB2 B4 MULB3 BS DIVB2 B6 DIVB3 B7 BISB2 BS BISB3 B9 BICB2 BA BICB3 BB XORB2 BC XORB3 BD MNEGB BE CASEB BF Instruction MOVB CMPB MCOMB BITB CLRB TSTB INCB DECB CVTBL CVTBW MOVZBL !oiOVZBW ROTL ACBB MOVAB PUSHAB ADDW2 ADDW3 SUBW2 SUBW3 MULW2 MULW3 DIVW2 DIVW3 BISW2 BISW3 BICW2 BICW3 XORW2 XORW3 MNEGW CASEW MOVW CMPW MCOMW BITW CLRW TSTW INCW DECW BISPSW BICPSW POPR PUS HR CHMK CHME CHMS CHMU HEX Value co Cl C2 C3 C4 cs C6 C7 CB C9 CA CB cc CD CE CF DO Dl D2 D3 D4 DS D6 D7 DS D9 DA DB DC DD DE DF EO El E2 E3 E4 ES E6 E7 EB E9 EA EB EC ED EE EF Instruction HEX Value FO ADDL2 Fl ADDL3 F2 SUBL2 F3 SUBL3 F4 MULL2 FS MULL3 DIVL2 F6 F7 DIVL3 FS BISL2 F9 BISL3 FA BICL2 FB BICL3 FC XORL2 XORL3 FD MNEGL FE CASEL FF 32FD MOVL CMPL 33FD MCOML 40FD BITL 41FD CLRF, CLRL 42FD TSTL 43FD INCL 44FD DECL 4SFD 46FD ADWC SBWC 47FD MTPR 4SFD MFPR 49FD MOVPSL 4AFD PUSHL 4BFD MOVAF, MOVAL 4CFD PUSHAF, PUSHAL 4DFD BBS 4EFD BBC 4FFD BBSS SOFD BBCS SlFD S2FD BBSC S3FD BBCC BBSSI S4FD SSFD BBCCI S6FD BLBS 60FD BLBG FFS 61FD FFC 62FD CMPV 63FD CMPZV 64FD EXTV 6SHD EXTZV 66FD Instruction INSV ACBL AO BL SS AOBLEQ SOBGEQ SOBGTR CVTLB CVTLW ASHP CVTLP CALLG CALLS XFC reserved reserved reserved CVTDH CVTGF ADDG2 ADDG3 SUBG2 SUBG3 MULG2 MULG3 DIVG2 DIVG3 CVTGB CVTGW CVTGL CVTRGL CVTBG CVTWG CVTLG ACBG MOVG CMPG MNEGG TSTG EMODG POLYG CVTGH ADDH2 ADDH3 SUBH2 SUBH3 MULH2 MULH3 DIVH2 HEX Value 67FD 6SFD 69FD 6AFD 6BFD 6CFD 6DFD 6EFD 6FFD 70FD 71FD 72FD 73FD 74FD 7SFD 76FD 7CFD 7DFD 7EFD 7FFD 9SFD 99FD F6FD F7FD Instruction DIVH3 CVTHB CVTHW CVTHL CVTRHL CVTBH CVTWH CVTLH ACBH MOVH CMPH MNEGH TSTH EMODH POLYH CVTHG CLRH, CLRO MOVO MOVAH, MOVAO PUSHAB, PUSHAO CVTFH CVTFG CVTHF CVTHD .,, ,, t:rJ z~ t:rJ z toi en ~ 3: °' 0 t"" toi > °' t"" t:rJ APPENDIX D HEXADECIMAL/DECIMAL CONVERSION Table D-1 lists the decimal value for each possible hexadecimal value in each byte of a longword. The following sections contain instructions to use the table to convert hexadecimal numbers to decimal and vice versa. D.l HEXADECIMAL TO DECIMAL For each integer position of the hexadecimal value, locate the corresponding column integer and record its decimal equivalent in the conversion table. Add the decimal equivalent to obtain the decimal value. For example: D0500ADO {16) D.2 ?{10) DOOOOOOO 500000 AOO DO 3,489,660,928 5,242,880 2,560 208 D0500ADO 3,494,904,576 DECIMAL TO HEXADECIMAL Step 1: locate in the conversion table the largest decimal value that does not exceed the decimal number to be converted. Step 2: record the hexadecimal equivalent followed by the number of Os that corresponds to the integer column minus 1. Step 3: subtract the table decimal value from the decimal number to be converted. Step 4: repeat steps 1 through 3 until the subtraction balance equals o. Add the hexadecimal equivalents to obtain the hexadecimal value. D-1 HEXADECIMAL/DECIMAL CONVERSION Example: 22,466 (10) = ?(16) 20,480 1,792 192 5000 700 22,4nn -20,480 2 2 l,98n - 1,792 22,466 57C2 co 194 192 2 2 0 D.3 POWERS OF 2 AND 16 This section lists the decimal values of powers of 2 and 16. These values are often useful in converting decimal numbers to hexadecimal. Powers of 2 Powers of Hi 2**n n Hi**n n 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16 777 216 8 9 10 11 12 13 14 15 1 16 256 4096 65536 1048576 111777216 2'18435456 4294%7296 n8719476736 1099511627776 175921860444ln 28147497671065() 450359962737049fi 72057594037927936 115292150460l184n976 0 l Hi 17 18 19 20 21 22 23 24 D-2 2 3 4 5 fi 7 8 9 10 11 12 13 14 15 Table D-1 Hexadecimal/Decimal Conversion HEX DEC HEX u 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 w A 0 268,435,456 536,870,912 805,306,368 1,073,741,824 1,342,177,280 1,610,612,736 1,879,048,192 2,147,483,643 2,415,919,104 2,684,354,560 2,952,790,016 3,221,225,472 3,489,660,928 3,758,096,384 4,026,531,840 I B c D E F A B c D E F DEC 0 16,777,216 33,554,432 50,331,648 67,108,864 83,886,080 100,663,296 117,440,512 134,217,728 150,994,944 167, 772 ,160 184,549,376 201,326,592 218,103,808 234,881,024 251,658,240 HEX DEC HEX DEC HEX DEC HEX DEC HEX DEC HEX DEC 0 1 2 3 4 5 6 7 8 9 0 1,048,576 2,097,152 3,145,728 4,194,304 5,242,880 6,291,456 7,340,032 8,388,608 9,437,184 10,485,760 11,534,336 12,582,912 13,631,488 14,680,064 15,728,640 0 1 2 3 4 5 6 7 8 9 0 65,536 131,072 196,608 262,144 327,680 393,216 458,752 524,288 589,824 655,360 720, 896 786,432 851,968 917,504 983,040 0 1 2 3 4 5 6 7 0 4,096 8,192 12,288 16,384 20,480 .24,576 28,672 32,768 36,864 40,960 45,056 49,152 53,248 57,344 61,440 0 1 2 3 4 5 6 7 8 9 0 256 512 768 1,024 1,280 1,536 1,792 2,048 2,304 2,560 2,816 3,072 3,328 3,584 3,840 0 1 2 3 4 5 6 7 8 9 0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 A B c D E F A B c D E F 8 9 A B c D E F A B c D E F A B c D E F A B c D E F ::c tSJ >< > 0 tSJ n t-1 3 > r1 'n 0 tSJ t-1 3 > r1 n 0 z < tSJ ,, Cll BYTE BYTE WORD BYTE BYTE WORD LONGWORD t-1 0 z INDEX A AA operator, 3-11, 3-13 Absolute, index mode, 4-15, 4-17 mode, 4-3, 4-13, 4-14 program sections, 5-46, 5-48 ABS program section attribute, 5-48 Accuracy of floating-point numbers, 3-4 Addition, 3-15 Address data, initializing memory with, 5-3 reserving memory for, 5-9 .ADDRESS directive, 5-3 Address, starting, 5-21, 5-22 Address, transfer, 5-20, 5-21 Addressing modes, 2-3, 4-1 through 4-18 summary of, 4-2 through 4-4, B-11 through B-13 .ALIGN directive, 5-4, 5-5 Alignment, data, 5-4, 5-5 location counter, 5-4, 5-5, 5-24' 5-41 program section, 5-47, 5-50 AMA argument, 5-18 AND operator, 3-16 AP register, 3-5 Argument, concatenation in macros, 6-6 macro, 6-1 through 6-8 pointer, 3-5 Arithmetic shift, operator, 3-16 Arithmetic trap enable, 3-13, 3-14 .ASCIC directive, 5-7 .ASCID directive, 5-8 ASCII character set, A-1 .ASCII directive, 5-7 ASCII, hexadecimal conversion, A-1 operator, 3-11, 3-13 strings, 3-11, 3-13, 5-6 through 5-9 string storage, 5-6 through 5-9 .ASCix storage directives, 5-6 through 5-9 .ASCIZ directive, 5-8 Assembler directives, 2-3, 5-1 through 5-67, 6-1 through 6-29 summary of, 5-1, 5-2, 6-2, B-1 through B-7 Assembler functions, 5-17 through 5-19 Assigning a value, 3-17 Assignment statements, 3-17, 3-18 Attributes, program section, 5-46 through 5-50 Autodecrement index mode, 4-15, 4-17 Autodecrement mode, 4-7 Autoincrement deferred index mode, 4-15, 4-16, 4-17 Autoincrement deferred mode, 4-6, 4-7 Autoincrement index mode, 4-15, 4-16, 4-17 Autoincrement mode, 4-6 B BA displacement specifier, 4-8, 4-9' 4-12 AB unary operator, 3-11, 3-12 Base mode, 4-15, 4-17 Binary operators, 3-15 through 3-17, B-10 Binary radix, 3-11, 3-12 Blank lines, 2-2 .BLKA directive, 5-9, 5-10 .BLKB directive, 5-9, 5-10 .BLKD directive, 5-9, 5-10 .BLKF directive, 5-9, 5-10 ~BLKG directive, 5-9, 5-10 .BLKH directive, 5-9, 5-10 .BLKL directive, 5-9, 5-10 .BLKO directive, 5-9, 5-10 .BLKQ directive, 5-9, 5-10 .BLKW directive, 5-9, 5-10 .BLKx directives, 5-9, 5-10 Block labels, 3-7, 3-8 Block storage directives, 5-9, 5-10 Branch addresses, 3-8 Branch instructions, 4-18 Branch mode, 4-18 Byte data, initializing memory with, 5-11, 5-57 reserving memory for, 5-9, 5-10, .BYTE directive, 5-11 c Ac operator, 3-15 Call instruction, 5-21, 5-22 Character, indefinite repeat block, 6-16, 6-17 Index-1 INDEX Character, {Cont.) separating, 3-3 set, 3-1, 3-2 set, ASCII, A-1 special, 3-1, 3-2, B-7, B-8 strings, 3-12, 3-13, 5-6 through 5-8 Characters, counting, 6-9, 6-25 Combining arguments in macros, 6-6 Comment field, 2-1, 2-4 Complement operator, 3-15 Concatenated program sections, 5-48 Concatenating arguments in macros, 6-6 Conditional assembly blocks, 5-30 through 5-36 controlling listing of, 5-55, 5-56 one line block, 5-36 subconditionals, 5-33 through 5-35 Condition tests, 5-30, 5-31 CON program section attribute, 5-48 Continuation lines, 2-2 Continuing program sections, 5-46 Controlling listings, 5-55, 5-56 Counted ASCII string storage, 5-7 Counter, current location, 3-18 Counting characters, 6-9, 6-25 Counting macro arguments, 6-24 Counts, repeat, 3-10, 5-11, 5-38, 5-57, 5-S8, 5-67 Created local labels, 6-7, 6-8 .CROSS directive, 5-12, 5-13 Cross reference listing, 5-12, 5-13 Current location counter, 3-18 D AD unary operator, 3-11, 3-12 Data alignment, 5-4, 5-5 Data, reserving memory for, 5-9 Data, initializing memory with, address, 5-3 ASCII, 5-6 through 5-8 byte, 5-11, 5-57 D floating, 5-16 Double precision, 5-16 F floating, 5-25 floating-point, 5-16, 5-25, 5-26, 5-28 G floating, 5-26 H-floating, 5-28 longword, 5-38 octaword, 5-41 Data, initializing memory with, {Cont.) packed decimal, 5-44 quadword, 5-51 signed, 5-57, 5-58, 5-59 word, 5-58, 5-67 DBG argument, 5-18 .DEBUG directive, 5-14 Debugging information, 5-14, 5-18 Decimal/hexadecimal conversion, D-1 through D-4 Decimal radix, 3-11, 3-12 Decimal strings, 3-4, 3-5, 5-44 .DEFAULT directive, 5-15 Default program sections, 5-46, 5-50 Default radix, 3-12 Default values of macro arguments, 6-3 Deferred mode, autoincrement, 4-6, 4-7 displacement, 4-9 register, 4-5 relative, 4-12 Defining, labels, 2-2 macros, 6-19, 6-20 opcodes, 5-42, 5-43 Degree of precision, 3-4 Deleting a macro, 6-22 Delimited ASCII strings, 5-6 Delimiters in macro arguments, 6-4 through 6-6 Descriptors, string, 5-8 D_floating data, initializing memory with, 5-16 reserving memory for, 5-9, 5-10 .D_FLOATING directive, 5-16 Direct assignment statements, 3-17, 3-18 Directives, 2-3, 3-5, 5-1 through 5-67, 6-1 through 6-29 summary of, 5-1, 5-2, 6-2, B-1 through B-7 .DISABLE directive, 5-17 through 5-19 LOCAL BLOCK attribute, 3-8 Disabli~g assembler functions, 5-17 through 5-19 Displacement, controlling default, 5-15 deferred index mode, 4-15 through 4-17 deferred mode, 4-9 index mode, 4-15 through 4-17 mode, 4-7, 4-8 specifier, 4-8, 4-9, 4-12 Division, 3-15 Documenting a program, 2-4 Index-2 INDEX .DOUBLE directive, 5-16 Double precision, 3-4, 5-16 Double-precision data, initializing memory with, 5-16 reserving memory for, 5-9, 5-10 .DSABL directive, 5-17 through 5-19 DV arithmetic trap enable, 3-13, 3-14 E .ENABL directive, 5-17 through 5-19 .ENABLE directive, 5-17 through 5-19 LOCAL_BLOCK attribute, 3-8 Enabling assembler functions, 5-17 through 5-19 .END directive, 5-20 .ENDC directive, 5-20, 5-30 through 5-35 Ending, conditional assembly blocks, 5-20, 5-30 through 5-35 macro definitions, 6-13, 6-19, 6-20 modules, 5-20 repeat range definitions, 6-13, 6-14 through 6-17 .ENDM directive, 6-13, 6-19, 6-20 .ENDR directive, 6-13 through F AF operator, 3-14, 3-15 Factors, repetition, 3-10, 5-11, 5-38, 5-57, 5-58, 5-67 Field, comment, 2-1, 2-4 label, 2-1 through 2-3 operand, 2-1, 2-3, 2-4 operator, 2-1, 2-3 F floating data, initializing memory with, 5-25 reserving memory for, 5-9, 5-10 .F FLOATING directive, 5-25 .FLOAT directive, 5-25 Floating-point data, initializing memory with, 5-16, 5-25, 5-26, 5-28 reserving memory for, 5-9, 5-10 Floating-point expressio~s, 3-14 Floating-point numbers, 3-3, 3-4, 3-14, 3-15 format of, 3-4 rounding of, 5-17, 5-19 truncation of, 5-17, 5-19 Floating-point operator, 3-14 Floating-point short literals, 4-10 Format, statement, 2-1 through 2-4 Formatting with tabs, 2-1, 2-2 FP register, 3-6, 3-14 FPT attribute, 5-19 Frame pointer, 3-6 Functions, assembler, 5-17 through 6-17 5-19 .ENTRY directive, 5-21 Entry mask, 3-13, 3-14, 5-20, 5-21, 5-39 .ERROR directive, 5-23 Exclusive OR operator, 3-17 Executable program sections, 5-46 through 5-50 EXE program section attribute, 5-48 Expanding a macro, 6-1, 6-2 Exponent, 3-4 Expressions, 3-9, 3-10 evaluation of, 3-9 floating point, 3-14 restrictions on, 3-10 Extended precision, 3-4, 5-28 .EXTERNAL directive, 5-24 External symbols, 3-7, 5-24, 5-27, 5-66 %EXTRACT macro string operator, 6-11, 6-12 .EXTRN directive, 5-24 .EVEN directive, 5-24 Exiting a macro, 6-13, 6-19, 6-20 G GBL argument, 5-18, 5-19 GBL program section attribute, 5-48 General mode, 4-14 General registers, 3-5 General register modes, 4-1 through 4-11 G floating data, -initializing memory with, 5-26 reserving memory for, 5-9, 5-10 .G_FLOATING directive, 5-26 GLOBAL argument, 5-18, 5-19 Global attribute, 5-48, 5-49 .GLOBAL directive, 5-27 Global program sections, 5-48 Global symbols, 2-2, 3-7, 3-17, 5-18, 5-19, 5-24, 5-27, 5-66 defining, 2-2 weak, 5-66 .GLOBL directive, 5-27 Index-3 INDEX H .IRPC directive, 6-16, 6-17 IV arithmetic trap enable, 3-14 Hexadecimal/ASCII conversion, A-1 Hexadecimal/decimal conversion, D-1 through D-4 Hexadecimal radix, 3-11, 3-12 H floating data, -initializing memory with, 5-28 reserving memory for, 5-9, 5-10 .H FLOATING directive, 5-28 K Keyword arguments in macros, 6-3, 6-4 L L~ I~ addressing mode, 4-14, 4-15 .IDENT directive, 5-29 Identifying a module, 5-29, 5-61 .IF directive, 5-30 through 5-32 .IF_FALSE directive, S-33 through 5-35 .IF_TRUE directive, 5-33 through 5-35 .IF TRUE FALSE directive, 5-33 -through 5-35 .IFF directive, 5-33 through 5-35 .IFT directive, 5-33 through 5-35 .IFTF directive, 5-33 through 5-35 .IFx directives, 5-33 through 5-35 .IIF directive, 5-36 Immediate conditional block, 5-36 Immediate mode, 4-13, 4-14 Inclusive OR operator, 3-15, 3-17 Indefinite repeat blocks, 6-14, 6-15 Indefinite repeat character blocks, 6-16, 6-17 Index mode, 4-15 through 4-17 Initializing memory with address data, 5-3 ASCII data, 5-6 through 5-8 byte data, 5-11, 5-57 D floating data, 5-16 fToating-point data, 5-16, 5-25, 5-26, 5-28 G floating data, 5-26 H-floating data, 5-28 longword data, 5-38 octaword data, 5-41 packed data, 5-44 quadword data, 5-51 word data, 5-58, 5-67 Instructions, 1-1, 2-3, 3-5, C-1 through C-8 redefining, 5-42, 5-43, 6-20 Integer expressions, 3-9, 3-10 Integers, 3-3 Internal symbols, 2-2, 3-7, 3-17 .IRP directive, 6-14, 6-15 displacement specifier, 4-8, 4-9, 4-12, 4-13 Label, defining a, 2-2 field, 2-1, 2-2 local, 3-7, 3-8 names, 2-2 terminator, 2-2 LCL program section attribute, 5-48 %LENGTH macro string operator, 6-9 Length of source line, 2-1 Lexical operators, 6-8 through 6-12 .LIBRARY directive, 6-18 Lines, continuation, 2-2 .LIST directive, 5-37, 5-55, 5-56 Listing, control of, 5-44, 5-55, 5-56 cross reference, 5-13, 5-14 table of contents, 5-59 Literal mode, 4-10 through 4-12 Literals, short, 4-10 through 4-12 Local label block, delimiters, 3-8 disabling, 3-8, 5-17, 5-18 enabling, 3-8, 5-17, 5-18 restoring, 5-53 saving, 5-54 Local labels, 3-7, 3-8, 5-17, 5-18 created, 6-7, 6-8 Local program sections, 5-48, 5-49 %LOCATE macro string operator, 6-10, 6-11 Location counter, 3-18 alignment, 5-4, 5-5, 5-24, 5-41 Logical AND operator, 3-16 Logical exclusive OR operator, 3-17 Logical inclusive OR operator, 3-17 .LONG directive, 5-38 Longword data, initializing memory with, 5-38 reserving memory for, 5-9, 5-10 LSB argument, 3-8, 5-18 Index-4 INDEX M AM operator, 3-13, 3-14 Machine instructions, 1-1 .MACRO directive, 6-19, 6-20 Macros, 6-1 through 6-29 arguments in, 6-1 through 6-8 calls to, 2-3 controlling listing of, 5-55, 5-56 definitions of, 6-19, 6-20 deletion of, 6-22 exiting from, 6-23 expanding, 6-1, 6-2 libraries containing, 6-18 maximum line size, 2-2 names of, 3-6, 6-13, 6-19, 6-20 redefining, 6-19, 6-20 string operators in, 6-8 through 6-12 .MASK directive, 5-21, 5-39 Mask operator, 3-13, 3-14 Mask, register save, 3-13, 3-14, 5-21, 5-39 .MCALL directive, 6-21 .MDELETE directive, 6-22 Messages, printing assembly, 5-23, 5-45, 5-65 .MEXIT directive, 6-23 Mnemonic instructions, 3-5, C-1 through C-8 Modes, addressing, 2-3, 4-1 through 4-18 summary of, 4-2 through 4-4, B-11 through B-13 Module, identifying, 5-29, 5-61 Multiplication, 3-15 N Names, macro, 3-6, 6-13, 6-19, 6-20 module, 5-61 register, 3-5 symbol, 3-6 .NARG directive, 6-24 .NCHR directive, 6-25 Negative numbers, 3-3 .NLIST directive, 5-39, 5-55, 5-56 .NOCROSS directive, 5-12, 5-13, 5-40 NOEXE program section attribute, 5-48 NOPIC program section attribute, 5-48 .NOSHOW directive, 5-39, 5-55, 5-56 NOSHR program section attributes, 5-48 NOWRT program section attribute, 5-49 .NTYPE directive, 6-26 Number of macro arguments, 6-1, 6-24 Numbers, 3-3 floating point, 3-3, 3-4, 3-14, 3-15, 5-16, 5-25, 5-26, 5-28 integer, 3-3 packed decimal, 3-4, 3-5, 5-44 Numeric control operators, 3-14, 3-15 0 Ao unary operator, 3-11, 3-12 .OCTA directive, 5-41 Octal radix, 3-11, 3-12 Octaword data, initializing memory with, 5-28 reserving memory for, 5-9, 5-10 .ODD directive, 5-41 Opcodes, C-1 through C-8 defining, 5-42, 5-43 redefining, 5-42, 6-20 .OPDEF directive, 5-42, 5-43 Operand, descriptors, 5-43 field, 2-1, 2-3 generation directives, 5-52 types, 6-26 Operator, binary, 3-15 through 3-17, B-9 field, 2-1, 2-3 macro string, 6-8 through 6-12, B-10 unary, 3-10 through 3-15, B-8, B-10 OR operators, 3-17 Overlaid program sections, 5-49 OVR program section attribute, 5-49 p Packed decimal strings, 3-4, 3-5, 5-44 .PACKED directive, 5-44 .PAGE directive, 5-44 Page ejection, 5-44 Passing numeric values in macros, 6-7 PC register, 3-6 Permanent symbols, 3-5, C-1 PIC program section attribute, 5-49 Position-independent code, 5-49 Precision of floating-point numbers, 3-4 Index-5 INDEX .PRINT directive, 5-45 Printing assembly messages, 5-23, 5-45' 5-65 Privileged shareable image attribute, 5-49 Program counter, 3-6 Program counter modes, 4-11 through 4-14 Program section attributes, 5-48, 5-49 def a ult, 5-49 Program sections, 5-46 through 5-50, 5-53, 5-54 Q .QUAD directive, 5-51 Quadword data, initializing memory with, 5-51 reserving memory for, 5-9, 5-10 R Radix control, 3-11, 3-12 Radix default, 3-11 Radix operators, 3-11, 3-12 in macro arguments, 6-5 Rea~ numbers, 3-3, 3-4 Redefining instructions, 5-42, 6-20 macros, 6-19, 6-20 opcodes, 5-42, 6-20 .REFn directive, 5-52 Register, deferred index mode, 4-15 through 4-17 deferred mode, 4-5 mask operator, 3-13, 3-14 mode, 4-5 names, 3-5, 3-6 save mask, 3-13, 3-14, 5-21, 5-39 Relative, default displacement, 5-15 deferred index mode, 4-15, 4-17 deferred mode, 4-12 index mode, 4-15, 4-17 mode, 4-11, 4-12 Relocatable program sections, 5-49' 5-50 REL program section attribute, 5-49 Repeat blocks, 6-28, 6-29 character, indefinite repeat, 6-16, 6-17 controlling listing of, 5-55, 5-56 indefinite, 6-14, 6-15 Repeat counts, 3-10, 5-11, 5-38, 5-57, 5-58, 5-67 .REPEAT directive, 6-28, 6-29 Repeating a block of code, 6-28, 6-29 Repetition factors, 3-10, 5-11, 5-38, 5-57, 5-58, 5-67 .REPT directive, 6-28, 6-29 .RESTORE directive, 5-53 .RESTORE PSECT directive, 5-53 Restoring a program section, 5-53 Reserved bits in entry mask, 3-14, 5-21 Reserving storage, 5-9 Rounding floating-point numbers, 5-19 s SA addressing mode, 4-10 through 4-12 .SAVE directive, 5-54 .SAVE PSECT directive, 5-54 Saving a program section, 5-54 Saving local label block, 5-54 .SBTTL directive, 5-60 Sections, program, 5-46 through 5-50, 5-53, 5-54 Separating charactars, 3-3 Shareable images, 5-62 through 5-64 Shareable program sections, 5-49 Shift operator, arithmetic, 3-16 Short literals, 4-10, 4-11 .SHOW directive, 5~55, 5-56 SHR program section attribute, 5-49 .SIGNED BYTE directive, 5-57 Signed data storage, 5-57 through 5-59 .SIGNED WORD directive, 5-58, 5-59 Single precision, 3-4, 5-25 Single-precision data, initializing memory with, 5-25 reserving memory for, 5-9, 5-10 Source lines, blank, 2-2 continuing, 2-2 format of, 2-1 length of, 2-1 SP register, 3-6 Special characters, 3-1, 3-2, B-7, B-8 Stack pointer, 3-6 Starting address, 5-21, 5-22 Statement format, 2-1 through 2-4 Storage, reserving, 5-9 ASCII, 5-6 through 5-8 block, 5-9 Index-6 INDEX Storing, address, 5-3 ASCII, 5-6 through 5-8 byte, 5-11, 5-57 D floating, 5-16 double-precision, 5-16 F floating, 5-25 floating-point, 5-25 G floating, 5-26 H-floating, 5-28 longword, 5-37 octaword, 5-28 packed decimal, 5-42 signed, 5-57, 5-58 quadword, 5-51 word, 5-58, 5-67 String, arguments in macros, 6-4 through 6-6 ASCII, 3-12, 3-13, 5-6 descriptors, 5-8 operators, 6-8 through 6-12 packed decimal, 3-4, 3-5, 5-44 Subconditional assembly blocks, 5-33 through 5-35 .SUBTITLE directive, 5-60 Subtraction, 3-15 Suppressing symbol table listing, 5-17, 5-18 Symbols, 3-5, 3-17 external, 3-7, 5-24, 5-27, 5-66 global, 2-2, 3-7, 3-17, 5-18, 5-19, 5-24, 5-27, 5-66 internal, 3-7 names of, 3-6 permanent, 3-5, C-1 undefined, 5-17 through 5-19 user-defined, 2-2, 3-6 T Tab formatting, 2-1, 2-2 Table of contents, listing, 5-60 TBK argument, 5-18 Temporary labels, 3-7, 3-8 Terms, 3-9 Testing conditions, 5-30 through 5-32 Textual operators, 3-12 through 3-14 .TITLE directive, 5-61 Traceback information, 5-18 .TRANSFER directive, 5-62 through 5-64 Trap enable, arithmetic, 3-13, 3-14 Truncating floating-point number, 5-19 Type of operand in macros, 6-24 u Unary operators, 3-11 through 3-15, B-9 in macro arguments, 6-5 summary of, 3-11, B-9 Undefined symbols, 5-17 through 5-19 User-defined program sections, 5-46 through 5-50 User-defined symbol, 2-2 User-generated errors, 5-23 messages, 5-45 opcodes, 5-42, 5-43 operands, 5-52 warnings, 5-65 v Value, passing arguments by, 6-7 VEC program section attribute, 5-49 Vector, transfer, 5-62 through 5-64 Version number, 5-29 w WA displacement specifier, 4-8, 4-9, 4-12, 4-13 .WARN directive, 5-65 Warning directive, 5-65 .WEAK directive, 5-66 Weak symbols, 5-66 Word data, initializing memory with, 5-58, 5-67 reserving memory for, 5-9, 5-10 .WORD directive, 5-67 Write protecting program sections, 5-46, 5-49, 5-50 WRT program section attribute, 5-49 x AX unary operator, 3-12 z Zero terminated ASCII stririg, 5-8 Index-7 VAX-11 MACRO Language Reference Manual AA-D032C-TE 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. -------- C-'--· ----------------· -·-~ --------- ---------···~- --------------~- Did you find errors in this manual? page number. If so, specify the error and the ------------------"-·----·------ 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>~~~~~~~~~~~~~~~~~~ Ci t Y - - - - - - - - - - - - - - S t a t e - - - - - - - Zip Code _ _ _ _ _ __ or Country - - Do Not Tear - Fold Here and Tape - - - - - - - - - - - No Postag Necessar) if Mailed in United Sta1 BUSINESS REPLY MAIL FIRST CLASS PERMIT N0.33 MAYNARD MASS. POSTAGE WILL BE PAID BY ADDRESSEE BSSG PUBLICATIONS TW/A14 DIGITAL EQUIPMENT CORPORATION 1925 ANDOVER STREET TEWKSBURY, MASSACHUSETTS 01876 Do Not Tear - Fold Here
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies