HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Character constant—C

HLASM Language Reference
SC26-4940-06

The character constant specifies character strings, such as error messages, identifiers, or other text, that the assembler converts into binary representations. If no type extension is provided, then the constant might be changed, depending on the value of the TRANSLATE option. If the type extension of "E" is provided, then the representation is also EBCDIC, but it cannot be changed by the TRANSLATE option. For information about type extension "A" see ASCII data in character constants, and for information about type extension "U" see Unicode UTF-16 data from character constants.

Any of the 256 characters from the EBCDIC character set can be designated in a character constant. Each character specified in the nominal value subfield is assembled into one byte (see  1  in Table 1). For more information, see the discussion about the 82 invariant characters in Character self-defining term.

A null nominal value is permitted if a length is specified. For example:
         DC              CL3''
is assembled as three EBCDIC spaces with object code X'404040', whereas
         DC              CAL3''
is assembled as three ASCII spaces with object code X'202020'.
Multiple nominal values are not allowed because a comma in the nominal value is considered a valid character (see  2  in Table 1) and is assembled into its binary (EBCDIC) representation (see Standard character set code table). For example:
         DC              C'A,B'
is assembled as A,B with object code X'C16BC2'.

Give special consideration to representing apostrophes and ampersands as characters. Each apostrophe or ampersand you want as a character in the constant must be represented by a pair of apostrophes or ampersands. Each pair of apostrophes is assembled as one apostrophe, and each pair of ampersands is assembled as one ampersand (see  3  in Table 1).

Table 1. Character constants
Subfield Value Example Result
1. Duplication factor Allowed    
2. Type C    

3. Type Extension

U
A
E

U  DC  CU'UNICODE'
A  DC  CA'ASCII'
E  DC  CE'EBCDIC'
L'U = 14
L'A = 5
L'E = 6
4. Program type Allowed    
5. Modifiers

Implicit length:    
(length modifier
  not present)

Evaluate as an even
number, if Type
Extension of U is
specified

 
C  DC  C'LENGTH'
 
L'C = 6   1 
Alignment: Byte    
Range for length:

1 to 256
(byte length)
 
Must be a multiple
of 2 when the
Type Extension is U
 
.1 to .2048
(bit length)
(Not permitted
if Type Extension
of U is specified.)

   
Range for scale: Not allowed    
Range for exponent: Not allowed    

6. Nominal value
   Represented by:

 
Characters
(all 256 eight bit
combinations)

 
DC C'A''B'
DC CU'AA'
DC CA'AB'

Object code
X'C17DC2'  3 
X'00410041'
X'4142'

Enclosed by: Apostrophes    
Exponent allowed: No (is interpreted as character data)    

   Number of values
   per operand:

One

DC C'A,B'

Object code
X'C16BC2' 2 

Padding: With spaces at right (X'40' EBCDIC, X'20' ASCII)    

   Truncation of
   assembled value:

At right

   
In the following example, the length attribute of FIELD is 12:
FIELD    DC              C'TOTAL IS 110'
However, in this next example, the length attribute is 15, and three spaces appear in storage to the right of the zero:
FIELD    DC              CL15'TOTAL IS 110'
In the next example, the length attribute of FIELD is 12, although 13 characters appear in the operand. The two ampersands are paired, and so count as only one byte.
FIELD    DC              C'TOTAL IS &&10'
In the next example, a length of 4 has been specified, but there are five characters in the constant.
FIELD    DC              3CL4'ABCDE'
The generated constant is:
ABCDABCDABCD
The same constant can be specified as a literal.
         MVC             AREA(12),=3CL4'ABCDE'
On the other hand, if the length modifier is specified as 6 instead of 4, the generated constant is:
ABCDE ABCDE ABCDE (with one trailing space)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014