1 MACRO When used with the /ALPHA qualifier, the MACRO command invokes the MACRO-64 Assembler for OpenVMS Alpha Systems (provided it is installed). When used with the /MIGRATION qualifier, the MACRO command invokes the MACRO-32 Compiler for OpenVMS Alpha to compile one or more VAX MACRO assembly language source files into native OpenVMS Alpha object code. 2 /ALPHA Invokes the MACRO-64 Assembler for OpenVMS Alpha Systems. MACRO-64 is an assembly language for programming Alpha computers. Source programs written in MACRO-64 are translated into object (or binary) code by the MACRO-64 Assembler, which produces an object module and, optionally, a listing file. NOTE The MACRO-64 product does not ship with the OpenVMS operating system. (Only this help file and the DCL command are included in the base system.) You must install MACRO-64 from the Freeware CD-ROM. To invoke MACRO-64, enter the MACRO command and the /ALPHA command-line qualifier, using the following syntax: MACRO/ALPHA file-spec[, . . . ] You must specify the /ALPHA command-line qualifier before any other command-line parameters, qualifiers, or file specifications. If you do not specify a file type for an input file, the assembler uses the default file type of .M64. You can specify one or more source files to be assembled. To assemble files individually, separate the file specifications with commas. To concatenate and assemble the files as a single input file, separate the file specifications with plus signs (+). Command-line qualifiers control special assembler options. Assembler options can apply to the entire MACRO/ALPHA command-line, or to the individual file being assembled. When the qualifier follows the MACRO/ALPHA command, it applies to all files listed. For more information on qualifiers, see the Qualifiers on-line help section. 3 Qualifiers 4 /ALIGNMENT=option The full command-line option is /[NO]ALIGNMENT=option. Controls the alignment of code and data. Valid options are: Option Function CODE Alignment of certain branch target labels. DATA Natural alignment of data items. If you omit the qualifier from the command line, the default options are /NOALIGNMENT=(CODE, DATA). If more than one option is specified, the options must be enclosed in parentheses and separated by a comma. 4 /ARCHITECTURE=option Determines which instructions are legal. Option Function GENERIC All instructions are allowed; equivalent to EV4. HOST Instruction set is that of the host processor. EV4 Instruction set is that of the EV4 base design processors (21064, 20164A, 21066, and 21068 chips). EV5 Instruction set is that of the EV5 processor (some 21164 chips). EV56 Instruction set is that of the EV56 processors (some 21164 chips). Includes BWX extensions. PCA56 Instruction set is that of the PCA56 processor (21164PC chips). Includes BWX and MAX extensions. EV6 Instruction set is that of the EV6 processor (21264 chips). Includes BWX and MAX extensions and SQRT instructions. 4 /DEBUG[=(options)] The full command-line option is /[NO]DEBUG[=(options)]. Specifies DEBUG support. Valid options are: Option Function SYMBOL Generates debug symbol information. TRACEBACKGenerates traceback information. ALL Generates all previous debug information. NONE Generates no debug information. The default qualifier is /NODEBUG. When you specify /DEBUG with no options, the default option is /DEBUG=ALL. 4 /DEFINE=(symbol_[=[=]value],...) The full command-line option is /[NO]DEFINE=(symbol [= [=]value],...). Performs the same function as direct symbol assignment in your source program. That is, the /DEFINE qualifier defines a numeric symbol. The Digital Command Language (DCL) converts all input to uppercase unless you enclose it within quotation marks. Use a single equal sign between the symbol and the value to define a local symbol. Use two equal signs between the symbol and the value to define a global symbol. The final value of a global symbol is output to the object module and is available during the linking process. A local symbol is only available during the assembly process. You cannot define a lexical string symbol with /DEFINE. The value you specify for a symbol must be an integer literal. You can specify this value using a binary, octal, decimal, or hexadecimal radix. The default radix is decimal. If you specify an alternate radix, you must use MACRO-64 radix syntax, not DCL radix syntax. If you do not specify a value for the symbol, it defaults to 1. The simplest form of a /DEFINE definition is as follows: /DEFINE=TRUE This definition is equivalent to the following definition: TRUE=1 You can also specify more than one symbol definition as with the following command: /DEFINE=(CHIP==21064,UNROLL=4) This definition is equivalent to the following definitions: CHIP==21064 UNROLL=4 When more than one /DEFINE qualifier is present on the MACRO command line or in a single assembly unit, the assembler uses only the last one. The default qualifier is /NODEFINE. 4 /DIAGNOSTIC[=file-spec] The full command-line option is /[NO]DIAGNOSTIC[=file-spec]. Controls whether diagnostics are created and stored in the specified optional file. If a file specification is not supplied, the assembler creates a diagnostic file using the same name as the source file. For example, if you use a source file named XXX.M64, the assembler creates a diagnostic file named XXX.DIA. You can use the diagnostic file with other Digital layered products including, but not limited to, the DEC Language- Sensitive Editor (LSE). The default qualifier is /NODIAGNOSTIC. 4 /ENVIRONMENT=[NO]FLOAT The full command-line option is /ENVIRONMENT=[NO]FLOAT. Controls whether the assembler generates floating-point instructions when optimizing code and performing code-label alignment. Currently, the only floating-point instruction generated by the assembler during optimization and alignment processing is FNOP, the floating-point no-operation instruction. If you specify /ENVIRONMENT=NOFLOAT, the assembler does not generate any floating-point instructions as part of optimization and alignment processing. Floating-point instructions that you specify in your source program are unaffected. 4 /LIBRARY The full command-line option is /LIBRARY[=file-spec]. Searches macro libraries in the following order: 1. The library designated by the /LIBRARY qualifier. 2. The .LIBRARY directives. 3. The MACRO64.MLB library. The assembler searches for the MACRO64.MLB macro library in the following locations: MACRO64$LIBRARY, ALPHA$LIBRARY, and finally SYS$LIBRARY. 4. The STARLET.MLB library. The assembler searches for the STARLET.MLB macro library in the following locations: MACRO64$LIBRARY, ALPHA$LIBRARY, and finally SYS$LIBRARY. In addition, you can place the macro library definitions in the listing file by using the command-line qualifier /SHOW=LIBRARY. 4 /LIST[=file-spec] The full command-line option is /[NO]LIST[=file-spec]. Controls whether a listing is created and optionally provides an output file specification for the listing file. Do not use wildcard characters in this file specification. If you enter the MACRO/ALPHA command interactively, the default qualifier is /NOLIST. The assembler sends output to the current output device rather than to a listing file. If you execute the MACRO/ALPHA command in a batch job, the default qualifier is /LIST. If you do not specify a file specification, the assembler creates a listing file using the same name as the source file. For example, if you use a source file named XXX.M64, the assembler creates a listing file named XXX.LIS. 4 /MACHINE_CODE The full command-line option is /[NO]MACHINE_CODE. Produces a binary machine code listing after the source text if a listing file is requested. The default qualifier is /NOMACHINE_ CODE. 4 /NAMES=case_option The full command-line option is /NAMES=case_option. Specifies the alphabetic casing of identifiers in source code statements. Valid options are: Option Function UPPER_ Converts all identifiers to upper alphabetic case. CASE LOWER_ Converts all identifiers to lower alphabetic case. CASE AS_IS Causes all identifiers to remain in the case used in source statements. If you use the /NAMES qualifier in a command line, you must supply a case_option. If you omit the qualifier from the command line, the default option is /NAMES=UPPER_CASE. 4 /OBJECT[=file-spec] The full command-line option is /[NO]OBJECT[=file-spec]. Controls whether an object file is created and optionally provides a file specification. Do not use wildcard characters in this file specification. If you do not specify a file specification, the assembler creates an object file using the same name as the source file. For example, if you use a source file named XXX.M64, the assembler creates an object file named XXX.OBJ. The default qualifier is /OBJECT. 4 /OPTIMIZE[=(option-list)] The full command-line option is /[NO]OPTIMIZE[=(option-list)]. Specifies optional assembler optimizations. Valid items in the option-list are: Option Function SCHEDULE Specifies instruction scheduling. PEEPHOLE Specifies peepholing. Specifying /OPTIMIZE with no options is the same as specifying /OPTIMIZE=(PEEPHOLE,SCHEDULE). The default qualifier is /NOOPTIMIZE. 4 /PREPROCESSOR_ONLY_[=filespec] \BK_ADDED_27) The full command-line option is /PREPROCESSOR_ONLY [=filespec]). Causes the assembler to output a source file that is the result of the input source file after preprocessing. Suppresses diagnostic messages and does not produce diagnostic (.ANA) or object (.OBJ) files. The default option, /NOPREPROCESSOR_ONLY-MACRO-64, assembles your source files normally. If you specify /PREPROCESSOR_ONLY without a file specification argument, the output file name defaults to the name of the primary source input file. The output file type defaults to .ASM. The following MACRO-64 directives are executed by the preprocessor and screened from the preprocessor output file: .DISABLE PREPROCESSOR_OUTPUT .ENABLE PREPROCESSOR_OUTPUT .IF .ELSE .ENDC .IIF .IF_FALSE .IF_TRUE .IF_TRUE_FALSE .INCLUDE .LIBRARY .IRP .IRPC .REPEAT .ENDR .MACRO .ENDM .MCALL .MDELETE .MEXIT .NARG .NCHR Include files are inserted in place of the .INCLUDE directive into the preprocessor output file. Macro definitions and repeat block definitions are screened from the preprocessor output file. Macro expansion lines and repeat block expansion lines are inserted in place of the macro invocation line or repeat block, respectively, into the preprocessor output file. Lexical string-symbol assignment statements are screened from the preprocessor output file. Lines containing lexical operators are replaced with their equivalents after lexical operator processing. Lexical line continuations are processed into a single, uncontinued line. All other language elements, including directives not previously listed, label definitions, direct numeric-symbol assignments, and so forth are passed through unchanged to the preprocessor output file. 4 /SHOW=(item,...) The full command-line option is /[NO]SHOW=(item,...). Modifies the output listing file. This qualifier is meaningful only when /LIST is specified. Valid items are: Option Function BINARY Lists macro expansions that generate binary code. BINARY is a subset of EXPANSIONS. CONDITIONALS Shows sections of code conditionally skipped. EXPANSIONS Shows macro expansions. INCLUDE Shows all .INCLUDE files. LIBRARY Shows macro library modules. The default option is /SHOW=CONDITIONALS. 4 /WARNINGS=(option-list) The full command-line option is /[NO]WARNINGS=(option-list). Controls the severity level of messages and diagnostics. Valid options are: Option Function WARNINGS Display/suppress warnings. INFORMATIONALS Display/suppress informationals. ALL Display/suppress warnings and informationals. NONE Display/suppress nothing. The default options are /WARNINGS=(WARNINGS,INFORMATIONALS). If more than one option is specified, options must be enclosed in parentheses separated by a comma. 3 Source_Statement_Format MACRO-64 source statements can have a maximum of four fields, as follows: o Label field-Symbolically defines a location in a program. o Operator field-Specifies the action to be performed by the statement; this can be an instruction, an assembler directive, or a macro call. o Operand field-Contains the instruction operands or the assembler directive arguments or the macro arguments. o Comment field-Contains a comment that explains the meaning of the statement; this does not affect program execution. You can separate statement fields by either a space or a tab stop, but Digital recommends that you format statements with the Tab key to ensure consistency and clarity. Table 1 Using Tab Stops in Statement Fields Column in Which Field Field Begins Tab Stops to Reach Column Label 1 0 Operator 9 1 Operand 17 2 Comment 41 5 The following example shows a typical source statement: EXP: .BLKL 50 ; Table stores expected values Rules for Coding Source Statements The following rules apply for coding source statements: o You can continue a single statement 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). o In most cases, you can continue a statement at any point. If a symbol name is continued and the first character on the second line is a tab or a blank, the symbol name is terminated at that character. o Blank lines are legal, but they have no significance in the source program except that they terminate a continued line. The following sections describe each of the statement fields in detail. 4 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 where the label occurs. The following rules apply when coding source statements with labels: o If a statement contains a label, the label must be in the first field on the line. o The user-defined symbol name can be up to 31 characters long and can contain any alphanumeric character, as well as the underscore (_), dollar sign ($), and period (.) characters. o If a label extends past column 7, Digital recommends you place it on a line by itself so that the following operator field can start in column 9 of the next line. o A label is terminated by a colon (:) or a double colon (::). In the following source statement, EXP: is the label field: EXP: .BLKL 50 ; Table stores expected values There are three types of labels: o Global labels-Can be referenced by other object modules and are defined using a double colon (::). o Local labels-Can be referenced only within the current module and are defined using a single colon (:). o Temporary labels-Can be referenced only within the bounds of either two local labels, two global labels, two psects (program sections), or within the bounds of a temporary label scope, as defined by .ENABLE LOCAL_BLOCK and .DISABLE LOCAL_BLOCK. Temporary labels are defined using one to five digits followed by a dollar sign and a single colon ($:). The following example shows how these labels appear in use: EXP: .BLKL 50 ; EXP is a local label used to ; identify a 50-word block of storage DATA:: .BLKW 25 ; DATA is a global label used to ; identify a 25-word block of storage 10$: .BLKW 5 ; 10$ is a temporary label used to ; identify a five word block of ; storage. 4 Operator_Field The operator field specifies the action to be performed by the statement. This field can contain an instruction, an assembler directive, or a macro call. If the operator is: o An instruction, MACRO-64 generates the binary code for that instruction in the object module. o A directive, MACRO-64 performs certain control actions or processing operations during source program assembly. o A macro call, MACRO-64 expands the macro. Use either a space or a tab stop to terminate the operator field; however, Digital recommends that you use the tab stop to terminate the operator field. In the following source statement, .BLKL is the operator field: EXP: .BLKL 50 ; Table stores expected values 4 Operand_Field The operand field can contain operands for instructions or arguments for either assembler directives or macro calls. Operands for instructions identify the memory locations or the registers that are used by the machine operation. The operand field for a specific instruction must contain the correct number and type of operands required by that instruction. Arguments for a directive must meet the format requirements of that directive. Operands for a macro must meet the requirements specified in the macro definition. Use a comma (,) to separate operands for instructions and directives. 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. In the following source statement example, 50 is the operand field supplied to the operator field, .BLKL: EXP: .BLKL 50 ; Table stores expected values 4 Comment_Field The comment field contains text that explains the function of the statement. You can use comments to describe algorithms, reasons for selecting particular methods, and parameters passed to routines. Comments do not affect assembly processing or program execution. The comment field must be preceded by a semicolon (;) and can contain any printable ASCII character. It is terminated by the end of the line. A comment can appear on a line by itself. 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. In the following source statement example, "Table stores expected values" is the comment field. Note that the comment field begins with a semicolon. EXP: .BLKL 50 ; Table stores expected values 3 Character_Set When coding source statements, you need to be aware of what characters are acceptable to the assembler, and how the assembler interprets them. The following numbers and characters are accepted by the assembler: o The letters of the alphabet, A to Z, uppercase and lowercase. By default, the assembler converts all lowercase letters to uppercase. This means it considers lowercase letters equivalent to uppercase letters. The assembler can operate in a case-sensitive mode. In case- sensitive mode, the assembler does not convert lowercase letters to uppercase letters. On OpenVMS and OpenVMS Alpha systems, you can select case-sensitive mode from the command line with the /NAMES=AS_IS qualifier. o The digits 0 to 9. o The special characters listed in the Special Characters Table which follows. Table 2 Special Characters Used in MACRO-64 Statements Character CharactName Function _ Underscore Character in symbol names. $ Dollar Character in symbol names. sign . Period Character in symbol names, current location counter, and decimal point. : Colon Local label terminator. :: Double Global label terminator. colon = Equal Local direct assignment operator and macro sign keyword argument terminator. == Double Global direct assignment operator. equal sign # Number Literal value indicator. sign @ At sign Arithmetic shift operator. ; Semicolon Comment field indicator. + Plus Unary plus operator and arithmetic addition sign operator. - Minus Unary minus operator, arithmetic subtraction sign or operator, and line continuation indicator. hyphen * Asterisk Arithmetic multiplication operator. / Slash Arithmetic division operator. & Ampersand Logical AND operator. ! ExclamationLogical inclusive OR operator. point \ Backslash Logical exclusive OR and numeric conversion indicator in macro arguments. ^ Circumflex Unary operators and macro argument delimiter. ( ) ParenthesesDisplacement and register field delimiter in an instruction operand. Argument delimiter to a lexical operator. <> Angle Argument or expression grouping delimiters. brackets ? Question Created local label indicator in macro mark arguments. ' Apostrophe Macro argument concatenation indicator. " Double Quoted literal delimiter. quote % Percent Delimits the beginning of a lexical sign operator. (space)Space or Separates source statement fields. Spaces tab within expressions are otherwise ignored. (tab) , Comma Separates symbolic arguments within the operand field. Multiple expressions in the operand field must be separated by commas. 3 Numbers Numbers can be integers or floating-point numbers. The following sections describe these types of numbers. 4 Integers You can use integers in any expression, including expressions in operands and in direct assignment statements. FORMAT snn s An optional sign: plus sign (+) for positive numbers (the default), or minus sign (-) for negative numbers. nn A string of numeric characters that is legal for the specified radix. MACRO-64 interprets all integers in the source program as decimal unless the number is preceded by a radix control operator. Integers must be in the range of -263 to +263 -1 for signed data or in the range of 0 to 264 -1 for unsigned data. Negative numbers must be preceded by a minus sign; MACRO-64 translates such numbers into two's complement form. In positive numbers, the plus sign is optional. 4 Floating_Point_Number You can use a floating-point number in the .DOUBLE, .FLOAT, .F_FLOATING, .D_FLOATING, .G_FLOATING, .S_FLOATING, and .T_FLOATING directives. You cannot use a floating-point number in an expression or with a unary or binary operator except the unary plus and unary minus. You can specify a floating-point number with or without an exponent. FORMAT Floating-point number without exponent: snn snn.nn snn. Floating-point number with exponent (E): snnEsnn snn.nnEsnn snn.Esnn s An optional sign. nn A string of decimal digits in the range of 0 to 9. The decimal point can appear anywhere to the right of the first digit. A floating-point number cannot start with a decimal point because MACRO-64 treats the number as a user-defined symbol. 3 Quoted_Literals A quoted literal is a string of characters enclosed in double quotes (" "). Use the following guidelines when specifying characters in a quoted literal: o Any character except null, carriage return, and form feed can appear within the string. o To include a double quote or backslash in a string, you must precede it with a backslash (\). o To specify an arbitrary character, you can specify "\xhh", where each h represents a single hexadecimal digit. For example: "AB\\CD\"EF\x47" This string contains the following characters: AB\CD"EFG Also note that the assembler does not convert the case of alphabetic characters within a quoted literal. Quoted literals can be continued over several lines. Use the hyphen (-) as the line continuation character and delimit the string with double quotes. For example: .ASCII "Strings are delimited with double quotes." .ASCII "The backslash is an escape character." .ASCII "Strings can be continued onto multiple lines - just as any other line." .ASCII "Use two backslashes (\\) to represent - the back-slash itself." .ASCII "Hexidecimal escape sequences use - lower or upper X: \x00 or \X00" .ASCII "Precede a double quote with a backslash (\") - to embed the quote." 3 Symbols You use symbols in MACRO-64 source statements to represent an instruction, directive, register name, or value. You can use four types of symbols in MACRO-64 source programs: permanent symbols, predefined symbols, user-defined symbols, and macro names. 4 Permanent_Symbols Permanent symbols consist of MACRO-64 directives and instruction mnemonics. You need not define directives before you use them in the operator field of a MACRO-64 source statement. It is also not necessary to define instruction mnemonics before using them in the instruction statements. 4 Predefined_Symbols Predefined symbols are MACRO-64 register symbols that are not permanently reserved. You can delete the definition of any of these predefined register symbols. You can also define your own register symbols. You can express the 32 general registers and the 32 floating- point registers of the Alpha processor in a source program as follows: Register Name Description R0 General register 0. R1 General register 1. . . . . . . R29 General register 29 or frame pointer. If you use R29 as a or FP frame pointer, Digital recommends you use the name FP. If you use R29 as a general register, Digital recommends you use the name R29. R30 General register 30 or stack pointer. If you use R30 as a or stack pointer, the name SP is recommended; if you use R30 SP as a general register, the name R30 is recommended. R31 General register 31. F0 Floating-point register 0. . . . . . . F31 Floating-point register 31. NOTE When MACRO-64 operates in /NAMES=AS_IS mode, all of the previous register symbols are defined in all uppercase and all lowercase. To define your own register symbols, use either the .DEFINE_ FREG or .DEFINE_IREG directive for floating-point or integer registers, respectively. For more information about the .DEFINE_ FREG or .DEFINE_IREG directives, see .DEFINE_FREG and .DEFINE_ IREG, respectively. You can delete a register symbol definition with the .UNDEFINE_ REG directive. For more information about the .UNDEFINE_REG directive, see .UNDEFINE_REG. While an identifier is defined as a register symbol, it can only be used in those contexts that allow a register. 4 User-Defined_Symbols_and_Macro_Names You can use symbols to define labels, or you can equate them to a specific value by a direct assignment statement. You can also use these symbols in expressions. Use the following rules to create user-defined symbols: o Use alphanumeric characters, underscores (_), dollar signs ($), and periods (.). Any other character terminates the symbol. o The first character of a symbol cannot be a number. o The symbol must be no more than 31 characters long and must be unique. o The symbol must not be a register name. o The symbol cannot be one of the following conditional or macro directives: .ELSE .ENDC .ENDM .ENDR .IF .IF_FALSE (.IFF) .IF_TRUE .IF_TRUE_ .IIF (.IFT) FALSE (.IFTF) .INCLUDE .IRP .IRPC .LIBRARY .MACRO .MCALL .MDELETE .MEXIT .NARG .NCHAR .REPEAT In addition, by Digital convention: o The dollar sign ($) is reserved for names defined by Digital. This convention ensures that a user-defined name (that does not have a dollar sign) will not conflict with a Digital- defined name (that does have a dollar sign). o Do not use the period (.) in any global symbol name because many languages, such as Fortran, do not allow periods in symbol names. Macro names follow the same rules and conventions as user-defined symbols. User-defined symbols and macro names do not conflict; that is, you can use the same name for a user-defined symbol and a macro. 4 Determining_Symbol_Values The value of a symbol depends on its use in the program. MACRO-64 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. 4 Using_Symbols_in_the_Operator_Field A symbol in the operator field can be either a permanent symbol or a macro name. MACRO-64 searches for a symbol definition in the following order: 1. Macro and conditional directives: .ELSE .ENDC .ENDM .ENDR .IF .IF_FALSE (.IFF) .IF_TRUE .IF_TRUE_ .IIF (.IFT) FALSE (.IFTF) .INCLUDE .IRP .IRPC .LIBRARY .MACRO .MCALL .MDELETE .MEXIT .NARG .NCHAR .REPEAT 2. Previously defined macro names 3. Permanent symbols (instructions and other directives) This search order allows most permanent symbols, except conditional directives and macro directives, 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. 4 Using_Symbols_in_the_Operand_Field A symbol in the operand field must be either a user-defined numeric symbol, a label, or a register name. User-defined numeric symbols and labels can be either local (internal) symbols or global (external) symbols. Whether numeric symbols and labels are local or global depends on their use in the source program. You can reference a local numeric symbol or label only in the module in which it is defined. If local numeric symbols or labels with the same names are defined in different modules, the symbols and labels are completely independent. The definition of a global numeric symbol or label, however, can be referenced from any module in the program. MACRO-64 treats all user-defined numeric symbols and labels as local unless you explicitly declare them to be global by doing one of the following: o Use the double colon (::) in defining a label. o Use the double equal sign (==) in a direct assignment statement. o Use the .WEAK directive. You can only use user-defined lexical string symbols with the lexical string operators. You can define a macro using the same name as a previously defined local numeric symbol, global numeric symbol, or a lexical string symbol. However, you cannot define a lexical string symbol and a numeric symbol using the same name. In addition, you cannot use the same name for both a local and global numeric symbol. You cannot use the same symbol name for both a numeric symbol (local or global) and a label (local or global). 3 Temporary_Labels_Within_Source_Code Use temporary labels to identify addresses within a block of source code. Format nnnnn$: nnnnn A decimal integer in the range of 1 to 65,535. In most cases, you can use temporary labels in the same way you use other labels that you define; however, there are some differences: o Temporary labels cannot be referenced outside the temporary label block in which they are declared. o Temporary labels can be redeclared in another block of source code. o Temporary labels that occur within a psect with the MIX or NOMIX attribute do not appear in the debugger symbol table; thus, they cannot be accessed by the symbolic debugger. o Temporary labels cannot be used in the .END or .PROCEDURE_DESCRIPTOR directives. By convention, temporary labels are positioned like statement labels: left-justified in the source text. Although temporary labels can appear in the program in any order, by convention, the temporary labels in any block of source code should be in increasing numeric order. Temporary labels are useful as branch addresses when you use the address only within the block. You can use temporary labels 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 temporary labels is that their numeric names do not provide any indication of their purpose. Consequently, you should not use temporary labels to label sequences of statements that are logically unrelated; you should use user-defined symbols instead. Digital recommends that users create temporary labels only in the range of 0$ to 29999$ because the assembler automatically creates temporary labels in the range of 30000$ to 65535$ for use in macros. The temporary label block in which a temporary label is valid is delimited by the following statements: o A user-defined label: global or local. o A .PSECT directive. An example showing the correct and incorrect use of temporary labels follows: A: ADDQ R1, R2, R3 BEQ R3, 2$ ; correct use MULQ R2, R3, R4 2$: ADDQ R1, R4, R5 ; definition of temporary label B: BNE R5, 2$ ; illegal C: SUBQ R2, R4, R6 In this example, 2$ is a temporary label defined in the block between A: and B:. The forward reference in the second instruction is properly resolved. The line labeled B: also references 2$, but the label B has already closed the range. The temporary label 2$ can be used later in the program, but its definition must appear within the same block as the label. o The .ENABLE and .DISABLE directives, which can extend a local label block beyond user-defined labels and .PSECT directives. A temporary label block is usually delimited by two user-defined labels. However, the .ENABLE LOCAL_BLOCK directive starts a local block that is terminated by one of the following: o A second .ENABLE LOCAL_BLOCK directive o A .DISABLE LOCAL_BLOCK directive followed by a user-defined label or a .PSECT directive Temporary labels can be preserved with the context of the program section in which they are defined for future reference. See the descriptions of the .SAVE_PSECT [LOCAL_BLOCK] directive and the .RESTORE_PSECT directive. 3 Label_Addresses In the absence of optimization and automatic data alignment, label addresses are defined to be the psect and offset of the current location counter at the point where the label is defined. When either optimization or automatic data alignment are enabled, the following additional considerations apply. 4 Label_Addresses,_Optimization,_and_Code_Alignment Optimization and code alignment can affect the addresses assigned to labels defined in psects that have the EXE and NOMIX attributes. Optimization and code alignment are disabled by default, and can be enabled with the /OPTIMIZE and /ALIGNMENT command-line qualifiers and the .ENABLE directive In general, the assembler assigns the psect and offset of the current location counter before optimization or alignment of code labels. However, the assembler adjusts references to labels in branch instructions to the address of the label after optimization and code alignment processing. The assembler does not adjust references to labels where the label reference occurs in an expression with more than one term. The following example shows this: .PSECT CODE, EXE, NOMIX BSR R0, 10$ ; R0 -> 10$ (postoptimization) 10$: LDA R1, 20$-10$(R0) ; R1 -> 20$ (preoptimization) JMP (R1) [...] 20$: In the previous example, the assembler adjusts the target address of the BSR instruction to be the location of 10$ after optimization and code alignment have taken place. Thus, the branch to 10$ functions as expected. However, when processing the LDA instruction, the assembler computes the offset between 20$ and 10$ before optimization and code alignment. Thus, the address of 20$ that is stored in R1 is the address prior to optimization and code alignment. Depending on the sequence of instructions between 10$ and 20$, the address before optimization and code alignment may differ from the address after optimization and code alignment and the JMP instruction may not transfer control to the expected address. Note also that the assembler only performs postoptimization adjustment of label addresses when the label is the only term in the expression. For example: .PSECT CODE, EXE, NOMIX .BASE R27,LINKAGE LDQ R26, ROUTINE1_ADDR JSR R26, (R26) LDQ R26, ROUTINE2_ADDR JSR R26, (R26) RET R28 NOP NOP ROUTINE1: RET (R26) ROUTINE2: RET (R26) .PSECT LINKAGE, NOEXE LINKAGE: ROUTINE1_ADDR: .ADDRESS ROUTINE1 ROUTINE2_ADDR: .ADDRESS ROUTINE2+0 In the previous example, the assembler adjusts the address stored with the .ADDRESS ROUTINE1 directive to the address of label ROUTINE1 after optimization and code alignment. However, since the expression in the .ADDRESS ROUTINE2+0 directive is not a single term, the assembler adds the offset 0 and the address of ROUTINE2 before optimization and code alignment and stores the result. Since the address stored is the address before optimization and code alignment, the second JSR instruction may not transfer control to the address that is expected. 4 Label_Addresses_and_Automatic_Data_Alignment Automatic data alignment can affect the addresses assigned to labels in psects that have the NOEXE or MIX attributes. Automatic data alignment is enabled with the .ENABLE ALIGN_DATA directive or the /ALIGNMENT=data command-line option. A label that occurs in a statement with a data-storage directive is assigned the psect and offset of the storage allocated by the data-storage directive. If the data-storage directive requires automatic alignment, the address is assigned to the label after automatic alignment. The same is true of labels that occur in statements by themselves and that are followed by a data directive in a subsequent statement. However, if a label occurs in a statement by itself and is followed by a statement that is not a data-storage directive, a macro directive, a conditional directive, or a lexical-string symbol assignment, the label is assigned the psect and offset of the current location counter before any automatic alignment. The assembler only assigns addresses to labels after alignment under the conditions previously described and only with automatic alignment. If you place a label before a .ALIGN directive that manually aligns the current location counter, the assembler assigns the address of the label before performing the manual alignment. The following example shows the interaction of label address assignment and automatic data alignment: .ENABLE ALIGN_DATA .PSECT DATA, NOEXE .BYTE 1 ; The byte is stored in psect data at offset 0 A: .PRINT "Not aligned" ; Any non-macro, nonconditional ; statement, including this .PRINT directive ; prevents A from being automatically aligned ; -- A is assigned offset 1 B: ; B is automatically aligned to offset 4 C: .LONG 2 ; C is automatically aligned to offset 4 D: .ALIGN 0 ; The .ALIGN global directive prevents D ; from being automatically aligned -- ; D is assigned offset 8 E: .OCTA 3 ; E is automatically aligned to offset 16 Automatic data alignment and label-address assignment can be an important consideration when calculating the difference between two labels. For example, consider the following macro, which stores a string preceded by a word that contains the string's length: .MACRO VARYING_STRING STRING ?L1, ?L2 .WORD L2-L1 L1: .ASCII "STRING" L2: .ENDM VARYING_STRING If an invocation of the VARYING_STRING macro is followed by a data-storage directive that requires automatic alignment, the VARYING_STRING macro will not store the correct string length. For example: .PSECT DATA, NOEXE, .OCTA .ENABLE ALIGN_DATA VARYING_STRING