Please note:

The error I mentioned occures with optimzation -O2.
I now found out with -O3 everything works fine, no further
workaround required.

Volker.


mspgcc-users-requ...@lists.sourceforge.net wrote:
Send Mspgcc-users mailing list submissions to
        mspgcc-users@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/mspgcc-users
or, via email, send a message with subject or body 'help' to
        mspgcc-users-requ...@lists.sourceforge.net

You can reach the person managing the list at
        mspgcc-users-ad...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Mspgcc-users digest..."


Today's Topics:

   1. BUG with float to int cast crashes msp430 + WORKAROUND (Volker Schindler)

--__--__--

Message: 1
Date: Sun, 28 May 2006 18:00:22 +0200
From: Volker Schindler <volker.schind...@aon.at>
To:  mspgcc-users@lists.sourceforge.net
Subject: [Mspgcc-users] BUG with float to int cast crashes msp430 + WORKAROUND
Reply-To: mspgcc-users@lists.sourceforge.net


Hello,

I experienced problems with the floating point package.
If I use a cast from float to integer, the msp430 totally crashes.

This cast uses the __fixunssfsi subroutine, which in turn calles
the __fixsfsi routine. Code of this routine is included below.
The first command and the last command before ret indicate
that it needs 12 additional bytes on the stack. This additional
stack space however does not seem to be reserved properly.

In particular I had a look how the stack pointer is initialized an
I found out that the 12 up most bytes of the msp430f149 are
NOT used. The code generated by the compiler initializes r1
with the value 2548; the up most byte of the ram is 2559 instead,
so I would expect r1 to be initialized at 2560. (Note: the 149 has
2048Bytes Ram + 512bytes SFR).

Comparing these 12 bytes offset with the 12 bytes the __fixsfsi
needs additional stack space I became curios and tried some
tricks in order to get the stackpointer initialized at 2560.
Adding RESERVE_RAM(-12) does the job. I was a bit surprised
that the compiler allowed me to consume this neg. amount of bytes
above the stack, but the result was

(a) the sp get properly initialized at 2560

(b) the float to int cast no longer crashes the msp430 into  nowhere land.

Greetings.

00003b26 <__fixsfsi>:
    3b26:    31 80 0c 00     sub    #12,    r1    ;#0x000c
    3b2a:    81 4e 08 00     mov    r14,    8(r1)    ;
    3b2e:    81 4f 0a 00     mov    r15,    10(r1)    ;
    3b32:    0e 41           mov    r1,    r14    ;
    3b34:    0f 41           mov    r1,    r15    ;
    3b36:    3f 52           add    #8,    r15    ;r2 As==11
    3b38:    b0 12 7a 3d     call    #15738        ;#0x3d7a
    3b3c:    0e 43           clr    r14        ;
    3b3e:    6f 41           mov.b    @r1,    r15    ;
    3b40:    6f 93           cmp.b    #2,    r15    ;r3 As==10
    3b42:    3a 24           jz    $+118        ;abs 0x3bb8
    3b44:    0e 93           cmp    #0,    r14    ;r3 As==00
    3b46:    33 20           jnz    $+104        ;abs 0x3bae
    3b48:    0e 43           clr    r14        ;
    3b4a:    6f 93           cmp.b    #2,    r15    ;r3 As==10
    3b4c:    01 2c           jc    $+4          ;abs 0x3b50
    3b4e:    1e 43           mov    #1,    r14    ;r3 As==01
    3b50:    0e 93           cmp    #0,    r14    ;r3 As==00
    3b52:    2d 20           jnz    $+92         ;abs 0x3bae
    3b54:    0e 43           clr    r14        ;
    3b56:    6f 92           cmp.b    #4,    r15    ;r2 As==10
    3b58:    2d 24           jz    $+92         ;abs 0x3bb4
    3b5a:    0e 93           cmp    #0,    r14    ;r3 As==00
    3b5c:    07 20           jnz    $+16         ;abs 0x3b6c
    3b5e:    1d 41 02 00     mov    2(r1),    r13    ;
    3b62:    0d 93           cmp    #0,    r13    ;r3 As==00
    3b64:    24 38           jl    $+74         ;abs 0x3bae
    3b66:    3d 90 1f 00     cmp    #31,    r13    ;#0x001f
    3b6a:    0b 38           jl    $+24         ;abs 0x3b82
    3b6c:    c1 93 01 00     cmp.b    #0,    1(r1)    ;r3 As==00
    3b70:    04 24           jz    $+10         ;abs 0x3b7a
    3b72:    0e 43           clr    r14        ;
    3b74:    3f 40 00 80     mov    #-32768,r15    ;#0x8000
    3b78:    21 3c           jmp    $+68         ;abs 0x3bbc
    3b7a:    3e 43           mov    #-1,    r14    ;r3 As==11
    3b7c:    3f 40 ff 7f     mov    #32767,    r15    ;#0x7fff
    3b80:    1d 3c           jmp    $+60         ;abs 0x3bbc
    3b82:    3c 40 1e 00     mov    #30,    r12    ;#0x001e
    3b86:    1e 41 04 00     mov    4(r1),    r14    ;
    3b8a:    1f 41 06 00     mov    6(r1),    r15    ;
    3b8e:    0c 8d           sub    r13,    r12    ;
    3b90:    0c 93           cmp    #0,    r12    ;r3 As==00
    3b92:    05 24           jz    $+12         ;abs 0x3b9e
3b94: 12 c3 clrc 3b96: 0f 10 rrc r15 ;
    3b98:    0e 10           rrc    r14        ;
    3b9a:    1c 83           dec    r12        ;
    3b9c:    fb 23           jnz    $-8          ;abs 0x3b94
    3b9e:    c1 93 01 00     cmp.b    #0,    1(r1)    ;r3 As==00
    3ba2:    0c 24           jz    $+26         ;abs 0x3bbc
    3ba4:    3e e3           inv    r14        ;
    3ba6:    3f e3           inv    r15        ;
    3ba8:    1e 53           inc    r14        ;
    3baa:    0f 63           adc    r15        ;
    3bac:    07 3c           jmp    $+16         ;abs 0x3bbc
    3bae:    0e 43           clr    r14        ;
    3bb0:    0f 43           clr    r15        ;
    3bb2:    04 3c           jmp    $+10         ;abs 0x3bbc
    3bb4:    1e 43           mov    #1,    r14    ;r3 As==01
    3bb6:    d1 3f           jmp    $-92         ;abs 0x3b5a
    3bb8:    1e 43           mov    #1,    r14    ;r3 As==01
    3bba:    c4 3f           jmp    $-118        ;abs 0x3b44
    3bbc:    31 50 0c 00     add    #12,    r1    ;#0x000c
3bc0: 30 41 ret



--__--__--

_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


End of Mspgcc-users Digest




Reply via email to