[OpenVMS documentation]
[Site home] [Send comments] [Help with this site] [How to order documentation] [OpenVMS site] [Compaq site]
Updated: 11 December 1998

VAX MACRO and Instruction Set Reference Manual


Previous Contents Index


Chapter 3
Components of MACRO Source Statements

This chapter describes the following components of VAX MACRO source statements:

3.1 Character Set

The following characters can be used in VAX MACRO source statements:

Table 3-1 Special Characters Used in VAX MACRO Statements
Character Character Name Function
_ Underscore 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
@ At sign Deferred 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
/ Slash Arithmetic division operator
& Ampersand Logical AND operator
! Exclamation point Logical inclusive OR operator point
\ 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 deferred addressing mode indicators
<> Angle brackets Argument or expression grouping delimiters
? Question mark Created local label indicator in macro arguments
' Apostrophe Macro argument concatenation indicator
% Percent sign Macro string operators

Table 3-2 defines the separating characters used in VAX MACRO.

Table 3-2 Separating Characters in VAX MACRO Statements
Character Character Name Usage
(space)
(tab)
Space or tab Separator between statement fields. Spaces within expressions are ignored.
, Comma Separator between symbolic arguments within the operand field. Multiple expressions in the operand field must be separated by commas.

3.2 Numbers

Numbers can be integers, floating-point numbers, or packed decimal strings.

3.2.1 Integers

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 numbers (the default) or minus sign (--) for negative numbers.

nn

A string of numeric characters that is legal for the current radix.

VAX 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 --2,147,483,648 to +2,147,483,647 for signed data or in the range of 0 to 4,294,967,295 for unsigned data.

Negative numbers must be preceded by a minus sign; VAX MACRO translates such numbers into two's complement form. In positive numbers, the plus sign is optional.

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 6) or as an operand in 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 (F_FLOATING). Section 3.6 and Section 3.7 describe unary and binary operators.

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 0 to 9.

The decimal point can appear anywhere to the right of the first digit. Note that a floating-point number cannot start with a decimal point because VAX 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, 16 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 1.7E38.

Single-precision floating-point numbers can be rounded (by default) or truncated. The .ENABLE and .DISABLE directives (described in Chapter 6) control whether single-precision floating-point numbers are rounded or truncated. Double-precision and extended-precision floating-point numbers are always rounded.

Section 8.3.6, Section 8.3.7, Section 8.3.8, and Section 8.3.9 describe the internal format of floating-point numbers.

3.2.3 Packed Decimal Strings

A packed decimal string can be used only in the .PACKED directive (described in Chapter 6).

Format

snn 

s

An optional sign.

nn

A string containing up to 31 decimal digits in the range of 0 to 9.

A packed decimal string cannot have a decimal point or an exponent.

Section 8.3.14 describes the internal format of packed decimal strings.

3.3 Symbols

Three types of symbols can be used in VAX MACRO source programs: permanent symbols, user-defined symbols, and macro names.

3.3.1 Permanent Symbols

Permanent symbols consist of instruction mnemonics (see Appendix D), VAX MACRO directives (see Chapter 6), and register names. You need not define instruction mnemonics and directives before you use them in the operator field of a VAX MACRO source statement. Also, you need not define register names before using them in the addressing modes (see Chapter 5).

Register names cannot be redefined; that is, a symbol that you define cannot be one of the register names contained in the following list. You can express the 16 general registers of the VAX processor in a source program only as follows:
Register Name Processor Register
R0 General register 0
R1 General register 1
R2 General register 2
. .
. .
. .
R11 General register 11
R12 or
AP
General register 12 or argument pointer. If you use R12 as an argument pointer, the name AP is recommended; if you use R12 as a general register, the name R12 is recommended.
FP Frame pointer
SP Stack pointer
PC Program counter

Note that the symbols IV and DV are also permanent symbols and cannot be redefined. These symbols are used in the register mask to set the integer overflow trap (IV) and the decimal string overflow trap (DV). See Section 3.6.2.2 for an explanation of their uses.

3.3.2 User-Defined Symbols and Macro Names

You can use symbols that you define as labels or you can equate them to a specific value by a direct assignment statement (see Section 3.8). These symbols can also be used in any expression (see Section 3.5).

The following rules govern the creation of user-defined symbols:

In addition, by Digital convention:

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. To avoid confusion, give the symbols and macros that you define different names.

3.3.3 Determining Symbol Values

The value of a symbol depends on its use in the program. VAX 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 MACRO searches for a symbol definition in the following order:

  1. Previously defined macro names
  2. User-defined opcode (see the .OPDEF description in Chapter 6)
  3. Permanent symbols (instructions and directives)
  4. 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 or a register name.

User-defined symbols can be either local (internal) symbols or global (external) symbols. Whether symbols are local 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. The definition of a global symbol, however, can be referenced from any module in the program.

