This section discusses the expressions used in coding operand entries for source statements. You can use an expression to specify:
Expressions have absolute and relocatable values. Whether an expression is absolute or relocatable depends on the value of the terms it contains. The assembler evaluates relocatable and absolute expressions at assembly time. Figure 10 shows examples of valid expressions.
In addition to expressions used in coding operand entries, there are three types of expression that you can use only in conditional assembly instructions: arithmetic, logical, and character expressions. They are evaluated during conditional assembly. For more information, see Assigning values to SET symbols.
An expression is composed of a single term or an arithmetic combination of terms. The assembler reduces multiterm expressions to single values. Thus, you do not have to compute these values yourself. The following are examples of valid expressions:
* BETA*10 AREA1+X'2D' B'101' *+32 C'ABC' N-25 29 FIELD+332 L'FIELD FIELD LAMBDA+GAMMA (EXIT-ENTRY+1)+GO TEN/TWO ALPHA-BETA/(10+AREA*L'FIELD)-100 =F'1234' =A(100,133,175,221)+8
The rules for coding an absolute or relocatable expression are:
Figure 11 shows the definitions of absolute and relocatable expressions.
*-----------*
| |
|Absolute |
|Expression |
| |
*-----*-----*
|
V Can be any of
*-------------*-------------*-------------*-------------*-------------*-------------*-------------*-------------*
| | | | | | | | |
V V V V V V V V V
*-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----*
| | | | | | | | | | | | | | | | | |
| Rel. Exp. | | Absolute | | Abs. Exp. | | Abs. Exp. | | Abs. Exp. | | Abs. Exp. | |(Abs. Exp.)| | +Abs. Exp.| | -Abs. Exp.|
| - | | Term | | + | | - | | * | | / | | | | ^ | | ^ |
| Rel. Exp. | | | | Abs. Exp. | | Abs. Exp. | | Abs. Exp. | | Abs. Exp. | | | | | | | | |
*-----*-----* *-----*-----* *-----------* *-----------* *-----------* *-----------* *-----------* *-+---------* *-+---------*
| | *------*------*
| V Can be any of |
| *-------------*-------------*-------------*-------------* unary operators
| | | | | |
| V V V V V
| *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----*
| |Absolute | | Self- | | Symbol | | Symbol | | Symbol |
| |Valued | | Defining | | Length | | Integer | | Scale |
| |Ordinary | | Term | | Attribute | | Attribute | | Attribute |
| |Symbol | | | | | | | | |
| *-----------* *-----------* *-----------* *-----------* *-----------*
|
V
*-----*-----*
| |
|Relocatable|
|Expression |
| |
*-----*-----*
|
V Can be any of
*-------------*-------------*-------------*-------------*-------------*
| | | | | |
V V V V V V
*-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* *-----*-----* Operators Allowed
| | | | | | | | | | | |
|Relocatable| | Rel. Exp. | | Rel. Exp. | |(Rel. Exp.)| |+Rel. Exp. | |-Rel. Exp. | Unary: + Positive
|Term | | + | | - | | | |^ | |^ | - Negative
| | | Abs. Exp. | | Abs. Exp. | | | || | || |
*-----*-----* *-----------* *-----------* *-----------* *+----------* *+----------* Binary: + Addition
| | | - Subtraction
| *------*------* * Multiplication
V Can be any of | / Division
*-------------* unary operators
| |
V V
*-----*-----* *-----*-----*
|Relocatable| | Location | Rel. Exp. = Relocatable Expression
|Valued | | Counter | Abs. Exp. = Absolute Expression
|Ordinary | | Reference |
|Symbol | | |
*-----------* *-----------*A single-term expression, like 29 or BETA, has the value of the term involved. The assembler reduces a multiterm expression, like 25*10+A/B or BETA+10, to a single value, as follows:
The assembler evaluates paired relocatable terms at each level of expression nesting.
An expression is absolute if its value is unaffected by program relocation. An expression is relocatable if its value depends upon program relocation. The two types of expressions, absolute and relocatable, take on these characteristics from the term or terms composing them. A description of the factors that determine whether an expression is absolute or relocatable follows.
An absolute expression is one whose value remains the same after program relocation. The value of an absolute expression is called an absolute value.
An expression is absolute, and is reduced to a single absolute value if the expression:
The absolute terms may include Integer and Scale attributes, but not Type attributes.
The relocatability attribute describes the attribute of a relocatable term. If a pair of terms are defined in the same control section, they are characterized as having the same relocatability attribute.
If the terms are defined in different control sections, or have different relocatability attributes, the expression is said to be "complex relocatable".
The relocatability attribute is the same as the ESDID for external symbols, and the "Relocation ID" in the listing.
An expression can be absolute even though it contains relocatable terms, provided that all the relocatable terms are paired. The pairing of relocatable terms cancels the effect of relocation.
The assembler reduces paired terms to single absolute terms in the intermediate stages of evaluation. The assembler considers relocatable terms as paired under the following conditions:
The following examples show absolute expressions. A is an absolute term; X and Y are relocatable terms with the same relocatability:
A-Y+X A A*A X-Y+A (*+*)-(*+*) *-*
A reference to the location counter must be paired with another relocatable term from the same control section; that is, with the same relocatability. For example:
*-Y
A relocatable expression is one whose value changes by n if the origin of the control section in which it appears is relocated n bytes.
A relocatable expression can be a single relocatable term. The assembler reduces a relocatable expression to a single relocatable value if the expression:
The following examples show relocatable expressions. A is an absolute term, W and X are relocatable terms with the same relocatability attribute, and Y is a relocatable term with a different relocatability attribute.
Y-32*A W-X+* =F'1234' (literal) * (reference to W-X+W Y location counter) W-X+Y A*A+W-W+Y
Complex relocatable expressions, unlike relocatable expressions, can contain:
Using the same symbols, the following are examples of complex relocatable expressions:
W+X *+*
X-Y A-W+Y
Complex relocatable expressions are used in A-type and Y-type address constants to generate address constant values. For more details, refer to "Complex relocatable expressions", and Address constants--A and Y. V-type and S-type constants may not contain complex relocatable expressions. You can assign a complex relocatable value to a symbol using the EQU instruction, as described on page EQU instruction.
[ Top of Page | Previous Page | Next Page | Contents | Index ]