OK, thanks.  Good to know.  I'll go back and put a bookmark in my K&R :-)

On Thu, Oct 7, 2010 at 2:21 PM, Peter Bigot <[email protected]> wrote:

> Third time's the charm?  It's been so long since I've dealt with K&R C I've
> forgotten the rules.
>
> The behavior is correct.  char and short are upcast to int when no
> declaration is in scope.  Integral types that are larger than int are left
> as is.  That you're masking off all but the low byte does not change the
> type of the expression that's used as a parameter: it's a 32-bit int on a
> 16-bit microcontroller, and requires two registers to pass by value.
>
> No bug here.  Either explicitly cast to int, or make sure there's a
> declaration in scope so the compiler knows what to do.  I suggest the
> latter.
>
> 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

Reply via email to