comp.lang.ada
 help / color / mirror / Atom feed
* Type-safe low-level programming?
@ 2003-02-18  0:06 Bernd Trog
  2003-02-18  2:04 ` David C. Hoos, Sr.
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bernd Trog @ 2003-02-18  0:06 UTC (permalink / raw)


Hi,
lets say I've something like this:

pragma No_Run_Time;

type Bit_Number is range 0 .. 7;
type Address_Type is range 0 .. 16#ff#;

Register_A : constant Address_Type := 1;
Bit_A1 : constant Bit_Number := 4;  --Register A, Bit 4
Bit_A2 : constant Bit_Number := 1;
Bit_A3 : constant Bit_Number := 7;

Register_B : constant Address_Type = 2;
Bit_B1 : constant Bit_Number :=4;
Bit_B2 : constant Bit_Number :=2;
Bit_B3 : constant Bit_Number :=5;
[...]
Register_Z : constant Address_Type = 2;
Bit_Z1 : constant Bit_Number :=6;
Bit_Z2 : constant Bit_Number :=0;
Bit_Z3 : constant Bit_Number :=5;

procedure Set_Bit( Adr : in Address_Type; Nr : in Bit_Number );
procedure Clear_Bit( Adr : in Address_Type; Nr : in Bit_Number );

On a not-so-good day I wrote:
Set_Bit( Register_A, Bit_B3 );
and found my error days later :-(

Now I wonder, if its possible to make 'Set_Bit' type-safe *without*
increasing the program memory size for every new register?


Bernd



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-02-18 16:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2003-02-18 14:53 ` Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox