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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f849b,b8d52151b7b306d2 X-Google-Attributes: gidf849b,public X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-29 08:16:56 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn11feed!worldnet.att.net!216.166.71.14!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 29 Dec 2003 10:16:55 -0600 Date: Mon, 29 Dec 2003 11:16:54 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.arch.embedded,comp.lang.ada Subject: Re: Certified C compilers for safety-critical embedded systems References: <3fe00b82.90228601@News.CIS.DFN.DE> <$km9afA3DB7$EAYO@phaedsys.demon.co.uk> <3feda44e_3@mk-nntp-1.news.uk.worldonline.com> <3fedbbf0_3@mk-nntp-1.news.uk.worldonline.com> <3fef5f9b_2@mk-nntp-1.news.uk.worldonline.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-sqm2wrR/e8IAsZf815NceGL46MjaHtkCvJjEZBgWpeUQwLYfscKjtLqkpplUCRRxRSNk9fYzbXjc7Ws!+11Jx2/QdCbfd9IPHTQ/JksNozbcUvxNizpGb7FA+aCZf01nOdF75OExPysQ5A== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.arch.embedded:6290 comp.lang.ada:3925 Date: 2003-12-29T11:16:54-05:00 List-Id: Georg Bauhaus wrote: > That is, I might presume that color Red is not too different from > Light_Red. I might know that the number of bits used for values > in the two types will be the same (char in C terms, say). Still the > compiler will not let me use Light_Red_Index's value 101 and > Red_Index's value 101 interchangeably. Well, it would be better to say that the compiler won't let you mix Light_Red_Index and Red_Index implicitly. You can always say: if buffer(Red_Index(some_val)) then... If the two types are represented the same, then there will be no real run-time cost for the conversion. (If both Red_Index and Light_Red_Index were SUBtypes of Integer, then you could write: if buffer(some_val) then... and there would be a range check associated with the indexing operation. With Red_Index and Light_Red_Index as separate types, there will be a range check now associated with the conversion instead of the subscripting. But assuming that the representations of the types are identical, the code should be identical. > The assembly listing shows > 8bit register use on i686 when the index range permits, even with > numbers ranging beyond 255 (or > 65535 for that matter). > > type Light_Red_Index is range 92_000 .. 92_200; > for Light_Red_Index'Size use 8; > > In short, convenient, checked at compile time, and efficient :-) Yep, and if you do a type conversion as above, the compiler will add the bias back in (or add the net difference if there are two different biases). This means you can write your code in meaningful units and allow the compiler to remember and generate any conversions. This is real handy when you have a sensor that for example, returns a 12-bit encoding of an angle. You can write the code using units of degrees (or radians or grads if you want) and the compiler will convert your constants at compile time. Get a new sensor with a 16-bit ADC, and all you have to change is the type declaration (and of course, recompile and test). -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush