Organization: FidoNet node 1:106/2000.25 - COMM Port One, Sugar Land TX
Lines: 58
Andries Dippenaar (1:105/42) writes to All:
: >>>I need a DOS Modula-2 compiler that will pack subranges, for
: >>>example, [0..255] would be stored in 1 BYTE. The compiler
: >>>that I ues store it as an INTEGER.
>Most DOS compilers should -- for one I know that the TopSpeed
>compilers pack all data types into the smallest possible memory.
>You may select to override it here and there if you wish. I
>haven't got any experience with the Stony Brook compiler, but
>would expect nothing less of it.
As it happens, I left my the relevant Stony Brook manual at work. However, thanks to the wonders of OS/2, I can whip up a sample program right away.
This program:
MODULE PackTest;
FROM InOut IMPORT WriteCard, WriteString, WriteLn;
FROM SYSTEM IMPORT BYTE;
TYPE
SubRange = [0..255];
SubRangeArray = ARRAY SubRange OF SubRange;
VAR
Size : CARDINAL;
BEGIN
Size := SIZE(SubRange);
WriteString('The Size of the subrange [0..255] is ');
WriteCard(Size, 2);
WriteLn;
Size := SIZE(SubRangeArray);
WriteString('The size of an array [0..255] of that subrange is ');
WriteCard(Size, 2);
WriteLn;
Size := SIZE(BYTE);
WriteString('The Size of a byte is ');
WriteCard(Size, 2);
WriteLn
END PackTest.
When Compiled to an executable by SBM2 for OS/2 produces this output:
The Size of the subrange [0..255] is 2
The size of an array [0..255] of that subrange is 512
The Size of a byte is 1
I believe that I have selected all of the options properly. So, it appears that SBM2 does NOT pack small subranges into bytes even if there are arrays of those subrange values.