[Color Computer] [coco] Learning MW C
Joel Ewy
jcewy at swbell.net
Sat Aug 12 11:23:10 EDT 2006
Carey Eugene wrote:
> From: "George's Coco Address" <yahoo at dvdplayersonly.com>
>
>
>> For several years, I've been wanting to learn "C" .. the one that comes
>> with OS-9.
>>
>> The hang up is peeks and pokes. I can't find a way to do this with "C".
>>
>
> The other replies have already told you how to do the equivalent of peek &
> poke, however I have just got to add a few things.
>
> First, I'm not so sure it's a good idea to learn that old MW C. It's a
> limited form of K&R style C. It doesn't meet the current 1999 ISO C
> standards, or the 1989 C standards. It doesn't even completely meet the old
> K&R unofficial C standards. It has some limitations and quirks due to it
> being an 8 bit compiler.
>
>
This is true, though if you really just plan on writing programs for the
CoCo, standards compliance is probably a non-issue. If you want to
learn C for more general use, or with an eye to porting your programs
between platforms, then it becomes more important. But Going from K&R
to ANSI is probably easier than the other way around I would think. My
understanding is that the Microware C compiler does produce pretty good
code for the 6809, and if that's your intent, I would think it would
still be a reasonable option.
> Microware's C compiler was the first version of C that I learned, and when I
> later switched to a more modern compiler, I had a lot to unlearn and
> re-learn.
>
> Now, having said that, if you want to learn it and use it, go ahead....
>
> But, unless you are planning on doing something rather unusual, like
> accessing hardware directly, you shouldn't really need 'peek' and 'poke'.
>
> C can do that sort of thing, and about anything else. But C prefers that
> you deal with more abstract data types. Arrays, structures, pointers to
> them, etc.
>
> Never directly 'peek' and 'poke'ing data. You can do it. But you rarely
> will need to do it. If you do, then you are probably doing something
> 'wrong'. (Like writing ASM style code in BASIC, Fortran, PASCAL or C... You
> can do it, but it'll look ugly, be awkward and wont take advantage of the
> features and abilities of the language.)
>
>
Right. The only reason you would need to write directly to specific
memory locations is if you are writing a device driver -- which should
probably be done in assembly language on the 6809. But I suppose that
it wouldn't be totally wrong to poke at the hardware a little from
within a C program while figuring out how to use the hardware as you're
developing your driver.
> I'd suggest you browse the web for a few good free C tutorials. (Just be
> aware that whatever you find will likely be for ANSI / ISO C, rather than
> the older K&R C. If you browse hard enough or search the p2p networks, you
> might be able to find a scanned copy of the Kernighan & Ritchie's original
> K&R C book.)
>
> ...
>
What alternatives are there for C programmers on the CoCo? I know of
James Dessart's GCC cross-compiler, which now seems to be maintained by
someone else at this site: http://www.oddchange.com/gcc6809/. How well
does this work with the CoCo? With OS-9? It looks like you need to add
linker, assembler, etc. to get a complete toolchain. And it looks like
there are few if any libraries that will work with this thing on the
CoCo. Am I wrong? It would be really cool to see this project become
completely useful for producing CoCo software, but from the look of the
web sites it would seem that at this moment the Microware C compiler is
still probably the most usable option for programming in C on the CoCo.
JCE
More information about the Coco
mailing list