HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Rules for coding expressions

HLASM Language Reference
SC26-4940-06

The rules for coding an absolute or relocatable expression are:
  • Unary (operating on one value) operators and binary (operating on two values) operators are allowed in expressions.
  • An expression can have one or more unary operators preceding any term in the expression or at the beginning of the expression.
  • An expression must not begin with a binary operator, nor can it contain two binary operators in succession. When + and - are used as prefix operators, then they are unary, and not binary, operators.
  • An expression starting with * is interpreted as a location counter reference, and not a multiplication operator.
  • An expression must not contain two terms in succession.
  • No spaces are allowed between an operator and a term, nor between two successive operators.
  • An expression can contain any number of unary and binary operators, and any number of levels of parentheses.
  • A single relocatable term is not allowed in a multiply or divide operation. Paired relocatable terms have absolute values and can be multiplied and divided if they are enclosed in parentheses. See Paired relocatable terms.
Figure 1 shows the definitions of absolute and relocatable expressions.
Figure 1. 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     │ │           │
└───────────┘ └───────────┘

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014