• Keine Ergebnisse gefunden

BALR USING

CONTROL SECTIONS

The concept of program sectioning is a consideration at coding time, assembly time, and load time. To the programmer, a program is a logical unit. He may want to divide it into sections called control sections; if

so, he writes it in such a way that control passes properly from one section to another regardless of the relative physical position of the sections in storage. A control section is a block of coding that can be relocated, independently of other coding, at load time without altering or impairing the operating logic of the program. It is normally identified by the CSECT instruction. However, if it is desired to specify a tentative starting location, the START instruction may be used to identify the first control section.

To the assembler, there is no such thing as a program; instead, there is an assembly, which consists of one or more control sections. (However, the terms assembly and program are often used interchangeably.) An unsectioned program is treated as a single control section. To the linkage editor, there are no programs, only control sections that must be fashioned into a load module.

The output from the assembler is called an object module. It contains data required for linkage editor processing. The external symbol dictionary, which is part of the object module, contains information the

linkage editor needs in order to complete cross-referenclng between control sections as it combines them into an object program. The linkage editor can take control sections from various assemblies and combine them properly with the help of the corresponding control dictionaries. Successful

combination of separately assembled control sections depends on the techniques used to provide symbolic linkages between the control sections.

Whether the programmer writes an unsectioned program, a multisection program, or part of a multisection program, he still knows what eventually will be entered into storage because he has described storage symbolically.

He may not know where each section appears in storage, but he does know what storage contains. There is no constant relationship between control sections. Thus, knowing the location of one control section does not make another control section addressable by relative addressing techniques.

The programmer must be aware that there is a limit to external symbol dictionary entries. The total number of control sections, dummy sections, unique symbols in EXTRN and WXTRN statements, V-type address constants, and external dummy sections must not exceed 255. Certain constants may cause a symbol to be counted twice: e.g., external symbols in V-type address

constants (unless they are explicitly defined in an EXTRN or WXTRN statement), and external dummy sections implicitly defined by Q-type address constants and corresponding DSECT statements. EXTRN and WXTRN statements are described in this section; V-type and Q-type constants in Section 5 under "Operand Subfield 4: Constant."

3-7

Control Section Location Assignment

Control sections can be intermixed because the assembler provides a location counter for each control section. Locations are assigned to control sections as if the sections are placed in storage consecutively, in the same order as they first occur in the program. Each control section subsequent to the first begins at the next available double-word boundary.

FIRST CONTROL SECTION

The first control section of a program has the following special properties:

I. Its initial location counter value may be specified as an absolute value, if the START instruction is used.

. It contains the literals of the program, unless their positioning has been altered by LTORG statements.

START -- Start Assembly

The START instruction may be used to give a name to the first (or only) control section of a program. It may also be used to specify an initial location counter value for the first control section of the program. The format of the START instruction statement is as follows:

Name Any

symbol or blank

Operation START

Operand

A self-defining term, or blank

If a symbol names the START instruction, the symbol is established as the name of the control section. If not, the control section is considered to be unnamed. All subsequent statements are assembled as part of that control section. This continues until a CSECT instruction identifying a different control section or a DSECT instruction is encountered. A CSECT instruction named by the same symbol that names a START instruction is considered to identify the continuation of the control section first identified by the START. Similarly, an unnamed CSECT that occurs in a program initiated by an unnamed START is considered to identify the continuation of the unnamed control section.

The symbol in the name field is a valid relocatable symbol whose value represents the address of the first byte of the control section. It has a

length attribute of i.

q

The assembler uses the self-definlng term specified by the operand as the initial location counter value of the Program. This value should be divisible by eight. For example, either of the following statements could be used to assign the name PROG2 to the first control section and to

indicate an initial assembly location counter value of 2040. If the operand is omitted, the assembler sets the initial location counter value of the program at zero. The location counter is set at the next doubleword boundary when the value of the START operand is not divisible by eight.

Name Operation Operand

PROG2 START 2040

PROG2 START X'7F8'

Note: The START instruction must not be preceded by any code that will cause an unnamed control section to be assembled. (See "Unnamed First Control Section" below.)

