Re:
>
> Change TYPE SMALL_INTEGER = -32767..32767;
> to TYPE SINGLE_INTEGER = -32767..32767;
>
> Remove TYPE LARGE_INTEGER = INTEGER;
>
> Replace SMALL_INTEGER
> with SHORTINT
Problems/notes about the above:
1) in both CM and NM, that lower bound ought to be -32768,
not -32767.
2) why not just remove "SMALL_INTEGER" (instead of changing
it), since you're removing uses of it?
BTW, here's an example of how negative lower bounds can foul you up
(as in: TYPE SINGLE_INTEGER = -32767..32767;), coupled with
a mean compiler bug:
$STANDARD_LEVEL 'EXT_MODCAL'$
program test (output);
type
single_integer = -32767..32767;
var
i_single : single_integer;
i_single_arr : array [1..2] of single_integer;
begin
writeln ('');
writeln ('Sizeof (integer) = ', sizeof (integer):1);
writeln ('Sizeof (shortint) = ', sizeof (shortint):1);
writeln ('Sizeof (single_integer) = ', sizeof (single_integer):1);
writeln ('Sizeof (i_single) = ', sizeof (i_single):1);
writeln ('Sizeof (i_single_arr) = ', sizeof (i_single_arr):1);
end.
sample output:
Sizeof (integer) = 4
Sizeof (shortint) = 2
Sizeof (single_integer) = 2
Sizeof (i_single) = 4
Sizeof (i_single_arr) = 8
Note that ***EXTREMELY*** misleading and, IMHO, incorrect result
of "sizeof (single_integer). I lost a lot of time due to that bug!
You can see that a negative lower bound causes the variable to truly
take 4 bytes by looking at the result of "sizeof (i_single)", or by
looking at the size/packing of arrays/records using single_integer.
Note that if you compile with "$HP3000_16$", the compiler works
correctly, and the last two "Sizeof" lines come out as 2 and 4.
(Ok, HP, *you* can try to claim the default NM operation is
correct, but if it looks like a duck, and quacks like a duck... :)
> The PAUSE intrinsic cannot be called directly from a program which
> contains the compiler directive $H3000_16$. The work-around
> is to change the procedure declaration for PAUSE as follows:
> { PROCEDURE PAUSE; INTRINSIC; }
> PROCEDURE PAUSE $ALIAS 'em_pause'$(VAR r: real);
> EXTERNAL;
Good note!
The reason that's needed is that $hp3000_16$ tells Pascal/iX to
use Classic floating point for "real" and "longreal". The NM PAUSE
intrinsic is expecting IEEE floating point, hence the problem.
Cecile's solution is to call "em_pause", an NM routine that expects
Classic floating point values instead of IEEE values.
Note: I'm puzzled...I'd have said you would have to add:
$literal_alias on$
but a quick test shows that wasn't needed.
A second test implies that the "$standard_level 'ext_modcal'$
does an implied $literal_alias on$
The moral:
When I write a program, I generally include code like the
following at the start of my primary initialization routine:
{Sample type-size checking code}
var
i : integer;
...
i := sizeof (shortint);
if i <> hex ('2') then
die (3, 'Internal coding error: shortint is ' +
num32 (i) + ' bytes, expected 2');
(Of course, I usually replace "shortint" and "2" with
other type names (e.g., dbinfo_202_type and 34.)
In other words, checking the sizes of types that *have*
to match an expected layout is dirt cheap, and pays off
tremendously! Just remember the Pascal bug...for non-records,
non-arrays, you may be better off doing sizeof(var) (where
"var" is a variable of the desired type) than doing sizeof(typename).
thanks,
Stan
Stan Sieler [log in to unmask]
www.allegro.com/sieler/wanted/index.html www.allegro.com/sieler
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|