Version 3.2.3 is doing some strange things when I try to
multiply 32bit and 16bit variables.

look this (with -O2)

volatile long a;
volatile int b;

int test ( void )
{
    long c = (long)b * 65536l;

    return ( ! ( (a==0) || (a>=c) || (b==42) ) );
}

00002988 <test>:
    2988:       0b 12           push    r11             ;
    298a:       1f 42 3e 02     mov     &0x023e,r15     ;0x023e -> b
    298e:       0e 4f           mov     r15,    r14     ;
    2990:       0f 4e           mov     r14,    r15     ;
    2992:       0f 5f           rla     r15             ;
    2994:       0f 7f           subc    r15,    r15     ;
    2996:       3f e3           inv     r15             ;
    2998:       0d 4e           mov     r14,    r13     ;
    299a:       0b 43           clr     r11             ; <- should be R12??
    299c:       1e 42 9a 02     mov     &0x029a,r14     ;0x029a ->a
    29a0:       1f 42 9c 02     mov     &0x029c,r15     ;0x029c ->a
    29a4:       0f de           bis     r14,    r15     ;
    29a6:       0f 93           cmp     #0,     r15     ;r3 As==00
    29a8:       0c 24           jz      $+26            ;abs 0x29c2
    29aa:       1e 42 9a 02     mov     &0x029a,r14     ;0x029a ->a 
    29ae:       1f 42 9c 02     mov     &0x029c,r15     ;0x029c ->a
    29b2:       0e 8c           sub     r12,    r14     ;<----------??
    29b4:       0f 7d           subc    r13,    r15     ;
    29b6:       05 34           jge     $+12            ;abs 0x29c2
    29b8:       b2 90 2a 00     cmp     #42,    &0x023e ;#0x002a
    29bc:       3e 02
    29be:       01 24           jz      $+4             ;abs 0x29c2
    29c0:       1b 43           mov     #1,     r11     ;r3 As==01
    29c2:       0f 4b           mov     r11,    r15     ;
    29c4:       3b 41           pop     r11             ;
    29c6:       30 41           ret

Where is R12 initialized??? (using <<16 it works).

And there must be another bug, that I have not yet found.
When I try to calculate a average over 256 values using long I get
different results compared to my solution calculated with
the host PC (I use "short int" and int instead of int and long).

Use long with care! ;-(

How can I avoid the usage of so much registers?
  mov #1, r11
  mov r11,r15
  ret
seems a little bit crazy!?

M.

Reply via email to