28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Array<br />

Using <strong>Pascal</strong> with other languages<br />

Arrays are implemented in the obvious simple fashion, as contiguous linear<br />

sequences of elements, each of which will be aligned as the element type<br />

requires. It should be noted that, as for records, use of the keyword<br />

PACKED has no effect on the storage layout adopted for arrays.<br />

Multi-dimensional arrays are stored in order such that the elements of an<br />

array accessed by the two sets of subscripts [i 1,i2..ij] and [i 1,i2..ij + 1] are<br />

stored in adjacent memory locations. This is a consequence of the definition<br />

of multi-dimensional arrays in <strong>Pascal</strong>, i.e. ARRAY [T1; T2] OF T3 is<br />

defined to be the same as ARRAY [T1] OF ARRAY [T2] OF T3;<br />

Note<br />

32-bit single precision reals are not used in <strong>Pascal</strong>, and so there is no simple<br />

way to interface to a procecdure with parameter(s) or result(s) which are<br />

32-bit reals, unless such objects are not to be interpreted or modified by the<br />

<strong>Pascal</strong> code. In this case it is possible to treat the object simply as an<br />

integer, for purposes of assignment and parameter passing. However by<br />

using the facilities of extended <strong>Pascal</strong> to incorporate machine code in a<br />

program, such an object may be converted into a standard <strong>Pascal</strong> Real<br />

variable, and vice versa. This process is illustrated below:<br />

TYPE<br />

Real32 = Integer; {NB Cannot manipulate Real32's directly)<br />

FUNCTION RealOfReal32 (r: Real32): Real;<br />

VAR<br />

res: Real;<br />

BEGIN<br />

*MOVFL_r,res; (MOVe Floating (32-bit) to Long (64-bit))<br />

RealOfReal32 := res<br />

END;<br />

FUNCTION Real32OfReal (r: Real): Real32;<br />

VAR<br />

res: Real32;<br />

BEGIN<br />

[ NB the instruction below will fail (i.e. generate an I<br />

I exception) if r is too large to be represented as I<br />

<strong>Pascal</strong> Issue 1 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!