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

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

[avr-gcc-list] Optimisation help


From: Magnus Johansson
Subject: [avr-gcc-list] Optimisation help
Date: Mon, 21 Jan 2008 08:57:26 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Hi!

I'm new to avr-gcc and am having some trouble, could you help explain this optimisation to me, to me it doesn't work.

gcc version 4.1.1 (WinAVR 20070122) -Os

From .lss-file;

signed char read_gauge(void)
{
    13e2:       1f 93           push    r17
        unsigned char temp_uchar = 0;
        unsigned char result = 0;
...
        temp_uchar = ow_read_byte(matsticka, 1);
    14be:       61 e0           ldi     r22, 0x01       ; 1
    14c0:       81 e0           ldi     r24, 0x01       ; 1
    14c2:       0e 94 8a 05     call    0xb14   ; 0xb14 <ow_read_byte>
    14c6:       18 2f           mov     r17, r24

        if ((temp_uchar & 0x01) == 0)                                           
                                                    // If P0 = 1
                result += 1;
...
        temp_uchar = ow_read_byte(matsticka, 1);
    14ee:       61 e0           ldi     r22, 0x01       ; 1
    14f0:       81 e0           ldi     r24, 0x01       ; 1
    14f2:       0e 94 8a 05     call    0xb14   ; 0xb14 <ow_read_byte>

        if ((temp_uchar & 0x80) == 0x00)                                        
                                    // If P7 = 1
    14f6:       87 ff           sbrs    r24, 7
                result += 2;
    14f8:       1e 5f           subi    r17, 0xFE       ; 254
                
...

        temp_uchar = ow_read_byte(matsticka, 1);
    151a:       61 e0           ldi     r22, 0x01       ; 1
    151c:       81 e0           ldi     r24, 0x01       ; 1
    151e:       0e 94 8a 05     call    0xb14   ; 0xb14 <ow_read_byte>

        if ((temp_uchar &  0x40) == 0x00)                                       
                            // If P6 = 1
    1522:       86 ff           sbrs    r24, 6
                result += 4;
    1524:       1c 5f           subi    r17, 0xFC       ; 252
...

I totally get the second and third reads. But the first one, just moving r24 to r17 will only work if r24 is only 0x00 or 0x01 not otherwise...?

What should I do?




reply via email to

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