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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,40bf3d9b43d88cff,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: Tomas Cernaj Subject: Access to fixed memory location Newsgroups: comp.lang.ada User-Agent: Pan/0.129 (Benson & Hedges Moscow Gold) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 30 Nov 2007 19:32:29 GMT Message-ID: <4750654d$0$13115$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 30 Nov 2007 20:32:29 CET NNTP-Posting-Host: cd7355a9.newsspool2.arcor-online.net X-Trace: DXC=f00X`Y1UjSHf;Bg=1B;EnI3JDLR[O15[\ACO6h7]UAPH2FD X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:18682 Date: 2007-11-30T20:32:29+01:00 List-Id: Hello everyone, is there any way to tell the Ada compiler that an Address attribute should be constant? I want to use it for accessing fixed memory locations, and without the Address attribute being constant the compiler won't optimize away an indirect access. I couldn't find anything in the RM or GNAT documentation... The point is that I want to use the 'Address construct on the AVR target, which is an 8-bit processor, so the indirect access is quite expensive. I suppose that was a bit unclear, so here's an example: :) I have the following declarations in a package spec file: type T_Type is array (0 .. 7) of Boolean; pragma Pack (T_Type); for T_Type'Size use 8; package TA is new System.Address_To_Access_Conversions (T_Type); X : constant access T_Type := TA.To_Pointer (System.Storage_Elements.To_Address (50)); Y : T_Type; for Y'Address use System.Storage_Elements.To_Address (51); pragma Import (Ada, Y); Note that X is something like a "T_Type * const X" in C. Compiling the following code X (4) := True; Y (5) := True; with GNAT (gcc-4.2 -O -S) yields this assembler output (x86-64): orb $16, 50 ; X (4) := True movq testpkg__y(%rip), %rdx ; Y (5) := True movzbl (%rdx), %eax orl $32, %eax movb %al, (%rdx) That's because the compiler can not assume that Y'Address will not be changed. Thank you for your help, Tomas