
/* static char rcsid[] = "$Header: main.c,v 1.2 85/05/03 17:46:11 ed Exp $" */

/************************************************************************
 *									*
 *				Copyright 1984				*
 *			VALID LOGIC SYSTEMS INCORPORATED		*
 *									*
 *	This listing contains confidential proprietary information	*
 *	which is not to be disclosed to unauthorized persons without	*
 *	written consent of an officer of Valid Logic Systems 		*
 *	Incoroporated.							*
 *									*
 *	The copyright notice appearing above is included to provide	*
 *	statutory protection in the event of unauthorized or 		*
 *	unintentional public disclosure.				*
 *									*
 ************************************************************************/


/*
 * ERM - Extended Resident Monitor
 * Initial Version - 4/10/85 - ELP
 */

#include <sys/types.h>
#include "erm.h"

extern u_int *erm_regsave;
extern u_char erm_disasm_buf[];
extern struct bpt bpts[];
extern struct commtable *curr_comms;
extern char erm_cmd_buf[];

/*
 *	do_cmd - This is the main command processing loop.
 */

do_cmd ()
{
	u_long addr;
	register u_char comchar0, comchar1;
	register struct commtable *comm_ptr;
	register u_long ret_getnum;

	for (;;)
	 {
top:
		printf ("ERM> ");
		fillcmdbuf ();
		comchar0 = erm_cmd_buf[0];
		if (comchar0 == '\n' || comchar0 == '\r') goto top;
		comchar1 = erm_cmd_buf[1];
		ret_getnum = 1;
		for (comm_ptr = curr_comms; comm_ptr -> comchar0; comm_ptr++)
			if (comm_ptr -> comchar0 == comchar0 && 
			    (comm_ptr -> comchar1 == ' ' ||
			    comm_ptr -> comchar1 == comchar1))
			 {
				if (comchar1 != '\n' && comchar1 != '\r')
					ret_getnum = getnum (&addr, 2);
				if (ret_getnum)
					addr = erm_regsave [ERM_PC];
				(*comm_ptr -> fun) (addr, ret_getnum);
				goto top;
			 }
		printf ("%c%c: No such command\n", comchar0, comchar1 != '\n'?
			comchar1: ' ');
	 }
}
