HP Pascal/iX Reference Manual (31502-90022)

11- 10
| -134217728..-67108865 | 67108864..134217727 | 28 |
| -268435456..-134217729 | 134217728..268435455 | 29 |
| -536870912..-268435457 | 268435456..536870911 | 30 |
| -1073741824..-536870913 | 536870912..1073741823 | 31 |
| -2147483648..-1073741825 | 1073741824..2147483647 | 32 |
| | | |
----------------------------------------------------------------------------------------------
Example
TYPE
cr1_t = CRUNCHED RECORD
f1 : 0..15; { takes 4 bits }
f2 : -1..15; { takes 5 bits }
f3 : -16..15; { takes 5 bits }
f4 : 13..15; { takes 4 bits }
END; { total: 18 bits }
cr2_t = CRUNCHED RECORD
f1 : CRUNCHED set of 0..15; { takes 16 bits }
f2 : CRUNCHED set of 13..15; { takes 3 bits }
f3 : CRUNCHED set of -5..5; { takes 11 bits }
END; { total: 30 bits }
cr3_t = CRUNCHED RECORD
f1 : integer; { takes 32 bits }
CASE tag : Boolean OF { takes 1 bit }
true: ( v1 : cr1_t ); { takes 18 bits }
false:( v2 : cr2_t ); { takes 30 bits }
END; { total: 63 bits }
The restrictions that apply to packed types also apply to crunched types.
In particular, it is illegal:
* To pass a component of a crunched structure as a reference
parameter.
* To take the address of a component of a crunched structure.
In addition:
* File types cannot be crunched.
* Structured types that contain file, real, longreal, string, or
pointer types cannot be crunched.
* All structured types contained in a crunched structured type must
also be crunched.
* All integer based types and enumeration based types are
represented with the most significant bit first through least
significant bit last. Byte swapping is not permitted.
Pointer Types
In HP Pascal,
pointers
are designators that point only to a
specific
class of objects
, namely
objects on the heap
.
When using the system programming extensions, pointers can point to any
data; that is, objects on the heap, as well as global and local
variables. In this sense pointers truly are addresses.
In HP Pascal, the only way to create a pointer is by calling the
predefined procedure NEW or the intrinsic getheap to dynamically allocate
a heap object. In order to create pointers, the system programming
extensions define the addr function that returns the address of its
argument, and the functions buildpointer and addtopointer that perform
address arithmetic.
There are three predefined pointer types defined in the system
programming extensions that allow relaxed type checking of pointers.
These are anyptr, localanyptr, and globalanyptr.
Short and Long Pointers.
The system programming extensions define two classes of pointers:
short