Index: prolog/croot.c
===================================================================
--- prolog/croot.c	(revision 109c83b4de0a1be1740921110e1aab18add40866)
+++ prolog/croot.c	(revision 109c83b4de0a1be1740921110e1aab18add40866)
@@ -0,0 +1,164 @@
+/*
+   ============================================================================
+	croot.c -- Root for Buchla 700 C programs
+	Version 8 -- 1987-06-29 -- D.N. Lynx Crowe
+
+	This version can be setup for I/O redirection or not, depending on the
+	value of REDIRECT.  If redirection is supported, so are command line
+	arguments, which must be passed to Croot() at 'cp' by the startup code.
+
+	Normally, this won't be selected, as this is a dedicated application
+	that doesn't expect command line arguments or I/O redirection.
+   ============================================================================
+*/
+
+#define	ROOTMSG	"{Buchla 700 Croot - Version 8 - 1987-06-29}"
+
+#define	_FS_DEF_		/* to avoid unnecessary externals */
+
+#include "biosdefs.h"
+#include "errno.h"
+#include "fcntl.h"
+#include "io.h"
+#include "stddefs.h"
+
+#define	REDIRECT	0	/* non-zero for command line stuff */
+
+#define	MAXARGS		30	/* maximum number of command line arguments */
+
+extern	int	open(), creat();
+
+extern	int	InitFS();
+extern	int	_fd_cls();
+extern	int	xtrap15();
+
+int (*_clsall)();
+
+/* 
+
+*/
+
+static	int	Argc;
+static	char	*Argv[MAXARGS];
+
+/* 
+
+*/
+
+/*
+   ============================================================================
+	exit(code) -- return control to the BIOS
+   ============================================================================
+*/
+
+exit(code)
+{
+	(*_clsall)();		/* close all open files */
+	xtrap15(code);		/* return to the BIOS */
+}
+
+
+#if	REDIRECT
+
+/*
+   ============================================================================
+	_eredir(name) -- output I/O redirection error message to stderr
+   ============================================================================
+*/
+
+static
+_eredir(name)
+char *name;
+{
+	char buff[200];
+
+	strcpy(buff, "Can't open file for redirection: ");
+	strcat(buff, name);
+	strcat(buff, "\n");
+	write(2, buff, strlen(buff));
+	exit(EINVAL);
+}
+
+#endif
+
+/* 
+
+*/
+
+/*
+   ============================================================================
+	Croot(cp) -- C root module for the Buchla 700
+   ============================================================================
+*/
+
+Croot(cp)
+register char *cp;
+{
+	register	char	*fname;
+	register	int	k;
+
+	Argv[0] = ROOTMSG;
+	Argc = 1;
+
+	_clsall = _fd_cls;
+	InitFS();
+
+#if	REDIRECT
+
+	while (Argc < MAXARGS) {	/* handle command line arguments */
+
+		while (*cp EQ ' ' OR *cp EQ '\t')	/* skip whitespace */
+			++cp;
+
+		if (*cp EQ 0)			/* check for end of line */
+			break;
+
+		if (*cp EQ '>') {		/* > - redirect output */
+
+			k = 1;	/* stdout */
+			goto redir;
+
+		} else if (*cp EQ '<') {	/* < - redirect input */
+
+			k = 0;	/* stdin */
+redir:
+			while (*++cp EQ ' ' OR *cp EQ '\t')	/* skip whitespace */
+				;
+
+			fname = cp;	/* pointer to start of name */
+
+			while (*++cp)	/* skip to whitespace */
+				if (*cp EQ ' ' OR *cp EQ '\t') {
+
+					*cp++ = 0;
+					break;
+				}
+
+			close(k);	/* close old assignment */
+
+			if (k)
+				k = creat(fname, 0666);		/* stdout */
+			else
+				k = open(fname, O_RDONLY);	/* stdin */
+
+			if (k EQ -1)
+				_eredir(fname);
+
+		} else {	/* collect a command line argument */
+
+			Argv[Argc++] = cp;
+
+			while (*++cp)	/* find end of argument */
+				if (*cp EQ ' ' OR *cp EQ '\t') {
+
+					*cp++ = 0;
+					break;
+				}
+		}
+	}
+
+#endif
+
+	main(Argc,Argv);	/* call application */
+	exit(0);		/* exit in case the application didn't */
+}
Index: prolog/fsmain.s
===================================================================
--- prolog/fsmain.s	(revision 109c83b4de0a1be1740921110e1aab18add40866)
+++ prolog/fsmain.s	(revision 109c83b4de0a1be1740921110e1aab18add40866)
@@ -0,0 +1,125 @@
+* ------------------------------------------------------------------------------
+* fsmain.s -- startup code for the Buchla 700 standalone C runtime library
+* Version 3 -- 1987-06-29 -- D.N. Lynx Crowe
+*
+*	This code clears 'bss' space, sets up some global variables,
+*	and calls Croot(), which sets up the file system and calls main().
+*
+*	This routine should be entered with the address of the basepage
+*	as its parameter.
+* ------------------------------------------------------------------------------
+		.text
+*
+		.xdef	start_
+*
+		.xref	_Croot
+*
+		.xdef	_panic
+		.xdef	_brk
+*
+		.xdef	__heap
+		.xdef	__break
+		.xdef	__pmesg
+*
+		.xdef	_errno
+*
+p_bbase		.equ	$18		* bss base
+p_blen		.equ	$1C		* bss length
+*
+		.page
+*
+* start_ -- Initial entry point -- Must be first object file in link statement
+* ------    ------------------------------------------------------------------
+*
+* WARNING:  Hazardous assumptions
+*
+* We assume that: 
+*
+* 	the system has set the stack pointer for us.
+* 	the system passed us a pointer to a valid basepage.
+* 	the stack is above the heap.
+*	BSS is located in RAM.
+*
+* If any of these assumptions is in error, we're in for serious trouble.
+*
+start_:		clr.l	a6		* Clear frame pointer
+		movea.l	4(a7),a1	* Set pointer to base page
+		movea.l	p_bbase(a1),a0	* Setup to clear bss space
+*
+start1:		clr.w	(a0)+		* Clear a word
+		cmpa.l	a0,a7		* See if we're done
+		bne	start1		* Loop if not done yet
+*
+		move.l	p_bbase(a1),d0	* Calculate break address
+		add.l	p_blen(a1),d0	* ...
+		move.l	d0,__break	* Set initial break
+		move.l	d0,__heap	* Set heap start
+*
+		move.l	#0,-(a7)	* Pass NULL to Croot  (no command line)
+		jsr	_Croot		* call Croot() routine
+		addq.l	#4,a7		* ...
+*
+		move.l	#pmsg1,-(a7)	* panic(pmsg1);
+		jsr	_panic		* ...
+		addq.l	#4,a7		* ...
+*
+hstop:		stop	#$2000		* "Die, sucker!"
+		bra	hstop
+*
+		.page
+*
+* _panic -- hard halt for fatal errors
+* ------    --------------------------
+_panic:		movea.l	4(a7),a0	* Save panic message address
+		move.l	a0,__pmesg	* ...
+*
+		trap	#15		* Invoke ROMP  (we hope ...)
+*
+pstop:		stop	#$2700		* HARD HALT
+		bra	pstop
+*
+		.page
+*
+* _brk -- set break value
+* ----    ---------------
+* WARNING:  This only works if the stack is above the heap.
+*
+_brk:		cmpa.l	__break,a7	* compare current break with stack
+		bcs	pstop		* actual stack overflow!
+*
+		movea.l	4(sp),a0	* get new break
+		move.l	a0,d0		* compare with current stack,
+		adda.l	#$100,a0	* ... including 256-byte slop factor
+		cmpa.l	a0,a7		* if (sp < a0+256)
+		bcs	badbrk		* 	bad break;
+*
+		move.l	d0,__break	* OK break: save the break
+		clr.l	d0		* Set OK return
+		rts			* return
+*
+badbrk:		moveq.l	#-1,d0		* Load return reg
+		rts			* Return
+*
+		.page
+*
+*************************************************************************
+* 		Data Area						*
+*************************************************************************
+*
+		.data
+*
+pmsg1:		dc.b	'  returned from Croot() ',0
+*
+*************************************************************************
+* 		BSS Area						*
+*************************************************************************
+*
+		.bss
+		.even
+*
+__pmesg:	ds.l	1	* panic() message string address
+__heap:		ds.l	1	* Heap start  (initial break)
+__break:	ds.l	1	* Current break location
+_errno:		ds.w	1	* System error number
+*
+	.end
