A *term* is the smallest element that the assembler parser can recognize when processing an expression. Each term has a value and a type. An expression is formed by one or more terms. The assembler evaluates each expression into a single value, and uses that value as an operand. Each expression also has a type. If an expression is formed by one term, the expression has the same type as the type of the term. If an expression consists of more than one term, the type is determined by the expression handler according to certain rules applied to all the types of terms contained in the expression. Expression types are important because:

- Some pseudo-ops and instructions require expressions with a particular type.
- Only certain operators are allowed in certain types of expressions.

AIX 4.3 adds an additional aspect to assemly language expressions:
that of the object mode and relocation vs. the size of the data
value being calculated. In 32-bit mode, relocation is applied
to 32-bit quantities; expressions resulting in a requirement for
relocation (for example, a reference to an external symbol)
can not have their value stored in any storage area other than
a word. As the 4.3 assembler has added the **.llong**
pseudo-op, it is worthwhile to point out that expressions used
to initialize the contents of a .llong may not require relocation.
In 64-bit mode, relocation is applied to double-word quantities. Thus,
expression results that require relocation can not have their
value stored in a location smaller than a double-word.

Arithmetic evaluations of expressions in 32-bit mode is consistent with the behavior found in prior releases of the assembler. Integer constants are considered to be 32-bit quantities, and the calculations are 32-bit calculations. In 64-bit mode constants are 64-bit values, and expressions are evaluated using 64-bit calculations.

The following is a list of all the types of terms and an abbreviated name for each type:

- Absolute (
`E_ABS`) - Relocatable (
`E_REL`) - External relocatable (
`E_EXT`) - TOC-relative relocatable (
`E_TREL`) - TOCOF relocatable (
`E_TOCOF`)

A term is absolute if its value does not change upon program relocation. In other words, a term is absolute if its value is independent of any possible code relocation operation.

An absolute term is one of the following items:

- A constant (including all the kinds of constants defined in "Constants").
- A symbol set to an absolute expression.

The value of an absolute term is the constant value.

A term is relocatable if its value changes upon program relocation. The value of a relocatable term depends on the location of the control section containing it. If the control section moves to a different storage location (for example, a csect is relocated by the binder at bind time), the value of the relocatable term changes accordingly.

A relocatable term is one of the following items:

- A label defined within a csect that does not have TD or TC as its Storage Mapping Class (SMC)
- A symbol set to a relocatable expression
- A label defined within a dsect
- A dsect name
- A location counter reference (which uses $
**,**the dollar sign)

If it is not used as a displacement for a D-form instruction, the value of a csect label or a location counter reference is its relocatable address, which is the sum of the containing csect address and the offset relative to the containing csect. If it is used as a displacement for a D-form instruction, the assembler implicitly subtracts the containing csect address so that only the the offset is used for the displacement. A csect address is the offset relative to the beginning of the first csect of the file.

A dsect is a reference control section that allows you to describe the layout of data in a storage area without actually reserving any storage. A dsect provides a symbolic format that is empty of data. The assembler does assign location counter values to the labels that are defined in a dsect. The values are the offsets relative to the beginning of the dsect. The data in a dsect at run time can be referenced symbolically by using the labels defined in a dsect.

Relocatable terms based on a dsect location counter (either the dsect name or dsect labels) are meaningful only in the context of a **.using** statement. Since this is the only way to associate a base address with a dsect, the addressability of the dsect is established in combination with the storage area.

A relocatable term may be based on any control section, either csect or dsect, in all the contexts except if it is used as a relocatable address constant. If a csect label is used as an address constant, it represents a relocatable address, and its value is the offset relative to the csect plus the address of the csect. A dsect label cannot be used as a relocatable address constant since a dsect is only a data template and has no address.

If two dsect labels are defined in the same dsect, their difference can be used as an absolute address constant.

A term is external relocatable (`E_EXT`
) if it is an external symbol (a symbol not defined, but declared within the current module, or defined in the current module and globally visible), a csect name, or a TOC entry name.

This term is relocatable because its value will change if it, or its containing control section, is relocated.

An external relocatable term or expression cannot be used as the operand of a **.set** pseudo-op.

