(By the way, is this getting anywhere? The mailing list archive doesn't
show anything more recent than May 20...)
Just a few more notes about sloppy code generation.
extern unsigned char P1OUT, P2OUT;
extern unsigned int BUF;
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:
1) As long as you're copying REG to r12, why not do:
mov ®, r12
mov.b r12, &P1OUT
swpb r12
mov.b r12, &P2OUT
ret
2) How about the shorter and faster version:
mov.b ®, &P1OUT
mov.b ®+1, &P2OUT
ret
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).
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!