--  Unchecked_Conversion between two record layouts, field by field from the bits each
--  overlaps (D196: no number wider than a field), and a bit field passed in out.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Conversion;
procedure Main is
   type Nibbles is record
      Lo, Hi : Integer range 0 .. 15;
   end record with Size => 8;
   for Nibbles use record
      Lo at 0 range 0 .. 3;
      Hi at 0 range 4 .. 7;
   end record;
   type Swapped is record
      A, B : Integer range 0 .. 15;
   end record with Size => 8;
   for Swapped use record
      A at 0 range 4 .. 7;
      B at 0 range 0 .. 3;
   end record;
   function Swap is new Ada.Unchecked_Conversion (Nibbles, Swapped);
   procedure Bump (X : in out Integer) with Pre => X < 15 is
   begin
      X := X + 1;
   end Bump;
   N : Nibbles := (Lo => 3, Hi => 9);
   S : Swapped;
begin
   S := Swap (N);
   Bump (N.Lo);
   Put_Line (Integer'Image (S.A) & Integer'Image (S.B) & Integer'Image (N.Lo) & Integer'Image (N.Hi));
end Main;
