ееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееееее/*
	1802 Cross-Assembler  v. 2.3

	May, 1980

	June, 1980 -- Rev. 2.1 consisting of fixing P errors that come
		from EQUing things to the pre-defined symbols, and adding
		the LOAD pseudo-op.

	July, 1980 -- Rev. 2.2 consisting of fixing the M errors that
		come from forward references in WORD and BYTE pseudo-ops.

	October, 1980 -- Rev. 2.3 consisting of modifying the assembly
		language routines and I/O routines to match and take
		advantage of BDS C V1.4.

	Copyright (c) 1980 William C. Colley, III.

File:	a18.c

It all begins here.
*/

/*  Get globals:  */

#include "a18.h"

/*  The assembler starts here.  */

main(argc,argv)
int argc;
char *argv[];
{
	int n, m;
	puts("1802 Cross-Assembler  v. 2.3\n");
	puts("   Copyright (c) 1980  William C. Colley, III\n");
	curdrive = bdos(GETDISK);
	setfiles(argc,argv);
	sympoint = symtbl;		/*  Initialize symbol table.	*/
	symend = symtbl[SYMBOLS].symname;
	setmem(sympoint,(SYMBOLS * (SYMLEN + 2)),'\0');
	setmem(linbuf,SYMLEN,' ');	/*  Install initial symbols.	*/
	linbuf[0] = 'R';
	linbuf[1] = '0';
	for (n = 0; n < 16; n++)
	{
		addsym(linbuf);
		sympoint -> symvalu = n;
		if ((linbuf[1] += 1) == ('9' + 1)) linbuf[1] = 'A';
	}
	ifsp = 0;			/*  Initialize if stack.	*/
	ifstack[ifsp] = 0xffff;
	hxbytes = 0;			/*  Initialize hex generator.	*/
	flshhbf(0);
	pc = errcount = 0;
	pass = 1;
	puts("\nEntering Pass 1.\n");

	while (pass != 3)	/*  The actual assembly starts here.	*/
	{
		errcode = ' ';
		if (!getlin())
		{
			strcpy(linbuf,"\tEND\t\t;You forgot this!\n");
			linptr = linbuf;
			markerr('*');
			ifstack[ifsp] = 0xffff;
		}
		asmline();		/*  Get binary from line.	*/
		if (pass > 1)
		{
			lineout();	/*  In pass 2, list line.	*/
			hexout();	/*  In pass 2, build hex file.	*/
		}
		pc += nbytes;
		if (pass == 0)	/*  This indicates end of pass 1.	*/
		{
			pass = 2;
			rewind(source);

			/*  Mark symbols as not for direct addressing.	*/

			for (sympoint = symtbl; sympoint < symend; sympoi