Alas, I'm not sure this explanation holds water. In a normal
implementation of a vararg style function in C the address of the last
fixed argument to the function is used as the starting point, and
subsequent arguments are located on the stack as offsets from the
address of this fixed argument. At a glance, this mechanism appears to
be being used in the 430X C library.

As luck would have it I've hit some anomalous *printf behavior myself in
the last few hours, so I'll dig a bit deeper tomorrow and see what I can
come up with - hopefully it'll be the same issue.
Cheers
phil


JMGross wrote:
>
> One possible explanation:
>
> when calling a function in msp430x environment, the CALLA instruction is used 
> and two words are pushed to the stack for the return address (instead of one 
> with the CALL instruction).
> The printf function in the library does not know about this, so it takes the 
> upper word of the return address as pointer to the format string, leading to 
> a totally wrong result.
> (Actually, printf just generates a pointer to the (wrong) locations of the 
> parameters on the stack and forwards this to vprintf. And vprintf will look 
> at the wrong places.)
>
> -mdata64k does only ensure that the addresses of the format string and any 
> other data pointers will be in lower 64k and therefore 16 bit pointers. It 
> won't help printf to work with the unexpected extra word on the stack.
>
> I'm not 100% sure that this really is the reason, but unless printf has been 
> rewritten...
>
> you can try to use vprintf instead, it should work, as it does not get its 
> parameters on the stack.
>
> JMGross
>
> ----- Ursprüngliche Nachricht -----
> Von: enken
> An: [email protected]
> Gesendet am: 23 Jan 2010 17:40:10
> Betreff: Re: [Mspgcc-users] mspx54xx msp430X mspgcc libc printf not working
>
> simonC wrote:
>   
>> Hi,  I have built the latest msp430X release from mspgcc repository. 
>> Spent time cleaning up headers, binutil 2.18 to support correct infomem
>> start and size values.  Also corrected issues with libmspgcc.  
>>
>> I have hit a wall, printf with formating strings and subsequent variables
>> doesn't work.  I have tried compiling with -mdata-64k but doesn't solve
>> the problem.
>>
>> Has anyone been able to resolve this issue?
>>
>> Bye Simon
>>
>>     
>
> I have the same problem.
>
>
> ------------------------------------------------------------------------------
> 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
>
> Checked for Virus & Spam by West Australian Networks Internet Service 
> Providers see www.westnet.net.au
>   


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

Reply via email to