Hi All,

I have some strange code with gcc-3.2.3/binutils 2.16.1/msp430-libc (from the cvs).

I have a function that takes a function pointer, this function pointer gets pushed onto the stack.

The function prolog pushes the function pointer onto the stack as

push r15, 12(r1)

and then uses it in the function as

call 12(r1)

which is incorrect, because the call function decrements the stack pointer, then does the indirection, it should compile as

call 10(r1)

this appears to be a msp430-gcc bug and is quite hard to replicate.

Here is the output from msp430-objdump

int vuprintf(register int (*func)(int), const char *fmt, va_list ap) {
  14:   0b 12           push    r11             ;
  16:   0a 12           push    r10             ;
  18:   09 12           push    r9              ;
  1a:   08 12           push    r8              ;
  1c:   07 12           push    r7              ;
  1e:   06 12           push    r6              ;
  20:   05 12           push    r5              ;
  22:   04 12           push    r4              ;
  24:   31 80 1c 00     sub     #28,    r1      ;#0x001c
  28:   81 43 10 00     mov     #0,     16(r1)  ;r3 As==00
  2c:   81 43 12 00     mov     #0,     18(r1)  ;r3 As==00
  30:   81 4f 0c 00     mov     r15,    12(r1)  ;
  34:   04 4e           mov     r14,    r4      ;
  36:   81 4d 0e 00     mov     r13,    14(r1)  ;
    union {
        char c;
        uint8_t u8;
        int8_t i8;
        long l;
        unsigned long ul;
        char *pc;
#if PRINTF_LEVEL >= PRINTF_FLT
        double d;
        div_t dv;
#endif
    } a;
    char        c;      /* holds a char from the format string */
    uint8_t     base = 10;
  3a:   f1 40 0a 00     mov.b   #10,    20(r1)  ;#0x000a
3e: 14 00 char b[BUFLEN]; /*
                            * Contains character representation of the
                            * number and its prefix, written from back
                            * to front.
                            */
    char        *pb = 0;        /* used as pointer to an element in b */
  40:   81 43 16 00     mov     #0,     22(r1)  ;r3 As==00
    int         total_len;
#if PRINTF_LEVEL > PRINTF_MIN
    int8_t      width = 0;
  44:   c1 43 18 00     mov.b   #0,     24(r1)  ;r3 As==00
    int8_t      prec = 0;
  48:   c1 43 19 00     mov.b   #0,     25(r1)  ;r3 As==00
#endif
#if PRINTF_LEVEL >= PRINTF_FLT
    int8_t      decpt = 0;
    char        *fb;    /* floating point buffer, malloc'ed */
#endif
#if PRINTF_LEVEL < PRINTF_STD
    uint8_t flags;
#else
    uint16_t flags;
#endif

    flags = 0;
  4c:   81 43 1a 00     mov     #0,     26(r1)  ;r3 As==00
    total_len = 0;
#if PRINTF_LEVEL >= PRINTF_FLT
    fb = 0;
#endif
//    __write_char = func;

    DOPRINT('A');
  50:   3f 40 41 00     mov     #65,    r15     ;#0x0041
  54:   91 12 0c 00     call    12(r1)          ;

Anyone got any ideas?

Thanks,

--
Peter Jansen
STS
Australian Antarctic Division
203 Channel Highway
Kingston
TAS  7050
AUSTRALIA
Phone +61 3 6232 3533

___________________________________________________________________________

   Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not 
the
intended recipient, you are notified that use or dissemination of this 
communication is
strictly prohibited by Commonwealth law. If you have received this transmission 
in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 
3209 and
DELETE the message.
       Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________

Reply via email to