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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd74f408cd771388 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-13 16:36:39 PST Sender: jerry@localhost Newsgroups: comp.lang.ada Subject: Re: Compute a Sin(X) and Cos(X) pair, FSINCOS, inlining References: <3F0C7B5D.81F0FDCD@somewhere.nil> <3F0FAA0E.7BCA9AA7@somewhere.nil> From: Jerry van Dijk Date: 14 Jul 2003 01:32:02 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.93 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: slip32-106-5-49.rot.nl.prserv.net X-Trace: 13 Jul 2003 23:34:54 GMT, slip32-106-5-49.rot.nl.prserv.net Organization: Global Network Services - Remote Access Mail & News Services X-Complaints-To: abuse@prserv.net Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newshub.sdsu.edu!elnk-pas-nf2!newsfeed.earthlink.net!newsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!cyclone.swbell.net!newsfeed.us.prserv.net!prserv.net!news3.prserv.net!slip32-106-5-49.rot.nl.prserv.net Xref: archiver1.google.com comp.lang.ada:40244 Date: 2003-07-14T01:32:02+02:00 List-Id: Gautier Write-only writes: > # Sorry, the original article already scrolled off my system. > > Nice... (what system! even with on a VT220 I could scroll up news ;-) Nah. I just hooked my VT220 clone to the serial port of my laptop, but it didn't help... :-) BTW, I always preferred the TeleVideo 970. > BTW, what is the variant for Long_Float ? Here is a full example of both: ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Ada.Numerics; use Ada.Numerics; with System.Machine_Code; use System.Machine_Code; with Ada.Numerics.Generic_Elementary_Functions; procedure Check is package Float_Funcs is new Ada.Numerics.Generic_Elementary_Functions (Float); use Float_Funcs; package Long_Float_Funcs is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Long_Float_Funcs; procedure Sin_Cos (Angle : Float; Sin : out Float; Cos : out Float); procedure Sin_Cos (Angle : Long_Float; Sin : out Long_Float; Cos : out Long_Float); pragma Inline (Sin_Cos); procedure Sin_Cos (Angle : Float; Sin : out Float; Cos : out Float) is use ASCII; begin Asm (("fsincos" & LF & HT & "fstp %0" & LF & HT & "fst %1"), Outputs => (Float'Asm_Output ("=m", Cos), (Float'Asm_Output ("=m", Sin))), Inputs => (Float'Asm_Input ("t", Angle))); end Sin_Cos; procedure Sin_Cos (Angle : Long_Float; Sin : out Long_Float; Cos : out Long_Float) is use ASCII; begin Asm (("fsincos" & LF & HT & "fstpl %0" & LF & HT & "fstl %1"), Outputs => (Long_Float'Asm_Output ("=m", Cos), (Long_Float'Asm_Output ("=m", Sin))), Inputs => (Long_Float'Asm_Input ("t", Angle))); end Sin_Cos; package IO_Concats is function "&" (S : String; F : Float) return String; function "&" (S : String; F : Long_Float) return String; end IO_Concats; package body IO_Concats is function "&" (S : String; F : Float) return String is begin return S & Float'Image (F); end "&"; function "&" (S : String; F : Long_Float) return String is begin return S & Long_Float'Image (F); end "&"; end IO_Concats; use IO_Concats; Sin_Float, Cos_Float : Float; Float_Value : constant Float := 0.25 * Pi; Sin_Long_Float, Cos_Long_Float : Long_Float; Long_Float_Value : constant Long_Float := 0.25 * Pi; begin Sin_Float := Sin (Float_Value); Cos_Float := Cos (Float_Value); Put_Line ("Sin_Float:" & Sin_Float & ", Cos_Float:" & Cos_Float); Sin_Cos (Float_Value, Sin_Float, Cos_Float); Put_Line ("Sin_Float:" & Sin_Float & ", Cos_Float:" & Cos_Float); Sin_Long_Float := Sin (Long_Float_Value); Cos_Long_Float := Cos (Long_Float_Value); Put_Line ("Sin_LFloat:" & Sin_Long_Float & ", Cos_LFloat:" & Cos_Long_Float); Sin_Cos (Long_Float_Value, Sin_Long_Float, Cos_Long_Float); Put_Line ("Sin_LFloat:" & Sin_Long_Float & ", Cos_LFloat:" & Cos_Long_Float); end Check; ------------------------------------------------------------------------------- > In any case, it would be nice to have a compiler producing FSINCOS - e.g. > for those users not familiar with machine code. Yes. Have you checked gcc 3.3 ? Probably the Fortran folks would like this too. -- -- Jerry van Dijk | email: jvandyk@attglobal.net -- Leiden, Holland | web: users.ncrvnet.nl/gmvdijk