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 08:52:55 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 16:52:55 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 1045587175 2677 137.226.32.75 (18 Feb 2003 16:52:55 GMT) X-Complaints-To: abuse@rwth-aachen.de NNTP-Posting-Date: 18 Feb 2003 16:52:55 GMT Originator: broeker@ Xref: archiver1.google.com comp.lang.ada:34203 comp.arch.embedded:59740 Date: 2003-02-18T16:52:55+00:00 List-Id: In comp.arch.embedded Hans-Bernhard Broeker wrote: > 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 [...] > Bit_A2 : constant Bit_Number := Register_A*8 + 1; On second thinking, a better alternative is still possible. But I'll have to switch to C to explain it, because I don't speak Ada, so those of you allergic to C may want shade their eyes.... typedef unsigned short tByteNumber; typedef unsinged char tBitNumber; typedef struct { tByteNumber byte_number; tBitNumber bit_number; } tBitDefinition; const tByteNumber Register_A = 8; const bit_definition WhatEverThisDoes = {Register_A, 1}; inline void SetBit(tBitDefinition bit) { USUAL_SETBIT_MACRO(bit.byte_number, bit.bit_number); } -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.