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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d36fc3985d071e34 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 30 Dec 2004 12:51:05 -0600 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Pointer address References: <1224531.Y4V0fVubSt@jellix.jlfencey.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Thu, 30 Dec 2004 12:51:05 -0600 NNTP-Posting-Host: 67.161.24.234 X-Trace: sv3-zfn8IRsjFppWnnPRAVrLWXgNTUFgaEA/F3+GvsZ2vejpizDySyic87YtXT/Yq1KgJFCX77SoTl7RZdL!ehE6BkpRvzE8VLRZxfOxwdANkJd6RBzH6pGsC16zfPwyuPIfNKgNd3eWvCTDZA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.22 Xref: g2news1.google.com comp.lang.ada:7334 Date: 2004-12-30T12:51:05-06:00 List-Id: >>cpdata.dwData = 0x0001B001 (dwData being a ptr to an ulong) This says dwData is a pointer whose value is 0x0001B001. >> DwData : PULONG; >> for DwData'Address use Some_Address; This says DwData itself is at Some_Address. The value of DwData is null, unless you manage to override the default with a pragma Import, in which case the pointer DwData will point to the address given by whatever happened to be in the bytes at Some_Address. >if dwData really is a pointer to some data at a fixed address you could >declare the data itself and apply the address clause to it directly. >Again, this is Ada -> no need for pointers. ;-) >... > DwData : Interfaces.C.Unsigned_Long; > for DwData'Address use Some_Address; Yes, and (with *cpdata.dwData changing to DwData) probably the correct translation of the (non-Windows) design. But since cpdata.dwData is a variable, there could be other code like cpdata.dwData = 0x0001B011; cpdata.dwData = 0x0002C022; etc, in which case he really would need to use pointers. >Hmm, one problem: if I change the address to 16#0001B001#, I get > >"raised PROGRAM_ERROR : temp.adb:13 misaligned address value". Objects of type "access all Interfaces.C.Unsigned_Long", most likely have an alignment of 4, and ARM 13.3(27) says "Program execution is erroneous if an Address clause is given that conflicts with the Alignment." 16#1B001# is not a multiple of 4. >What was the target architecture/OS of the original C-Code? Using fixed >addresses looks like it was assuming DOS or some other system with >fixed memory areas (like some microcontroller stuff). Such code simply >will not work with Windows. That's a bit strong. The address will be interpreted as a location in the program's virtual address space, which might be, though probably isn't, what was meant. Perhaps 16#1B001# was an absolute address in a microcontroller, or an offset into the data segment in a large-model DOS program, or an IO mapped address in some other architecture. Porting this C program to another architecture certainly requires more than a transliteration into Ada.