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: f849b,869d7890f1bd9878 X-Google-Attributes: gidf849b,public X-Google-Thread: 103376,869d7890f1bd9878 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-18 02:39:23 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!newsfeed.freenet.de!news.rwth-aachen.de!!broeker From: Hans-Bernhard Broeker Newsgroups: comp.lang.ada,comp.arch.embedded Subject: Re: Type-safe low-level programming? Date: 18 Feb 2003 10:39:22 GMT Organization: Aachen University of Technology (RWTH) Message-ID: References: NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1045564762 6304 137.226.32.75 (18 Feb 2003 10:39:22 GMT) X-Complaints-To: abuse@rwth-aachen.de NNTP-Posting-Date: 18 Feb 2003 10:39:22 GMT Originator: broeker@ Xref: archiver1.google.com comp.lang.ada:34190 comp.arch.embedded:59709 Date: 2003-02-18T10:39:22+00:00 List-Id: In comp.arch.embedded Bernd Trog wrote: > Now I wonder, if its possible to make 'Set_Bit' type-safe *without* > increasing the program memory size for every new register? The only way I see is to drop the idea of passing the register and the bit number inside that register as independent parameters --- they aren't independent, and pretending they are is what causes your grief. The need to introduce a comment to explain what Bit_A1 is supposed to mean should have given you the hint. What you need would be more like type Bit_Number is range 0 .. 8*16#ff#); Register_A : constant Address_Type := 1; Bit_A1 : constant Bit_Number := Register_A*8 + 4; Bit_A2 : constant Bit_Number := Register_A*8 + 1; [...] and then procedure Set_Bit(Nr : in Bit_Number ); which would split up the Bit_Number in two parts, one to address a register, the other to address bits inside that register. Disclaimer: the above are the first lines of Ada code I ever edited in my life, so don't trust them any further than you can throw your car ;-) -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.