From: Richard G. <ri...@re...> - 2008-09-06 06:44:21
|
Forgive my picking up the thread here, but the discussion was so deeply nested I felt that a fresh-ish start was warranted. I must admit that I'm a bit puzzled by the paralysis the (admittedly poor) documentation seems to have caused... About two weeks ago I installed the SDCC rpm on my linux workstation and wrote a trivial program to see what happened when I compiled it. I must admit that there are still one or two things that I don't understand properly, but I consider that I've got a workable route from a C source to an EPROM and I can go from an edit to an EPROM in less than a minute now. All that with crap documentation too! I have probably only spent some six hours or so on this whole affair, to date. I've always felt that because I'm moderately intelligent (and far too modest!), all I really need with these things is a punt in the right direction to start me on my way. The rest I'll pick-up as I go along. Haphazard as this is, it's a method that has never failed me yet, and the documentation such as it is gave me exactly what I needed - a punt in the right direction - and in that respect I would say that it's a resounding success. Sure, there are lots of inaccuracies, but I have a pretty good idea what these are now, and at some point I might even be in a position to offer/make some corrections to the manual, if only because that's the kind of participation that Open Source tends to encourage. In time to come, the manual will be better than it is now because people such as myself are able to put their real experiences into it. Here's the program code that I used to get started (called test.c) - it's mostly un-commented; but was intended to give the compiler and the eventual target machine a good workout (hence the recursive factorial routine), and it's written in such a way that I can watch the progress fairly easily with a logic analyser. #include <z180.h> __sfr __at (Z180_IO_BASE+0x70) WDTRST; /* Watchdog timer reset */ static long Results[11]; void ConfigureCPU() { CNTLA0=0; /* Switch off serial port & clear RTS */ } long Factorial(int X) { long F; if (X>1) { F=X*Factorial(X-1); return F; } else return X; } void main() { int N; ConfigureCPU(); while (1) { char T; T=WDTRST; CNTLA0=CNTLA0 ^ 0x10; for (N=0; N<=10;N++) { long R; R=Factorial(N); Results[N]=R; } } } There's a tiny bit of assembler startup code required to make this work properly on my target machine; but this was all I needed to get to a position where I can actually now start to write some software that does something worthwhile with an adequate understanding of what SDCC can do for me. A bit of (not so bold) experimentation yields usable results very quickly, I would say. -- Richard. PGP Key-id: 0x5AB3D350 Do not try to solve all life's problems at once -- learn to dread each day as it comes. -- Donald Kaul |