• Aucun résultat trouvé

Terms Term Can Be Value Is

symbols

A term is the smallest element of the assembler language that represents a distinct and separate value. It can, therefore, be used alone or in combination with other terms to form

expressions. Terms are classified as absolute or relocatable"

depending on the effect of program relocation upon them.

Program relocation is the loading of the object program into storage locations other than those originally assigned by the assembler. Terms have absolute or relocatable values that are assigned by the assembler or that are inherent in the terms themselves.

A term is absolute if its value does not change upon program relocation, and is relocatable if its value changes upon relocation. Figure 8 summarizes the various types of terms.

The following text discusses each term and the rules for its use.

Terms Term Can Be Value Is

Absolute Relocatable Assigned by Inherent in Assembler Term

Symbols X X X

Location

Counter X X

Reference Symbol

Length X X

Attribute

Other Data X X

Attributes

Self-Defining X X

Terms

Figure 8. Summary of Terms

You can use a symbol to represent storage locations or arbitrary values. If you write a symbol in the name field of an

instruction, you can then specify this symbol in the operands of other instructions and thus refer to the former instruction symbolically. This symbol represents a relocatable 'address.

You can also assign an absolute value to a symbol by coding it in the name field of an EQU instruction with an operand whose

Chapter 2. Coding and Structure 21

value is absolute. This allows you to use this symbol in instruction operands to re.present registers, displacements in explicit addresses, immediate data, lengths, and implicit addresses with absolute values. For details of these program elements, see "Operand Entries" on page 72.

The advantages of symbolic over numeric representation are:

1. Symbols are easier to remember and use than numeric values, thus reducing programming errors and increasing programming efficiency.

2. You cah use meaningful symbols to describe the program

elements they represent; for example, INPUT can name a field that is to contain input data, or INDEX can name a register to be used for indexing.

3. You can change the value of one symbol (through an EQU

instruction) more easily than you can change several numeric values in many instructions.

4. Symbols are entered into a cross-reference table that the assembler prints in the program listing. This table helps you to find a symbol in a program listing, because it lists

(a) the number of the statement in which the symbol is defined, that is, used as the name entry, and (b) the

numbers of all the statements in which the symbol is used in the operands.

SYMBOL TABLE: The assembler maintains an internal table called a symbol table. When the assembler processes your source

statements for the first time, it assigns an absolute or

relocatable value to every symbol that appears in the name field of an instruction. The assembler enters this value, which

normally reflects the setting of the location counter, into the symbol table; it also enters the attributes associated with the data represented by the symbol. The values of the symbol and its attributes are available later when the assembler finds this symbol or attribute reference used as a term in an operand or expression. ~ee "Symbol length Attribute Reference" and

"Self-Defining Terms" in this chapter for more details. The three types of symbols recognized by the assembler are:

• Ordinary symbols

• Variable symbols

• Sequence symbols

Ordinary symbols can be used in the name and operand fields of machine and assembler instruction statements. They must be coded to conform to these rules:

1. The symbol must not consist of more than 63 alphameric characters. The first character must be an alphabetic character (A through Z, $, I, or ~). The other characters may be alphabetic characters, digits, or a combination of the two.

2. No special characters may be included in an ordinary symbol.

3. No blanks are allowed in an ordinary symbol.

4. An underscore character is allowed, with the restrictions listed below.

22 Assembler H Version 2 Application Programming: Language Reference

o

c

o

character and, optionally, up to 61 alphameric characters.

Variable symbols can only be used in macro processing and

conditional assembly instructions. They allow different values to be assigned to one symbol. A complete discussion of variable alphabetic character, and up to 61 additional alphameric characters. Sequence symbols can be used only in macro

processing and conditional assembly instructions. They are used to indicate the position of statements within the source program or macro definition. Through their use, you can vary the

sequence in which statements are processed by the assembler program. (See the compl~te discussion in "Chapter 9. How to Write Conditional Assembly Instructions.")

The following are valid symbols:

.BlABEl04

.BRAHCHTOMEFIRST .1359

.A

SYMBOL DEFINITION: An ordinary symbol is considered defined when it appears as:

• The name entry in a machine or assembler instruction of the assembler language

• One of the operands of an EXTRH or WXTRN instruction

Note:

Ordinary symbols that appear in instructions generated from model statements at preassembly time are also considered defined.

Chapter 2. Coding and Structure 23

In Figure 9, the assembler assigns a value to the ordinary symbol in the name fields as follows:

1. According to the address of the leftmost byte of the storage field that contains one of the following:

a. (See (1) in Figure 9.) Any machine or assembler instruction (except the EQU or OPSYN instruction)

b. (See (2) in Figure 9.) A storage area defined by the DS instruction

c. (See (3) in Figure 9.) Any constant defined by the DC instruction

d. A channel command word defined by the CCW, CCWO, or CCW1 instruction

The address value thus assigned is relocatable, because the object code assembled from these items is relocatablei the relocatability of addresses is describad "Addresses" on page 74.

Assembler Language Statements

Address Value of Symbol

Object Code in Hexadecimal

LOAD

AREA

F200

FULL