You can use literals as operands in order to introduce data into your program. The literal is a special type of relocatable term. It behaves like a symbol in that it represents data. However, it is a special kind of term because it also is used to define the constant specified by the literal. This is convenient because:

The assembler assembles the data item specified in a literal into a literal pool (See Literal pool). It then assembles the address of this literal data item in the pool into the object code of the instruction that contains the literal specification. Thus, the assembler saves you a programming step by storing your literal data for you. The assembler also organizes literal pools efficiently, so that the literal data is aligned on the correct boundary alignment and occupies a minimum amount of space.

Literals, constants, and self-defining terms

Literals, constants, and self-defining terms differ in three important ways:

Figure 9 shows examples of the differences between literals, constants, and self-defining terms.

Figure 9. Differences between literals, constants, and self-defining terms
  1. A literal with a relocatable address:
             L     3,=F'33'       Register 3 set to 33.  See note 1
             L     3,F33          Register 3 set to 33.  See note 2
    F33      DC    F'33'
  2. A literal with a self-defining term and a symbol with an absolute value
             MVC   FLAG,=X'00'    FLAG set to X'00'.  See note 1
             MVI   FLAG,X'00'     FLAG set to X'00'.  See note 3
             MVI   FLAG,ZERO      FLAG set to X'00'.  See note 4
    FLAG     DS    X
    ZERO     EQU   X'00'
  3. A symbol having an absolute address value specified by a self-defining term
             LA    4,LOCORE       Register 4 set to 1000.  See note 4
             LA    4,1000         Register 4 set to 1000.  See note 3
    LOCORE   EQU   1000
  1. A literal both defines data and represents data. The address of the literal is assembled into the object code of the instruction in which it is used. The constant specified by the literal is assembled into the object code, in the literal pool.
  2. A constant is represented by a symbol with a relocatable value. The address of a constant is assembled into the object code.
  3. A self-defining term has an absolute value. In this example, the absolute value of the self-defining term is assembled into the object code.
  4. A symbol with an absolute value does not represent the address of a constant, but represents either immediate data or an absolute address. When a symbol with an absolute value represents immediate data, it is the absolute value that is assembled into the object code.

General rules for using literals

You can specify a literal as either a complete operand in a machine instruction, or as part of an expression in the operand of a machine instruction. A literal can also be specified as the name field on a macro call instruction.

Because literals define read-only data, they must not be used in operands that represent the receiving field of an instruction that modifies storage.

The assembler requires a description of the type of literal being specified as well as the literal itself. This descriptive information assists the assembler in assembling the literal correctly. The descriptive portion of the literal must indicate the format of the constant. It can also specify the length of the constant.

The method of describing and specifying a constant as a literal is nearly identical to the method of specifying it in a single operand of a DC assembler instruction. The only difference is that the literal must start with an equal sign (=), which indicates to the assembler that a literal follows. The length of the literal, including the equal sign, constant type and modifiers, delimiters, and nominal values is limited to a maximum of 256 characters.

A literal may be coded as indicated here:


where the subfields are:

Duplication factor 10
Type                X
Modifiers          L5
Nominal value      'F3'

The following instruction shows one use of a literal:

GAMMA    L               10,=F'274'

The statement GAMMA is a load instruction using a literal as the second operand. When assembled, the second operand of the instruction refers to the relative address at which the value F'274' is stored.

You cannot rely on the ordering of literals in the literal pool remaining the same. For this reason, referring to a point that extends beyond the bounds of a literal is flagged with warning message ASMA015W. Here is an example of such a reference:

BETA     L               10,=F'274'+4

In general, literals can be used wherever a storage address is permitted as an operand, including in conjunction with an index register in instructions with the RX format. For example:

DELTA    LH              5,=H'11,23,39,48,64'(6)

is equivalent to:

DELTA    LH              5,LENGTHS(6)
LENGTHS  DC              H'11,23,39,48,64'

See DC instruction for a description of how to specify the subfields in a literal.

Literals cannot be used in any assembler instruction where a previously defined symbol is required, but length attribute references to previously defined literals are allowed. Literals are relocatable terms because the address of the literal, rather than the literal-generated constant itself, is assembled in the statement that references a literal. The assembler generates the literals, collects them, and places them in a specific area of storage, as explained under Literal pool. Because the assembler determines the order in which literals are placed in the literal pool, the effect of using two literals as paired relocatable terms (see Paired relocatable terms) is unpredictable.

Location counter reference describes how you can use the current location counter in a literal.

The rules for determining whether two literals are identical are:

  1. A literal which contains a location counter reference is not identical to any other literal.
  2. Otherwise, two literals are identical (and will be generated only once), if their source forms are identical.
Summary of literal rules
  1. S-type address constants may be used in literals.
  2. Location counter references (*) may be used in address constants.
  3. When not in a literal, * in an address constant refers to the first byte of the constant.
  4. When not in a literal, if an address constant containing * is duplicated, the value of * is updated for each duplication to refer to the address of that duplication.
  5. When a literal address constant contains *, each use of that literal is assigned a separate location in the literal pool.
  6. When a literal address constant contains *, the value used for * is the address of the (single) instruction in which the literal is used.
  7. When a literal address constant containing * also has a duplication factor, the value of * does not change for each duplication, but remains equal to the address if the first byte of the instruction in which the literal was used.
  8. When an S-type address constant is used in a literal, regardless of whether or not it contains *, the base register that is used to compute the base and displacement that are parts of the S-type address constant is determined by the USING statements that are in effect at the place that the literal is assembled, not the USING statements in effect at the place where the literal is referenced in an instruction. Note that there are two different base-displacement calculations: one in the instruction referring to the S-type address constant, and one in the S-type address constant to determine how to address the object of the constant.
Contrast with immediate data

You should not confuse a literal with the immediate data in an SI instruction. Immediate data is assembled into the instruction.

Literal pool

The literals processed by the assembler are collected and placed in a special area called the literal pool. You can control the positioning of the literal pool. Unless otherwise specified, the literal pool is placed at the end of the first control section.

You can also specify that multiple literal pools be created. However, the assembler controls the sequence in which literals are ordered within the pool. Further information on positioning literal pools is in LTORG instruction.

[ Top of Page | Previous Page | Next Page | Contents | Index ]