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,9f3d09bde7b33b5d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-09 12:34:50 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!adsl-213-200-246-247.cybernet.CH!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: Pass by reference Date: Fri, 09 Apr 2004 21:33:20 +0200 Organization: JeLlyFish software Message-ID: References: <19b0e504.0404080652.4eab9f80@posting.google.com> <5QAdc.7896$Jf6.4030@newssvr23.news.prodigy.com> NNTP-Posting-Host: adsl-213-200-246-247.cybernet.ch (213.200.246.247) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 1081539288 91326433 I 213.200.246.247 ([175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:6923 Date: 2004-04-09T21:33:20+02:00 List-Id: Pat Rogers wrote: >If you made the type volatile that would also force by-reference. Are you sure? I'm just looking at the assembly ouput of GNAT for a procedure that takes a volatile type (memory mapped register) and it does't seem so. Even worse, it optimizes the sequence of assignment which I need for this register. If you have any idea how can I avoid using access types to make it right, I'd be glad to hear it. Here's the procedure: | -- Write ------------------------------------------------------------ | -- writes a timer value (low byte/high byte in succession) to the -- | -- memory mapped timer port given by its access -- | --------------------------------------------------------------------- | procedure Write (Timer_Reg : in out Registers.Reg_8; | Value : in i8254_Timer) is | Internal_Value : Interfaces.Unsigned_16 :=3D To_U16 (Value); | begin | Timer_Reg :=3D Lo_Byte (Internal_Value); | Timer_Reg :=3D Hi_Byte (Internal_Value); | end Write; the assembly output is: |_timer__write: | pushl %ebp | movl %esp,%ebp | movl 12(%ebp),%eax | movl %eax,%edx | cmpl $65536,%eax | jne L21 | xorl %edx,%edx |L21: | movl %edx,%eax | movl %ebp,%esp | shrw $8,%ax | popl %ebp | ret which is not what it should be. If I change it back to use access types: | procedure Write (Timer_Reg : in Registers.Reg_8_Access; | Value : in i8254_Timer) is | Internal_Value : Interfaces.Unsigned_16 :=3D To_U16 (Value); | begin | Timer_Reg.all :=3D Lo_Byte (Internal_Value); | Timer_Reg.all :=3D Hi_Byte (Internal_Value); | end Write; everything is fine: |_timer__write: | pushl %ebp | movl %esp,%ebp | movl 12(%ebp),%eax | movl 8(%ebp),%ecx | movl %eax,%edx | cmpl $65536,%eax | jne L21 | xorl %edx,%edx |L21: | movl %edx,%eax | movb %dl,(%ecx) | shrw $8,%ax | movl %ebp,%esp | movb %al,(%ecx) | popl %ebp | ret Vinzent.