On Tue, Apr 06, 2004 at 11:33:28AM -0500, Sergei Sharonov wrote:

> volatile short *pbuf, *plast;

>   pbuf = buf;
>   plast = buf + 10;
>   while(pbuf < plast);

This compiles to

    1494:       82 41 26 02     mov     r1,     &0x0226 ;
    1498:       0e 41           mov     r1,     r14     ;
    149a:       3e 50 14 00     add     #20,    r14     ;#0x0014
    149e:       82 4e 28 02     mov     r14,    &0x0228 ;
    14a2:       0f 41           mov     r1,     r15     ;
    14a4:       0f 9e           cmp     r14,    r15     ;
    14a6:       fe 2b           jnc     $-2             ;abs 0x14a4

It does update pbuf and plast, but then use the values hold in the registers
to do the while loop - what is obviously wrong. When you change plast
in a int.routine the while loop will never get any notice of this.
Sergei was right. A little bit to much optimisation. ;-)

        Matthias

Reply via email to