comp.lang.ada
 help / color / mirror / Atom feed
* Re: Why Ada is not the Commercial Lang of  Choice
@ 1997-06-18  0:00 Robert I. Eachus
  1997-06-18  0:00 ` Dale Stanbrough
                   ` (2 more replies)
  0 siblings, 3 replies; 61+ messages in thread
From: Robert I. Eachus @ 1997-06-18  0:00 UTC (permalink / raw)



Paul Van Bellinghen writes:
> 
> Claim:
> It is much easier in C, for example, to output a data word to
> an I/O device that is memory mapped.
> 
> Supporting Evidence:
> 1       One need only define a pointer
> 2       and assign it the memory mapped address
> 3       then store the desired data value to the contents of the pointer.
> 
> Example:
>  #define mem_map_addr B0100040
>  unsigned int *p;
> 
>  p = (unsigned int *) mem_map_addr;
> 
>  *p = 0x00344556;
> 
> Claim:
> It is harder to do it in Ada because i write it out in more words.

   Wait a second here.  The eqivalent Ada is:

   Mem_Map: Integer;
   for Mem_Map'Address use 16#B0100040#;
 begin
   Mem_Map := 16#00344556#;

   ...which is a little shorter in terms of characters, words, and
lines.  I could go into the bugs in both the Ada and the C--I'd want
pragma Volitile(Mem_Map); in both Ada and C.  Most compilers will get it
"right" but why take the risk.  Also, it might be necessary to call
System.Storage_Elements.To_Address, but I can't imagine any compiler for
a machine where 16#B01000040# is a meaningful address not allowing
literals for addresses.

-- 


                                               Robert I. Eachus

with Standard_Disclaimer;
use Standard_Disclaimer;




^ permalink raw reply	[flat|nested] 61+ messages in thread
* Why Ada is not the Commercial Lang of Choice
@ 1997-06-13  0:00 Paul Van Bellinghen
  1997-06-17  0:00 ` Dale Stanbrough
                   ` (4 more replies)
  0 siblings, 5 replies; 61+ messages in thread
From: Paul Van Bellinghen @ 1997-06-13  0:00 UTC (permalink / raw)



I've been a real-time embeded Software Engineer since 1975. I've used
assembly,Pascal & Fortran (not in real-time), C, and now Ada. I think
that there are basicly two reasons why Ada did not replace C as the
real-time embeded language of choice - in the commercial world and
recently in the military. 

1. Ada is not and never was a programmer's language. It was never
meant to be. It was imposed upon companies that the DOD contracts in
an effort  to create more reliable (i.e. bug free) products. They saw
how much time and money was spent in fixing problems after a system
was delivered and operational in the field. It is excessivly
type-casted and cumbersome to use.

2. Ada is realy a high level language. C is more intermediate level.
This makes C more well suited to real-time embedded systems that are
really electronic products that use microprocessors to control
electronic devices in a functional manner. It is much easier in C, for
example, to output a data word to an I/O device that is memory mapped.
One need only define a pointer and assign it the memory mapped
address, then store the desired data value to the contents of the
pointer.

#define mem_map_addr B0100040
unsigned int *p;

p = (unsigned int *) mem_map_addr;

*p = 0x00344556;


In Ada you can either define P to be an access variable of type
unsigned interger (if this type is defined in your compiler as mod
2**32 for example) and assign it the address or else, if you know the
exact address you want to assign it, define it as type address (from
machine types) and just assign it the desired address to it (for p use
at B0100040, etc..) and then assign it the data value. 

This is not so bad. However, now try to perform some manipulation on
the address value. Suppose you had to mask off the lower 48 bits of
the address to get the start of the memory sector, as I had to do
recently.

in C:

unsigned int *sector 
 sector = (unsigned int *) ((unsigned int) p & 0xFF000000);

notice the easy way you can re-cast variables.

In Ada, I had to define sector as an access variable of type
internal_address which was defined as unsigned integer (mod 2**32)
within the appropriate range of memory values. I defined p to be of
type internal_address, not of type address since address type has no
operations associated with it in machine_types (I probably could have
defined these myself, I guess). I needed an unchecked conversion
function to convert type address (I was stuck with this type since I
was implementing my own version of a procedure (that input address
types) to write to EEPROM memory in a target debug monitor) to
internal_address. After converting the memory address to
internal_address via the unchecked conversion function, I was then
able to mask off the lower 48 bits (I originally used a logical "and"
function but switched to using the V_I_BITS package to keep it
compatable with Ada 83). Now I was able to assign sector address the
resulting internal_address value of the sector.








^ permalink raw reply	[flat|nested] 61+ messages in thread

end of thread, other threads:[~1997-07-22  0:00 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-18  0:00 Why Ada is not the Commercial Lang of Choice Robert I. Eachus
1997-06-18  0:00 ` Dale Stanbrough
1997-06-19  0:00   ` Steve Jones - JON
1997-06-19  0:00     ` Anonymous
1997-06-19  0:00     ` Peter Hermann
1997-07-17  0:00     ` Shmuel (Seymour J.) Metz
1997-06-19  0:00   ` Robert A Duff
1997-06-21  0:00     ` Paul Van Bellinghen
1997-06-20  0:00       ` Robert Dewar
1997-06-23  0:00         ` John G. Volan
1997-07-03  0:00           ` Shmuel (Seymour J.) Metz
1997-07-03  0:00             ` Robert Dewar
1997-07-06  0:00               ` Yasmiin S. Davis
1997-07-06  0:00                 ` Robert Dewar
1997-07-07  0:00               ` Shmuel (Seymour J.) Metz
1997-07-04  0:00             ` Paul Van Bellinghen
1997-07-13  0:00               ` Ken Mays
1997-07-13  0:00                 ` Robert Munck
1997-07-14  0:00                   ` Ken Mays
1997-06-20  0:00   ` Don Harrison
1997-06-20  0:00     ` Larry Kilgallen
1997-06-20  0:00       ` Nick Leaton
1997-06-23  0:00       ` Don Harrison
1997-06-24  0:00         ` Bertrand Meyer
1997-06-24  0:00           ` Nick Leaton
1997-07-22  0:00           ` Dr. Vladimir Il'ich Fomin
1997-06-20  0:00     ` Donovan Baarda
1997-06-20  0:00     ` Roy Grimm
1997-06-23  0:00     ` Robert Dewar
1997-06-24  0:00       ` Don Harrison
1997-06-24  0:00         ` Robert Dewar
1997-06-23  0:00     ` Joachim Durchholz
1997-06-20  0:00   ` Robert Dewar
1997-06-20  0:00 ` Robert Dewar
1997-06-21  0:00 ` Keith Thompson
1997-06-21  0:00   ` Robert Dewar
1997-06-24  0:00     ` Ken Garlington
1997-06-24  0:00       ` Robert Dewar
1997-06-28  0:00   ` Robert I. Eachus
1997-06-28  0:00     ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-06-13  0:00 Paul Van Bellinghen
1997-06-17  0:00 ` Dale Stanbrough
1997-06-17  0:00   ` Robert Munck
1997-06-18  0:00   ` Ken Garlington
1997-06-19  0:00     ` Ole-Hjalmar Kristensen FOU.TD/DELAB
1997-06-19  0:00       ` Ken Garlington
1997-06-17  0:00 ` Robert Dewar
1997-06-20  0:00   ` nma123
1997-06-24  0:00     ` Adam Beneschan
1997-06-18  0:00 ` Nick Roberts
1997-06-18  0:00   ` Peter Hermann
1997-06-20  0:00     ` Robert Dewar
1997-06-25  0:00     ` Van Snyder
1997-06-26  0:00       ` Robert Dewar
1997-06-30  0:00         ` Ralph Paul
1997-07-02  0:00           ` Joerg Rodemann
1997-07-02  0:00             ` Joerg Rodemann
1997-07-02  0:00             ` Ralph Paul
1997-06-19  0:00 ` Steve Doiel
1997-06-19  0:00   ` Anonymous
1997-07-22  0:00 ` Shmuel (Seymour J.) Metz

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