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

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

RE: [avr-gcc-list] An old but unfixed bug


From: Alexander Popov
Subject: RE: [avr-gcc-list] An old but unfixed bug
Date: Wed, 22 Aug 2001 10:03:37 +0300

Hello, Jeremy!
Thank you for your reply!

> Your while condition is comparing an int (0xffff == -1) cast to a pointer. 

        I don't know how pointers are compared, but i think it is as unsigned 
values  

>  If your pointer p is initialised to any value <= 0x7fff your while
> condition fails on the first pass.  The source file you sent showed p =
> RAMEND + 1.  Usually a small positive number (eg. 4433 --> 0x15F + 1) so you
> have:         while ( 352 < -1 );  // fail 

        I tried with 0x8001 and the result was absolutely the same as with 
0x15f  

        I made another try - changed the value 0xffff to 0xfffe and everithing 
was 
ok - the code generated included the loop. If you were right about signed 
compare, then this change would not have made any diference since       352 < -
1 fails 352 < -2 fails  
        
        Then I see the code generated for the decrement and compare part of the 
loop (with compare value 0xfffe) :

 subi r18,lo8(-(1))
 sbci r19,hi8(-(1))
 ldi r24,hi8(65535)
 cpi r18,lo8(65535)
 cpc r19,r24
 brlo .L18

        Noticed 65535? If we increment compare value with 1, this will become 
65536 which overflows and acts like 0. So we check if some unsigned value 
(the pointer) is less than 0. This is always false, so the loop is skipped.  

This is my theory...

Regards,
Alexander Popov



reply via email to

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