CSECT -- Identify Control Section

The CSECT instruction identifies the beginning or the continuation of a control section. The format of the CSECT instruction statement is as follows:

Name Any

symbol or blank

Operation CSECT

Operand

Not used; should be blank

If a symbol names the CSECT instruction, the symbol is established as the name of the control section; otherwise the section is considered to be unnamed. All statements following the CSECT are assembled as part of that control section until a statement identifying a different control section is encountered (i.e., another CSECT or a DSECT instruction).

The symbol in the name field is a valid relocatable symbol whose value represents the address of the first byte of the control section. It has a

length attribute of i.

Several CSECT statements with the same name may appear within a program. The first is considered to identify the beginning of the control

section; the rest identify the resumption of the section. Thus, statements from different control sections may be interspersed. They are properly assembled (aSsigned contiguous storage locations) as long as the statements

3-9

from the various control sections are identified by the appropriate CSECT instructions.

Unnamed First Control Section

All machine instructions and many assembler instructions have to belong to a control section. If such an instruction precedes the first

CSECT instruction, the assembler will consider it to belong to an unnamed control section (also referred to as private code), which will be the first

(or only) control section in the module.

The following instructions will not cause this to happen, since they do not have to belong to a control section:

Common Control Sections Dummy Con£rol Sections Macro Definitions

Conditional Assembly Instructions Comments

COPY (depends on the copied code) DXD

EJECT ENTRY EXTRN ICTL ISEQ OPSYN PRINT PUNCH REPRO SPACE TITLE WXTRN

No other assembler or machine instructions can precede instruction, since START, if used, must initiate the first control in the program.

a START section

An involuntary unnamed control section at the beginning can cause trouble if literals are used. Then the programmer must be aware of the fact, that unless he codes an LTORG statement in each control section where he uses literals, literals will be assembled in the first control section, which will in this case be the involuntary section. If that control

section does not establish addressability (through USING), an

addressability error will be the result. Therefore statements like EQU should not be placed before the first CSECT or the START instruction.

Resumption of an unnamed control section at later points can be accomplished through unnamed CSECT statements. A program can contain only one unnamed control section. Of course, it is possible to write a program

that does not contain CSECT or START statements. It will then be assembled as one unnamed control section.

DSECT -- Identlfy Dummy Section

A dummy section represents a control section that is assembled but is not part of the object program. A dummy section is a convenient means of describing the layout of an area of storage without actually reserving the storage. (It is assumed that the storage is reserved either by some other part of this assembly or else by another assembly.) The DSECT instruction identifies the beginning or resumption of a dummy section. More than one dummy section may be defined per assembly, but each must be named. The format of the DSECT instruction statement is as follows:

Name Operation Operand

DSECT A

vari-able symbol or ordinary

symbol

Not used; should be blank

The symbol in the name field is a valid relocatable symbol whose value represents the first byte of the section. It has a length attribute of i.

Program statements belonging to dummy sections may be interspersed throughout the program or may be written as a unit. In either case, the appropriate DSECT instruction should precede each set of statements. When multiple DSECT instructions with the same name are encountered, the first is considered to initiate the dummy section and the rest to continue it.

All assembler language instructions may occur within dummy sections.

Symbols that name statements in a dmmmy section may be used in USING instructions. Therefore, they may be used in program elements (e.g., machlne-lnstructlons and data definitions) that specify storage addresses.

An example illustrating the use of a dummy section appears subsequently under "Addressing Dummy Sections."

Note___._! Symbols that name statements in a dummy section may be used in A-type address constants only when they are paired with another symbol from the same dummy section in an absolute expression. (See "Absolute and Relocatable Expressions", Section 2.) For example, if X and B name statements in the same dummy section, C DC A(B-X) would be valid, but C DC A(X) would be Invalld--yielding a relocatability error.

DUMMY SECTION LOCATION ASSIGNMENT: A location counter is used to determine the relative locations of named program elements in a dummy section. The location counter is always set to zero at the beginning of the dummy

3-11

section, and the location values assigned to symbols that name statements