[Coco] Need some advice
William Astle
lost at l-w.ca
Sun May 22 00:56:45 EDT 2016
On 16-05-21 10:22 PM, Greg wrote:
> I think the C/C++ compilers today have significantly better optimizers,
> but I'm not quite willing to bet a nickle that machine-generated C code
> can always match human-generated assembly. On the other hand, I'm not
> quite so sure I could create assembly code on a modern processor any more.
Modern C compilers do quite well with optimization enabled. gcc6809, for
instance, does surprisingly well with 6809 code given that there are
some non-trivial problems with how it counts the cost of various
instructions.
gcc6809 also has a modified calling convention that uses B and X for the
first 8 and 16 bit parameters respectively and returns 8 bit values in B
and 16 bit values in X. Other parameters go on the stack as usual, and
all parameters do for variadic functions (for implementation reasons).
That makes a significant improvement in the average case, too.
Even so, hand written 6809 code is often slightly better than the
gcc6809 output and occasionally substantially better. That's not
surprising given the general simplicity of the 6809 itself. It also
supports your reluctance to wager that the compiler will always be better.
More information about the Coco
mailing list