HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

Terms, Literals, and Expressions ┌───────────┐ │ │ │Absolute │ │Expression │ │ │ └─────┬─────┘ │ ▼ Can be any of ├─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐ │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ │ ││ ││ ││ ││ ││ ││ ││ ││ │ │ 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. │ │ │ │ │ │ │ │ │ └─────┬─────┘ └─────┬─────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └─┼─────────┘ └─┼─────────┘ │ │ └──────┬──────┘ │ ▼ Can be any of │ │ ├─────────────┬─────────────┬─────────────┬─────────────┐ unary operators │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ │ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ │ │Absolute │ │ Self- │ │ Symbol │ │ Symbol │ │ Symbol │ │ │Valued │ │ Defining │ │ Length │ │ Integer │ │ Scale │ │ │Ordinary │ │ Term │ │ Attribute │ │ Attribute │ │ Attribute │ │ │Symbol │ │ │ │ │ │ │ │ │ │ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ │ ▼ ┌─────┴─────┐ │ │ │Relocatable│ │Expression │ │ │ └─────┬─────┘ │ ▼ Can be any of ├─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ ▼ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ 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 ▼ Can be any of │ / Division ├─────────────┐ unary operators │ │ ▼ ▼ ┌─────┴─────┐ ┌─────┴─────┐ │Relocatable│ │ Location │ Rel. Exp. = Relocatable Expression │Valued │ │ Counter │ Abs. Exp. = Absolute Expression │Ordinary │ │ Reference │ │Symbol │ │ │ └───────────┘ └───────────┘ Figure 17. Definitions of Absolute and Relocatable Expressions Evaluation of Expressions A single-term expression, like 29 or BETA, has the value of the term involved. The assembler reduces a multiterm expression, like 251+A/B or BETA+1, to a single value, as follows: 1. It evaluates each term. 2. It does arithmetic operations from left to right. However: a. It does unary operations before binary operations. b. It does binary operations of multiplication and division before the binary operations of addition and subtraction. 3. In division, it gives an integer result; any fractional portion is dropped. Division by zero gives 0. 46 HLASM V1R5 Language Reference

Terms, Literals, and Expressions 4. In parenthesized expressions, the assembler evaluates the innermost expressions first and then considers them as terms in the next outer level of expressions. It continues this process until the outermost expression is evaluated. 5. A term or expression's intermediate value and computed result must lie in the range of −2 31 through +2 31 −1. The assembler evaluates paired relocatable terms at each level of expression nesting. Absolute and Relocatable Expressions 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. Absolute Expression: 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: 1. Comprises a symbol with an absolute value, a self-defining term, or a symbol length attribute reference, or any arithmetic combination of absolute terms. 2. Contains relocatable terms alone or in combination with absolute terms, and if all these relocatable terms are paired. Relocatability Attribute: 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. Paired Relocatable Terms: 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 paired terms must have the same relocatability attribute. The paired terms must have opposite signs after all unary operators are resolved. In an expression, the paired terms do not have to be contiguous (that is, other terms can come between the paired terms). The value represented by the paired terms is absolute. Chapter 2. Coding and Structure 47

Terms, Literals, and Expressions<br />

┌───────────┐<br />

│<br />

│<br />

│Absolute │<br />

│Expression │<br />

│<br />

│<br />

└─────┬─────┘<br />

│<br />

▼ Can be any of<br />

├─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐<br />

│ │ │ │ │ │ │ │ │<br />

▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼<br />

┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐<br />

│ ││ ││ ││ ││ ││ ││ ││ ││ │<br />

│ Rel. Exp. │ │ Absolute │ │ Abs. Exp. │ │ Abs. Exp. │ │ Abs. Exp. │ │ Abs. Exp. │ │(Abs. Exp.)│ │ +Abs. Exp.│ │ –Abs. Exp.│<br />

│ – │ │ Term │ │ + │ │ – │ │ │ │ / │ │ │ │ ▲ │ │ ▲ │<br />

│ Rel. Exp. │ │ │ │ Abs. Exp. │ │ Abs. Exp. │ │ Abs. Exp. │ │ Abs. Exp. │ │ │ │ │ │ │ │ │<br />

└─────┬─────┘ └─────┬─────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └─┼─────────┘ └─┼─────────┘<br />

│ │ └──────┬──────┘<br />

│ ▼ Can be any of │<br />

│ ├─────────────┬─────────────┬─────────────┬─────────────┐ unary operators<br />

│ │ │ │ │ │<br />

│ ▼ ▼ ▼ ▼ ▼<br />

│ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐<br />

│ │Absolute │ │ Self- │ │ Symbol │ │ Symbol │ │ Symbol │<br />

│ │Valued │ │ Defining │ │ Length │ │ Integer │ │ Scale │<br />

│ │Ordinary │ │ Term │ │ Attribute │ │ Attribute │ │ Attribute │<br />

│ │Symbol │ │ │ │ │ │ │ │ │<br />

│ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘<br />

│<br />

▼<br />

┌─────┴─────┐<br />

│<br />

│<br />

│Relocatable│<br />

│Expression │<br />

│<br />

│<br />

└─────┬─────┘<br />

│<br />

▼ Can be any of<br />

├─────────────┬─────────────┬─────────────┬─────────────┬─────────────┐<br />

│ │ │ │ │ │<br />

▼ ▼ ▼ ▼ ▼ ▼<br />

┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐ ┌─────┴─────┐<br />

Operators Allowed<br />

│ ││ ││ ││ ││ ││ │<br />

│Relocatable│ │ Rel. Exp. │ │ Rel. Exp. │ │(Rel. Exp.)│ │+Rel. Exp. │ │–Rel. Exp. │ Unary: + Positive<br />

│Term │ │ + │ │ – │ │ │ │▲ │ │▲ │ – Negative<br />

│ │ │ Abs. Exp. │ │ Abs. Exp. │ │ │ ││ │ ││ │<br />

└─────┬─────┘ └───────────┘ └───────────┘ └───────────┘ └┼──────────┘ └┼──────────┘<br />

Binary: + Addition<br />

│ │ │ – Subtraction<br />

│ └──────┬──────┘ Multiplication<br />

▼ Can be any of │ / Division<br />

├─────────────┐<br />

unary operators<br />

│<br />

│<br />

▼<br />

▼<br />

┌─────┴─────┐ ┌─────┴─────┐<br />

│Relocatable│ │ Location │ Rel. Exp. = Relocatable Expression<br />

│Valued │ │ Counter │ Abs. Exp. = Absolute Expression<br />

│Ordinary │ │ <strong>Reference</strong> │<br />

│Symbol │ │ │<br />

└───────────┘ └───────────┘<br />

Figure 17. Definitions of Absolute and Relocatable Expressions<br />

Evaluation of Expressions<br />

A single-term expression, like 29 or BETA, has the value of the term involved. The<br />

assembler reduces a multiterm expression, like 251+A/B or BETA+1, to a single<br />

value, as follows:<br />

1. It evaluates each term.<br />

2. It does arithmetic operations from left to right. However:<br />

a. It does unary operations before binary operations.<br />

b. It does binary operations of multiplication and division before the binary<br />

operations of addition and subtraction.<br />

3. In division, it gives an integer result; any fractional portion is dropped. Division<br />

by zero gives 0.<br />

46 <strong>HLASM</strong> V1R5 <strong>Language</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!