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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2cba5965c7bfcd5,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-03 07:01:33 PST Message-ID: <3C823A1A.6030006@users.sf.net> From: Dave Poirier User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: 64bit access to an array of 8bit values Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 03 Mar 2002 09:58:34 -0500 NNTP-Posting-Host: 65.94.42.23 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1015167515 65.94.42.23 (Sun, 03 Mar 2002 09:58:35 EST) NNTP-Posting-Date: Sun, 03 Mar 2002 09:58:35 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!netnews.com!xfer02.netnews.com!newsin.iconnet.net!feed.tor.primus.ca!feed.nntp.primus.ca!newsfeed.torontointernetxchange.net!radon.golden.net!news1.tor.metronet.ca!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:20723 Date: 2002-03-03T09:58:34-05:00 List-Id: I'm trying to modelize a small virtual machine, and I'm stuck on the memory model. I'm defining the memory as an array of 8bit values, so that I am able to access every byte individually. The problem comes when I try to access them with other data size, like 16/32/64bit. GNAT simply refuses to do the pointer conversion (yeah, probably a bad habit). So, what would be a "clean" way to do it? here's what I tried ------ procedure test is type Bit8 is mod 2**8; type Bit64 is mod 2**64; type Bit8Acc is access Bit8; type Bit64Acc is access Bit64; type RamRange is range 0 .. 4000; Ram : array (RamRange) of aliased Bit8; Value : Bit64Acc; begin Value := Ram(0)'Access; end test; ------ test.adb:14:18: expected type "Bit64Acc" defined at line 6 test.adb:14:18: found type access to "bit8" defined at line 14 and also.. ------ procedure test is type Bit8 is mod 2**8; type Bit64 is mod 2**64; type Bit8Acc is access all Bit8; type Bit64Acc is access all Bit64; type RamRange is range 0 .. 4000; Ram : array (RamRange) of aliased Bit8; Value : Bit64Acc; begin Value := Bit64Acc(Ram(0)'Access); end test; ------ test.adb:14:12: argument of conversion cannot be access test.adb:14:12: use qualified expression instead I'm just a smooth skinned Ada95 newbie, so don't get too big weapons to send replies ;) Thanks for helping me learn :) EKS - Dave Poirier