comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <nobody@noplace.com>
Subject: Re: Ada and ASM
Date: Sat, 06 Sep 2003 13:14:10 GMT
Date: 2003-09-06T13:14:10+00:00	[thread overview]
Message-ID: <3F59DD79.1040103@noplace.com> (raw)
In-Reply-To: mailman.10.1062833240.295.comp.lang.ada@ada.eu.org

True, it would be difficult to have some sort of "full-up" Ada syntax 
for assembler that was anywhere near portable across all machines. 
Unless you simply got to the point where you're compiling Ada anyway, so 
why bother? ;-)

However, I recall at least one Ada compiler that essentially defined 
something that looked like a discriminated record for assembler 
instructions and your assembler routines effectively looked like a set 
of agregates for the discriminated record where each aggregate 
represented the machine instruction you wanted. That was pretty much an 
"Ada Syntax" of sorts. Perhaps something along those lines with some 
semi-standard "macro-like" capabilities would be a good thing. (For 
example, if there were some flavor of "if" or "loop" statements that 
automagically expanded out into the corresponding machine instructions, 
that would be helpful and about all you'd need when you are dipping into 
assembler.)

MDC


Simon Wright wrote:
> 
> 
> All very well if all you wanted to do was move things about. But
> machines have all sorts of features, not all of which have
> counterparts on each architecture to be supported. What about reading
> the high-resolution clock? (rdtsc on Pentium, mftb on PowerPC).
> 
>    function Clock return Time is
>       type Half is (Low, High);
>       Lower, Upper : Interfaces.Unsigned_32;
>       Results : array (Half) of Interfaces.Unsigned_32;
>       Result : Time;
>       for Result'Address use Results (Low)'Address;
>    begin
>       System.Machine_Code.Asm
>         ("rdtsc" & ASCII.LF & ASCII.HT &
>            "movl %%eax, %0"& ASCII.LF & ASCII.HT &
>            "movl %%edx, %1",
>          Outputs => (Interfaces.Unsigned_32'Asm_Output ("=g", Lower),
>                      Interfaces.Unsigned_32'Asm_Output ("=g", Upper)),
>          Clobber => "eax, edx");
>       Results := (Low => Lower, High => Upper);
>       return Result;
>    end Clock;
> 
> is an Intel version, the PPC version (which I can't post) is quite
> different in structure. For a start, you have to read the timestamp in
> two bites! (on 32-bit implementations).
> 
> The major reason for using asm must be precisely to accommodate these
> sorts of differences.


-- 
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jast.mil/

Send Replies To: m c o n d i c @ a c m . o r g

     "In general the art of government consists in taking as
     much money as possible from one class of citizens to give
     to the other."

         --  Voltaire
======================================================================




  reply	other threads:[~2003-09-06 13:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E19vQkV-0006EH-Ek@punt-3.mail.demon.net>
2003-09-06  7:25 ` Ada and ASM Simon Wright
2003-09-06 13:14   ` Marin David Condic [this message]
2003-09-06 15:25   ` Wes Groleau
     [not found] <200309051909.h85J9Flb002351@smaug.pushface.org>
2003-09-06  0:15 ` Robert C. Leif
     [not found] <E19vIlZ-0002mO-Fg@punt-3.mail.demon.net>
2003-09-05 19:09 ` Simon Wright
2003-09-05 21:38   ` Jerry van Dijk
2003-09-06  6:11     ` David Marceau
2003-09-07  7:18       ` sk
2003-09-04  7:47 luiX_
2003-09-04 11:43 ` David C. Hoos, Sr.
2003-09-04 15:07   ` Martin Krischik
2003-09-06  0:22   ` Freejack
2003-09-06  2:18     ` Jerry van Dijk
2003-09-06 12:59       ` Jeffrey Creem
2003-09-06 15:33         ` Wes Groleau
2003-09-06 17:11           ` Jerry van Dijk
2003-09-07  4:02             ` Wes Groleau
2003-09-06 17:16         ` Jerry van Dijk
2003-09-04 14:47 ` Martin Krischik
2003-09-04 15:08 ` Martin Krischik
2003-09-04 19:31 ` Leif Holmgren
2003-09-05  2:42   ` Robert C. Leif
2003-09-05 21:32   ` Jerry van Dijk
2003-09-23 10:45   ` Jacob Sparre Andersen
2003-09-05  5:46 ` Simon Wright
2003-09-05 15:44   ` Robert C. Leif
replies disabled

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