From: Norbert Caspari <nnc@gmx.li>
Subject: how to "put" a binary structure? (newbie question!)
Date: Wed, 1 Feb 2006 18:04:43 +0100
Date: 2006-02-01T18:04:43+01:00 [thread overview]
Message-ID: <drqpnb$43l$00$1@news.t-online.com> (raw)
Dear experts,
I like to print the content of a binary bit structure with the put
statement but it doesn't work. I'm a newbie to Ada programming and
therefore please excuse if my question might be silly or stupid. Maybe I
misunderstood something.
Here is some test case I tried to compile:
--------------------snip--------------------------
with Ada.Text_Io;
with Ada.Integer_Text_Io;
with Interfaces;
use Interfaces;
use Ada;
procedure Bittest is
type Bit_T is
(Off,
On);
for Bit_T use (
Off => 0,
On => 1);
for Bit_T'Size use 1;
type Byte is
record
Bit0 : Bit_T;
Bit1 : Bit_T;
Bit2 : Bit_T;
Bit3 : Bit_T;
Bit4 : Bit_T;
Bit5 : Bit_T;
Bit6 : Bit_T;
Bit7 : Bit_T;
end record;
for Byte'Size use 8;
pragma Pack(Byte); -- the whole structure should fit in one byte
package Byte_Io is new Text_Io.Integer_Io(Byte => Unsigned_8);
--^^^^^^^^^
-- This does not work, why???
Xxx.Bit0 := off;
Xxx.Bit1 := on;
Xxx.Bit2 := off;
Xxx.Bit3 := off;
Xxx.Bit4 := on;
Xxx.Bit5 := on;
Xxx.Bit6 := off;
Xxx.Bit7 := off;
-- and of course this does not work too because the declaration
-- of the child package above failed.
Byte_IO.Put(Xxx.Bit0,
Width=>1,
Base=>2);
-- Is it possible to print the whole content of a record structure with one
-- put statement?
end Bittest;
-------------------------snap----------------------
The compiler says
missing actual for instantiation of "Num"
instantiation abandoned
How can I correct the source code to print the values stored in the
structure Xxx? Is it possible, to print the whole content of Xxx with just
one put statement? Or alternatively how can I assign the content of Xxx to
another variable of the type Unsigned_8 that I can use for output? Or is
there maybe another way?
Questions over questions ;-)
Anyway, thanks a lot in advance for your help.
Best regards, Norbert
next reply other threads:[~2006-02-01 17:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-01 17:04 Norbert Caspari [this message]
2006-02-01 18:23 ` how to "put" a binary structure? (newbie question!) Dmitry A. Kazakov
2006-02-01 18:34 ` Georg Bauhaus
2006-02-01 18:59 ` Martin Krischik
2006-02-02 11:06 ` Stephen Leake
2006-02-02 2:10 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox