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-Thread: 103376,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.germany.com!feeder2.news.saunalahti.fi!feeder1.news.saunalahti.fi!nntp.inet.fi!inet.fi!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Fri, 19 Jan 2007 10:57:29 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Translating an embedded C algorithm References: <1168871816.263502.212100@11g2000cwr.googlegroups.com> <45acc0c3$0$22514$39db0f71@news.song.fi> <45af9c60$0$22524$39db0f71@news.song.fi> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <45b086b7$0$22532$39db0f71@news.song.fi> Organization: TDC Song Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1169196727 news.song.fi 22532 81.17.205.61:32798 X-Complaints-To: abuse@song.fi Xref: g2news2.google.com comp.lang.ada:8314 Date: 2007-01-19T10:57:29+02:00 List-Id: Cesar Rabak wrote: > Niklas Holsti escreveu: > ... >> ... >> So here is my try at an Ada version of the code and some of the >> context. ... > > Nice! I will only make a pair of comments that I believe relate to the > OP idea, and will skip suggestions or observations which in the bottom > line may be considered by other engineers as stylistic. Well, I would like to hear your stylistic views, too... even if no objective right or wrong can be judged. >> ... It would be interesting to compile this code with AVR-Ada; > > Note that the home page for AVR-Ada has this (Status 2nd paragraph): > > "The Ada run time system (RTS) on the other hand is for the most part > not even a run time system. It is more a compile time system :-). Most > files in the RTS are only needed at compile time. As a consequence we > don't yet have support for exceptions nor for tasking (multi-threading)." Yes, so the exception-raising form of ADC.Thermometer.Temperature would have to be excluded. Luckily :-) there is the other form with a variant record type. To diverge a bit, it would be lovely if some intrepid academic with access to hordes of eager students would give them a project to port the Open Ravenscar Kernel (ORK) to the AVR for use with AVR-Ada. That would give us tasking, at least. > [snipped] > >> type Celsius_T is delta 0.1 digits 5 range -40.0 .. 120.0; > > I don't know how an Ada compiler targeted for microcontrollers would > make the internal representation of this type, but if it employs more > than a 16 bit word, I would rather stick to the other implementation > elsethread. Gnat (3.15p on Debian, target native Intel x86) accepts a 'Size clause of 12 bits for this type. I don't see why a compiler targeted to a microcontroller should use a larger representation. I'm not expert in fixed-point arithmetic implementations but I think addition and subtraction can be done without using larger intermediate representations, and the example program has no multiplication or division operations with this type (it has Celsius_T * Natural, but that does not need special scaling). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .