home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / packitin.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  3.0 KB  |  105 lines

  1.                                        -- Chapter 30 - Program 3
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure PackItIn is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    type LITTLE1 is range 1..57;
  11.  
  12.    type LITTLE_REC1 is 
  13.       record
  14.          A,B,C : LITTLE1;
  15.       end record;
  16.  
  17.    type LIST1 is array(1..5) of LITTLE_REC1;
  18.  
  19.    type LITTLE2 is range 1..57;
  20.  
  21.    type LITTLE_REC2 is
  22.       record
  23.          A,B,C : LITTLE2;
  24.       end record;
  25.    pragma PACK(LITTLE_REC2);
  26.  
  27.    type LIST2 is array(1..5) of LITTLE_REC2;
  28.    pragma PACK(LIST2);
  29.  
  30.    type LITTLE3 is range 1..57;
  31.    for LITTLE3'SIZE use 8;
  32.  
  33.    type LITTLE_REC3 is 
  34.       record
  35.          A,B,C : LITTLE3;
  36.       end record;
  37.    pragma PACK(LITTLE_REC3);
  38.  
  39.    type LIST3 is array(1..5) of LITTLE_REC3;
  40.    pragma PACK(LIST3);
  41.  
  42. begin
  43.    Put("Type LITTLE1 uses     ");
  44.    Put(LITTLE1'SIZE);
  45.    Put_Line(" bits for its representation.");
  46.  
  47.    Put("Type LITTLE_REC1 uses ");
  48.    Put(LITTLE_REC1'SIZE);
  49.    Put_Line(" bits for its representation.");
  50.  
  51.    Put("Type LIST1 uses       ");
  52.    Put(LIST1'SIZE);
  53.    Put_Line(" bits for its representation.");
  54.  
  55.    Put("Type LITTLE2 uses     ");
  56.    Put(LITTLE2'SIZE);
  57.    Put_Line(" bits for its representation.");
  58.  
  59.    Put("Type LITTLE_REC2 uses ");
  60.    Put(LITTLE_REC2'SIZE);
  61.    Put_Line(" bits for its representation.");
  62.  
  63.    Put("Type LIST2 uses       ");
  64.    Put(LIST2'SIZE);
  65.    Put_Line(" bits for its representation.");
  66.  
  67.    Put("Type LITTLE3 uses     ");
  68.    Put(LITTLE3'SIZE);
  69.    Put_Line(" bits for its representation.");
  70.  
  71.    Put("Type LITTLE_REC3 uses ");
  72.    Put(LITTLE_REC3'SIZE);
  73.    Put_Line(" bits for its representation.");
  74.  
  75.    Put("Type LIST3 uses       ");
  76.    Put(LIST3'SIZE);
  77.    Put_Line(" bits for its representation.");
  78.  
  79. end PackItIn;
  80.  
  81. -- Result of execution, Compiler 1. (Did not support Line 31)
  82.  
  83. -- Type LITTLE1 uses         16 bits for its representation.
  84. -- Type LITTLE_REC1 uses     48 bits for its representation.
  85. -- Type LIST1 uses          240 bits for its representation.
  86. -- Type LITTLE2 uses         16 bits for its representation.
  87. -- Type LITTLE_REC2 uses     32 bits for its representation.
  88. -- Type LIST2 uses          160 bits for its representation.
  89. -- Type LITTLE3 uses         16 bits for its representation.
  90. -- Type LITTLE_REC3 uses     32 bits for its representation.
  91. -- Type LIST3 uses          160 bits for its representation.
  92.  
  93. -- Result of execution, Compiler 2. (Did not support Line 31)
  94.  
  95. -- Type LITTLE1 uses         16 bits for its representation.
  96. -- Type LITTLE_REC1 uses     48 bits for its representation.
  97. -- Type LIST1 uses          240 bits for its representation.
  98. -- Type LITTLE2 uses         16 bits for its representation.
  99. -- Type LITTLE_REC2 uses     48 bits for its representation.
  100. -- Type LIST2 uses          240 bits for its representation.
  101. -- Type LITTLE3 uses         16 bits for its representation.
  102. -- Type LITTLE_REC3 uses     48 bits for its representation.
  103. -- Type LIST3 uses          240 bits for its representation.
  104.  
  105.