From: Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de>
Subject: Re: Type-safe low-level programming?
Date: 18 Feb 2003 16:52:55 GMT
Date: 2003-02-18T16:52:55+00:00 [thread overview]
Message-ID: <b2tod7$2jl$1@nets3.rz.RWTH-Aachen.DE> (raw)
In-Reply-To: b2t2gq$650$1@nets3.rz.RWTH-Aachen.DE
In comp.arch.embedded Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> wrote:
> 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
[...]
> 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.
next prev parent reply other threads:[~2003-02-18 16:52 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
2003-02-18 16:21 ` Thad Smith
2003-02-18 16:52 ` Hans-Bernhard Broeker [this message]
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