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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a02:9526:: with SMTP id y35-v6mr21413173jah.16.1537224093959; Mon, 17 Sep 2018 15:41:33 -0700 (PDT) X-Received: by 2002:a9d:5c02:: with SMTP id o2-v6mr205817otk.7.1537224093831; Mon, 17 Sep 2018 15:41:33 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!2.eu.feeder.erje.net!4.us.feeder.erje.net!feeder.erje.net!nntp.club.cc.cmu.edu!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!x188-v6no7169ite.0!news-out.google.com!z5-v6ni14ite.0!nntp.google.com!x188-v6no7165ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 17 Sep 2018 15:41:33 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.158.108.171; posting-account=gOYTTAoAAADrNEg_oe5Etelo-0qd7UeW NNTP-Posting-Host: 69.158.108.171 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <87c83c63-f520-4f6e-a250-ad9665c8a20f@googlegroups.com> Subject: Re: GNAT for AVR - Mathematical Functions From: Aurele Vitali Injection-Date: Mon, 17 Sep 2018 22:41:33 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54350 Date: 2018-09-17T15:41:33-07:00 List-Id: I don't know anything about the ATmega328P, but if it uses a builtin floating point processor, you can use Ada inline floating point assembler. Its not hard to do. Here is a simple example of the square root function: with System.Machine_Code; use System.Machine_Code; EOL : constant String := ASCII.LF & ASCII.HT; function Sqrt( x : in Long_Float ) return Long_Float is Result : Long_Float := 0.0; begin Asm( ( "fldl %1" & EOL & -- Load x in St(0) "fsqrt " & EOL & -- Take the Sqrt of St(0) "fstpl %0" ), -- Store result and pop St(0) Outputs => ( Long_Float'Asm_Output("=m", Result ) ), Inputs => ( Long_Float'Asm_Input ( "m", x ) ) ); return Result; end Sqrt; You can do the same thing for trig functions... Just cut and past and see if this example works. Cheers