From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,edb329885d962c1d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-06 00:28:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!proxad.net!usenet-fr.net!enst.fr!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada and ASM Date: Sat, 6 Sep 2003 08:25:00 +0100 Organization: ENST, France Message-ID: References: NNTP-Posting-Host: marvin.enst.fr X-Trace: avanie.enst.fr 1062833248 51035 137.194.161.2 (6 Sep 2003 07:27:28 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 6 Sep 2003 07:27:28 +0000 (UTC) Cc: comp.lang.ada@ada.eu.org To: rleif@rleif.com Return-Path: In-reply-to: (rleif@rleif.com) X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:42203 Date: 2003-09-06T08:25:00+01:00 > I want to replace the ASM call by Ada syntax. Assuming one had a > package Asm, then I would like something like the following > > A,B:Asm.register_32; > A:=10_000; > Asm.Move(From=>A To=>B); > > The assembly operations are expressed as true Ada subprograms. 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.