HP Pascal/iX Programmer's Guide (31502-90023)
5-: 7
Column-major order:
The HP Pascal packing algorithm uses this formula to allocate an array:
number_of_elements
*
space_for_one_element
The
space_for_one_element
depends upon the array element type and whether
the array is unpacked, packed, or crunched. The same factors determine
element alignment. See the tables indicated below:
If the array is: See: In the section:
Unpacked Table 5-1 "Unpacked Variables"
Packed Table 5-3 "Packed Arrays"
Crunched Table 5-5 "Crunched Arrays and
Records"
Records
A record allocation is the sum of the allocations of the fields in the
fixed part and (if the record has them) the allocations of the tag field
and the largest field in the variant part, plus trailing bits.
Field allocation depends on field type and whether the record is
unpacked, packed, or crunched. The same factors determine field
alignment. See the tables indicated below:
If the array is: See: In the section:
Unpacked Table 5-1 "Unpacked Variables"
Packed Table 5-4 "Packed Records"
Crunched Table 5-5 "Crunched Arrays and
Records"
The HP Pascal packing algorithm uses these two rules to align a record:
* The entire record is aligned on the same boundary as its most
restricted field.
* The variant part of a record is aligned on the same boundary as
the most restricted first field of all variants.
Example
TYPE
Rec = RECORD
CASE b : Boolean OF
TRUE : (c : char; {1 byte, 1-byte-aligned}
l : longreal; {8 bytes, 8-byte-aligned}
);
FALSE : (i : integer; {4 bytes, 4-byte-aligned}
);
END;