Sorry, you're right: I read this too quickly.

I don't think it's an ABI problem so much as a compiler problem: it's
actually passing the 32-bit value in registers r14 and r15, instead of
truncating it to an int and passing it in r15, as it's supposed to do when
there's no declaration.

Fine.  Yet another bug to fix.

Still, work around is to properly declare the function.  Then you can pass
it as a uint32_t, int, or uint8_t, whatever you want.

Peter

On Thu, Oct 7, 2010 at 7:26 AM, Kim Toms <[email protected]> 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.
>
> 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
>
> main()
> {
> uint32_t i = 123456;
> bytefunc(i & 0xFFL);
> }
>
>
> ------------------------------------------------------------------------------
> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to