avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] avr-gcc (GCC) 3.4.5 Bug: copying structure through po


From: Ned Konz
Subject: Re: [avr-gcc-list] avr-gcc (GCC) 3.4.5 Bug: copying structure through pointer will destroy the pointer
Date: Mon, 6 Feb 2006 09:47:20 -0800


On Feb 5, 2006, at 11:54 PM, address@hidden wrote:

there is a bug in avr-gcc (GCC) 3.4.5, that comes with the latest WinAVR
distribution (20060125).
The avr-gcc (GCC) 3.4.3, that comes with WinAVR 20050214 does NOT contain
this bug.
The bug exists with and without optimization (I tried -O0 and -Os)
If you try to copy a structure with
 *struct_pointer = struct;
the struct_pointer gets destroyed.
The assembler code generated seems to add one structure length foreach
copied byte to the pointer.

Looks OK with avr-gcc 4.0.2

avr-gcc (GCC) 4.0.2

-O0

  49:main.c        ****             *rx_tel_in_ptr++ = RXtemp;
126                .LM8:
127 0052 8091 0000         lds r24,rx_tel_in_ptr
128 0056 9091 0000         lds r25,(rx_tel_in_ptr)+1
129 005a 9D83              std Y+5,r25
130 005c 8C83              std Y+4,r24
131 005e EC81              ldd r30,Y+4
132 0060 FD81              ldd r31,Y+5
133 0062 FF83              std Y+7,r31
134 0064 EE83              std Y+6,r30
135 0066 80E0              ldi r24,lo8(RXtemp)
136 0068 90E0              ldi r25,hi8(RXtemp)
137 006a 9987              std Y+9,r25
138 006c 8887              std Y+8,r24
139 006e 98E4              ldi r25,lo8(72)
140 0070 9A87              std Y+10,r25
141                .L7:
142 0072 E885              ldd r30,Y+8
143 0074 F985              ldd r31,Y+9
144 0076 0080              ld r0,Z
145 0078 8885              ldd r24,Y+8
146 007a 9985              ldd r25,Y+9
147 007c 0196              adiw r24,1
148 007e 9987              std Y+9,r25
149 0080 8887              std Y+8,r24
150 0082 EE81              ldd r30,Y+6
151 0084 FF81              ldd r31,Y+7
152 0086 0082              st Z,r0
153 0088 8E81              ldd r24,Y+6
154 008a 9F81              ldd r25,Y+7
155 008c 0196              adiw r24,1
156 008e 9F83              std Y+7,r25
157 0090 8E83              std Y+6,r24
158 0092 9A85              ldd r25,Y+10
159 0094 9150              subi r25,lo8(-(-1))
160 0096 9A87              std Y+10,r25
161 0098 EA85              ldd r30,Y+10
162 009a EE23              tst r30
163 009c 51F7              brne .L7
164 009e 8C81              ldd r24,Y+4
165 00a0 9D81              ldd r25,Y+5
166 00a2 885B              subi r24,lo8(-(72))
167 00a4 9F4F              sbci r25,hi8(-(72))
168 00a6 9093 0000         sts (rx_tel_in_ptr)+1,r25
169 00aa 8093 0000         sts rx_tel_in_ptr,r24


-Os
  49:main.c        ****             *rx_tel_in_ptr++ = RXtemp;
110                .LM7:
111 0038 8091 0000         lds r24,rx_tel_in_ptr
112 003c 9091 0000         lds r25,(rx_tel_in_ptr)+1
113 0040 FC01              movw r30,r24        ; z reg
114 0042 A0E0              ldi r26,lo8(RXtemp) ; x reg
115 0044 B0E0              ldi r27,hi8(RXtemp)
116 0046 28E4              ldi r18,lo8(72)
117                .L6:
118 0048 0D90              ld r0,X+
119 004a 0192              st Z+,r0
120 004c 2150              subi r18,lo8(-(-1))
121 004e E1F7              brne .L6
122 0050 885B              subi r24,lo8(-(72))
123 0052 9F4F              sbci r25,hi8(-(72))
124 0054 9093 0000         sts (rx_tel_in_ptr)+1,r25
125 0058 8093 0000         sts rx_tel_in_ptr,r24


-O2

  49:main.c        ****             *rx_tel_in_ptr++ = RXtemp;
110                .LM7:
111 003c F901              movw r30,r18
112 003e A0E0              ldi r26,lo8(RXtemp)
113 0040 B0E0              ldi r27,hi8(RXtemp)
114 0042 88E4              ldi r24,lo8(72)
115                .L6:
116 0044 0D90              ld r0,X+
117 0046 0192              st Z+,r0
118 0048 8150              subi r24,lo8(-(-1))
119 004a E1F7              brne .L6
120 004c 285B              subi r18,lo8(-(72))
121 004e 3F4F              sbci r19,hi8(-(72))
122 0050 3093 0000         sts (rx_tel_in_ptr)+1,r19
123 0054 2093 0000         sts rx_tel_in_ptr,r18


--
Ned Konz
address@hidden







reply via email to

[Prev in Thread] Current Thread [Next in Thread]