VAX MACRO treats all symbols that you define as local unless you explicitly declared them to be global by doing any one of the following:

When your code references a symbol within the module in which it is defined, VAX MACRO considers the reference internal. When your code references a symbol within a module in which it is not defined, VAX MACRO considers the reference external (that is, the symbol is defined externally in another module). You can use the .DISABLE directive to make references to symbols not defined in the current module illegal. In this case, you must use the .EXTERNAL directive to specify that the reference is an external reference. See Chapter 6 for descriptions of the .DISABLE and .EXTERNAL directives.

3.4 Local Labels

Use local labels to identify addresses within a block of source code.

Format

nn$ 

nn

A decimal integer in the range of 1 to 65535.

Use local labels in the same way as you use the symbol labels that you define, with the following differences:

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 you use the address only within the block. You can use local 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 local labels is that their numeric names cannot provide any indication of their purpose. Consequently, you should not use local labels 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 4.7).

The local label block in which a local label is valid is delimited by the following statements:

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:

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 6.

An example showing the use of local labels follows:


RPSUB:  MOVL    AMOUNT,R0       ; Start local label block 
10$:    SUBL2   DELTA,R0        ; Define local label 10$ 
        BGTR    10$             ; Conditional branch to local label 
        ADDL2   DELTA,R0        ; Executed when R0 not > 0 
COMP:   MOVL    MAX,R1          ; End previous local label 
        CLRL    R2              ;   block and start new one 
10$:    CMPL    R0,R1           ; Define new local label 10$ 
        BGTR    20$             ; Conditional branch to local label 
        SUBL    INCR,R0         ; Executed when R0 not > R1 
        INCL    R2              ; . . . 
        BRB     10$             ; Unconditional branch to local label 
20$:    MOVL    R2,COUNT        ; Define local label 
        BRW     TEST            ; Unconditional branch to user-defined label 
 
        .ENABLE LOCAL_BLOCK     ; Start local label block that 
ENTR1:  POPR    #^M<R0,R1,R2>   ;   will not be terminated 
        ADDL3   R0,R1,R3        ;   by a user-defined label 
        BRB     10$             ; Branch to local label that appears 
                                ;   after a user-defined label 
ENTR2:  SUBL2    R2,R3          ; Does not start a new local label block 
10$:    SUBL2   R2,R3           ; Define local label 
        BGTR    20$             ; Conditional branch to local label 
        INCL    R0              ; Executed when R2 not > R3 
        BRB     NEXT            ; Unconditional branch to user-defined label 
20$:    DECL    R0              ; Define local label 
        .DISABLE LOCAL_BLOCK    ; Directive followed by user-defined 
NEXT:   CLRL    R4              ;   label terminates local label block 

3.5 Terms and Expressions

A term can be any of the following:

VAX MACRO evaluates terms as longword (4-byte) values. If you use an undefined symbol as a term, the linker determines the value of the term. 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 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. In the first case, A and B are multiplied and then C added to the product. In the second case, B and C are added and the sum is multiplied by A. Angle brackets can also be used to apply a unary operator to an entire expression, such as --<A+B>.

If an arithmetic expression is continued on another line, the listing file will not show the continued line. For example:


.WORD <DATA1'$^XFF@8+- 
      89> 

You must use /LIST/SHOW=EXPANSION to show the continuation line.

VAX MACRO considers unary operators part of a term and thus, performs the action indicated by a unary operator before it performs the action indicated by any binary operator.

Expressions fall into three categories: relocatable, absolute, and external (global), as follows:

Any type of expression can be used in most MACRO statements, but restrictions are placed on expressions used in the following:

See Chapter 6 for descriptions of the directives listed in the preceding list.

Expressions used in these directives and in direct assignment statements can contain only 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                 ; 2*100 is an absolute expression 
        .BLKB   A+50      ; A+50 is an absolute expression and 
                          ;   contains no undefined symbols 
LAB:    .BLKW   A         ; LAB is relocatable 
HALF = LAB+<A/2>          ; LAB+<A/2> is a relocatable 
                          ;   expression and contains no 
                          ;   undefined symbols 
LAB2:   .BLKB   LAB2-LAB  ; LAB2-LAB is an absolute expression 
                          ;   and contains no undefined symbols 
                          ;   but contains the symbol LAB3 
                          ;   that is defined later in this module 
LAB3:   .WORD   TST+LAB+2 ; TST+LAB+2 is an external expression 
                          ;   because TST is an external symbol 


Previous Next Contents Index

[Site home] [Send comments] [Help with this site] [How to order documentation] [OpenVMS site] [Compaq site]
[OpenVMS documentation]

Copyright © Compaq Computer Corporation 1998. All rights reserved.

Legal
4515PRO_001.HTML