On Tue, 7 Feb 2012, allison wrote:
On 02/07/2012 05:39 PM, Ethan Dicks wrote:
On Tue, Feb 7, 2012 at 12:51 AM, Cameron
Kaiser<spectre at floodgap.com>
wrote:
> I've been trying to figure out if the
PDP-8 could handle C, and
> the answers I get range from "I don't know" to "Definitely
not".
I am not aware of a C compiler for the PDP-8, but I think it would be
exceedingly difficult to write one if were possible at all
Think of C as a macro
assembler. The PDP-8 was generic that it could do
all of the possible tasks. The compiler would have to be smart but they
write
in C for PIC micros.
While not exactly C, I've done a bit of fiddling with a byte code
derived from the venerable Small-C compiler.
The compiler figures things out in terms of a simple single-stack
machine. There is one module in the compiler that takes the single-stack
primitives and outputs assembly code for the target processor. It's
possible to replace that module with one that outputs the primitives,
then make an back end to turn them into code for something else. By
that means, I made a variant of Small C that could compile for
a variety processors ranging from from Z80 to VAX.
I reworked them a bit to come up with something that could
describe a simple FORTH.
*That* I made go on stuff ranging from PDP-8 to VAX. Since the
low-level words were written in the primitives derived from
Small C, the same source could be compiled for any of the
processors I ran it on.
Essentially, a byte code. Of course, the PDP-8 version used 12-bit
bytes.
In the PDP-8 variant, each bytecode consisted of a JMS I Z
instruction. Page zero was loaded up with JMP instructions that
transferred to the routines that implement each primitive.
For what it's worth (which is not much), it can be found here:
http://anachronda.homeunix.com:8000/~rivie/third/
I've only put up the PDP-8 and Z80 versions, but I've also done
a handful of other processors; enough to wring out byte-order
and word-size dependencies. The PDP-8 version was done as a
degenerate case involving one-byte cells.
I used long symbol names in the PDP-8 source, so you'll need
a variant of Doug Jone's PAL assembler that I've tweaked to
take them.
--
roger ivie
rivie at
ridgenet.net