comp.lang.ada
 help / color / mirror / Atom feed
From: Vinzent 'Gadget' Hoefler <nntp-2004-12@t-domaingrabbing.de>
Subject: Re: Pointer address
Date: Fri, 31 Dec 2004 09:57:28 +0000
Date: 2004-12-31T09:57:28+00:00	[thread overview]
Message-ID: <1902346.BAagqHZ0Mk@jellix.jlfencey.com> (raw)
In-Reply-To: wp6dnZVo_NWE00ncRVn-3A@comcast.com

tmoran@acm.org wrote:

> 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.

Yes, agreed. (But of all the C-code that used fixed address values I've
seen yet, there was not one that used such a variable in that way.)

>>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,

I figured that. ;-)

> 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 surprised me a little bit was that GNAT didn't warn (ok, I have to
admit I didn't turn on all the warnings) or even refused to compile at
all.

>>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.

Ok, maybe. But even if it "works", the reason why it works might be the
wrong one...

>  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.

I'd say it is very improbable that it does.

> Porting this C program to another architecture certainly requires more
> than a transliteration into Ada.

That's what I was trying to say. ;-)


Vinzent.



  reply	other threads:[~2004-12-31  9:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-30 11:29 Pointer address Bj?rn
2004-12-30 12:18 ` Martin Krischik
2004-12-30 12:23 ` Vinzent 'Gadget' Hoefler
2004-12-30 18:51   ` tmoran
2004-12-31  9:57     ` Vinzent 'Gadget' Hoefler [this message]
2004-12-31  9:49   ` Björn
replies disabled

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