comp.lang.ada
 help / color / mirror / Atom feed
* Can someone explain this to me please?
@ 1999-08-06  0:00 J. Marshall
  1999-08-06  0:00 ` Ted Dennison
  1999-08-07  0:00 ` David Kristola
  0 siblings, 2 replies; 4+ messages in thread
From: J. Marshall @ 1999-08-06  0:00 UTC (permalink / raw)


I am a C programmer, recently assigned to an Ada project due to staff
problems here.
The project, originally built in 1492 using Verdix on a VAX, it is now being
ported to Green Hills AdaMULTI version 1.8.9 running on a SunOS host, for a
VMEbus embedded target running VxWorks.
I've never used Ada before, and am having some difficulty with some portions
of the project, the direct hardware addressing in particular.

Example of some of the "old" code used...

COMMAND_REG_PTR :
   COMMAND_REG_PTR_TYPE :=
      TO_CMD_PTR( SYSTEM.ADDRESS'ref( BOARD_CONFIGURATION ) );

..to which the compiler responds with

   UNRECOGNIZED ATTRIBUTE "ref"

The former Ada guru faxed me the following "fix":
(however, he is generally unavailable for help)

  generic
    type Object(<>) is limited private;
  package System.Address_To_Access_Conversions is
    pragma Preelaborate(Address_To_Access_Conversions);

    type Object_Pointer is access all Object;
    function To_Pointer(Value : Address) return Pbject_Pointer;
    function To_Address(Value : Object_Pointer) return Address;

    pragma Convention(Intrinsic, To_Pointer);
    pragma Convention(Intrinsic, To_Address);
  end System.Address_To_Access_Conversions

Can anyone tell me how to implement this into working code?
Thanks very much.
Jim Marshall







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

* Re: Can someone explain this to me please?
  1999-08-06  0:00 Can someone explain this to me please? J. Marshall
@ 1999-08-06  0:00 ` Ted Dennison
  1999-08-07  0:00 ` David Kristola
  1 sibling, 0 replies; 4+ messages in thread
From: Ted Dennison @ 1999-08-06  0:00 UTC (permalink / raw)


In article <rqm730dlkur11@corp.supernews.com>,
  "J. Marshall" <a_revelation@hotmail.com> wrote:
> I am a C programmer, recently assigned to an Ada project due to staff
> problems here.
Welcome to the light side of the force. :-)

> The project, originally built in 1492 using Verdix on a VAX, it is now

Hmmm. I guess Columbus' crew had to do something during that long voyage
across the Atlantic.

