You specify the DC instruction to define the data constants you
need for program execution. The DC instruction causes the assembler
to generate the binary representation of the data constant you specify
into a particular location in the assembled source module; this is
done at assembly time.
The DC instruction's name — Define Constant — is
misleading: DC simply creates initial data in an area of the program.
The contents of that area might be modified during program execution,
so the original data is not truly "constant". If you want to
declare values that are more likely to behave like constants, use
literals (Literals); the assembler attempts to detect and
diagnose instructions that might change the contents of a field defined
by a literal. If a control section has not been established previously,
DC initiates an unnamed (private) control section.
The DC instruction can generate the following types of constants:
Table 1. Types of data constantsType of Constant |
Function |
Example |
---|
Address |
Defines address mainly for the use of fixed-point and other
instructions |
L 5,ADCON
ADCON DC A(SOMWHERE)
|
Binary |
Defines bit patterns |
FLAG DC B'00010000'
|
Character |
Defines character strings or messages |
CHAR DC C'string of characters'
|
Decimal |
Used by decimal instructions |
ZAP AREA,PCON
PCON DC P'100'
AREA DS PL3
|
Fixed-point |
Used by the fixed-point and other instructions |
L 3,FCON
FCON DC F'100'
|
Floating-point |
Used by floating-point instructions |
LE 2,ECON
ECON DC E'100.50'
|
Graphic |
Defines character strings or messages that contain pure double-byte
data |
DBCS DC G'<.D.B.C.S. .S.T.R.I.N.G>'
|
Hexadecimal |
Defines large bit patterns |
PATTERN DC X'FF00FF00'
|
Zoned |
Defines numeric characters |
ZONEVVAL DC Z'-123'
|
.-,-------.
V |
>>-+--------+--DC----operand-+---------------------------------><
'-symbol-'
- symbol
- Is one of the following:
- An ordinary symbol
- A variable symbol that has been assigned a character string with
a value that is valid for an ordinary symbol
- A sequence symbol
If symbol denotes an ordinary
symbol, the ordinary symbol represents the address of the first byte
of the assembled constant. If several operands are specified, the
first constant defined is addressable by the ordinary symbol. The
other constants can be reached by relative addressing.
- operands
- An operand of six subfields. The first five subfields describe
the constant. The sixth subfield provides the nominal values for
the constants.
A DC operand has this format:
>>-+--------------------+--type--+----------------+------------->
'-duplication_factor-' '-type_extension-'
>--+--------------+--+----------+--nominal_value---------------><
'-program_type-' '-modifier-'
- duplication_factor
- Causes the nominal_value to be generated the number
of times indicated by this factor. See Subfield 1: Duplication Factor.
- type
- Further determines the type of constant the nominal_value represents.
See Subfield 2: Type.
- type_extension
- Determines some of the characteristics of the constant. See Subfield 3: Type Extension.
- program_type
- assign a programmer determined 32
bit value to the symbol naming the DC instruction, if a symbol was
present. See Subfield 4: Program type.
- modifier
- Describes the length, the scaling, and the exponent of the nominal_value. See Subfield 5: Modifier.
- nominal_value
- Defines the value of the constant. See Subfield 6: Nominal Value.
For example, in:
10EBP(7)L2'12'
the six subfields are:
- Duplication factor is 10
- Type is E
- Type extension is B
- Program type is P(7)
- Modifier is L2
- Nominal value is 12
If all subfields are specified,
the order given above is required. The first, third, fourth, and fifth
subfields can be omitted, but the second and sixth must be specified
in that order.