HP OpenVMS Systems Documentation
VAX MACRO and Instruction Set Reference Manual
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. You can use unary operators to indicate whether a term or expression is positive or negative. If unary plus or minus is not specified, the default value is assumed to be plus. In addition, unary operators perform radix conversion, textual conversion (including ASCII conversion), and numeric control operations, as described in the following sections. Table 3-3 summarizes the unary operators.
More than one unary operator can be applied to a single term or to an expression enclosed in angle brackets. For example:
This construct is equivalent to:
3.6.1 Radix Control Operators
VAX 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.
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.
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 default decimal operator is needed only within an expression that has another radix control operator. In the following example, "16" is interpreted as a decimal number because it is preceded by the decimal operator ^D even though the "16" is in an expression prefixed by the octal radix control operator.
3.6.2 Textual Operators
The textual operators are the ASCII operator (^A) and the register mask
The ASCII operator converts a string of printable characters to their 8-bit ASCII values and stores them 1 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. Use nonalphanumeric characters to avoid confusion.
The delimited ASCII string must not be larger than the data type of the operand. For example, if the ^A operator occurs in an operand in a Move Word (MOVW) instruction (the data type is a word), the delimited string cannot be more than 2 characters.
184.108.40.206 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 Push Registers (PUSHR) and Pop Registers (POPR) instructions and the .ENTRY and .MASK directives (see Chapter 6).
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 follow.
When the POPR or PUSHR instruction uses the register mask operator, R0 to R11, R12 or AP, FP, and SP can be specified. You cannot specify the PC register name and the IV and DV arithmetic trap-enable specifiers.
When the .ENTRY or .MASK directive uses the register mask operator, you can specify R2 to R11 and the IV and DV arithmetic trap-enable specifiers. However, you cannot specify R0, R1, FP, SP, and PC. IV sets the integer overflow trap, and DV sets the decimal string overflow trap.
The arithmetic trap-enable specifiers are described in Chapter 8.
3.6.3 Numeric Control Operators
The numeric control operators are the floating-point operator (^F) and
the complement operator (^C). The use of the numeric control operators
is explained in Section 220.127.116.11 and Section 18.104.22.168.
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 MACRO does not perform floating-point expression evaluation.
The floating-point operator is useful because it allows a floating-point number in an instruction that accepts integers.
22.214.171.124 Complement Operator
The complement operator produces the one's complement of the specified value.
VAX MACRO evaluates the term or expression as a 4-byte value before complementing it.
3.7 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.
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 evaluated first, and remaining operations are performed from left to right. For example:
Note that a 4-byte result is returned from all binary operations. If you use a 1-byte or 2-byte operand, the result is the low-order bytes of the 4-byte result. VAX 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.
You use the arithmetic shift operator (@) to perform left and right arithmetic shifts of arithmetic quantities. The first argument is shifted left or right by the number of bit positions that you specify in 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 zero. 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).
3.7.2 Logical AND Operator
The logical AND operator (&) takes the logical AND of two operands.
3.7.3 Logical Inclusive OR Operator
The logical inclusive OR operator (!) takes the logical inclusive OR of two operands.
3.7.4 Logical Exclusive OR Operator
The logical exclusive OR operator (\) takes the logical exclusive OR of two arguments.
3.8 Direct Assignment Statements
A direct assignment statement equates a symbol to a specific value. Unlike a symbol that you use as a label, you can redefine a symbol defined with a direct assignment statement as many times as you want.
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 three syntactic rules apply to direct assignment statements:
By Compaq convention, the symbol in a direct assignment statement is placed in the label field.
3.9 Current Location Counter
The symbol for the current location counter, the period (.), always has the value of the address of the current byte. VAX MACRO sets the current location counter to zero at the beginning of the assembly and at the beginning of each new program section.
Every VAX 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, with the exception of the special form described below, a direct assignment statement 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. This method of setting the location counter is often useful when defining data structures. Data storage areas should not be reserved by explicitly setting the location counter; use the .BLKx directives (see Chapter 6).
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 may be relative to the current location counter.
When a program section that you 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 you use the current location counter 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, you would not normally use the current location counter as a part of the operand specifier.