So does that mean that calling a function which takes an int with a byte
won't work? Or, alternatively, that calling a function with a byte that
expects an int won't work? Because, in my experience that does seem to
work. Maybe I haven't run across the problem in other contexts, though.
I expected the long to be shortened to int before the call, so that it would
be in R15. The confusing part was when it passed the lower portion in R14
instead.
On Thu, Oct 7, 2010 at 8:42 AM, Peter Bigot <[email protected]> wrote:
> 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
>
>
------------------------------------------------------------------------------
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