Folks,
The following patch fixes a bug in long long handling in the gcc library
for 430X - an incorrect stack offset was being used to fetch an argument
when MSP430X compiling was enabled. The bug affected low-level
multiplication, division and modulus operations on 64 bit integers.
Cheers
phil
Index: gcc/config/msp430/libgcc.S
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/libgcc.S,v
retrieving revision 1.15.2.2
diff -u -8 -p -r1.15.2.2 libgcc.S
--- gcc/config/msp430/libgcc.S 5 Feb 2009 01:29:37 -0000 1.15.2.2
+++ gcc/config/msp430/libgcc.S 30 Mar 2010 11:53:05 -0000
@@ -1,19 +1,21 @@
/* -*- Mode: Asm -*- */
#if defined(__MSP430X__)
#if defined(__MSP430X_ADDR_16BIT__)
#define XBR br
#define XCALL call
#define XRET ret
+ .equ RET_SIZE, 2
#else
#define XBR bra
#define XCALL calla
#define XRET reta
+ .equ RET_SIZE, 4
#endif
#if defined(__MSP430X_REGS_16BIT__)
#define XPUSH pushx.w
#define XPOP popx.w
#define XPUSHM pushm.w
#define XPOPM popm.w
.equ PUSH_BYTES, 2
#else
@@ -25,16 +27,17 @@
#endif
#else
#define XBR br
#define XCALL call
#define XRET ret
#define XPUSH push
#define XPOP pop
.equ PUSH_BYTES, 2
+ .equ RET_SIZE, 2
#endif
.section .text.libgcc, "ax", @progbits
#if defined (L_cmpdi2)
.global __cmpdi2
.func __cmpdi2
@@ -762,20 +765,20 @@ __udivmoddi3_parts:
#define r_arg2hl r6
#define r_arg2lh r5
#define r_arg2ll r4
#endif
.macro load_arg2
;; First arg will be in r15:r12
;; next on stack
- .equ stack_offset, PUSH_BYTES * 8 + 2
+ .equ stack_offset, PUSH_BYTES * 8 + RET_SIZE
- mov stack_offset+0(r1), r_arg2ll ; 18/34 is a stack offset
- mov stack_offset+2(r1), r_arg2lh ; so move arg 2 in.
+ mov stack_offset+0(r1), r_arg2ll ; Retrieve 2nd argument
from stack, allowing for
+ mov stack_offset+2(r1), r_arg2lh ; 430/430X and reg save
model variations
mov stack_offset+4(r1), r_arg2hl
mov stack_offset+6(r1), r_arg2hh
.endm
#if defined (L_udivdi3)
;; First arg will be in r15:r12
;; next on stack
Checked for Virus & Spam by West Australian Networks Internet Service Providers
see www.westnet.net.au