comp.lang.ada
 help / color / mirror / Atom feed
From: okellogg@cube.net (Oliver Kellogg)
Subject: Re: Fortran's Equivalence
Date: 1997/03/28
Date: 1997-03-28T00:00:00+00:00	[thread overview]
Message-ID: <5hhg7q$9ra$1@salyko.cube.net> (raw)
In-Reply-To: 5hbcdn$i1h@top.mitre.org


Michael F Brenner (mfb@mbunix.mitre.org) wrote:
> [...]                         The portability problem comes in because
> the Ada-95 manual did not standardize a bit numbering in the word, nor
> does it standardize a pragma to tell which bit is zero in a portable
> manner. 

Portability is nevertheless not impossible, just more difficult to
achieve. For porting code between a host computer and a 1750A target, we
wrote following package:

-- package Bitranges, 1750A version

with System;

package Bitranges is    -- MIL-STD-1750A version

  Unit : constant := System.Storage_Unit;

  subtype Bit_00_00 is Natural range 15..15;
  subtype Bit_00_01 is Natural range 14..15;
  subtype Bit_00_02 is Natural range 13..15;
  subtype Bit_00_03 is Natural range 12..15;
  subtype Bit_00_04 is Natural range 11..15;
  subtype Bit_00_05 is Natural range 10..15;
  subtype Bit_00_06 is Natural range 09..15;
  subtype Bit_00_07 is Natural range 08..15;
  subtype Bit_00_08 is Natural range 07..15;
  subtype Bit_00_09 is Natural range 06..15;
  subtype Bit_00_10 is Natural range 05..15;
  subtype Bit_00_11 is Natural range 04..15;
  subtype Bit_00_12 is Natural range 03..15;
  subtype Bit_00_13 is Natural range 02..15;
  subtype Bit_00_14 is Natural range 01..15;
  subtype Bit_00_15 is Natural range 00..15;

  subtype Bit_01_01 is Natural range 14..14;
  subtype Bit_01_02 is Natural range 13..14;
  subtype Bit_01_03 is Natural range 12..14;
  subtype Bit_01_04 is Natural range 11..14;
  [...]
  subtype Bit_01_14 is Natural range 01..14;
  subtype Bit_01_15 is Natural range 00..14;

  subtype Bit_02_02 is Natural range 13..13;
  subtype Bit_02_03 is Natural range 12..13;
  [...]
  subtype Bit_02_15 is Natural range 00..13;

  [...]

  subtype Bit_14_14 is Natural range 01..01;
  subtype Bit_14_15 is Natural range 00..01;

  subtype Bit_15_15 is Natural range 00..00;

end Bitranges;


-- Package bitranges spec, host computer version

with System;

package Bitranges is    -- host computer native version

  Unit : constant := System.Storage_Unit;

  subtype Bit_00_00 is Natural range 00..00;
  subtype Bit_00_01 is Natural range 00..01;
  subtype Bit_00_02 is Natural range 00..02;

  [...]

  subtype Bit_15_15 is Natural range 15..15;

end Bitranges;


-- Representation clauses must then be written e.g. as follows:

with Bitranges;  use Bitranges;

package Example is

  type My_Rec is record
    A : Short_Integer;
    B : Short_Integer;
  end My_Rec;

  for My_Rec use record
    A  at 0*Unit range Bit_00_01'first..Bit_00_01'last;
    B  at 0*Unit range Bit_02_15'first..Bit_02_15'last;
  end record;

end Example;






  parent reply	other threads:[~1997-03-28  0:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-25  0:00 Fortran's Equivalence Viqar Abbasi
1997-03-26  0:00 ` Michael F Brenner
1997-03-26  0:00   ` Larry Kilgallen
1997-03-28  0:00   ` Oliver Kellogg [this message]
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-04-01  0:00       ` Keith Thompson
1997-04-01  0:00         ` Robert Dewar
1997-04-01  0:00           ` Robert A Duff
1997-04-01  0:00             ` Robert Dewar
1997-04-04  0:00           ` Keith Thompson
1997-04-04  0:00             ` Robert Dewar
1997-04-07  0:00               ` Keith Thompson
1997-04-07  0:00               ` Charles H. Sampson
1997-04-07  0:00               ` Viqar Abbasi
1997-04-08  0:00                 ` Charles H. Sampson
1997-04-08  0:00                   ` Matthew Heaney
1997-04-09  0:00                     ` Stephen Leake
1997-04-09  0:00                       ` Robert Dewar
1997-04-10  0:00                         ` Simon Wright
1997-04-10  0:00                           ` Robert Dewar
1997-04-08  0:00                   ` Robert Dewar
     [not found]                     ` <1997Apr15.163103.27481@nosc.mil>
1997-04-16  0:00                       ` Robert Dewar
1997-04-04  0:00             ` Keith Thompson
1997-04-04  0:00               ` Robert Dewar
1997-04-08  0:00                 ` Keith Thompson
1997-04-07  0:00             ` Charles H. Sampson
1997-03-29  0:00     ` Robert Dewar
1997-03-26  0:00 ` Tom Moran
1997-03-26  0:00 ` FORTRAN's Equivalence Nick Roberts
1997-03-26  0:00 ` Fortran's Equivalence Robert Dewar
1997-03-26  0:00   ` Robert A Duff
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-04-02  0:00       ` JP Thornley
1997-03-28  0:00 ` Charles H. Sampson
1997-03-29  0:00   ` Matthew Heaney
1997-04-01  0:00     ` Charles H. Sampson
1997-03-29  0:00 ` Matthew Heaney
1997-03-29  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox