While there may be bugs in the msp430 floating point support (I've never
used it myself), as a general rule you should never try to test floats for
equality, since floats are inherintly inexact - for example, you may find
that 1.0+3.0 != 2.0+2.0 .  Of course, there are other things going wrong
here in this example.


> Hi,
>
>   The following code:
>
>     int a=0,b=0;
>
>     asm(";oops begin...\n");
>
>     float data;
>     data = 12.345;
>
>     if (data==0.0) {
>       a=1;
>     } else {
>       a=2;
>     }
>     if (data!=0.0) {
>       b=3;
>     } else {
>       b=4;
>     }
>
>     asm(";oops end...\n");
>
>   Always returns a=1 and b=3 ... which means there is some bug... the .s
> file follows:
>
> /* #APP */
> ;oops begin...
>
> /* #NOAPP */
> mov #llo(0x4145851f), r10
> mov #lhi(0x4145851f), r11
> mov #llo(0x0), r12
> mov #lhi(0x0), r13
> mov r10, r14
> mov r11, r15
> call #__eqsf2
> tst r15
> jne .L89
> mov #llo(1), r9
> jmp .L91
> .L89:
> mov #llo(2), r9
> .L91:
> mov #llo(0x0), r12
> mov #lhi(0x0), r13
> mov r10, r14
> mov r11, r15
> call #__nesf2
> tst r15
> jeq .L92
> mov #llo(3), r15
> jmp .L94
> .L92:
> mov #llo(4), r15
> .L94:
> /* #APP */
> ;oops end...
>
> /* #NOAPP */
>
>    How you can see, both comparisons are wrong.
>
>    I had similar problems with less than "<" comparing floats, but I
> don't have a source code now to demonstrate.
>
>    I compiled with:
>
> msp430-gcc -O -Wall -mmcu=msp430x149 -S -o xxx.s xxx.c
>
>    Thanks,
>      Pedro
>
> --
>   .''`.   Pedro Zorzenon Neto <p...@terra.com.br>
>  : :'  :  Debian GNU/Linux | GNU/Hurd: <http://www.debian.org>
>  `. `'`   Debian BR: <http://debian-br.cipsga.org.br>
>    `-     Be Happy! Be FREE!
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>



Reply via email to