That's not an ABI problem. Without a declaration available at the point of
call, C mandates that the parameter be assumed to be an int (two bytes). If
you define a function with non-int parameters, you have to have a compatible
declaration in scope wherever it's invoked. Using && to mask off bits, or
even casting the parameter, won't do any good.
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