> void
> foo(void)
> {
> P1OUT = (unsigned char)BUF;
> P2OUT = (unsigned char)(BUF>>8);
> }
>
> compiles to:
> foo:
> mov.b ®, &P1OUT
> mov ®, r12
> swpb r12
> mov.b r12, &P2OUT
> ret
>
> Two improvements that chould be made:
cannot do that, cause )1OUT declated as volatile.
> 2) How about the shorter and faster version:
> mov.b ®, &P1OUT
> mov.b ®+1, &P2OUT
> ret
The rule is "do not be tooooo smart" :).
>
> mspgcc doesn't appaear to know how to read only the high byte of an
> integer. (gcc-3.2.3 on x86 can do it).
how? which instruction?
The next -- it does exactly what you're saying. Obviously, the compiler cannot
do everything as good as people do. So, just forgive gcc for it :)
I wrote in faq, and docs, that just analyze the code and do something, or
whatever you whant to improve it... So, if you can show the way _how_ to
improve it -- just do it.
~d
>
>
> Second, gcc sometimes creates unnecessary temporaries.
>
> unsigned baz(unsigned x, unsigned y)
> {
> return x + y;
> }
>
> Compiles to the desired code:
> baz:
> add r14, r15
> ret
>
> But if I swap x + y to y + x, it gets a lot worse:
> baz:
> mov r15, r12
> mov r14, r15
> add r12, r15
> ret
>
>
>
> Thanks for the great tool and apologies for complaining so much!
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ObjectStore.
> If flattening out C++ or Java code to make your application fit in a
> relational database is painful, don't do it! Check out ObjectStore.
> Now part of Progress Software. http://www.objectstore.net/sourceforge
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
--
/********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 3468202, 5585314
********************************************************************/