Character constant—C

The character constant specifies character strings, such as error messages, identifiers, or other text, that the assembler converts into binary representations.

The type extension specifies the character encoding; "E" for EBCDIC encoding, "A" for ASCII encoding, and "U" for Unicode UTF-16 encoding. For example, with EBCDIC encoding the character A assembles to hexadecimal C1; with ASCII encoding the character A assembles to hexadecimal 41, with UTF-8 encoding the character A assembles to hexadecimal 0041. When the type extension is omitted, the TRANSLATE option (see High Level Assembler Programmer's Guide) specifies the character encoding. The TRANSLATE option defaults to EBCDIC. 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. For example:
         DC              C'A,B'
is assembled as A,B with object code X'C16BC2'.
For a description of the binary and hexadecimal representations of the characters that make up the standard character set, refer to the web page “Coded Character Set Reference Material”, which is located at:
http://www.ibm.com/software/globalization/g11n-res.html 

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      

   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.)

   

      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    

   Scale:

Not allowed    

   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)