pTAL Conversion Guide

Arrays
pTAL Conversion Guide527302-002
9-2
Constant Lists in Array Declarations
Constant Lists in Array Declarations
pTAL introduces two requirements for array declarations, as follows:
If an array declaration includes an initialization string, the number of bits in the
array and in the initialization string must be equal.
If the alignment of the elements of the initialization string under SHARED2 rules
and SHARED8 rules is different, you must specify a FIELDALIGN clause in the
initialization string.
pTAL rules for initializing arrays are more restrictive than TAL rules. In pTAL, the
number of bits in a constant list you assign to an array must be the same as the
number of bits in the array. Read-only arrays, however, do not have a declared length
and, therefore, have slightly different rules.
Topics:
Read-Only Arrays on page 9-2
Nonstring Arrays on page 9-3
Read-Only Arrays
TAL
You can assign any constant string to any read-only array.
pTAL
The number of bits in the initialization string must equal the number of bits in the
read-only array.
If the read-only-array declaration does not specify array bounds, the number of bits
in the initialization string must be an integral multiple of the number of bits in the
array’s base type.
Example 9-2. Constant Lists in Read-Only Array Declarations
(pTAL) (page1of2)
Invalid:
string u[0:3] = 'P' := [1,2,3]; ! ERROR: Initialization size
! (24 bits) must equal
! array size (32 bits)
int x = 'P' := "abc"; ! ERROR: Initialization size
! must be integral multiple
! of array’s base type size