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.


Reply via email to