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


Fixed-point constants—F and H

HLASM Language Reference
SC26-4940-06

Fixed-point constants let you introduce data that is in a form suitable for the arithmetic operations of the binary fixed-point machine instructions. The constants you define can also be automatically aligned to the correct doubleword, fullword, or halfword boundary for the instructions that refer to addresses on these boundaries (unless the NOALIGN option has been specified; see General information about constants). You can do algebraic operations using this type of constant because they can have positive or negative values.

A fixed-point constant is written as a decimal number, which can be followed by a decimal exponent. The format of the constant is as follows:
  1. The nominal value can be a signed or unsigned (see  1  in Table 1) integer, fraction, or mixed number (see  2  Table 1) followed by a signed exponent (see  3  in Table 1). If a sign is not specified for either the number or exponent, + is assumed. To generate unsigned data, precede the numeric value with the letter U; signs are not allowed.
  2. The exponent must lie within the permissible range (see  4  in Table 1). If an exponent modifier is also specified, the algebraic sum (see  5  in Table 1) of the exponent and the exponent modifier must lie within the permissible range.

Here are some examples of the range of values that can be assembled into fixed-point constants:

Length Range of signed values that can be assembled Range of unsigned values that can be assembled
8 -263 to 263-1 0 to 264-1
4 -231 to 231-1 0 to 232-1
2 -215 to 215-1 0 to 216-1
1 -27 to 27-1 0 to 28-1

The range of values depends on the implicitly or explicitly specified length (if scaling is disregarded). If the value specified for a particular constant does not lie within the allowable range for a given length, the constant is not assembled, but flagged as an error.

A fixed-point constant is assembled as follows:
  1. The specified number, multiplied by any exponents, is converted to a binary number.
  2. Scaling is done, if specified. If a scale modifier is not provided, the fractional portion of the number is lost.
  3. The binary value is rounded, if necessary. The resulting number does not differ from the exact number specified by more than one in the least significant bit position at the right.
  4. A negative number is carried in two's-complement form.
  5. Duplication is applied after the constant has been assembled.
The example statement generates 3 fullwords of data. The location attribute of CONWRD is the address of the first byte of the first word, and the length attribute is 4, the implied length for a fullword fixed-point constant. The expression CONWRD+4 can be used to address the second constant (second word) in the field.
CONWRD   DC              3F'658474'
Table 1. Fixed-point constants
Subfield Value Example Result
1. Duplication factor Allowed    
2. Type F and H    
3. Type Extension D permitted with type F    
       
4. Program type Allowed    

5. Modifiers
   Implicit length:
   (length modifier
   not present)

 
Doubleword: 8 bytes
Fullword: 4 bytes
Halfword: 2 bytes

   

   Alignment:
   (Length modifier
   not present)

Doubleword,
fullword,
or halfword

   

Range for length:

1 to 8
(byte length)
 
.1 to .64
(bit length)

   

Range for scale:

F:  -187 to +346
H:  -187 to +346

   
Range for exponent: -85 to +75  4  DC HE+75'2E-73'  5  value=2x10²

6. Nominal value
   Represented by:

 
Decimal
digits
(0 to 9)

 
Doubleword
DC  FD'-200'  1 
DC  FD'U7890123456'
 
Fullword
DC  FS4'2.25'  2 
DC  FS4'U2.25'
 
Halfword:
DC  H'+200'
DC  HS4'.25'
DC  H'U200'
DC  HS4'U0.25'

 
Enclosed by: Apostrophes    

Exponent allowed:

Yes

Doubleword:
DC  FD'2E6'
DC  FD'U2E6'
 
Fullword:
DC  F'2E6'  3 
DC  F'U2E6'
 
Halfword:
DC  H'2E+1'
DC  H'U2E+1'

 

   Number of values
   per operand:

Multiple

   
Padding: With sign bits at left    

   Truncation of
   assembled value:

At left
(error message
issued)

   
In the following example, the DC statement generates a 2 byte field containing a negative constant. Scaling has been specified in order to reserve 6 bits for the fractional portion of the constant.
HALFCON  DC              HS6'-25.46'
In the following example, the constant (3.50) is multiplied by 10 to the power -2 before being converted to its binary format. The scale modifier reserves 12 bits for the fractional portion.
FULLCON  DC              HS12'3.50E-2'
The same constant can be specified as a literal:
         AH              7,=HS12'3.50E-2'
The final example specifies three constants. The scale modifier requests 4 bits for the fractional portion of each constant. The 4 bits are provided whether or not the fraction exists.
THREECON DC              FS4'-10,25.3,U268435455'
Remember that commas separate operands. For readability, use spaces instead, as shown in this example:
TWOCONS  DC              F'123,445'            Two constants
ONECON   DC              F'123 456'            One constant

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014