[Coco] C and Stack size

John W. Linville linville at tuxdriver.com
Tue Apr 8 16:07:56 EDT 2008


On Tue, Apr 08, 2008 at 01:55:15PM -0400, Ries, Rich (NY80) wrote:
> This piece of a message set tripped the ol' grey cells:
> > I'd hate to have to implement that on the 6502.  A C compiler on the
> > 6502 is ugly and C is only partially stack based.  The 6502 only has
> > an 8 bit stack pointer, 8 bit pointer registers and to get around that
> > you have to use page 0.
> 
> 'Way back in '93, Byte Craft Limited had a C compiler for the National
> Semiconductor COP chips. The lower end of the family did not have any
> stack access, and all of 112 bytes of RAM, including registers and I/O
> ports and the timer. (There are also C compilers for the 8051, which
> also has limited stack space.)
> 
> The project I am working on here at work has a stack which allows 40
> (forty!) entries, with 8K of byte-wide RAM. There are two solutions: (1)
> use a LOT of global variables, or (2) create your own stack(s) for
> parameter passing. We use both methods. It ain't purty, but we're not
> paid for "purty."

Sometimes "C" compilers for oddball devices don't actually look
that much like C at all.  I worked on a network processor that
had effectively no stack (although it had a way to chain together
dynamically allocated fixed-size blocks) and a set of 8 64-bit
registers which could be concatenated together to so that unaligned
accesses could spill from one register to the next (e.g. an 8-byte
load to r1_6 would fill r1_6 through r1_7 and r2_0 through r2_5).

Most of the work I did there was in assembly language.  But, an
internal team did manage to produce a compiler that processed a
language the strongly resembled C (with lots of restrictions of
course).  Could you port nethack using it?  No.  But, it was easier
to use than the assembler. :-)

John
-- 
John W. Linville
linville at tuxdriver.com



More information about the Coco mailing list