• Aucun résultat trouvé

Arithmetic Expression

Dans le document Information When (Page 122-126)

The count function determines the length, in bytes, of the value assigne.d to a symbolic parameter. This length is obtained by prefixing K' to the label of a symbolic parameter. For example, if &LIST equals ABCDEFG, the K'&LIST equals 7.

You can refer to the count function only in the operand ofa macroprocessor control statement (for example, AIF or SET A).

An arithmetic expression is a term or series of terms separated by operators. The valid terms of an arithmetic expression are variable symbols, self-defining terms, or count functions. The valid operators in an arithmetic expression are addition (+ ), subtraction (-), multiplication (*), and division (/). Parenthesized expressions are supported for up to three nested levels.

The following rules apply to arithmetic expressions:

• Terms must be separated by operators.

• Operators must be separated by terms.

• No more than three nested levels of parentheses are allowed.

• Parentheses must be balanced; that is, for each left parenthesis there must be a right parenthesis.

• Unless a left parenthesis is the first element in the expression, there must be an operator or another left parenthesis immediately before it.

• A left parenthesis must be immediately followed by a term or another left parenthesis.

• A right parenthesis must be immediately preceded by a term or another right parenthesis.

• A right parenthesis must be immediately followed by an operator or another right parenthesis unless it is the end of the expression.

Arithmetic expressions are evaluated using 24-bit signed arithmetic (a 3-byte field ranging from -8388608 to 8388607). An expression is reduced to a single value as follows:

• Parenthesized expressions are evaluated from the innermost set of parentheses outward.

• Multiplication and division are performed before addition and subtraction.

All operations are performed from left to right.

Continuation

Concatenation

Only prototype statements can be continued. Any character in position 72 following a comma after the last operand indicates that a continuation line of the prototype statement follows. Columns 1 through 15 must be blank. At least one operand, beginning in position 16, must appear on every continuation line of a prototype statement. Only nine continuation lines can be used, giving a maximum statement of ten lines for each prototype record.

Separate values physically combined so that they appear as one value are said to be concatenated. Concatenation occurs under any of the following conditions:

• A symbolic parameter or set symbol is immediately before or after another symbolic parameter or set symbol with no delimiter between them.

• Characters are immediately before a symbolic parameter or set symbol with no delimiter between them.

• Characters are joined to the symbolic parameter immediately before them or to a set symbol by a period between them.

You can concatenate symbolic parameters, set symbols, and character strings of AIF statements. However, model records and assembler instructions can concatenate only symbolic parameters or set symbols and alphameric values.

Chapter 4.Creating Macroinstructions 4-9

Creating Macroinstruction Definitions

You must use definition control statements to create macroinstruction definitiot:ls.

The values established in the definition control statements are used by the macroprocessor to generate assembler and/or machine instruction statements.

The following list shows the definition control statements in the order that they must appear in a macroinstruction definition:

MACRO (required) Prototype (required) Global declares Local declares Table

Table definitions TEXT (required) MEXIT

MEND (required) Definition Control Statement Format

A definition control statement can contain up to four entries: name, operation, operands, and remarks. Name, operation, and operands are position-dependent and must begin in positions 1, 10, and 16, respectively. The remarks entry can occur in any position following the operands if at least one blank separates it from the operands.

Macroinstruction Format

Symbol or Blank

The format of a macroinstruction follows:

Blank Before Remark (optional)

Label

If the label field on the macroinstruction contains a symbol, and if a symbolic parameter is used in the label field of the associated prototype statement, the symbolic parameter is assigned the value of the symbol in the macroinstruction.

(See Prototype in this chapter.)

If the label field on the macroinstruction contains a symbol, and if the label field of the associated prototype statement does not contain a symbolic parameter, the symbol is ignored.

If the label field on the macroinstruction is not used, and if a symbolic parameter is used in the label field of the associated prototype statement, the symbolic parameter is assigned a null value. The length of the label field is up to 8 bytes with blanks padded on the right.

Operation

The mnemonic operation code must be identical to the mnemonic operation code of the associated prototype statement.

Operand

The operand can contain either keyword or positional parameters, or both. The value assigned a keyword or positional parameter in a macroinstruction is assigned to the corresponding symbolic parameter defined in the associated prototype statement.

A symbolic parameter defined without a value in a prototype statement is assigned a null value with an undefined attribute, unless an operand referring to the corresponding keyword or positional parameter is used in the associated macroinstruction.

A keyword parameter defined with a value in a prototype statement retains the assigned value, unless an operand containing the corresponding keyword appears in the associated macroinstruction.

The keyword parameters can be written in any order; however, positional

parameters must be in the sequence specified on the prototype statement and must occur before any keyword parameters.

Chapter 4.Creating Macroinstructions 4-11

PROGRAM

Keyword Parameter 'Operands: Each keyword operand.must consist of a keyword immediately followed by a dash, immediately followed by the value assigned to the keyword.

Each keyword in the operand must correspond to one of the symbolic parameters in the operand of the associated prototype statement. However, each symboiic parameter in the associated prototype record does not require a corresponding keyword in the macroinstruction. A keyword corresponds to a symbolic parameter when the characters in the keyword are identical to the characters following the ampersand in the symbolic parameter.

Positional Parameter Operands: A positional parameter operand corresponds to a keyword value; that is, just the value is given, not the keyword. Conimas in succession indicate the omission of positional parameters and the assignment of null value. An example of a macroinstruction statement and its relationship to the prototype definition control statement follows:

I

TYPING GRAPHIC

I I

Macroinstruction Statement

\

Prototype

&DATlis assigned YES by the macroinstruction.

&DAT2 is assigned null value by omission.

&DAT3 is assigned 8 by prototype default.

&DAT 4 is assigned 12 by the macroinstruction.

Dans le document Information When (Page 122-126)

Documents relatifs