Introducing Built-In Functions

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.

    Logical-expression unary format

    Read syntax diagramSkip visual syntax diagram( built-in_functionoperand )

    Logical-expression binary format

    Read syntax diagramSkip visual syntax diagram(operandbuilt-in_functionoperand)

    (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.

    Function-invocation format

    Read syntax diagramSkip visual syntax diagrambuilt-in_function( operand,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-E1 F-I2 Result3 Operands3 Topic
A2B Representation conversion   X C A A2B
A2C Representation conversion   X C A A2C
A2D Representation conversion   X C A A2D
A2X Representation conversion   X C A A2X
AND Logical X   A A AND
AND Logical X   B B AND
AND NOT Logical X   B B AND NOT
B2A Representation conversion   X A C B2A
B2C4 Representation conversion   X C C B2C
B2D Representation conversion   X C C B2D
B2X4 Representation conversion   X C C B2X
BYTE Representation conversion X X C A BYTE
C2A Representation conversion   X A C C2A
C2B4 Representation conversion   X C C C2B
C2D Representation conversion   X C C C2D
C2X4 Representation conversion   X C C C2X
D2A Representation conversion   X A C D2A
D2B Representation conversion   X C C D2B
D2C Representation conversion   X C C D2C
D2X Representation conversion   X C C D2X
DCLEN String manipulation   X A C DCLEN
DCVAL String manipulation   X C C DCVAL
DEQUOTE String manipulation   X C C DEQUOTE
DOUBLE String manipulation X X C C DOUBLE
ESYM String manipulation   X C C ESYM
FIND String scanning X X A C FIND
INDEX String scanning X X A C INDEX
ISBIN Validity checking   X B C ISBIN
ISDEC Validity checking   X B C ISDEC
ISHEX Validity checking   X B C ISHEX
ISSYM Validity checking   X B C ISSYM
LOWER String manipulation X X C C LOWER
NOT Logical X X A A NOT
NOT Logical X   B B NOT
OR Logical X   A A OR
OR Logical X   B B OR
OR NOT Logical X   B B OR NOT
SIGNED Representation conversion X X C A SIGNED
SLA Shift X   A A SLA
SLL Shift X   A A SLL
SRA Shift X   A A SRA
SRL Shift X   A A SRL
SYSATTRA Information retrieval   X C C SYSATTRA
SYSATTRP Information retrieval   X C C SYSATTRP
UPPER String manipulation X X C C UPPER
X2A Representation conversion   X A C X2A
X2B4 Representation conversion   X C C X2B
X2C4 Representation conversion   X C C X2C
X2D Representation conversion   X C C X2D
XOR Logical X   A A XOR
XOR Logical X   B B XOR
XOR NOT Logical X   B B XOR NOT
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 refers to arithmetic.
    • B refers to binary.
    • C refers to character.
  4. For these functions, the maximum length of the operand (and output) is the maximum string length that the assembler supports, currently 4064.