AnsweredAssumed Answered

Problems with the value returned from a function - MCF52233

Question asked by Ruben Valls Blasco on Dec 2, 2009
Latest reply on Dec 3, 2009 by Ruben Valls Blasco

Hi everyone!

I am having problems with a function that should return a pointer if it find free memory (it is calloc1, in the Interniche Lite Stack). The problem is that when it returns a valid memory, it returns a correct result, but when it should return NULL, then it returns something but NULL. I am having problems also with tcp_pkalloc, having exactly the same behaviour.

I have been looking at the ASM code, and realized that when they return an address, they use A0, but when they return the NULL, both functions put a zero in D0, NOT in A0, but the caller function (in both cases) takes A0 as the register where is the result, resulting in malfunction only when result is NULL.

I have got this functions in a pre-compiled library using Standard Parameter Passing, that is the same I am using in my application.

 

I am using MCF52233 and CodeWarrior for ColdFire V 6.3. 

 

I am absolutely lost on this.  Any help is welcomed.

 

Thanks in advance,

Rubén

Message Edited by RValls on 2009-12-02 12:58 PM

Outcomes