Hi Kim,

On Thu, 7 Oct 2010 08:26:15 -0400
Kim Toms <kim.t...@gmail.com> wrote:

> I had a function which took a byte argument and returned a byte.  From
> another file (compiled into a separate object), I called the function
> without first declaring it.  The calling function used an argument which
> evaluated to uint32_t.

That seems to be your problem. At the time the compiler compiles
file2.c it doesn't know anything about bytefunc so it assumes its
declaration is int bytefunc (int arg). If you enabled warnings (-Wall)
you could see the compiler complaining about that.

> 
> In the called function, it looked for the argument in R15.  In the calling
> function, it left the low byte of the argument in R14.
> 
> Declaring the called function fixed the problem.  Here's an example:
> 
> file1.c:
> uint8_t bytefunc(uint8_t arg)
> { ...
> }
> 
> file2.c:
> extern uint8_t bytefunc(uint8_t); // this line required to make the ABI
> generate the correct code
> 

That's one way to solve it, but it is a bit tedious and not very clean.
Better, define a header file with your forward declarations and include
that one in file2.c.

> main()
> {
> uint32_t i = 123456;
> bytefunc(i & 0xFFL);
> }

Regards,

Hans

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to