An external relocatable term is one of the following items:

- A symbol defined with the
**.comm**pseudo-op - A symbol defined with the
**.lcomm**pseudo-op - A csect name
- A symbol declared with the
**.globl**pseudo-op - A TOC entry name
- An undefined symbol declared with the
**.extern**pseudo-op

Except for the undefined symbol, if this term is not used as a displacement for a D-form instruction, its value is its relocatable address, which is the offset relative to the begining of the first csect in the file. If it is used as a displacement for a D-form instruction, the assembler implicitly subtracts the containing csect address (except for a TOC entry name), usually producing a zero displacement because the csect address is subtracted from itself. If a TOC entry name is used as a displacement for a D-form instruction, the assembler implicitly subtracts the address of the TOC anchor, so the offset relative to the TOC anchor is the displacement.

An undefined symbol cannot be used as a displacement for a D-form instruction. In other cases, its value is zero.

A term is TOC-relative relocatable (`E_TREL`
) if it is a label contained within the TOC.

This type of term is relocatable since its value will change if the TOC is relocated.

A TOC-relative relocatable term is one of the following items:

- A label on a
**.tc**pseudo-op - A label defined within a csect that has TD or TC as its storage mapping class.

If this term is not used as a displacement for a D-form instruction, its value is its relocatable addresss, which is the sum of the offset relative to the TOC and the TOC anchor address. If it is used as a displacement for a D-form instruction, the assembler implicitly subtracts the TOC anchor address, so the offset relative to the TOC anchor is the displacement.

A term has TOCOF relocatable (`E_TOCOF`
) type if it is the first operand of a **.tocof** pseudo-op.

This type of term has a value of zero. It cannot be used as a displacement for a D-form instruction. It cannot participate in any arithmetic operation.

Expressions can have all the types that terms can have. An expression with only one term has the same type as its term. Expressions can also have restricted external relocatable (`E_REXT`
) type, which a term cannot have because this type requires at least two terms.

An expression has restricted external relocatable (`E_REXT`
) type if it contains two relocatable terms that are defined in different control sections (terms not meeting the requirements for *paired relocatable terms*, as defined in "Expression Type of Combined Expressions") and have opposite signs.

The following are examples of combinations of relocatable terms that produce an expression with restricted external relocatable type:

`<E_EXT> - <E_EXT>``<E_REL> - <E_REL>``<E_TREL> - <E_TREL>``<E_EXT> - <E_REL>``<E_REL> - <E_EXT>``<E_EXT> - <E_TREL>``<E_TREL> - <E_REL>`The value assigned to an expression of this type is based on the results of the assembler arithmetic evaluation of the values of its terms. When participating in an arithmetic operation, the value of a term is its relocatable address.

Terms within an expression can be combined with binary operators. Also, a term can begin with one or more unary operators. The assembler expression handler evaluates and determines the resultant expression type, value, and relocation table entries.

The following rules apply when calculating a value:

- If it is participating in an arithmetic operation, the value of an absolute term is its constant value, and the value of a relocatable term (
`E_EXT`,`E_REL`, or`E_TREL`) is its relocatable address. - If the resultant expression is used as a displacement in a D-form instruction, the assembler implicitly subtracts the containing csect address from the final result for expressions of type
`E_EXT`or`E_REL`, or subtracts the TOC anchor address for expressions of type`E_TREL`. There is no implicit subtracting for expressions with`E_ABS`or`E_REXT`type.

The assembler applies the following rules when determining the requirements for object file relocation table entries for an exression.

- When an expression is used in a data definition, TOC entry definition, or a branch target address, it may require from zero to two relocation table entries (RLDs) depending on the resultant type of the expression.
`E_ABS`requires zero relocation entries.`E_REL`requires one relocation entry, except that a dsect name or a dsect label does not require a relocation entry.`E_EXT`requires one relocation entry`E_REXT`requires two relocation entries`E_TREL`requires one relocation entry`E_TOCOF`requires one relocation entry

- When an expression is used as a displacement within a D-form instruction operand, only
`E_TREL`and`E_REXT`expressions have relocation entries. They each require one relocation entry.

The assembler applies the following rules when determining the type of a combined expression.

