Hacker News new | ask | show | jobs
by druzyek 2369 days ago
This article is specific to the 6502 where the commonly used CC65 C compiler the author references produces much, much worse code speed wise than what you can with pure assembly. In that regard, the article is not simplistic in the least. Coincidentally, I messaged the author just yesterday about the for loop example to point out that it was generated without optimization. Even with optimization enabled, the code is still about 3 times slower than hand written assembly. I know this may not be typical for other architectures like AVR but it certainly is for 6502.
1 comments

I used to do my production code exclusively in 6502 assembler, with some tools in P-system Pascal. As I would read in magazines about the C language I would try to imagine what the C compiler would generate for certain constructs, and I couldn't imagine it being efficient compared to other 8-bit processors. Then we decided to experiment (at the company) with C and got a compiler. I was right, the code was awful. It used exactly the idioms I thought I would use if I had to to it. I can picture a really top-notch compiler doing better (because I'm more familiar with optimization in compilers now), but sooner or later some of the quirks (like 8-bit index registers and only page 0 can be used for pointers) will catch you.