[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C programming langauge on Apple II
Eric wrote:
> Leor, didn't you write BDS C in 8080 assembly language? As I recall it
> was faster than the alternatives, and perhaps the best overall 8-bit C
> compiler. I think I saw that you've also opened the source for it, so
> I'll have to check on it for old times sake.
Yup, 8080 assembler using ASM.COM for the first several versions, then
others such as LINKASM. It's all I had to work with...and it got a lot
easier once I got a hard disk to do the building on, lol.
In reference to the discussion of generated code quality, 8080's aren't
all that much better "optimized" for compiler-generated code than
6502's, I guess, except for the 16-bit SP support. I had an "aha!"
moment when I realized I could employ the 1-byte interrupt vector
"restart" ops as subroutine calls to very common code sequences used to
fetch 16 bits of data at an offset specified by the following 1 or 2
bytes. That led to somewhere around a 20% code size reduction for those
valuing space over speed (or with -o, it left the fetch code in situ).
My biggest "Aw man, I shoulda done it THAT way...." moment was when PJ
Plauger told me how he did the local variable accessing with
Whitesmiths. Instead of using BC as a base-of-frame pointer, which to
me seemed intuitive, Bill just always offset from the SP, and kept
track of how much stuff had been pushed/popped and just adjusted the
offsets accordingly. If I'd done that instead of hogging up BC with the
frame pointer, I would have had BC to use for an actual "register"
variable, and that would have made a major impact (not only would the
compiler have compiled 10 time faster than Whitesmiths, the code would
have been better...as it was, Whitesmiths was a little better.)
Hindsight is always 20-20... ;-)
-leor
>
> UPDATE: as I was writing this message I found this link from Google.
> Very cool site for BDS C. Thanks much Leor! If you're ever in the
> Atlanta area I'll buy you a beer!
Darn, I was just there for two weeks in March teaching C and C++. I'll
probably be back at some point...