[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] avr-gcc generating ldd r31, Z+
From: |
Jens Andersen |
Subject: |
Re: [avr-gcc-list] avr-gcc generating ldd r31, Z+ |
Date: |
Sat, 29 Dec 2001 04:32:35 +0100 |
Hi Ken
I have checked the Atmel instruction set document, and to me it
seems that the gcc generated code is ok.
As i read it, it says that if you load (Z) r30,r31 using the
Z+ (post-increment) or -Z (pre-decrement) form the result is undefined.
The gcc code uses the Z+q (displacement) form of the ldd instruction
which leaves Z unchanged, so it should be ok.
I hope this helps you.
Jens Andersen
ken restivo wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I seem to have found an avr-gcc/as bug, or perhaps I am doing something wrong
> here.
>
> Here is the relevant section of disassembly:
>
> t = t->next;
> 152: 07 80 ldd r0, Z+7 ; 0x07
> 154: f0 85 ldd r31, Z+8 ; 0x08
> 156: e0 2d mov r30, r0
>
> The databook states that ldd r31, Z+ is undefined, and simulavr is honoring
> that and halting at instruction 0x154.
>
> But t = t->next seems like a straightforward idiom. It works fine with gcc on
> i386, of course, and even works in avr-gcc in a simple test program, if the X
> and Z registers are free for use. But not here, though, for some reason I
> don't understand.
>
> At this point in the function's execution, most of the call-used registers
> are in use, and a few of the call-saved registers too... there aren't a lot
> of free registers floating around. So I could understand if there was simply
> no place else to put this except to over-use the Z register. But why would
> avr-gcc use the LDD instruction in a way that is undefined? I would guess
> that it would move the items in the Z reg out of the way, save stuff onto the
> stack, or at least fail to compile with an error? I wonder if I am not doing
> something that I shouldn't be?
>
> Any help or clues would be appreciated.
>
> - -ken
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iD8DBQE8LQ7Ke8HF+6xeOIcRArZMAKCdKmRMKTWx3P2DIzah2SCxXQJ1tACfVgkf
> q5IXRUWT9woYHnR0fyspRfM=
> =cpWJ
> -----END PGP SIGNATURE-----
> avr-gcc-list at http://avr1.org
avr-gcc-list at http://avr1.org