> being ported to Green Hills AdaMULTI version 1.8.9 running on a SunOS
> host, for a VMEbus embedded target running VxWorks.
> Example of some of the "old" code used...
>
> COMMAND_REG_PTR :
>    COMMAND_REG_PTR_TYPE :=
>       TO_CMD_PTR( SYSTEM.ADDRESS'ref( BOARD_CONFIGURATION ) );
>
> ..to which the compiler responds with
>
>    UNRECOGNIZED ATTRIBUTE "ref"

"'ref" was a compiler-specific attribute for the VADS compilers. It
should be described in detail in appendix F of your Verdix compiler
documentation. I highly suggest reading that.

To help much more, we'd probably need to see what the type of
"BOARD_CONFIGURATION" is, and how "COMMAND_REG_PTR_TYPE" is defined.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

* Re: Can someone explain this to me please?
  1999-08-06  0:00 Can someone explain this to me please? J. Marshall
  1999-08-06  0:00 ` Ted Dennison
@ 1999-08-07  0:00 ` David Kristola
  1999-08-09  0:00   ` J. Marshall
  1 sibling, 1 reply; 4+ messages in thread
From: David Kristola @ 1999-08-07  0:00 UTC (permalink / raw)


In article rqm730dlkur11@corp.supernews.com, "J. Marshall" <a_revelation@hotmail.com> () writes:
>I am a C programmer, recently assigned to an Ada project due to staff
>problems here.

There are some on-line Ada tutorials you might want to check out.
http://www.adahome.com/Tutorials/

There is even one listed for C/C++ programmers going to Ada.

>The project, originally built in 1492 using Verdix on a VAX, it is now being
>ported to Green Hills AdaMULTI version 1.8.9 running on a SunOS host, for a
>VMEbus embedded target running VxWorks.
>I've never used Ada before, and am having some difficulty with some portions
>of the project, the direct hardware addressing in particular.

One of the problems you are going to have is moving from the
Verdix unique environment to the new compiler's environment
(or to Ada95, since many new and powerful features have been
added, and many of them can be used to replace Verdix
specific attributes and library units).

>Example of some of the "old" code used...
>
>COMMAND_REG_PTR :
>   COMMAND_REG_PTR_TYPE :=
>      TO_CMD_PTR( SYSTEM.ADDRESS'ref( BOARD_CONFIGURATION ) );
>
>...to which the compiler responds with
>
>   UNRECOGNIZED ATTRIBUTE "ref"

Yes, "'ref" is a Verdix specific attribute that returns
an address of the object being referenced.  I assume
there was a ".<something>" after Board_Configuration
(since that is a package).

To_CMD_PTR is probably an instantiation of
Unchecked_Convertion.

There is now a better way to do this, see below.

>The former Ada guru faxed me the following "fix":
>(however, he is generally unavailable for help)
>
>  generic
>    type Object(<>) is limited private;
>  package System.Address_To_Access_Conversions is
>    pragma Preelaborate(Address_To_Access_Conversions);
>
>    type Object_Pointer is access all Object;
>    function To_Pointer(Value : Address) return Pbject_Pointer;
>    function To_Address(Value : Object_Pointer) return Address;
>
>    pragma Convention(Intrinsic, To_Pointer);
>    pragma Convention(Intrinsic, To_Address);
>  end System.Address_To_Access_Conversions
>
>Can anyone tell me how to implement this into working code?
>Thanks very much.
>Jim Marshall


This generic is part of the 1995 definition of Ada
(it was not available in the 1983 version of Ada used
in the original code you are porting).

You would instantiate this generic with the object
type you want a pointer to (presumably
Command_Register_Type), and then use the To_Pointer
call from that instantiation to get a pointer (access
type) to that object.  Ex:

   type Command_Register_Type is ...

   package Command_Register_Converter is new
      System.Address_To_Access_Conversions
         (Object => Command_Register_Type);

   subtype Command_Reg_Ptr_Type is
      Command_Register_Converter.Object_Pointer;

then in the code to set Command_Reg_Ptr....

   Command_Reg_Ptr : Command_Reg_Ptr_Type :=
      Command_Register_Converter.To_Pointer
         (Board_Configuration.Cmd_Reg'ADDRESS);


Now the question: since you have changed compilers
and runtime systems, why are you still using
Verdix's Board_Configuration?

How does the Green Hill's compiler define the embedded
system's board configuration?


--djk, keeper of arcane lore & trivial fluff (including
some minor knowledge of Verdix things)
Home: David95037 at aol dot com
Spam: goto.hades@welovespam.com





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

* Re: Can someone explain this to me please?
  1999-08-07  0:00 ` David Kristola
@ 1999-08-09  0:00   ` J. Marshall
  0 siblings, 0 replies; 4+ messages in thread
From: J. Marshall @ 1999-08-09  0:00 UTC (permalink / raw)


Thanks very much for the info, guys.  I appreciate your time very much.
JM


David Kristola wrote in message <7ogaeo$a665@svlss.lmms.lmco.com>...
>In article rqm730dlkur11@corp.supernews.com, "J. Marshall"
<a_revelation@hotmail.com> () writes:
>>I am a C programmer, recently assigned to an Ada project due to staff
>>problems here.
>
>There are some on-line Ada tutorials you might want to check out.
>http://www.adahome.com/Tutorials/
>
>There is even one listed for C/C++ programmers going to Ada.
>
>>The project, originally built in 1492 using Verdix on a VAX, it is now
being
>>ported to Green Hills AdaMULTI version 1.8.9 running on a SunOS host, for
a
>>VMEbus embedded target running VxWorks.
>>I've never used Ada before, and am having some difficulty with some
portions
>>of the project, the direct hardware addressing in particular.
>
>One of the problems you are going to have is moving from the
>Verdix unique environment to the new compiler's environment
>(or to Ada95, since many new and powerful features have been
>added, and many of them can be used to replace Verdix
>specific attributes and library units).
>
>>Example of some of the "old" code used...
>>
>>COMMAND_REG_PTR :
>>   COMMAND_REG_PTR_TYPE :=
>>      TO_CMD_PTR( SYSTEM.ADDRESS'ref( BOARD_CONFIGURATION ) );
>>
>>...to which the compiler responds with
>>
>>   UNRECOGNIZED ATTRIBUTE "ref"
>
>Yes, "'ref" is a Verdix specific attribute that returns
>an address of the object being referenced.  I assume
>there was a ".<something>" after Board_Configuration
>(since that is a package).
>
>To_CMD_PTR is probably an instantiation of
>Unchecked_Convertion.
>
>There is now a better way to do this, see below.
>
>>The former Ada guru faxed me the following "fix":
>>(however, he is generally unavailable for help)
>>
>>  generic
>>    type Object(<>) is limited private;
>>  package System.Address_To_Access_Conversions is
>>    pragma Preelaborate(Address_To_Access_Conversions);
>>
>>    type Object_Pointer is access all Object;
>>    function To_Pointer(Value : Address) return Pbject_Pointer;
>>    function To_Address(Value : Object_Pointer) return Address;
>>
>>    pragma Convention(Intrinsic, To_Pointer);
>>    pragma Convention(Intrinsic, To_Address);
>>  end System.Address_To_Access_Conversions
>>
>>Can anyone tell me how to implement this into working code?
>>Thanks very much.
>>Jim Marshall
>
>
>This generic is part of the 1995 definition of Ada
>(it was not available in the 1983 version of Ada used
>in the original code you are porting).
>
>You would instantiate this generic with the object
>type you want a pointer to (presumably
>Command_Register_Type), and then use the To_Pointer
>call from that instantiation to get a pointer (access
>type) to that object.  Ex:
>
>   type Command_Register_Type is ...
>
>   package Command_Register_Converter is new
>      System.Address_To_Access_Conversions
>         (Object => Command_Register_Type);
>
>   subtype Command_Reg_Ptr_Type is
>      Command_Register_Converter.Object_Pointer;
>
>then in the code to set Command_Reg_Ptr....
>
>   Command_Reg_Ptr : Command_Reg_Ptr_Type :=
>      Command_Register_Converter.To_Pointer
>         (Board_Configuration.Cmd_Reg'ADDRESS);
>
>
>Now the question: since you have changed compilers
>and runtime systems, why are you still using
>Verdix's Board_Configuration?
>
>How does the Green Hill's compiler define the embedded
>system's board configuration?
>
>
>--djk, keeper of arcane lore & trivial fluff (including
>some minor knowledge of Verdix things)
>Home: David95037 at aol dot com
>Spam: goto.hades@welovespam.com
>






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

end of thread, other threads:[~1999-08-09  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-06  0:00 Can someone explain this to me please? J. Marshall
1999-08-06  0:00 ` Ted Dennison
1999-08-07  0:00 ` David Kristola
1999-08-09  0:00   ` J. Marshall

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