comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: ada newbie
Date: Tue, 7 Aug 2001 12:09:28 -0400
Date: 2001-08-07T16:09:29+00:00	[thread overview]
Message-ID: <9kp3rp$ge5$1@nh.pace.co.uk> (raw)
In-Reply-To: 9kp053$ro0$1@zeus.orl.lmco.com

You are delving into things (representation) that can be hardware/compiler
dependent.

From the ARM 13.5.1 - an example of how to create records wherein you
control representation issues. (Read chapter 13 - its really worth it if you
want to do low level programming like this.)

type Program_Status_Word is
    record
        System_Mask : Byte_Mask;
        Protection_Key : Integer range 0 .. 3;
        Machine_State : State_Mask;
        Interrupt_Cause : Interruption_Code;
        Ilc : Integer range 0 .. 3;
        Cc : Integer range 0 .. 3;
        Program_Mask : Mode_Mask;
        Inst_Address : Address;
    end record;

for Program_Status_Word use
    record
        System_Mask at 0*Word range 0 .. 7;
        Protection_Key at 0*Word range 10 .. 11; -- bits 8,9 unused
        Machine_State at 0*Word range 12 .. 15;
        Interrupt_Cause at 0*Word range 16 .. 31;
        Ilc at 1*Word range 0 .. 1; -- second word
        Cc at 1*Word range 2 .. 3;
        Program_Mask at 1*Word range 4 .. 7;
        Inst_Address at 1*Word range 8 .. 31;
    end record;

for Program_Status_Word'Size use 8*System.Storage_Unit;
for Program_Status_Word'Alignment use 8;

In general, you can see how the representation clause indicates that you
have to specify a byte offset (assuming a byte oriented machine) and a bit
range for each of the record elements. You don't need to create "spares" -
just don't specify anything occupying those bits.

Hope this gets you going - but you *really* should read chapter 13 and look
at your compiler documentation and target processor to make sure that you
get the clauses correct for *your* specific hardware. You'll discover that
in general Ada is very good at letting you control the low level stuff...

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"mop" <mop65715@pegasus.cc.ucf.edu> wrote in message
news:9kp053$ro0$1@zeus.orl.lmco.com...
> so my data looks like this.   In C I could create a structure and go from
> there.   I'm new to Ada and need help on how to setup the data.  I suspect
I
> could use some sort of a record once I setup the structure in Ada to pass
> the data.
>
>
> example data
> word          bit            function            remarks
> 1                2-0          command         logic 001
>                     3            mode               logic 0 - normal
>                                                           logic 1 -
> diagnostic
>                   7-4          spare
>
> etc.etc
> 8                7-0        checksum          sum of above message bytes
>
>
> i'll be sending data across a serial port and need to change the parity
bit
> on the fly.  from MarkParity to SpaceParity.   So I'll send word 1 -
default
> parity bit MarkParity then change to SpaceParity for the rest of the data.
>
> help.  already wrote fully functional GUI is C but now need to do the same
> in Ada and have no idea where to start.
>
>





  reply	other threads:[~2001-08-07 16:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-07 15:06 ada newbie mop
2001-08-07 16:09 ` Marin David Condic [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-07-26 18:10 Ada Newbie agate!howland.reston.ans.net!usc!cs.utexas.edu!asuvax!ennews!mcdphx!schbb
replies disabled

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