From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,31b048c5bb0fb3ed X-Google-Attributes: gid103376,public From: dkristol@see-my.sig (David Kristola) Subject: Re: Can someone explain this to me please? Date: 1999/08/07 Message-ID: <7ogaeo$a665@svlss.lmms.lmco.com>#1/1 X-Deja-AN: 509831264 Distribution: world References: Organization: LockMart Reply-To: dkristol@see-my.sig Newsgroups: comp.lang.ada Date: 1999-08-07T00:00:00+00:00 List-Id: In article rqm730dlkur11@corp.supernews.com, "J. Marshall" () 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 "." 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