comp.lang.ada
 help / color / mirror / Atom feed
From: kalvin.news@gmail.com
Subject: Re: Ada to C translator for small microcontrollers
Date: Sun, 1 Apr 2012 04:23:37 -0700 (PDT)
Date: 2012-04-01T04:23:37-07:00	[thread overview]
Message-ID: <6816433.161.1333279417653.JavaMail.geo-discussion-forums@ynel5> (raw)
In-Reply-To: <38bda08b-e807-4f5d-b6f9-c4466240a075@h9g2000yqe.googlegroups.com>


lauantaina 31. maaliskuuta 2012 22.52.03 UTC+3 Rugxulo kirjoitti:
> Hi,
> 
> On Mar 31, 10:46 am, kalvin.n...@gmail.com wrote:
> > keskiviikkona 28. maaliskuuta 2012 19.36.37 UTC+3 Niklas Holsti kirjoitti:
> >
> > > It is true that C does not provide all the features of assembly
> > > language, for all that it is called a "portable assembler". But I'm not
> > > sure that this would be a large handicap for an Ada compiler that uses C
> > > as an intermediate language (like the SofCheck one).
> >
> > > The C level could be a performance bottleneck if one wanted to support
> > > wider numbers in Ada than the C compiler supports -- for example, an Ada
> > > 64-bit Long_Integer with a C compiler that supports only 32-bit integers
> > > -- but this is a marginal effect, I think.
> >
> > Yes, the translator should be implemented so, that it would be compatible with the target C ie. no
> > support for 64-bit integers etc. if the target C compiler doesn't support that.
> 
> If you stick to standard C, that shouldn't be a problem. C99 supports
> "long long" (64-bit), and even GCC has supported it for longer than
> that. Besides, it's probably? fairly trivial to hack up similar
> support with only 32-bit ints. (I know there was a small section an
> AMD manual which showed the basic arithmetic in assembly for such
> operations.)
> 
> > Nested procedures are also a bit tricy to implement in C, as the local stack frame needs to made
> > visible to the inner procedure. This is doable with the struct of pointers passed as parameters for
> > the "inner procedure", I guess. It is up to target C compiler optimization how much penalty there will be.
> 
> GCC supports nested procedures. Something like p2c (Pascal to C) had
> some weird workaround to support it in generic C, too. I imagine that
> using p2c is preferable to writing from scratch in C, though I know
> Pascal isn't quite Ada (but still less painful, no?).
> 
> Anyways, it may be easier to just use an interpreter, something like
> old NYU Ada/Ed, which was written in C, but I haven't ever looked
> close enough nor tried to recompile it. In other words, I don't know
> how portable that C code is, it was (AFAIK) 16-bit for an old Intel C
> compiler. Perhaps someone in this newsgroup has recompiled it before,
> who knows. I realize that's not native speed, but it's probably not
> too bad. It certainly is better than nothing.

P2C (Pascal-to-C) might also be a viable starting point for the translator. However, in order to take advantage of mature GNAT compiler front-end, the GCC looks tempting path. GCC seems to be quite complicated beast, but maybe it can be tamed for the purpose.



  reply	other threads:[~2012-04-01 11:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 12:48 Ada to C translator for small microcontrollers Tomi Saarnio
2012-03-26 13:44 ` Rego, P.
2012-03-26 14:14 ` Niklas Holsti
2012-03-26 15:48   ` Ludovic Brenta
2012-03-26 16:20     ` Simon Wright
2012-03-26 14:46 ` georg bauhaus
2012-03-26 19:16 ` anon
2012-03-27  9:46 ` kalvin.news
2012-03-27 17:22   ` anon
2012-03-27 20:13     ` kalvin.news
2012-03-28 14:29       ` KK6GM
2012-03-28 16:36       ` Niklas Holsti
2012-03-28 17:56         ` KK6GM
2012-03-28 21:03         ` Georg Bauhaus
2012-03-30 11:54           ` phil.clayton
2012-03-31 15:46         ` kalvin.news
2012-03-31 19:52           ` Rugxulo
2012-04-01 11:23             ` kalvin.news [this message]
2012-04-02 21:46             ` Niklas Holsti
2012-04-03  5:56               ` J-P. Rosen
2012-04-03  2:08 ` BrianG
2012-04-03  9:29   ` Georg Bauhaus
2012-05-21 10:35 ` kalvin.news
2012-05-21 12:27   ` Georg Bauhaus
2012-06-02 15:27     ` Marco
2012-06-05  9:18       ` kalvin.news
2012-06-05 12:17         ` Brian Drummond
2012-06-06  5:21           ` J-P. Rosen
2012-06-06 11:50             ` Brian Drummond
2012-06-10 15:41         ` Marco
replies disabled

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