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


Introducing Built-In Functions

HLASM Language Reference
SC26-4940-06

The assembler provides built-in functions for the SETA, SETB, and SETC expressions.

Each function returns one value - an arithmetic value for SETA, a binary bit for SETB, and a character string for SETC.

There are two different forms of invocation for the built-in functions:
  • The logical-expression format encloses the function and operands in parentheses. In the unary format, the function is followed by the one operand. In the binary format, the function is placed between the two operands. For both unary and binary formats, the function is separated from the operand or operands by spaces.
    Read syntax diagramSkip visual syntax diagram
    Logical-expression unary format
    
    >>-(built-in_function--operand)--------------------------------><
    
    
    Read syntax diagramSkip visual syntax diagram
    Logical-expression binary format
    
    >>-(operand--built-in_function--operand)-----------------------><
    
    

    (A OR B) and (&J SLL 2) are examples of binary logical-expression format functions, and (NOT C) and (SIGNED &J) are examples of unary logical-expression format functions.

  • The function-invocation format has the function first, followed by one or more operands in parentheses.
    Read syntax diagramSkip visual syntax diagram
    Function-invocation format
    
    >>-built-in_function(operand-+----------------+-)--------------><
                                 | .------------. |     
                                 | V            | |     
                                 '---,--operand-+-'     
    
    

    FIND('abcde','d') is an example of a function-invocation format. (The equivalent logical-expression format is ('abcde' FIND 'd').)

    Spaces are not allowed between the arguments of functions in function-invocation format.

In either format, the operand is an expression of the type expected by the built-in function. (The particular details of the number of operands and the operand type are provided with the information for each built-in function.)

Conditional-assembly functions do not always behave like functions in traditional high-level languages. The results of a function might not be automatically converted to the type expected in the invoking expression, and nested invocations might not produce expected results. In general, it is safest to invoke only one conditional assembly function in a SET expression or AIF statement.

Some functions are available in one format, some are available in both. Table 1, which provides a summary of all the built-in functions, shows the forms in which a function is available.

Because some function names such as AND and OR are used both as arithmetic operators and as logical connectives, their use might appear to be ambiguous. For example, the function (1 AND 2) in an arithmetic expression is interpreted as the logical AND of the two 32 bit SETA expressions 1 and 2, resulting in zero. In a logical expression, the two nonzero operands are converted to 1 (meaning "true") and the result is 1. Similarly, the function (1 XOR 2) in an arithmetic expression has value 3, while in a logical expression it has value 0.

To avoid ambiguities, such function names are interpreted as arithmetic operators in SETA statements, and as logical operators in SETB and AIF statements.

Table 1. Summary of Built-In Functions and Operators
Function Type L-E¹ F-I² Result³ Operands³ Topic
A2B Representation conversion   X C A Character-valued built-in functions
A2C Representation conversion   X C A Character-valued built-in functions
A2D Representation conversion   X C A Character-valued built-in functions
A2X Representation conversion   X C A Character-valued built-in functions
AND Logical X   A A Arithmetic (SETA) expressions
AND Logical X   B B Logical (SETB) expressions
AND NOT Logical X   B B Logical (SETB) expressions
B2A Representation conversion   X A C Arithmetic (SETA) expressions
B2C⁴ Representation conversion   X C C Character-valued built-in functions
B2D Representation conversion   X C C Character-valued built-in functions
B2X⁴ Representation conversion   X C C Character-valued built-in functions
BYTE Representation conversion X X C A Character-valued built-in functions
C2A Representation conversion   X A C Arithmetic (SETA) expressions
C2B⁴ Representation conversion   X C C Character-valued built-in functions
C2D Representation conversion   X C C Character-valued built-in functions
C2X⁴ Representation conversion   X C C Character-valued built-in functions
D2A Representation conversion   X A C Arithmetic (SETA) expressions
D2B Representation conversion   X C C Character-valued built-in functions
D2C Representation conversion   X C C Character-valued built-in functions
D2X Representation conversion   X C C Character-valued built-in functions
DCLEN String manipulation   X A C Arithmetic (SETA) expressions
DCVAL String manipulation   X C C Character-valued built-in functions
DEQUOTE String manipulation   X C C Character-valued built-in functions
DOUBLE String manipulation X X C C Character-valued built-in functions
FIND String scanning X X A C Arithmetic (SETA) expressions
INDEX String scanning X X A C Arithmetic (SETA) expressions
ISBIN Validity checking   X B C Arithmetic (SETA) expressions
ISDEC Validity checking   X B C Arithmetic (SETA) expressions
ISHEX Validity checking   X B C Arithmetic (SETA) expressions
ISSYM Validity checking   X B C Arithmetic (SETA) expressions
LOWER String manipulation X X C C Character-valued built-in functions
NOT Logical X X A A Arithmetic (SETA) expressions
NOT Logical X   B B Logical (SETB) expressions
OR Logical X   A A Arithmetic (SETA) expressions
OR Logical X   B B Logical (SETB) expressions
OR NOT Logical X   B B Logical (SETB) expressions
SIGNED Representation conversion X X C A Character-valued built-in functions
SLA Shift X   A A Arithmetic (SETA) expressions
SLL Shift X   A A Arithmetic (SETA) expressions
SRA Shift X   A A Arithmetic (SETA) expressions
SRL Shift X   A A Arithmetic (SETA) expressions
SYSATTRA Information retrieval   X C C Character-valued built-in functions
SYSATTRP Information retrieval   X C C Character-valued built-in functions
UPPER String manipulation X X C C Character-valued built-in functions
X2A Representation conversion   X A C Arithmetic (SETA) expressions
X2B⁴ Representation conversion   X C C Character-valued built-in functions
X2C⁴ Representation conversion   X C C Character-valued built-in functions
X2D Representation conversion   X C C Character-valued built-in functions
XOR Logical X   A A Arithmetic (SETA) expressions
XOR Logical X   B B Logical (SETB) expressions
XOR NOT Logical X   B B Logical (SETB) expressions
Notes:
  1. If a X is in this column, the function is available in the "logical-expression" format.
  2. If a X is in this column, the function is available in the "function-invocation" format.
  3. Possible values in these columns are:
    A
    Arithmetic
    B
    Binary
    C
    Character
  4. For these functions, the maximum length of the operand (and output) is the maximum string length that the assembler supports, currently 1024.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014