comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Not intended for use in medical devices
Date: 1997/05/07
Date: 1997-05-07T00:00:00+00:00	[thread overview]
Message-ID: <dewar.863006367@merv> (raw)
In-Reply-To: 5kn99d$jje@top.mitre.org


Michael Brenner says

<<   (1) computers are now finally fast enough to do source code rewriting
       as part of the optimization, and SHOULD

   (2) hardware devices should almost always be connected to software
       via memory boards, not registers or ports>>


I really have no idea what (1) might mean. It is of course the case that
many significant optimizations cannot be represented at the source level
(e.g. register allocation, instruction scheduling), so I really do not know
what this is about.

As for (2), I don't see that. Indeed memory mapped I/O devices are tricky.
Ada programmers in particular are tempted to speak to memory mapped I/O
devices by using address clauses, and this almost always results in subtly
non-portable code that is making unjustified assumptions.

For example, one of our large customers porting a big program wrote

    type x is array (1 .. 32) of Boolean;
    pragma Pack (x);

    vx : x;
    for vx use at .... 

    ...

    m := vx(3);

and was most distressed that the compiler issued a byte read for the
appropriate byte, rather than a word read, as required by their hardware
(which did not recognize a byte read, and blew up).

For another delicate example of the dangers of memory mapped access.
Consider running the above program using old Alsys technology. Well

a reference to vx(3) would work fine (doing a read just of that byte or
word), but if you do

   m : boolean renames vx(3);

now m is stored as a dynamic bit address, and an access to me will result
in reading bytes surrounding the original four bytes -- perfectly valid
Ada (though not very efficient), but of course disastrous in this context.

Robert Dewar
Ada Core Technologies





  parent reply	other threads:[~1997-05-07  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-04  0:00 Not intended for use in medical devices Robert C. Leif, Ph.D.
1997-05-05  0:00 ` Kaz Kylheku
1997-05-06  0:00   ` Robert Dewar
1997-05-06  0:00     ` Kaz Kylheku
1997-05-12  0:00     ` Ken Garlington
1997-05-06  0:00 ` Michael F Brenner
1997-05-06  0:00   ` Kaz Kylheku
1997-05-07  0:00   ` Robert Dewar [this message]
1997-05-08  0:00     ` Matthew Heaney
1997-05-10  0:00       ` Robert Dewar
1997-05-14  0:00         ` Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
1997-05-03  0:00 Robert C. Leif, Ph.D.
1997-05-03  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