Dear All,

Please remove my e-mail adress from your list

E-mail: [email protected]
Thanks,

E van den Boom
----- Original Message ----- From: "Phil Sutherland" <[email protected]>
To: <[email protected]>
Sent: Sunday, January 24, 2010 10:43 AM
Subject: [Mspgcc-users] 430X patch: ldiv.S, and strtoul problem


Folks,
The patch below sorts out an issue with ldiv.S for the MSP430X libc.
There were two problems in the file;
a. Two instead of 4 registers were pushed at entry to ldiv when
__MSP430X__ was defined
b. The call to __divmodsi4 had not been converted to use the XCALL macro

Due to these problems, calls to strtoul and strtol (and thus also atol)
were causing processing to run off the rails.

There's a separate problem with strtoul, but I'm not sure of the proper
way to fix it. There appear to be three version of strtoul.c in the
msp430-libc/src tree, one in each of the bsd, gnu and stdlib
directories. The one in stdlib appear to be based on the bsd version,
but with a slight change to fix a bug. However, in a normal build the
source file in the bsd directory appears to be the one used, and strtoul
remains broken - it consistently returns 0xffffffff. I fixed the problem
locally by placing the patched version of the file from stdlib back into
the bsd directory. I suspect the correct fix is to do this, but also to
remove the file (and strtol.c, and qsort.c - the other duplicated files)
from stdlib altogether and rely on the bsd or gnu files to be used
instead - this gets rid of a source of confusion.

With these changes, as well as some attention to handling function
pointers within my code (had to write some asm() macros to work around
compiler issues), I'm now successfully building MPS430X software on
Linux for the MSP430F2418. I'm using a Windows box with the Elprotronic
loader software for loading; but this is only until I get the bugs out
of a serial boot loader which will largely replace it. Thanks to all for
the help which this list has provided to date.
Cheers
phil



Index: ldiv.S
===================================================================
RCS file: /cvsroot/mspgcc/msp430-libc/src/stdlib/ldiv.S,v
retrieving revision 1.2.2.1
diff -U3 -r1.2.2.1 ldiv.S
--- ldiv.S      26 Jan 2009 15:47:13 -0000      1.2.2.1
+++ ldiv.S      24 Jan 2010 04:43:57 -0000
@@ -6,7 +6,7 @@
ldiv:
;; save clobbers first
#if defined(__MSP430X__)
-        XPUSHM  #2, r11
+        XPUSHM  #4, r11
#else
        push    r11
        push    r10
@@ -19,7 +19,7 @@
        mov     r15, r13       ;; num
        mov     r14, r12
;; divide
-        call    #__divmodsi4
+        XCALL   #__divmodsi4
;; result is in there already...
;; restore regs and return.
#if defined(__MSP430X__)






Checked for Virus & Spam by West Australian Networks Internet Service Providers see www.westnet.net.au

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


Reply via email to