The following operators belong to group #1:

Operators in group #1 have the following rules:

`<E_ABS> <op1> <E_ABS> ==> E_ABS`- Applying an operator in group #1 to any type of expression other than an absolute expression produces an error.

The following operators belong to group # 2:

Operators in group # 2 have the following rules:

- <
`E_ABS`> <`op2`> <`E_ABS`> ==>`E_ABS` - <
`E_ABS`> <`op2`> <`E_REXT`> ==>`E_REXT` - <
`E_REXT`> <`op2`> <`E_ABS`> ==>`E_REXT` - <
`E_ABS`> <`op2`> <`E_TOCOF`> ==> an error - <
`E_TOCOF`> <`op2`> <`E_ABS`> ==> an error - <non
`E_ABS`> <`op2`> <`E_REXT`> ==> an error - <
`E_REXT`> <`op2`> < non`E_ABS`> ==> an error - <
`E_ABS`> - <`E_TREL`> ==> an error - Unary
**+**and**-**are treated the same as the binary operators with absolute value 0 (zero) as the left term. - Other situations where one of the terms is not an absolute expression require more complex rules.

The following definitions will be used in later discussion:

The main difference between opposite terms and paired relocatable terms is that paired relocatable terms do not have to point to the same table entry, although they must be defined in the same section.

In the following example `L1`
and `-L1`
are opposite terms ; and `L1`
and `-L2`
are paired relocatable terms.

.file "f1.s" .csect Dummy[PR] L1: ai 10, 20, 30 L2: ai 11, 21, 30 br .csect A[RW] .long L1 - L1 .long L1 - L2

The following table shows rules for determining the type of complex combined expressions:

Type |
Conditions for Expression to have Type |
Relocation Table Entries |

E_ABS |
All the terms of the expression are paired relocatable terms, opposite terms, and absolute terms. | An RLD with type R_REF is generated for each opposite term. |

E_REXT |
The expression contains two unpaired relocatable terms with opposite signs in addition to all the paired relocatable terms, opposite terms, and absolute terms. | Two RLDs, one with a type of R_POS and one with a type of R_NEG, are generated for the unpaired relocatable terms. In addition, an RLD with a type of R_REF is generated for each opposite term. |

E_REL
, E_EXT |
The expression contains only one unpaired E_REL
or E_RXT
term in addition to all the paired relocatable terms, opposite terms, and absolute terms. |
If the expression is used in a data definition, one RLD with type R_POS or R_NEG will be generated. In addition, an RLD with type R_REF is generated for each opposite term. |

E_TREL |
The expression contains only one unpaired E_TREL
term in addition to all the paired relocatable terms, opposite terms, and absolute terms. |
If the expression is used as a displacement in a D-form instruction, one RLD with type R_TOC will be generated, otherwise one RLD with type R_POS or R_NEG will be generated. In addition, an RLD with type R_REF is generated for each opposite term. |

Error | If the expression contains more than two unpaired relocatable terms, or it contains two unpaired relocatable terms with the same sign, an error is reported. |

The following example illustrates the preceding table:

.file "f1.s" .csect A[PR] L1: ai 10, 20, 30 L2: ai 10, 20, 30 EL1: l 10, 20(20) .extern EL1 .extern EL2 EL2: l 10, 20(20) .csect B[PR] BL1: l 10, 20(20) BL2: l 10, 20(20) ba 16 + EL2 - L2 + L1 # Result is E_REL l 10, 16+EL2-L2+L1(20) # No RLD .csect C[RW] BL3: .long BL2 - B[PR] # Result is E_ABS .long BL2 - (L1 - L1) # Result is E_REL .long 14-(-EL2+BL1) + BL1 - (L2-L1) # Result is E_REL .long 14 + EL2 - BL1 - L2 + L1 # Result is E_REL .long (B[PR] -A[PR]) + 32 # Result is E_REXT

The **atof** subroutine.

The **.comm** pseudo-op, **.csect** pseudo-op, **.double** pseudo-op, **.dsect** pseudo-op, **.float** pseudo-op, **.lcomm** pseudo-op, **.tc** pseudo-op, **.toc** pseudo-op, **.tocof** pseudo-op.