[Color Computer] [coco] Learning MW C (REALLY!)

Joel Ewy jcewy at swbell.net
Tue Aug 15 11:48:24 EDT 2006


George's Coco Address wrote:
> The C Programming Language, by Kernighan and Ritchie
> ..., I think, would be a great start once I learn how to use the OS-9
> software that is needed to compile whatever it is I might try.
>
> I would expect that whatever I can learn in the book and the online
> suppliment would work with the OS-9 compiler but, correct me if I am
> wrong.
>
> The book that came with the C-Compiler for OS-9 claims an almost
> perfect implementation of the K&R C. There are five instances
> mentioned in this book whick are exceptions. The OS9 book also
> mentions the K&R book as a reference. pp 1-2
>
My experience with this compiler 10+ years ago (patched to run from hard
drive) was that it worked as advertised.  I read K&R and found it fun,
easy to read and understand, and quite pertinent to programming in C on
the CoCo.  I don't think you need ANSI bla bla bla to do what you want
to do.  You're on the right path.
> Tomorrow, I'm going to begin reading this OS-9 book and try to
> understand the process of compiling the simple "Hello World" thing
> before I actually begin trying to compile the simple "Hello World"
> thing. That's where I went wrong several years ago. I didn't start
> with the basics.
>
> Once I get that to work, I think the snowball will begin to roll.
>
I think you're right.  Start simple and work your way up.  When
programming in C on the CoCo, you might want to give some thought to the
text editor you intend to use.  In my first experiences with OS-9 years
ago, I was slowed down by the rather primitive and unintuitive editors
that came stock with the system.  I later found sled, TS/Edit (with the
vi patch), and Bob Van Der Poel's VED/VPRINT.  You probably already have
a text editor you're comfortable with.  I only mention this because with
a classical C compiler you will spend a lot of time going back and forth
between the editor and the compiler.  You'll probably want to open
multiple windows so you can keep your source file open in the editor,
write it out without closing the program, switch to a shell in another
window, compile the modified source, test, and then switch back to the
editor.
> In order for you to follow what I'm doing, why I'm doing it this way,
> then the following may help you understand. This will allow those of
> you who can help me to do so without much distraction. I'll then need
> some real help learning the "Tricks Of The Trade".
>
> Here goes the onslaught of excessive verbiage.......
>
> I'm not a hardware/software engineer. I don't make my living with this
> stuff. It's only a hobby and not a major interest(compared to other
> things I do). I love connecting things to a coco. I love building
> steam engines even more. I NEED the coco to help me make complicated
> and precision parts for these engines and I am not going to spend more
> money on the manufacturing needs than the result is worth.
>
> I collect old stuff. I use that old stuff. ...
> Sometimes simple is easy... uh... well maybe ALWAYS is more accurate.
> The coco is simple.
I suspect a lot of us who still have and use CoCos have a similar
attitude to a greater or lesser degree.
> OS9 is much better(IMO) than RSDOS. I haven't tried anything else,
> because I simply love OS9 just the way it is(with all the patches, of
> course)....
> Heck! It already works(mostly). I just want to make it work faster,
> the natural way. Not with Nitros9 or a faster clock or CPLDs or stuff
> like the modern, super chips.
>
You're probably already aware of this, so forgive me if this is review,
but since I'm the one who brought up NitrOS-9, I'll just mention a few
reasons you might consider it. 
1.  You mentioned "all the patches" to the original OS-9.  NitrOS-9
already has probably all those bug fixes and improvements and more. 
Obviously you have your copy of OS-9 patched the way you want it, so
this in itself isn't a reason to change anything.  On the other hand, if
you did start using NitrOS-9 you probably wouldn't have to change much
to get things to a state that resembles what you have now.
2.  There is now a 6809 version of NitrOS-9 that doesn't require a 6309
processor.  My suggestion to use NitrOS-9 isn't based on trying to
squeeze more performance out of the system with a CPU upgrade
3.  NitrOS-9 is, for all intents and purposes, the OS-9 you know and
love.  It just has bug fixes, performance improvements, available source
code, some enhanced features, and ongoing development.  I don't think
you would have to waste much time learning and re-learning how to use
it.  The only real visible differences I've noticed from a user
perspective are improvements in the shell's command history features.  I
used to use shell+.  NitrOS-9's shell has similar features, but they are
better and more flexible.  When developing a C program, with its
edit-compile-test cycles, it is very nice to be able to use the up-arrow
to go back through your command history and repeat long command lines again.
4.  The main reason I suggested trying NitrOS-9 is that source is
available, so you could adapt a proper driver from existing device
driver source code.  My guess is that that idea doesn't appeal to you
much :)  And this is your project, your CoCo, and your hobby, so of
course you can do it the way you want to do it.  If you want maximum
speed an assembly language driver coupled with a C user application is
the way to go.  Good programming practice would also dictate that a
device driver is the proper place to manipulate the hardware.  I see
nothing wrong with accessing the hardware from within a C program as a
step along the way to developing a device driver.  And if you never get
beyond that point in your personal project, well, who cares?
5.  The bottom line here is that using your existing OS-9 setup isn't
wrong, and you should be able to do what you want to do.  On the other
hand, using NitrOS-9 instead isn't the equivalent of starting over from
scratch, learning a foreign system, or adding needless complexity.  But
there might be some pragmatic benefits, especially in the event that you
find out you need more speed than you can get from C.

JCE




More information about the Coco mailing list