From: Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de>
Subject: Re: Type-safe low-level programming?
Date: 18 Feb 2003 10:39:22 GMT
Date: 2003-02-18T10:39:22+00:00 [thread overview]
Message-ID: <b2t2gq$650$1@nets3.rz.RWTH-Aachen.DE> (raw)
In-Reply-To: cbdd91ae.0302171606.57d2ba77@posting.google.com
In comp.arch.embedded Bernd Trog <berndtrog@yahoo.com> 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.
next prev parent reply other threads:[~2003-02-18 10:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-18 0:06 Type-safe low-level programming? Bernd Trog
2003-02-18 2:04 ` David C. Hoos, Sr.
2003-02-18 10:39 ` Hans-Bernhard Broeker [this message]
2003-02-18 16:21 ` Thad Smith
2003-02-18 16:52 ` Hans-Bernhard Broeker
2003-02-18 14:53 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox