home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!rutgers!rochester!rit!moscom!pap
- From: pap@moscom.com (Patrick Palmer)
- Newsgroups: alt.sources
- Subject: YAMPC (part 2/2)
- Message-ID: <4809@moscom.com>
- Date: 23 Dec 92 17:27:55 GMT
- Organization: Moscom Corp., E. Rochester, NY
- Lines: 4857
- X-Newsreader: TIN [version 1.3 beta PL7]
-
- --------CUT HERE--------
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > brkpts.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Break PointsX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X These are all of the support routines for using break pointsX
- X in the debugging mode. Adding, Deleting, and listing are allX
- X included. A simple array of integers stores the break point list.X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include <stdio.h>X
- X#include "main.h"X
- X#include "misc.h"X
- XX
- X/* need to the current mpc pointer */X
- Xextern int mpcptr;X
- XX
- X/* The pointer into the command line arguments */X
- Xextern int p_position;X
- XX
- X/* breakpoint list */X
- Xint brkpts[NUMBRKPTS];X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: setBrkPts()X
- X * PURPOSE: initialize all break points to not used (-1)X
- X * ARGUMENTS: noneX
- X * RETURNS: noneX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XsetBrkPts ( )X
- X{X
- X int temp = 0;X
- XX
- X for ( ; temp < NUMBRKPTS; temp++ )X
- X brkpts[temp] = -1;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: checkBrkPts()X
- X * PURPOSE: determine if the execution should breakX
- X * ARGUMENTS: noneX
- X * RETURNS: 1 - breakX
- X * 0 - don't breakX
- X * NOTES: this routine uses the mpcptr globalX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XcheckBrkPts ( )X
- X{X
- X int temp;X
- XX
- X /* check current mpc vs. breakpoint list */X
- X for ( temp = 0; temp < NUMBRKPTS; temp++ )X
- X if ( brkpts[temp] == mpcptr )X
- X return 1;X
- XX
- X /* none found */X
- X return 0;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: showBrkPts()X
- X * PURPOSE: show all the current break pointsX
- X * ARGUMENTS: command entry to display if misuseX
- X * RETURNS: P_CONT - continue processingX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XshowBrkPts ( which )X
- X int which;X
- X{X
- X int temp = 0, disp = 0;X
- X U_Ret rv;X
- XX
- X /* make sure there are no more arguments */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position != -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* print out list */X
- X for ( ; temp < NUMBRKPTS; temp++ )X
- X if ( brkpts[temp] != -1 ) X
- X if ( disp == 0 )X
- X printf ( "The breakpoint list: %x", brkpts[temp], disp++ );X
- X else printf ( ", %x", brkpts[temp] );X
- XX
- X /* End the list */X
- X if ( disp == 0 )X
- X printf ( "There are no breakpoints set.\n" );X
- X else printf ( ".\n" );X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: addBrkPts()X
- X * PURPOSE: add an address into the breakpoint listX
- X * ARGUMENTS: which - which command entry for misuse displayX
- X * RETURNS: P_CONT - continue processingX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XaddBrkPts ( which )X
- X int which;X
- X{X
- X int temp, place = -1;X
- X U_Ret rv;X
- XX
- X /* get entry off of the command line */X
- X if ( ( getEntry ( &rv, P_NUM ) != 0 ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- X X
- X /* make sure there are no more arguments */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position != -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- X X
- X /* check if the address is already in the list */X
- X for ( temp = 0; temp < NUMBRKPTS; temp++ )X
- X if ( rv.ival == brkpts[temp] ) {X
- X printf ( "Address already in breakpoint list.\n" );X
- X return P_CONT;X
- X }X
- XX
- X /* look for an available spot */X
- X temp = 0;X
- X for ( temp = 0; temp < NUMBRKPTS && place == -1; temp++ )X
- X if ( brkpts[temp] == -1 )X
- X place = temp;X
- XX
- X /* Tell user that there was no entry places */X
- X if ( place == -1 ) {X
- X printf ( "All %d of the breakpoint entries are filled.\n", NUMBRKPTS );X
- X return P_CONT;X
- X }X
- XX
- X /* place the address into the list */X
- X brkpts[place] = rv.ival;X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: delBrkPts()X
- X * PURPOSE: delete an address from the breakpoint listX
- X * ARGUMENTS: which - which command entry for misuse displayX
- X * RETURNS: P_CONT - continue processingX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XdelBrkPts ( which )X
- X int which;X
- X{X
- X int temp, found = 0;X
- X U_Ret rv;X
- XX
- X /* get the address to delete from the list */X
- X if ( ( getEntry ( &rv, P_NUM ) ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* make sure there are no more entries */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position != -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* look for the entry and delete it */X
- X for ( temp = 0; temp < NUMBRKPTS; temp++ )X
- X if ( brkpts[temp] == rv.ival )X
- X brkpts[temp] = -1, found = 1;X
- XX
- X /* Display message if there was no entry */X
- X if ( ! found ) X
- X printf ( "The address was not found in the breakpoint list.\n" );X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > correct.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Correctional File Support RoutinesX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This file contains all of the file support routines for theX
- X correctional file use. This includes the creation and the readingX
- X in of the correction file. X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X/* This is the module for the correction file routines */X
- XX
- X#include <stdio.h>X
- X#include <ctype.h>X
- X#include "main.h"X
- X#include "misc.h"X
- XX
- X/* needed parameters */X
- Xextern struct varlist var[];X
- Xextern int var_param[];X
- Xextern int mpcptr;X
- XX
- X/* definitions for readCorrect routine */X
- X#define RC_NUM 1 /* read in a number */X
- X#define RC_LINE 2 /* registers in a line */X
- XX
- X/* Correction File Pointer to the file */X
- XFILE * correctfp;X
- XX
- X/* next line value */X
- Xint nextCorrect;X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: openCorrect()X
- X * PURPOSE: open and check the file for readingX
- X * ARGUMENTS: mode - file mode to open withX
- X * fname - file name to openX
- X * RETURNS: noneX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- X/* openCorrect - open and check the file for reading */X
- XVOIDX
- XopenCorrect ( mode, fname )X
- X int mode;X
- X char *fname;X
- X{X
- X /* open up the file */X
- X if ( ( correctfp = fopen ( fname, X
- X ( mode == CORRECT ? "r" : "w" ) ) ) == NULL ) {X
- X printf ( "Unable to open the file '%s' for correctional use.\n",fname );X
- X exit ( 1 );X
- X }X
- XX
- X /* get the value for the first edit line */X
- X if ( mode == CORRECT )X
- X nextCorrect = readCorrect ( RC_NUM );X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: closeCorrect()X
- X * PURPOSE: close the fileX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XcloseCorrect ( )X
- X{X
- X fclose ( correctfp );X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: checkCorrect()X
- X * PURPOSE: check if the numbers in the file are correctX
- X * ARGUMENTS: noneX
- X * RETURNS: noneX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XcheckCorrect ( )X
- X{X
- X static int attempt = 0;X
- XX
- X /* increment number of attempts */X
- X attempt++;X
- XX
- X /* check if the attempt is same as next line */X
- X if ( nextCorrect == attempt ) {X
- X /* the line is the same, check registers */X
- X nextCorrect = readCorrect ( RC_LINE );X
- X }X
- X X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: readCorrect()X
- X * PURPOSE: read in a valuesX
- X * ARGUMENTS: RC_LINE - read in lineX
- X * RC_NUM - read in a valueX
- X * RETURNS: number/line read inX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XreadCorrect ( reason )X
- X int reason;X
- X{X
- X char buffer[80]; /* string buffer */X
- X int c; /* input character */X
- X int temp;X
- X static int sysCorrect = S_HEX; /* Numbering system */X
- XX
- X /* read in the information */X
- X if ( (c = getWchar ( correctfp ) ) == EOF ) X
- X return -1;X
- XX
- X while ( 1 ) {X
- X if ( c == '.' ) {X
- X /* format command */X
- X fscanf ( correctfp, "%s", buffer );X
- X if ( !strcmp ( "octal", buffer ) ) X
- X sysCorrect = S_OCT;X
- X else if ( !strcmp ( "decimal", buffer ) ) X
- X sysCorrect = S_DEC;X
- X elseX
- X fprintf ( stderr, "Inproper command in micro code\n" );X
- XX
- X } else if ( c == '\n' ) {X
- X /* new line - throw out - RC_LINE can't exist beyond 1 line */X
- X if ( reason == RC_LINE )X
- X reason = RC_NUM;X
- XX
- X } else if ( reason == RC_NUM && number ( c, sysCorrect ) ) {X
- X ungetc ( c, correctfp ); /* put it back */X
- XX
- X /* scan in the number */X
- X fscanf ( correctfp, ( sysCorrect == S_HEX ? "%x" :X
- X ( sysCorrect == S_OCT ? "%o" : "%d" ) ), &temp );X
- X X
- X /* tell the system the next line */X
- X return temp;X
- XX
- X } else if ( reason == RC_LINE && c != ';' ) {X
- X ungetc ( c, correctfp ); /* put it back */X
- XX
- X /* registers for a line */X
- X fscanf ( correctfp, "%s", buffer );X
- XX
- X /* process string */X
- X processCorrect ( buffer, sysCorrect );X
- X }X
- XX
- XX
- X /* see if there is a comment */X
- X if ( c == ';' ) X
- X while ( ( c = getWchar ( correctfp ) ) != '\n' && c != EOF )X
- X printf ( '.' );X
- XX
- X /* get another character */X
- X else if ( (c = getWchar ( correctfp ) ) == EOF ) X
- X return -1;X
- X }X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: processCorrectX
- X * PURPOSE: take a string (ie pc=8) and process itX
- X * ARGUMENTS: buffer - file string containing dataX
- X * system - current numbering systemX
- X * RETURNS: noneX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XprocessCorrect ( buffer, system )X
- X char *buffer; /* file string containing data */X
- X int system; /* numbering system */X
- X{X
- X long sval = 0L; /* the should-be value */X
- X int entry = -1; /* entry search */X
- X int found = 0;X
- X int temp; /* temp variable */X
- X char tempb[80]; /* temp buffer */X
- XX
- X /* get variable name ( look for the '=' ) and place a \0 at the end */X
- X sval = strlen ( buffer ); /* temporarily used */X
- X for ( temp = 0; temp < sval; temp++ )X
- X if ( buffer[temp] == '=' )X
- X buffer[temp] = '\0', found = temp + 1;X
- X sval = 0L; /* reset value */X
- XX
- X /* find out what the proper value should be */X
- X if ( found ) X
- X /* scan in the number */X
- X sscanf ( &buffer[found], ( system == S_HEX ? "%x" :X
- X ( system == S_OCT ? "%o" : "%d" ) ), &sval );X
- X else {X
- X fscanf ( correctfp, "%s", tempb );X
- X if ( tempb[0] == '=' && tempb[1] == '\0' )X
- X /* scan in the number */X
- X fscanf ( correctfp, ( system == S_HEX ? "%x" :X
- X ( system == S_OCT ? "%o" : "%d" ) ), &sval );X
- X else X
- X /* scan in the number */X
- X sscanf ( &tempb[1], ( system == S_HEX ? "%x" :X
- X ( system == S_OCT ? "%o" : "%d" ) ), &sval );X
- X }X
- XX
- X /* find the entry in the variable list */X
- X temp = var_param[FORMATNUM] + var_param[PARTSNUM] + var_param[VARSNUM];X
- X for ( found = 0; found < temp; found++)X
- X if ( !strcmp ( buffer, var[found].name ) ) X
- X entry = found;X
- XX
- X /* if there is no entry */X
- X if ( entry == -1 ) {X
- X printf ( ( system == S_HEX ? "%x" : X
- X ( system == S_OCT ? "%o" : "%d" ) ), nextCorrect );X
- X printf ( ": variable '%s' was not found in the list\n", buffer );X
- X return;X
- X }X
- XX
- X /* check if they are the same */X
- X if ( var[entry].val == sval )X
- X return;X
- XX
- X /* print out results if they are different */X
- X printf ( ( system == S_HEX ? "%x" : X
- X ( system == S_OCT ? "%o" : "%d" ) ), nextCorrect );X
- X sprintf ( tempb, ": variable '%s' is '%s' but should be '%s'\n", buffer,X
- X ( system == S_HEX ? "%x" : ( system == S_OCT ? "%o" : "%d" ) ),X
- X ( system == S_HEX ? "%x" : ( system == S_OCT ? "%o" : "%d" ) ) );X
- X printf ( tempb, var[entry].val, sval );X
- XX
- X /* set the register to its proper value */X
- X var[entry].val = sval & var[entry].bmask;X
- XX
- X /* check if it is a connected register */X
- X if ( var[entry].type == 1 ) {X
- X mpc ( "set", var[entry].val );X
- X mpcptr = var[entry].val;X
- X }X
- XX
- X}X
- XX
- XX
- X/* variables needed for building the correction file */X
- Xstruct varlist *correctList;X
- Xint countnum;X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: addCorrect()X
- X * PURPOSE: add correction entry into listX
- X * ARGUMENTS: str - string containing entryX
- X * RETURNS: noneX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XaddCorrect ( str )X
- X char *str;X
- X{X
- X int temp = 0;X
- X int count = 1;X
- X int len;X
- XX
- X /* determine if there is any registers, if none, error out */X
- X if ( ! ( len = strlen ( str ) ) ) {X
- X printf ( "Must specify which registers to set up correct file\n" );X
- X exit ( 1 );X
- X }X
- XX
- X /* count commas to determine number of arguments */X
- X while ( temp < len ) {X
- X /* check commas */X
- X if ( str[temp] == ',' )X
- X count++;X
- XX
- X temp++;X
- X }X
- XX
- X countnum = count;X
- X /* allocate the needed space */X
- X if ( ( correctList = (struct varlist *) malloc ( count * sizeof ( struct varlist ) ) ) == NULL ) {X
- X printf ( "Unable to allocate enough memory to build the correction file\n" );X
- X exit ( 1 );X
- X }X
- XX
- X /* place all the registers in the array */X
- X count = temp = 0;X
- X while ( temp < len ) {X
- X if ( isalpha ( str[temp] ) ) {X
- X int temp1 = temp;X
- X int i;X
- XX
- X while ( temp1 < len && str[temp1] != ',' )X
- X temp1++;X
- X strncpy ( correctList[count].name, &str[temp], temp1 - temp );X
- X correctList[count].name[temp1-temp] = '\0';X
- X correctList[count].val = 0L;X
- X correctList[count].bmask = -1;X
- XX
- X /* find entry in the variable list */X
- X for ( i = 0; i < var_param[FORMATNUM] + var_param[PARTSNUM]; i++ )X
- X if ( ! strcmp ( correctList[count].name, var[i].name ) ) X
- X correctList[count].bmask = i;X
- XX
- X if ( correctList[count].bmask == -1 ) {X
- X printf ( "Register '%s' is not defined.\n", correctList[count].name );X
- X exit ( 1 );X
- X }X
- XX
- X temp = temp1 + 1, count++;X
- X } else {X
- X printf ( "Improper format of registers for building the correction file\n" );X
- X exit ( 1 );X
- X }X
- X }X
- X X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: doCorrect()X
- X * PURPOSE: determine if there is a correction needed to be madeX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XdoCorrect ( )X
- X{X
- X static int line = 1;X
- X int printLine = 0;X
- X int temp = 0;X
- XX
- X while ( temp < countnum ) {X
- X if ( var[correctList[temp].bmask].val != correctList[temp].val ) {X
- X correctList[temp].val = var[correctList[temp].bmask].val;X
- X if ( ! printLine ) X
- X fprintf ( correctfp, "%x %s=%x", line, correctList[temp].name,X
- X correctList[temp].val, printLine++ );X
- X else X
- X fprintf ( correctfp, " %s=%x", correctList[temp].name, correctList[temp].val );X
- X }X
- XX
- X temp++;X
- X }X
- XX
- X /* print a newline if there is data */X
- X if ( printLine )X
- X fprintf ( correctfp, "\n" );X
- XX
- X /* increment the line counter */X
- X line++;X
- X}X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > debug.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Main debugging moduleX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This contains all of the support routines for the debuggingX
- X mode of YAMPC. The main debug routine is called "debug", go figure.X
- X "prtregs" prints out the registers. There is a parser and miscellaneousX
- X debugging functions.X
- XX
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include <stdio.h>X
- X#include "main.h"X
- X#include "misc.h"X
- X#include "debug.h"X
- X#include "y.tab.h"X
- XX
- Xextern int cycles, subcycles;X
- Xextern struct varlist var[];X
- Xextern struct interruptlist interrupt[];X
- Xextern int var_param[];X
- Xextern long *cpu, *mem;X
- Xextern int mpcptr;X
- XX
- X/* running in debug mode for a certain number of cycles */X
- Xint debug_run = 0;X
- XX
- X/* trace change */X
- Xint traceChange;X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: debug()X
- X * PURPOSE: main focal point of the interactive debugger X
- X * ARGUMENTS: mode - mode of debuggingX
- X * state - current state of debuggingX
- X * RETURNS: process to contine noteX
- X * NOTES: noteX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xdebug ( mode, state )X
- X int *mode;X
- X int state;X
- X{X
- X int exitcode = P_GOON; /* exit code */X
- X int loop = 1; /* continous loop */X
- X int promptUser = 1; /* prompt user with prompt (Default: YES) */X
- X int breaklist = 1; /* display the breakpt & bounds message once */X
- XX
- X /* set traceChange mode to Non possible state */X
- X traceChange = -1;X
- XX
- X while ( loop ) {X
- XX
- X /* now check the modes */X
- X switch ( *mode ) {X
- X case NOTRACE_FREG: /* display registers at every fetch */X
- X if ( mpcptr != var_param[FETCH] )X
- X return exitcode;X
- XX
- X case NOTRACE_REG: /* display registers at every cycle */X
- X prtregs ( );X
- X return exitcode;X
- XX
- X case DEBUG_REG: /* display registers at every prompt */X
- X prtregs ( );X
- X break;X
- XX
- X case CORRECT: /* correctional file */X
- X if ( mpcptr != var_param[FETCH] )X
- X return exitcode;X
- X checkCorrect ( ); /* check if there needs to do work */X
- X return exitcode;X
- XX
- X case CREATE_CORRECT: /* create correctional file */X
- X if ( mpcptr != var_param[FETCH] )X
- X return exitcode;X
- X doCorrect ( ); /* check if there needs to do work */X
- X return exitcode;X
- XX
- X }X
- XX
- X /* if trace state has changed, change the mode */X
- X if ( traceChange != -1 ) {X
- X *mode = traceChange;X
- X traceChange = -1;X
- X }X
- XX
- X /* check if hit end of code */X
- X if ( breaklist && state ) {X
- X printf ( "Out of bound reached in micro code\n" );X
- X debug_run = breaklist = 0;X
- X }X
- XX
- X /* check if this is a breakpoint */X
- X else if ( breaklist && checkBrkPts ( ) ) {X
- X printf ( "Breakpoint reached at %x(%d)\n", mpcptr, mpcptr );X
- X debug_run = breaklist = 0;X
- X }X
- XX
- X /* prompt user for commands */X
- X if ( debug_run ) {X
- X if ( debug_run != -1 )X
- X debug_run--;X
- X loop = 0;X
- X } else if ( ( exitcode = prompt ( ) ) != P_CONT )X
- X loop = 0;X
- X }X
- XX
- X return exitcode;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: prtregs()X
- X * PURPOSE: print out the format values and registersX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: noneX
- X *X
- X ******************************************************inter in the input string to zero */X
- X p_position = 0;X
- XX
- X /* check if NEWLINE is only pressed */X
- X for ( i = strlen ( p_inp ); i > 0; --i ) X
- X if ( p_inp[i-1] != ' ' && p_inp[i-1] != '\t' ) {X
- X info = 1;X
- X if ( p_inp[i-1] == '!' ) X
- X found = i;X
- X }X
- XX
- X /* check if it is a shell (!) command */X
- X if ( found ) {X
- X system ( &p_inp[found] );X
- X return P_CONT;X
- X }X
- XX
- X /* if there is information on the line, copy to last command */X
- X if ( info ) {X
- X strncpy ( last_p_inp, p_inp, 128 );X
- X if ( ! anyCmds )X
- X anyCmds = 1;X
- XX
- X /* if NEWLINE and a last command then repeat last command */X
- X } else if ( ! info && anyCmds ) {X
- X /* copy in last command */X
- X strncpy ( p_inp, last_p_inp, 128 );X
- X } X
- X X
- X if ( ( ! getEntry ( &inpSing, P_STR ) ) && p_position != -1 ) {X
- X while ( ! found && i < DEBUG_ENTRY ) {X
- X /* string compare length */X
- X if ( ( temp = strlen ( inpSing ) ) < cmds[i].matchnum )X
- X i++;X
- X else if ( ! strncmp ( inpSing.str, cmds[i].word, temp ) ) {X
- X p_val = ( * cmds[i].func ) ( i );X
- X found = 1;X
- X } elseX
- X i++;X
- X }X
- X if ( ! found ) X
- X printf ( "Invalid command, type 'help' for a list of commands\n" );X
- X } else X
- X printf ( "Not a valid entry\n" );X
- XX
- X /* return the value returned by the routine called */X
- X return p_val;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: getEntry()X
- X * PURPOSE: get an entry in the string inputX
- X * ARGUMENTS: rv - retrieved dataX
- X * type - type of information to retrieveX
- X * RETURNS: 1 - invalid entryX
- X * 0 - ok entryX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- X/* getEntry ( ) - get an entry in the string input */X
- XintX
- XgetEntry ( rv, type )X
- X U_Ret *rv;X
- X int type;X
- X{X
- X int pos = 0; /* position to start for number check */X
- X int i; /* temp for loop */X
- X int total = 0; /* running total of hex number in input */X
- X int temp;X
- X char istr[80]; /* input string subset */X
- XX
- X if ( p_position == -1 ) /* end of the input string */X
- X return 0;X
- XX
- X /* make sure there are no leading spaces */X
- X while ( p_inp[p_position] == ' ' || p_inp[p_position] == '\t' ) X
- X p_position++;X
- X if ( p_inp[p_position] == '\0' ) {X
- X p_position = -1; /* end of string found */X
- X return 0;X
- X }X
- XX
- X if ( sscanf ( &p_inp[p_position], "%s", istr ) == 0 ) {X
- X p_position = -1; /* end of string found */X
- X return 0;X
- X }X
- XX
- X /* reposition p_position */X
- X p_position += strlen ( istr );X
- X X
- X /* string input */X
- X if ( type == P_STR ) {X
- X rv->str = istr;X
- X return 0;X
- X }X
- XX
- X /* integer input */X
- X if ( istr[0] == '-' ) /* negative number */X
- X pos = 1;X
- XX
- X /* check number to see if it is valid */X
- X temp = strlen ( istr );X
- X for ( i = pos; i < temp; i++ )X
- X if ( istr[i] >= '0' && istr[i] <= '9' )X
- X total = ( total * 16 ) + ( istr[i] - '0' );X
- X else if ( istr[i] >= 'a' && istr[i] <= 'f' )X
- X total = ( total * 16 ) + ( istr[i] - 'a' + 10 );X
- X else X
- X /* invalid number */X
- X return 1;X
- X X
- X /* number is valid */X
- X rv->ival = total;X
- X return 0;X
- X}X
- XX
- XX
- X/***********************************\X
- X|* Debug Prompt Responce Functions *|X
- X\***********************************/X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: exitProg()X
- X * PURPOSE: exit program and return to previous applicationX
- X * ARGUMENTS: entry - command entry numberX
- X * RETURNS: P_LEAVE - leave command X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XexitProg ( entry )X
- X int entry;X
- X{X
- X return P_LEAVE;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: help()X
- X * PURPOSE: display help list X
- X * ARGUMENTS: entry - command entry numberX
- X * RETURNS: P_CONT - continue processingX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xhelp ( entry )X
- X int entry;X
- X{X
- X int i = 0;X
- XX
- X /* display title of help message */X
- X printf ( "Help list\n" );X
- XX
- X /* display each entry */X
- X for ( ; i < DEBUG_ENTRY; i++ )X
- X printf ( cmds[i].help );X
- XX
- X /* Other interesting points */X
- X printf ( "Pressing <RETURN> will repeat the last command\n" );X
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: run()X
- X * PURPOSE: running with debug on not stopping unless break pointX
- X * or addressX
- X * ARGUMENTS: entry - command entry numberX
- X * RETURNS: P_CONT - continue processing X
- X * P_GOON - start executing microcodeX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xrun ( entry )X
- X int entry;X
- X{X
- X U_Ret val;X
- X int rv;X
- XX
- X /* get value if one is available */X
- X if ( getEntry ( & val, P_NUM ) ) {X
- X misuse ( entry );X
- X return P_CONT;X
- X }X
- XX
- X /* no entry - just run */X
- X if ( p_position == -1 ) {X
- X debug_run = -1; /* keep running */X
- X return P_GOON;X
- X } else {X
- X /* make sure there are no more entries */X
- X getEntry ( & val, P_STR );X
- X if ( p_position != -1 ) {X
- X misuse ( entry );X
- X return P_CONT;X
- X }X
- X }X
- XX
- X /* make sure the entry is positive */X
- X if ( val.ival <= 0 ) {X
- X printf ( "Invalid number, can only accept positive numbers.\n" );X
- X return P_CONT;X
- X }X
- XX
- X /* set the running value to the inputed */X
- X debug_run = val.ival - 1;X
- X return P_GOON;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: display()X
- X * PURPOSE: display registers and memory X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_CONT - continue processing commands X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xdisplay ( which )X
- X int which;X
- X{X
- X int memlook = 0;X
- X int start, temp = 0;X
- X int found = 0;X
- X U_Ret rv;X
- XX
- X /* get the first argument, if any */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position == -1 ) { /* no arguments */X
- X /* display all the registers */X
- X prtregs ( );X
- X return P_CONT;X
- X }X
- XX
- X /* check the string to one of the registers, cpu, or mem */X
- X if ( ! strcmp ( rv.str, "cpu" ) )X
- X memlook = 1; /* cpu memory */X
- X else if ( ! strcmp ( rv.str, "mem" ) ) X
- X memlook = 2; /* main memory */X
- XX
- X if ( ! memlook ) { /* display a register */X
- X int val;X
- XX
- X /* search for the register */X
- X for ( ; temp < var_param[FORMATNUM] + var_param[PARTSNUM]; temp++ )X
- X if ( ! strcmp ( var[temp].name, rv.str ) )X
- X found = 1, val = temp;X
- XX
- X if ( ! found ) /* unable to find register */X
- X printf ( "Could not find the register specified\n" );X
- X else /* found the register */X
- X printf ( "%s\t%-4lx\n", var[val].name, var[temp].val );X
- X return P_CONT;X
- X }X
- XX
- X if ( ( getEntry ( &rv, P_NUM ) ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X start = rv.ival;X
- X if ( getEntry ( &rv, P_NUM ) ) {X
- X misuse ( which );X
- X return P_CONT;X
- X } else if ( p_position == -1 ) X
- X rv.ival = start;X
- XX
- X /* print results */X
- X if ( memlook == 1 ) X
- X /* print out each line */X
- X for ( ; start <= rv.ival; start++ )X
- X prtCpuLine ( ( found++ == 0 ? 2 : 0 ), start ); X
- X else {X
- X printf ( "Main memory display\n" );X
- X for ( ; start <= rv.ival; start+=10 ) {X
- X for ( temp = 0; X
- X temp <= ( rv.ival - start > 10 ? 10 : rv.ival - start ) ; temp++ )X
- X printf ( "%-5.4x", mem[start+temp] );X
- X printf ( "\n" );X
- X }X
- X }X
- X X
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: calculator()X
- X * PURPOSE: simple RPN line calculator X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_CONT - continue processing commands X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- X/* calculator - a simple RPN line calculator */X
- XintX
- Xcalculator ( which )X
- X int which;X
- X{X
- X int temp, stackCount = 1;X
- X int loop = 1, operation;X
- X int errop = 0;X
- XX
- X while ( loop ) {X
- X switch ( operation = getOp ( &temp ) ) {X
- X X
- X case END: /* end of input cmd string */X
- X loop = 0;X
- XX
- X /* print item if and only if there is something on stack */X
- X if ( stackCount ) {X
- X printf ( "$%x\n", (long) pop ( ) );X
- X stackCount--;X
- X }X
- X break;X
- X X
- X case NUM: /* number */X
- X case VAR: /* variable */X
- X push ( operation, temp );X
- X stackCount++;X
- X break;X
- XX
- X case UNKNOWN: /* unknown expression */X
- X printf ( "Expression has a syntax error\n" );X
- X loop = 0;X
- X break;X
- XX
- X default: /* math operation */X
- X if ( ( operation == NOT || operation == BNOT ) && stackCount ) {X
- X do_stack ( operation );X
- X } else if ( stackCount >= 2 ) {X
- X do_stack ( operation );X
- X stackCount--;X
- X } else X
- X loop = 0, errop = 1;X
- X }X
- X }X
- XX
- X /* remove all the values on the stack */X
- X for ( ; stackCount > 0 ; stackCount-- )X
- X pop ( );X
- XX
- X /* check if there was a math operation error */X
- X if ( errop )X
- X printf ( "Not enough arguments on the stack to do such operation\n" );X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- X/* define a macro needed a lot - ok, ok, 1-800-NO-MACRO, I had to, really! */X
- X#define CHECKOP(x) if ( rc == END ) /* no other character before */ \X
- X rc = x; \X
- X else { \X
- X rc = UNKNOWN; /* unknown operation */ \X
- X loop = 0; \X
- X }X
- XX
- X X
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: getOp()X
- X * PURPOSE: parse out one token and return the value X
- X * ARGUMENTS: val - value of operation location to place itX
- X * RETURNS: NUM - retrieved numberX
- X * VAR - retrived variableX
- X * UNKNOWN - unknown contentsX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- X/* getOp - parse out one token and return the value */X
- XintX
- XgetOp ( val )X
- X int *val;X
- X{X
- X int loop = 1; /* keep looping while not sure of token */X
- X int rc = END; /* return code ( token ) */X
- X int possibleNum = 1; /* at this point, the string could be a num */X
- X char str[32];X
- X int s_ptr = 0; /* pointer into the string */X
- X int temp;X
- XX
- X /* check to see if there is data on the line */X
- X if ( p_position == -1 )X
- X return END;X
- XX
- X /* set the number/variable pointer to non possible value */X
- X *val = -1;X
- XX
- X /* make sure there are no leading spaces */X
- X while ( p_inp[p_position] == ' ' || p_inp[p_position] == '\t' ) X
- X p_position++;X
- XX
- X /* parser */X
- X while ( loop ) {X
- XX
- X switch ( p_inp[p_position] ) {X
- XX
- X case '\0': /* END of string */X
- X p_position = -1;X
- XX
- X case ' ': /* argument break */X
- X case '\t':X
- X loop = 0;X
- X break;X
- XX
- X case '&': /* &, && */X
- X if ( rc == BAND ) /* already received 1 & */X
- X rc = AND;X
- X else if ( rc == END )X
- X rc = BAND;X
- X else {X
- X rc = UNKNOWN;X
- X loop = 0;X
- X }X
- X break;X
- XX
- X case '|': /* |, || */X
- X if ( rc == BOR ) /* already received 1 | */X
- X rc = OR;X
- X else if ( rc == END )X
- X rc = BOR;X
- X else {X
- X rc = UNKNOWN;X
- X loop = 0;X
- X }X
- X break;X
- XX
- X case '^': /* ^ */X
- X CHECKOP ( EOR );X
- X break; X
- XX
- X case '!': /* ! */X
- X CHECKOP ( NOT );X
- X break;X
- XX
- X case '~': /* ~ */X
- X CHECKOP ( BNOT );X
- X break;X
- XX
- X case '+': /* + */X
- X case '-': /* - */X
- X case '/': /* / */X
- X case '%': /* % */X
- X case '*': /* * */X
- X CHECKOP ( (int) p_inp[p_position] );X
- X break;X
- XX
- X case '=': /* =, ==, >=, <= */X
- X switch ( rc ) {X
- X case END:X
- X rc = (int) '=';X
- X break;X
- X case (int) '=':X
- X rc = EQ;X
- X break;X
- X case NOT:X
- X rc = NE;X
- X break;X
- X case GT:X
- X rc = GE;X
- X break;X
- X case LT:X
- X rc = LE;X
- X break;X
- X default:X
- X rc = UNKNOWN;X
- X loop = 0;X
- X }X
- X break;X
- XX
- X case '>': /* >, >> */X
- X if ( rc == END )X
- X rc = GT;X
- X else if ( rc == GT )X
- X rc = SR;X
- X else {X
- X rc = UNKNOWN;X
- X loop = 0;X
- X }X
- X break;X
- XX
- X case '<': /* <, << */X
- X if ( rc == END )X
- X rc = LT;X
- X else if ( rc == LT )X
- X rc = SL;X
- X else {X
- X rc = UNKNOWN;X
- X loop = 0;X
- X }X
- X break;X
- XX
- X default: /* number or string */X
- X /* see if it is a valid number */X
- X if ( ( p_inp[p_position] >= 'a' && p_inp[p_position] <= 'f' ) ||X
- X ( p_inp[p_position] >= '0' && p_inp[p_position] <= '9' ) ) ;X
- X elseX
- X possibleNum = 0;X
- XX
- X /* see if the character can be stuffed into the array */X
- X if ( s_ptr == 32 ) {X
- X printf ( "Variable specified is too big\n" );X
- X rc = UNKNOWN;X
- X loop = 0;X
- X break;X
- X }X
- XX
- X /* so far it is a string variable */X
- X rc = VAR;X
- XX
- X str[s_ptr++] = p_inp[p_position];X
- XX
- X break;X
- X X
- X }X
- XX
- X /* increment p_position */X
- X if ( p_position > 0 )X
- X p_position++;X
- XX
- X }X
- XX
- X /* don't bother checking for number if it can't be */X
- X if ( rc != VAR )X
- X return rc;X
- XX
- X str[s_ptr] ='\0';X
- X /* check if the string is a number or a variable (variable first) */X
- X for ( temp = 0; temp < var_param[FORMATNUM] + var_param[PARTSNUM]; temp++ )X
- X if ( ! strcmp ( var[temp].name, str ) ) {X
- X *val = temp;X
- X return VAR;X
- X }X
- XX
- X /* if not a variable and can possibly be a number do so otherwise a error */X
- X if ( possibleNum ) {X
- X str[( s_ptr == 32 ? 0 : s_ptr )] = '\0';X
- X sscanf ( str, "%x", val );X
- X return NUM;X
- XX
- X } X
- XX
- X /* no exactly sure what it was */X
- X return UNKNOWN;X
- XX
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: set()X
- X * PURPOSE: set a register or memory to a value X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_CONT - continue processing commands X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XsetSome ( which )X
- X int which;X
- X{X
- X int found, temp, val;X
- X U_Ret rv;X
- XX
- X /* get the first argument, if any */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position == -1 ) { /* no arguments */X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* check if it is a memory set */X
- X if ( ! strcmp ( "mem", rv.str ) ) {X
- X X
- X /* get an integer */X
- X if ( ( getEntry ( &rv, P_NUM ) ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* set the location */X
- X val = rv.ival;X
- XX
- X /* get an integer */X
- X if ( ( getEntry ( &rv, P_NUM ) ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- X X
- X /* do the math operation - equate */X
- X push ( MEM, val ); /* push onto stack */X
- X push ( NUM, rv.ival );X
- X do_stack ( (int) '=' ); /* equate them */X
- X pop ( ); /* pop off the element */X
- X X
- X return P_CONT; X
- X }X
- XX
- X /* search for the register */X
- X for ( temp = 0; temp < var_param[FORMATNUM] + var_param[PARTSNUM]; temp++ )X
- X if ( ! strcmp ( var[temp].name, rv.str ) )X
- X found = 1, val = temp;X
- XX
- X if ( ! found ) /* unable to find register */X
- X printf ( "Could not find the register specified\n" );X
- X else { /* found the register */X
- XX
- X /* get an integer */X
- X if ( ( getEntry ( &rv, P_NUM ) ) || p_position == -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* do the math operation - equate */X
- X push ( VAR, val ); /* push onto stack */X
- X push ( NUM, rv.ival );X
- X do_stack ( (int) '=' ); /* equate them */X
- X pop ( ); /* pop off the element */X
- X X
- X printf ( "%s\t%-4lx\n", var[val].name, var[temp].val );X
- X }X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: D_interrupt()X
- X * PURPOSE: list, unset or set interrupts X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_CONT - continue processing commands X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XD_interrupt ( which )X
- X int which;X
- X{X
- X U_Ret rv;X
- X int temp, found = 0;X
- X int num;X
- XX
- X /* get the first argument */X
- X if ( getEntry ( &rv, P_NUM ) ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* check if any arguments */X
- X if ( p_position == -1 ) { /* no arguments */X
- X printf ( "Number Period Next Interrupt (in fetchs)\n" );X
- X for ( temp = 0; temp < var_param[INTNUM]; temp++ ) X
- X if ( interrupt[temp].period != -1 ) {X
- X printf ( "%-12d%-12x%x\n", temp + 1, interrupt[temp].period,X
- X interrupt[temp].next );X
- X found++;X
- X }X
- XX
- X /* Print no-find message if didn't */X
- X if ( ! found )X
- X printf ( "No Interrupt Vectors Set\n" );X
- XX
- X /* Return and continue */ X
- X return P_CONT;X
- X }X
- XX
- X /* set and check the interrupt number */X
- X if ( ( num = rv.ival ) < 1 || rv.ival > var_param[INTNUM] ) {X
- X printf ( "Interrupt vectors range from 1 to %d\n", var_param[INTNUM] );X
- X return P_CONT;X
- X }X
- XX
- X /* get the second argument */X
- X if ( getEntry ( &rv, P_NUM ) ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* if only one argument - delete it from the list */X
- X if ( p_position == -1 ) {X
- X interrupt[num].period = interrupt[num].next = -1;X
- X return P_CONT;X
- X }X
- XX
- X /* check interrupt value */X
- X if ( rv.ival < 1 ) {X
- X printf ( "Interrupts can only occur during 1 or more cycles.\n" );X
- X return P_CONT;X
- X }X
- XX
- X /* check for any other arguments */X
- X getEntry ( &rv, P_NUM );X
- X if ( p_position != -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* set the value */X
- X interrupt[num-1].period = rv.ival;X
- X interrupt[num-1].next = cycles + rv.ival;X
- XX
- X /* continue on as normal */X
- X return P_CONT;X
- XX
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: trace()X
- X * PURPOSE: set the trace parameters for displaying stuff X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_CONT - continue processing commands X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xtrace ( which )X
- X int which;X
- X{X
- X U_Ret rv;X
- XX
- X /* get the first argument */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position == -1 ) { /* no arguments */X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* check if there any more - should not be */X
- X if ( getEntry ( &rv, P_NUM ) ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* check and see if the argument is valid */X
- X if ( !strcmp ( "on", rv.str ) || !strcmp ( "o", rv.str ) ) {X
- X /* set trace to ON */X
- X traceChange = DEBUG;X
- XX
- X } else if ( !strcmp ( "off", rv.str ) || !strcmp ( "f", rv.str ) ) {X
- X /* set trace to OFF */X
- X traceChange = NOTRACE;X
- XX
- X } else if ( !strcmp ( "header", rv.str ) || !strcmp ( "h", rv.str ) ) {X
- X /* set trace to register print */X
- X traceChange = DEBUG_REG;X
- XX
- X } else X
- X /* print misuse message */X
- X misuse ( which );X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: resetCPU()X
- X * PURPOSE: reset the CPU to the start state X
- X * ARGUMENTS: which - command entry numberX
- X * RETURNS: P_GOON - start executingX
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XresetCPU ( which )X
- X int which;X
- X{X
- X U_Ret rv;X
- X int saveFetch;X
- XX
- X /* No arguments */X
- X getEntry ( &rv, P_STR );X
- X if ( p_position != -1 ) {X
- X misuse ( which );X
- X return P_CONT;X
- X }X
- XX
- X /* Reset variables */X
- X subcycles = var_param[SUBNUM] + 1; /* complete all subcycles */X
- X mpc ( "set", 0 ); /* set the mpc to zero */X
- X mpcptr = -1; /* current mpc to nil */X
- X saveFetch = var_param[FETCH]; /* save the fetch */X
- X init ( var_param ); /* re-initialize */X
- X var_param[FETCH] = saveFetch; /* put the real fetch back */X
- X cycles = 0; /* reset number of cycles */X
- XX
- X return P_GOON;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: misuse()X
- X * PURPOSE: display a misuse of a command X
- X * ARGUMENTS: which - which command to display (cmd entry #)X
- X * RETURNS: none X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xmisuse ( which )X
- X int which;X
- X{X
- X printf ( cmds[which].help );X
- X printf ( "usage: %s <RETURN>\n", cmds[which].usage );X
- X}X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > debug.h
- XX
- XX
- X/* ----------------------------------------------------------------------- *\X
- X ***************************************************************************X
- XX
- X PROGRAM NAME: Debug headerX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X Debug header containing the definitions for the debug command set.X
- X X
- X ***************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X ***************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X *************************************************************************** X
- X\* ----------------------------------------------------------------------- */X
- XX
- X/* debug commands information and definitions */X
- X#define DEBUG_ENTRY 14X
- XX
- X/* structure containing the debug routines */X
- Xstruct debug_cmds {X
- X char *word; /* the word spelling */X
- X int matchnum; /* number of characters needed to match */X
- X char *usage; /* usage message if used improperly */X
- X char *help; /* help message */X
- X int (*func) ( ); /* function pointer */X
- XX
- X} cmds [DEBUG_ENTRY] = {X
- XX
- X { "breakpoint",X
- X 1,X
- X "breakpoint [#]",X
- X "(b)reakpoint [#]\t- set a breakpoint for address #\n",X
- X addBrkPtsX
- X },X
- XX
- X {X
- X "calculator", X
- X 1, X
- X "(c)alculator [expr]", X
- X "(c)alculator [expr]\t- calculate an expression (RPN, numbers in hex)\n", X
- X calculatorX
- X },X
- XX
- X {X
- X "delete", X
- X 2, X
- X "delete [#]", X
- X "(de)lete [#]\t\t- delete a breakpoint given the address\n", X
- X delBrkPtsX
- X },X
- XX
- X {X
- X "display", X
- X 1, X
- X "display <regs|(cpu|mem #)>",X
- X "(d)isplay <regs|(cpu|mem #)>\n\t\t\t- display registers, cpu memory, or main memory\n",X
- X displayX
- X },X
- XX
- X {X
- X "exit", X
- X 1, X
- X "exit", X
- X "(e)xit\t\t\t- Exit this program\n", X
- X exitProgX
- X },X
- XX
- X {X
- X "help", X
- X 1, X
- X "help", X
- X "(h)elp\t\t\t- This list of commands\n",X
- X helpX
- X },X
- XX
- X {X
- X "interrupt", X
- X 1, X
- X "interrupt <#> <##>", X
- X "(i)nterrupt <#> <##>\t- list, unset or set interrupts\n", X
- X D_interruptX
- X },X
- XX
- X {X
- X "list", X
- X 1, X
- X "list", X
- X "(l)ist\t\t\t- list all set breakpoints\n", X
- X showBrkPtsX
- X },X
- XX
- X {X
- X "quit", X
- X 1, X
- X "quit", X
- X "(q)uit\t\t\t- Exit this program\n", X
- X exitProgX
- X },X
- XX
- X {X
- X "run", X
- X 1, X
- X "run <#>", X
- X "(r)un <#>\t\t- run continous or a certain number\n",X
- X runX
- X },X
- XX
- X {X
- X "reset", X
- X 2, X
- X "reset", X
- X "(re)set\t\t\t- Reset the system to initial state\n", X
- X resetCPUX
- X },X
- XX
- X {X
- X "set", X
- X 1, X
- X "set [regs|mem] [#] <#>", X
- X "(s)et [regs|mem] [#] <#>- set a register or memory to a value\n", X
- X setSomeX
- X },X
- XX
- X {X
- X "trace", X
- X 1, X
- X "trace [On|oFf|Header]", X
- X "(t)race [On|oFf|Header]\t- set the trace of the debug mode\n", X
- X traceX
- X },X
- XX
- X {X
- X "version", X
- X 1, X
- X "version", X
- X "(v)ersion\t\t- display current version of this program\n", X
- X versionX
- X }X
- X};X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > lalr.y
- XX
- X%{X
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: YAMPC LALRX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X Parser for the input computer hardware file.X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- X#include <stdio.h>X
- X#include "yampc.h"X
- X#include "misc.h"X
- XX
- X#define YYSTYPE struct ystack /* yacc stack type */X
- XX
- Xextern int lineNo;X
- XX
- X/* current section */X
- Xint section;X
- XX
- X/* number of defaults for switches */X
- Xint def_num;X
- XX
- X/* temp buffer */X
- Xchar buffer[128];X
- XX
- X%}X
- XX
- X/* start and end tokens */X
- X%token START ENDX
- XX
- X/* subparts of the hardware description file */X
- X%token FORMAT PARTS MEMORY SUBCYCLE INTERRUPT INIT ENGINE VARSX
- XX
- X/* memory tokens */X
- X%token CMEM MEMX
- XX
- X/* statement commands */X
- X%token IF ELSEX
- X%token SWITCH CASE DEFAULT BREAK RETURNX
- XX
- X/* others */X
- X%token UNKNOWN VAR NUM SUB SUBSCRIPT INTERX
- XX
- X/* set the left associative with other tokens */X
- X%left '='X
- X%left OR ANDX
- X%left BOR EOR BANDX
- X%left SL SRX
- X%left EQ GT GE LT LE NEX
- X%left '+' '-'X
- X%left '*' '/' '%' X
- X%left BNOT NOTX
- XX
- X/* Get rid of the Shift/Reduce Warning Messages */X
- X%left ELSEX
- XX
- X%%X
- XX
- Xprogram: list;X
- X ;X
- XX
- Xlist:X
- X | START format parts vars memory sub interrupt init engine ENDX
- X | errorX
- X {X
- X warning ( "File not properly formatted", (char *) 0 );X
- X return 1; X
- X }X
- X ;X
- XX
- Xformat: formatcmd format_data ';'X
- X ;X
- XX
- Xformatcmd: FORMATX
- X {X
- X section = FORMATNUM;X
- X init_var ( );X
- X }X
- X ;X
- XX
- Xparts: partscmd parts_data ';'X
- X ;X
- XX
- Xpartscmd: PARTSX
- X {X
- X section = PARTSNUM;X
- X }X
- XX
- Xvars:X
- X {X
- X end_struct ( );X
- X }X
- X | varscmd format_data ';'X
- X {X
- X end_struct ( );X
- X }X
- X ;X
- XX
- Xvarscmd: VARSX
- X {X
- X section = VARSNUM;X
- X }X
- XX
- Xmemory: MEMORY CMEM '[' NUM ']' ',' MEM '[' NUM ']' '[' NUM ']' ';'X
- X {X
- X set_mem ( $4.val, $9.val, $12.val );X
- X }X
- X | error X
- X {X
- X warning ( "Memory definitions not properly defined", (char *) 0 );X
- X }X
- X ;X
- XX
- Xsub:X
- X | SUBCYCLE SUB '=' NUM ';'X
- X {X
- X set_entry ( SUBNUM, $4.val );X
- X }X
- X | errorX
- X {X
- X warning ( "Subcycle definition not properly defined", (char *) 0 );X
- X }X
- X ;X
- XX
- Xinterrupt:X
- X {X
- X set_entry ( INTNUM, 0 );X
- X }X
- X | INTERRUPT INTER '=' NUM ';'X
- X {X
- X set_entry ( INTNUM, $4.val );X
- X }X
- X | error X
- X {X
- X warning ( "Interrupt definition not properly defined", (char *) 0 );X
- X }X
- X ;X
- XX
- Xinit:X
- X | initcmd state_listX
- X {X
- X end_func ( );X
- X }X
- X | errorX
- X {X
- X warning ( "Error in defining initializations", (char *) 0 );X
- X }X
- X ;X
- XX
- Xinitcmd: INITX
- X {X
- X start_init ( );X
- X }X
- X ;X
- XX
- Xengine: enginecmd state_listX
- X {X
- X end_engine ( );X
- X }X
- X | errorX
- X {X
- X warning ( "Error in Microengine", (char *) 0 );X
- X }X
- X ;X
- XX
- Xenginecmd: ENGINEX
- X {X
- X start_engine ( );X
- X }X
- X ;X
- XX
- Xformat_data: format_varX
- X | format_var ',' format_dataX
- X ;X
- X X
- Xformat_var: VAR '[' NUM ']'X
- X {X
- X add_var ( $1.str, $3.val, section, 0 );X
- X }X
- X | error ';'X
- X {X
- X warning ( "Syntax error in declaration section", "" );X
- X yyerrok;X
- X }X
- X ;X
- XX
- Xparts_data: parts_varX
- X | parts_var ',' parts_dataX
- X ;X
- X X
- Xparts_var: '*' VAR '[' NUM ']'X
- X {X
- X add_var ( $2.str, $4.val, section, 1 );X
- X }X
- X | VAR '[' NUM ']'X
- X {X
- X add_var ( $1.str, $3.val, section, 0 );X
- X }X
- X | error ';'X
- X {X
- X warning ( "Syntax error in declaration section", "" );X
- X yyerrok;X
- X }X
- X ;X
- XX
- Xstate: start_brace state_list end_braceX
- X | expr ';'X
- X {X
- X put_msg ( "pop ( );" );X
- X }X
- X | IF if_clause state do_end_brace otherX
- X | SWITCH switch '{' in_switch end_braceX
- X | BREAK ';'X
- X {X
- X put_msg ( "break;" );X
- X }X
- X | RETURN ';'X
- X {X
- X put_msg ( "return 1;" );X
- X }X
- X | error ';'X
- X {X
- X warning ( "Syntax error", "with an expression" );X
- X yyerrok;X
- X }X
- X ;X
- XX
- Xstate_list: stateX
- X | state state_listX
- X ;X
- XX
- Xstart_brace: '{'X
- X {X
- X put_msg ( "{" );X
- X }X
- X ;X
- XX
- Xend_brace: '}'X
- X {X
- X put_msg ( "}" );X
- X }X
- X ;X
- XX
- Xdo_end_brace:X
- X {X
- X put_msg ( "}" );X
- X }X
- X ;X
- X X
- Xif_clause: '(' expr ')'X
- X {X
- X put_msg ( "if ( pop ( ) ) {" );X
- X }X
- X ;X
- XX
- Xother: X
- X | else stateX
- X {X
- X put_msg ( "}" );X
- X }X
- X ;X
- XX
- Xelse: ELSEX
- X {X
- X put_msg ( "else {" );X
- X }X
- X ;X
- XX
- Xexpr: valueX
- X | '(' expr ')' X
- X | uminas exprX
- X {X
- X sprintf ( buffer, "do_stack ( %d ); /* neg operation */",X
- X (int) '-' );X
- X put_msg ( buffer );X
- X }X
- X | expr oper exprX
- X {X
- X sprintf ( buffer, "do_stack ( %d ); /* math operation */",X
- X $2.val );X
- X put_msg ( buffer );X
- X }X
- X | MEM '[' expr ']'X
- X {X
- X sprintf ( buffer, "push ( %d, pop() ); /* memory access */",X
- X MEM );X
- X put_msg ( buffer );X
- X }X
- X ;X
- XX
- Xswitch: '(' expr ')' X
- X {X
- X def_num = 1;X
- X put_msg ( "switch ( pop ( ) ) {" );X
- X }X
- X | errorX
- X {X
- X warning ( "Inproper expression in switch", (char *) 0 );X
- X }X
- X ;X
- XX
- Xin_switch: sub_switchX
- X | sub_switch in_switchX
- X ;X
- XX
- Xsub_switch: case state_listX
- X | caseX
- X | default state_list X
- X | defaultX
- X | error ';'X
- X {X
- X warning ( "Inproper switch statement", (char *) 0 );X
- X yyerrok;X
- X }X
- X ;X
- XX
- Xcase: CASE NUM ':'X
- X {X
- X sprintf ( buffer, "case %d:", $2.val );X
- X put_msg ( buffer );X
- X }X
- X ;X
- XX
- Xdefault: DEFAULT ':'X
- X {X
- X if ( ! def_num )X
- X warning ( "Multidefined default statements in switch",X
- X (char *) 0 );X
- X else def_num = 0;X
- X put_msg ( "default:" );X
- X }X
- X ;X
- XX
- Xuminas: '-'X
- X {X
- X sprintf ( buffer, "push ( %d, 0 );", NUM );X
- X put_msg ( buffer );X
- X }X
- X ;X
- XX
- Xvalue:X
- X | NUMX
- X {X
- X sprintf ( buffer, "push ( %d, %d ); /* number - %d */",X
- X NUM, $1.val, $1.val );X
- X put_msg ( buffer );X
- X }X
- X | SUBX
- X {X
- X sprintf ( buffer, "push ( %d, 0 ); /* subcycle */", SUB );X
- X put_msg ( buffer );X
- X }X
- X | CMEMX
- X {X
- X sprintf ( buffer, "push ( %d, 0 ); /* computer memory */",X
- X CMEM );X
- X put_msg ( buffer );X
- X }X
- X | VARX
- X {X
- X sprintf ( buffer, "push ( %d, %d ); /* variable - %s */",X
- X VAR, queryLocalVar ( $1.str ), $1.str );X
- X put_msg ( buffer );X
- X }X
- X ;X
- XX
- Xoper: EQ { $$.val = EQ; }X
- X | GT { $$.val = GT; }X
- X | GE { $$.val = GE; }X
- X | LT { $$.val = LT; }X
- X | LE { $$.val = LE; }X
- X | NE { $$.val = NE; }X
- X | AND { $$.val = AND; }X
- X | OR { $$.val = OR; }X
- X | NOT { $$.val = NOT; }X
- X | BAND { $$.val = BAND; }X
- X | BOR { $$.val = BOR; }X
- X | SR { $$.val = SR; }X
- X | SL { $$.val = SL; }X
- X | BNOT { $$.val = BNOT; }X
- X | EOR { $$.val = EOR; }X
- X | '=' { $$.val = (int) '='; }X
- X | '+' { $$.val = (int) '+'; }X
- X | '-' { $$.val = (int) '-'; }X
- X | '*' { $$.val = (int) '*'; }X
- X | '/' { $$.val = (int) '/'; }X
- X | '%' { $$.val = (int) '%'; }X
- X ;X
- XX
- X%%X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: yyerror()X
- X * PURPOSE: When there is an error in parsing, error messageX
- X * ARGUMENTS: string - string containing reasoning of errorX
- X * RETURNS: nothingX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xyyerror ( str )X
- X char * str;X
- X{X
- X warning ( str, (char *) 0 );X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: warning()X
- X * PURPOSE: display a warning messageX
- X * ARGUMENTS: s, t - two strings to display side-by-sideX
- X * RETURNS: nothingX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xwarning ( s, t )X
- X char *s, *t;X
- X{X
- X fprintf ( stderr, "%s", s );X
- X if ( t )X
- X fprintf ( stderr, " %s", t );X
- X fprintf ( stderr, " in line %d\n", lineNo );X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > lex.l
- XX
- X%{X
- XX
- X/* ---------------------------------------------------------------------- *\X
- X **************************************************************************X
- XX
- X PROGRAM NAME: Lexical ParserX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X A parser to break down the input computer hardware file.X
- X X
- X **************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X **************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X ************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- X#include "y.tab.h"X
- X#include "yampc.h"X
- XX
- Xextern struct ystack yylval;X
- XX
- X/* line counter - should not use yylineno because it is incompatibleX
- X * with flex */X
- Xint lineNo = 0;X
- XX
- X%}X
- XX
- X%o 20000X
- XX
- X%%X
- X"/*" /* ignore comments */ X
- X { X
- X int done = 0;X
- X char c = getc ( yyin );X
- X while ( ! done ) /* find end of comment */X
- X if ( c == '\n' ) {X
- X lineNo++;X
- X c = getc ( yyin );X
- X } else if ( c == '*' ) {X
- X if ( ( c = getc ( yyin ) ) == '/' )X
- X done = 1;X
- X else if ( c != '*' )X
- X c = getc ( yyin );X
- X } elseX
- X c = getc ( yyin );X
- X }X
- XX
- X[ \t]+ /* ignore whitespaces */X
- X ;X
- XX
- X"\n"+ /* count newlines */X
- X lineNo += yyleng;X
- XX
- XBEGIN /* beginning of the hardware file */X
- X return START; X
- XX
- XEND /* end of the hardware file */X
- X return END;X
- XX
- XFORMAT /* defining the format of the microprogram */X
- X return FORMAT;X
- XX
- XPARTS /* defining the variable parts */X
- X return PARTS;X
- XX
- XVARS /* defining the local variables */X
- X return VARS;X
- XX
- XMEMORY /* defining the memory structure */X
- X return MEMORY;X
- XX
- XSUBCYCLE /* defining the number of subcycles */X
- X return SUBCYCLE;X
- XX
- XINTERRUPT /* defining the number of interrupts */X
- X return INTERRUPT;X
- XX
- XINIT /* the initialization of the variables */X
- X return INIT;X
- XX
- XMICROENGINE /* beginning of the micro-engine section */X
- X return ENGINE;X
- XX
- Xcpu /* computer memory - internal */X
- X return CMEM;X
- XX
- Xmem /* external memory */X
- X return MEM;X
- XX
- Xsubcycle /* the current subcycle variable */X
- X return SUB;X
- XX
- Xinterrupt /* 'interrupt = X' value */X
- X return INTER;X
- XX
- Xif /* 'if' - start of a compare */X
- X return IF;X
- XX
- Xelse /* 'else' - an extra clause in an if */X
- X return ELSE;X
- XX
- Xswitch /* 'switch' - beginning of a switch */X
- X return SWITCH;X
- XX
- Xcase /* 'case' - subpart of a switch */X
- X return CASE;X
- XX
- Xdefault /* 'default' - fall through in switch */X
- X return DEFAULT;X
- XX
- Xbreak /* 'break' - command used in switches */X
- X return BREAK;X
- XX
- XIreturn /* 'Ireturn' - return because unable to service interrupt */X
- X return RETURN;X
- XX
- X[a-zA-Z][a-zA-Z0-9]* /* variable */X
- X {X
- X strcpy ( yylval.str, yytext );X
- X return VAR;X
- X }X
- XX
- X("0x"|\$)[0-9A-Fa-f]+ /* hexidecimal number */X
- X {X
- X yylval.val = convStr ( ( yytext[0] == '$' ? X
- X &yytext[1] : &yytext[2] ), HEX );X
- X return NUM;X
- X }X
- XX
- X"0"[0-9]* /* Octal number or zero */ X
- X {X
- X yylval.val = convStr ( yytext, OCT );X
- X return NUM;X
- X }X
- XX
- X"==" /* query if equal */X
- X return EQ;X
- XX
- X">" /* greater than */X
- X return GT;X
- XX
- X">=" /* greater than or equal */X
- X return GE;X
- XX
- X"<" /* less than */X
- X return LT;X
- XX
- X"<=" /* less than or equal */X
- X return LE;X
- XX
- X"!=" /* not equal */X
- X return NE;X
- XX
- X"&&" /* and */X
- X return AND;X
- XX
- X"&" /* binary and */X
- X return BAND;X
- XX
- X"||" /* or */X
- X return OR;X
- XX
- X"|" /* binary or */X
- X return BOR;X
- XX
- X"^" /* X-or */X
- X return EOR;X
- XX
- X"~" /* one's compliment - not */X
- X return BNOT;X
- XX
- X"!" /* logical NOT */X
- X return NOT;X
- XX
- X">>" /* shift right */X
- X return SR;X
- XX
- X"<<" /* shift left */X
- X return SL;X
- XX
- X[0-9]+ /* Decimal number */X
- X {X
- X yylval.val = convStr ( yytext, DEC );X
- X return NUM;X
- X }X
- XX
- X. /* anything else */X
- X return yytext[0];X
- XX
- X%%X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: setInput()X
- X * PURPOSE: set the input file descriptor to the hardware spec fileX
- X * ARGUMENTS: fp - file pointer to the hardware spec fileX
- X * RETURNS: nothingX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XsetInput ( fp )X
- X FILE *fp; /* file pointer */X
- X{X
- X yyin = fp;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: yywrap()X
- X * PURPOSE: stub functionX
- X * ARGUMENTS: noneX
- X * RETURNS: 1 - completeX
- X * NOTES: the purpose of the routine is so the lex library X
- X * isn't needed; this can be useful when using otherX
- X * parsers besides the standard AT&T lex.X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xyywrap ( )X
- X{X
- X return 1; /* done with yywrap */X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > main.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Main moduleX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This is the first function executed. It sets up the necessaryX
- X variables and then starts running the engine (runMicro). X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include <stdio.h>X
- X#include "main.h"X
- X#include "misc.h"X
- XX
- Xextern struct varlist var[];X
- Xint var_param[NUM_PARAM];X
- Xstruct interruptlist *interrupt;X
- Xint cycles, subcycles;X
- Xint mpcptr;X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: main()X
- X * PURPOSE: first routine to start executing microcodeX
- X * ARGUMENTS: argc - number of command line argumentsX
- X * argv - command line argumentsX
- X * RETURNS: nothing interesting X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xmain ( argc, argv )X
- X int argc;X
- X char **argv;X
- X{X
- X int mema[3]; /* cmemory, memory, correct argument */X
- X int temp, temp1; /* temp variables used in loops */X
- X int memptr = 0; /* argument memory ptr */X
- X int mode; /* current debug mode */X
- XX
- X /* print version of this program */X
- X version ( );X
- XX
- X /* call the init program */X
- X init ( var_param );X
- XX
- X /* initialize the interrupt list */X
- X initInterrupt ( );X
- XX
- X /* mema[0] (cmemory) set to no new name */X
- X /* mema[1] (memory) set to no new name */X
- X /* mema[2] (correct) set the correction file */X
- X mema[0] = mema[1] = mema[2] = 0;X
- XX
- X /* call the memory allocation programs for access memory */X
- X allocCMem ( ); /* allocate memory for micro code */X
- X allocMMem ( ); /* allocate memory for main memory */X
- XX
- X /* set all the break points to zero */X
- X setBrkPts ( );X
- XX
- X /* set mode to NO DEBUGGING */X
- X mode = NOTRACE;X
- XX
- X /* check arguments */X
- X for ( temp = 1; temp < argc; temp++ )X
- X if ( argv[temp][0] == '-' ) {X
- X for ( temp1 = 1; temp1 < strlen ( argv[temp] ); temp1++ )X
- X switch ( argv[temp][temp1] ) {X
- X case 'c': /* create correction file */X
- X mode = CREATE;X
- X addCorrect ( &argv[temp][temp1+1] );X
- X temp1 = strlen ( argv[temp] );X
- X break;X
- XX
- X case 'd': /* debug mode */X
- X mode = DEBUG;X
- X break;X
- XX
- X case 'F': /* display all regs at each cycle */X
- X mode = NOTRACE_REG;X
- X break;X
- XX
- X case 'f': /* display all regs at each fetch */X
- X mode = NOTRACE_FREG;X
- X break;X
- XX
- X default:X
- X usage ( argv[0] );X
- X }X
- XX
- X } else if ( argv[temp][0] == '+' ) {X
- X int notperiod = 0, num[2];X
- XX
- X /* initialize */X
- X num[0] = num[1] = 0;X
- XX
- X /* check and get arguments */X
- X for ( temp1 = 1; temp1 < strlen ( argv[temp] ) + 1; temp1++ ) {X
- X if ( argv[temp][temp1] == '\0' ) {X
- X notperiod++;X
- X break;X
- X } else if ( ( argv[temp][temp1] >= '0' && argv[temp][temp1] <=X
- X '9' ) || ( argv[temp][temp1] >='a' && argv[temp][temp1] <= 'f' ) ) {X
- X if ( notperiod > 1 )X
- X usage ( argv[0] );X
- X num[notperiod] *= 16;X
- X num[notperiod] += ( argv[temp][temp1] - ( argv[temp][temp1] X
- X >= 'a' ? (int) 'a' : (int) '0' ) );X
- X } else if ( argv[temp][temp1] == ':' ) {X
- X if ( temp1 == strlen ( argv[temp] ) )X
- X usage ( argv[0] );X
- X notperiod++;X
- X } elseX
- X usage ( argv[0] );X
- X }X
- XX
- X /* check values */X
- X if ( notperiod < 2 || num[0] > var_param[INTNUM] || num[0] < 1 )X
- X usage ( argv[0] );X
- XX
- X /* set values */X
- X interrupt[num[0]-1].period = interrupt[num[0]-1].next = num[1];X
- XX
- X } else if ( memptr < 3 )X
- X mema[memptr++] = temp;X
- XX
- X else X
- X usage ( argv[0] );X
- X X
- X X
- X /* read in the memory */X
- X if ( mema[0] )X
- X readCmem ( argv[mema[0]] );X
- X elseX
- X readCmem ( "cmemory" );X
- X if ( mema[1] )X
- X readMmem ( argv[mema[1]] );X
- X elseX
- X readMmem ( "memory" );X
- X if ( mema[2] ) {X
- X if ( mode == CREATE ) X
- X mode = CREATE_CORRECT;X
- X elseX
- X mode = CORRECT;X
- X openCorrect ( mode, argv[mema[2]] );X
- X }X
- XX
- X if ( mode == CREATE )X
- X printf ( "Correction file must be specified for its' creation\n" );X
- X elseX
- X runMicro ( mode );X
- XX
- X /* close the correctional file if it is opened */X
- X if ( mode == CORRECT || mode == CREATE_CORRECT ) X
- X closeCorrect ( );X
- XX
- X /* return no error */X
- X return 0;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: runMicro()X
- X * PURPOSE: start executing the microcode X
- X * ARGUMENTS: mode - mode to start executing (ie NOTRACE, CORRECT, etc)X
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOID X
- XrunMicro ( mode )X
- X int mode; X
- X{X
- X int mpcold;X
- X int loop = 1;X
- X int temp;X
- XX
- X /* set the number of cycles and subcycles */X
- X cycles = 0;X
- X subcycles = 1;X
- XX
- X /* set old value of the mpc to the current one for start */X
- X mpcold = mpc ( "query", 0 ) - 1;X
- XX
- X /* Execute micro code while mpc is within the addr space */X
- X do {X
- X if ( ( mpcptr = mpc ( "query", 0 ) ) < var_param[CPUSIZE] ) {X
- XX
- X /* if the engine did not change the mpc, we will */X
- X if ( mpcptr == mpcold )X
- X mpcold = mpcptr = mpc ( "set", mpcptr + 1 );X
- XX
- X getCpuMem ( mpcptr );X
- XX
- X /* increment number of cycles executed */X
- X cycles++;X
- XX
- X /* check debug mode and break points */X
- X if ( mode != NOTRACE )X
- X loop = debug ( & mode, 0 );X
- XX
- X /* call the engine for possible subcycle */X
- X while ( subcycles <= var_param[SUBNUM] ) {X
- X engine ( subcycles );X
- X subcycles++;X
- X }X
- XX
- X /* call the engine for possible interrupts */X
- X for ( temp = 0; temp < var_param[INTNUM]; temp++ )X
- X if ( interrupt[temp].next == cycles ) {X
- X /* see if display message */X
- X if ( mode != NOTRACE && mode != NOTRACE_REG &&X
- X mode != NOTRACE_FREG && mode != CORRECT &&X
- X mode != CREATE_CORRECT )X
- X printf ( "Interrupt Vector #%d at cycle $%x\n", X
- X temp, cycles );X
- XX
- X /* call engine with interrupt */X
- X if ( engine ( var_param[SUBNUM] + temp + 1 ) )X
- X /* if interrupt was done, set up next interrupt */X
- X interrupt[temp].next = interrupt[temp].period +X
- X cycles;X
- X elseX
- X interrupt[temp].next++;X
- X }X
- XX
- X subcycles = 1;X
- X } else {X
- X if ( mode == NOTRACE || mode == NOTRACE_REG || mode == NOTRACE_FREGX
- X || mode == CORRECT || mode == CREATE_CORRECT )X
- X loop = 0;X
- X else X
- X loop = debug ( & mode, 1 );X
- X }X
- X } while ( loop );X
- XX
- X printf ( "Micro code executed in %d cycles\n", cycles );X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: initInterrupt()X
- X * PURPOSE: initialize the interrupts X
- X * ARGUMENTS: noneX
- X * RETURNS: OK - done X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XinitInterrupt ( )X
- X{X
- X int temp;X
- XX
- X /* check if need the memory */X
- X if ( var_param[INTNUM] == 0 ) {X
- X interrupt = (struct interruptlist *) NULL;X
- X return OK;X
- X }X
- XX
- X /* get the memory */X
- X if ( ( interrupt = (struct interruptlist *) malloc (X
- X sizeof ( struct interruptlist ) * var_param[INTNUM] ) ) == NULL ) {X
- X fprintf ( stderr, "Unable to allocate memory for the interrupt list\n" );X
- X exit ( 1 );X
- X }X
- XX
- X /* clear out the memory */X
- X for ( temp = 0; temp < var_param[INTNUM]; temp++ )X
- X interrupt[temp].period = interrupt[temp].next = -1;X
- XX
- X return OK;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: usage()X
- X * PURPOSE: display a usage message to the user X
- X * ARGUMENTS: name - name of programX
- X * RETURNS: none X
- X * NOTES: routine called exit() when doneX
- X *X
- X ***************************************************************************/X
- XX
- X/* usage - display usage message */X
- XVOIDX
- Xusage ( name )X
- X char *name; /* name of command program */X
- X{X
- X printf ( "usage: %s [-cdfF] [+#:##] [cmemory] [memory] [correction file]\n",X
- X name );X
- X printf ( " -creg,.. Create the correction file\n" );X
- X printf ( " -d Debug mode\n" );X
- X printf ( " -f Display registers before each fetch\n" );X
- X printf ( " -F Display registers before each cycle\n" );X
- X printf ( " +#:## Set interrupt # every ## fetches (in hex)\n" );X
- X exit ( 1 );X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > main.h
- XX
- XX
- X/* ----------------------------------------------------------------------- *\X
- X ***************************************************************************X
- XX
- X PROGRAM NAME: Computer Hardware Main module HeaderX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This is the header file for the main micro code program.X
- XX
- X ***************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X ***************************************************************************X
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X *************************************************************************** X
- X\* ----------------------------------------------------------------------- */X
- XX
- Xtypedef int VOID;X
- XX
- X/* union structure used for returning the actual value for debug parameters */X
- Xtypedef union u_ret {X
- X int ival; /* integer value */X
- X char * str; /* string */ X
- X} U_Ret;X
- XX
- X/* trace modes */X
- X#define NOTRACE 0 /* no debugging at all */X
- X#define NOTRACE_REG 1 /* display registers at every cycle but don't stop */X
- X#define NOTRACE_FREG 2 /* display registers at every fetch but don't stop */X
- X#define DEBUG 3 /* debugging mode */X
- X#define DEBUG_REG 4 /* display registers at every debug prompt */X
- X#define CORRECT 5 /* Correctional file is being used */X
- X#define CREATE_CORRECT 6 /* Correctional file is being created */X
- X#define CREATE 7 /* Create the correction file was specified */X
- XX
- X/* prototypes */X
- XX
- X#ifdef ANSI_CX
- X#define PROTO(x) xX
- X#elseX
- X#define PROTO(x) ()X
- X#endifX
- XX
- X/* FILE: brkpts.c */X
- Xint checkBrkPts PROTO (( void )),X
- X showBrkPts PROTO (( int )),X
- X addBrkPts PROTO (( int )),X
- X delBrkPts PROTO (( int ));X
- XVOID setBrkPts PROTO (( void ));X
- XX
- X/* FILE: correct.c */X
- Xint readCorrect PROTO (( int ));X
- XVOID openCorrect PROTO (( int, char * )),X
- X closeCorrect PROTO (( void )),X
- X checkCorrect PROTO (( void )),X
- X processCorrect PROTO (( char *, int )),X
- X addCorrect PROTO (( char * )),X
- X doCorrect PROTO (( void ));X
- XX
- X/* FILE: debug.c */X
- Xint debug PROTO (( int*, int )),X
- X getEntry PROTO (( U_Ret *, int )),X
- X prompt PROTO (( void )),X
- X exitProg PROTO (( int )),X
- X help PROTO (( int )),X
- X run PROTO (( int )),X
- X display PROTO (( int )),X
- X calculator PROTO (( int )),X
- X getOp PROTO (( int * )),X
- X setSome PROTO (( int )),X
- X D_interrupt PROTO (( int )),X
- X resetCPU PROTO (( int )),X
- X trace PROTO (( int ));X
- XVOID prtregs PROTO (( void )),X
- X prtCpuLine PROTO (( int, int )),X
- X misuse PROTO (( int ));X
- X X
- X/* FILE: main.c */X
- Xint main PROTO (( int, char ** )),X
- X initInterrupt PROTO (( void ));X
- XVOID runMicro PROTO (( int )),X
- X usage PROTO (( char * ));X
- XX
- X/* FILE: memory.c */X
- Xint getWchar PROTO (( FILE * )),X
- X number PROTO (( int, int ));X
- XVOID allocCMem PROTO (( void )),X
- X allocMMem PROTO (( void )),X
- X allocVarParam PROTO (( int * )),X
- X readCmem PROTO (( char * )),X
- X readMmem PROTO (( char * )),X
- X getCpuMem PROTO (( int ));X
- Xlong getMMem PROTO (( int ));X
- XX
- X/* FILE: stack.c */X
- XVOID push PROTO (( int, long )),X
- X do_stack PROTO (( int ));X
- Xlong pop PROTO (( void )),X
- X s_math PROTO (( int, long, long ));X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > makefile
- XX
- X# Yet Another Micro-Programming Compiler (yampc)X
- X# MakefileX
- XX
- X#X
- X# This program is free software; you can redistribute it and/orX
- X# modify it under the terms of the GNU General Public LicenseX
- X# (version 2) as published by the Free Software Foundation.X
- X#X
- X# This program is distributed in the hope that is will be useful,X
- X# but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X# GNU General Public License for more details.X
- X# X
- X# You should have received a copy of the GNU General Public X
- X# License along with this program; if not, write to the FreeX
- X# Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X# 02139, USA.X
- X#X
- X# YAMPC Microcode Development KitX
- X# (C) 1992 by Patrick PalmerX
- X#X
- XX
- X# Compiler (ANSI compliant)X
- X#CC = gccX
- XCC = ccX
- XX
- X# ANSI Compliant CompilerX
- X#CFLAGS = -DANSI_CX
- XX
- X# Compiler Options (-g : debug info)X
- XCFLAGS = -gX
- XX
- X# Yet Another Compiler Compiler FlagsX
- XYFLAGS = -dvX
- XX
- X# Linker commandsX
- X# System V.3X
- X#LD_CMDS = -Wl,-xX
- XX
- X# Library nameX
- XLIB = libyampc.aX
- XX
- X# Archive name X
- XARCHIVE = yampc.arX
- XX
- X# binary and library directories used by installX
- XDESTBIN = /usr/local/binX
- XDESTLIB = /usr/local/libX
- XX
- X# Create SystemX
- Xsys: yampc $(LIB)X
- XX
- X# Create the Yet Another Micro-Programming CompilerX
- Xyampc: lalr.o lex.o yampc.o y_misc.o misc.oX
- X $(CC) $(LD_CMDS) lex.o lalr.o yampc.o y_misc.o misc.o -lcX
- X mv a.out yampcX
- X size yampcX
- XX
- X# Create libraryX
- X$(LIB): $(LIB)(main.o) $(LIB)(stack.o) $(LIB)(memory.o) $(LIB)(brkpts.o) \X
- X $(LIB)(misc.o) $(LIB)(debug.o) $(LIB)(correct.o)X
- XX
- X# Create an archiveX
- Xarchive:X
- X ar r $(ARCHIVE) yampc.doc yampc.1 yampc.l yampc.y MakefileX
- X ar r $(ARCHIVE) misc.c misc.h yampc.h yampc.c y_misc.cX
- X ar r $(ARCHIVE) stack.c memory.c main.c mode.h debug.cX
- X ar r $(ARCHIVE) correct.c brkpts.c debug.hX
- X ar r $(ARCHIVE) hfile cfile mfileX
- XX
- X# Clean up systemX
- Xclean:X
- X rm yampc yampc.ar *.o y.tab.h y.outputX
- XX
- X# Install the system - need to have proper authorityX
- Xinstall:X
- X mv yampc $(DESTBIN)X
- X mv libyampc.a $(DESTLIB)X
- XX
- X# DependanciesX
- Xyampc.o: yampc.c yampc.h misc.hX
- Xlex.o: lex.l lalr.y yampc.hX
- Xlalr.o: lalr.y yampc.hX
- Xy_misc.o: y_misc.c yampc.h misc.hX
- XX
- Xmisc.o: misc.c misc.hX
- XX
- Xmain.o: main.c main.h misc.hX
- Xstack.o: stack.c main.h y.tab.h misc.hX
- Xmemory.o: memory.c main.h misc.hX
- Xdebug.o: debug.c main.h misc.h debug.hX
- Xcorrect.o: correct.c main.h misc.hX
- Xbrkpts.o: brkpts.c main.h misc.hX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > memory.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X ***************************************************************************X
- XX
- X PROGRAM NAME: Memory moduleX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X These routines deal with the allocation, reading and manipulationX
- X of the computer memory (microcode) and the program in memory.X
- X X
- X ***************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X ***************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X **************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include <stdio.h>X
- X#include "main.h"X
- X#include "misc.h"X
- XX
- Xlong *cpu, *mem; X
- Xextern int var_param[];X
- Xextern struct varlist var[];X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: allocCMem()X
- X * PURPOSE: allocate the memory for the micro code X
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XallocCMem ( )X
- X{X
- X if ( ( cpu = (long *) mallocX
- X ( var_param[CPUSIZE]*var_param[FORMATNUM]*sizeof(long) ) ) == NULL ) {X
- X fprintf ( stderr, "Unable to allocate the micro code memory\n" );X
- X exit ( 1 );X
- X }X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: allocMMem()X
- X * PURPOSE: allocate the main memory X
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XallocMMem ( )X
- X{X
- X if ( ( mem = (long *) X
- X malloc ( var_param[MAINSIZE]*sizeof(long) ) ) == NULL ) {X
- X fprintf ( stderr, "Unable to allocate the main memory\n" );X
- X exit ( 1 );X
- X }X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: allocVarParam()X
- X * PURPOSE: allocate the memory needed to store the parameter table X
- X * ARGUMENTS: int * var_param - the variable to place the variable X
- X * memory pointerX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XallocVarParam ( var_param )X
- X int * var_param;X
- X{X
- X if ( ( var_param = (int *) X
- X malloc ( NUM_PARAM * sizeof ( int ) ) ) == NULL ) {X
- X fprintf ( stderr, "Unable to allocate memory\n" );X
- X exit ( 1 );X
- X }X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: getCpuMem()X
- X * PURPOSE: copy the current micro code entry into the current value X
- X * ARGUMENTS: int entry - micro code entryX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XgetCpuMem ( entry )X
- X int entry;X
- X{X
- X int temp = 0;X
- XX
- X /* copy the entry */X
- X while ( temp < var_param[FORMATNUM] ) {X
- X var[temp].val = cpu[entry*var_param[FORMATNUM]+temp];X
- X temp++;X
- X }X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: getMMem()X
- X * PURPOSE: get main memory entry bit and with the memory mask X
- X * ARGUMENTS: int entry - memory entryX
- X * RETURNS: memory entry or -1 if there isn't such an address X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XlongX
- XgetMMem ( entry )X
- X int entry;X
- X{X
- X if ( entry < var_param[CPUSIZE] )X
- X return mem[entry] & MEM_MASK;X
- X elseX
- X return -1L;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: readCmem()X
- X * PURPOSE: read in the micro code source into memory X
- X * ARGUMENTS: char * file - filenameX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XreadCmem ( file )X
- X char *file;X
- X{X
- X char buffer[80];X
- X int c, entry = 0;X
- X int p_entry = 0;X
- X int dataline = 0;X
- X int system, temp;X
- X FILE *fp, *fopen ( );X
- XX
- X /* numbering system set to HEX */X
- X system = S_HEX;X
- XX
- X /* open the file */X
- X if ( ( fp =fopen ( file, "r" ) ) == NULL ) {X
- X printf ( "Unable to open %s for reading\n", file );X
- X exit ( 1 );X
- X }X
- XX
- X /* read in the information */X
- X c = getWchar ( fp );X
- X while ( c != EOF ) {X
- X if ( c == '.' ) {X
- X /* format command */X
- X fscanf ( fp, "%s", buffer );X
- X if ( !strcmp ( "octal", buffer ) ) X
- X system = S_OCT;X
- X else if ( !strcmp ( "decimal", buffer ) ) X
- X system = S_DEC;X
- X else if ( !strcmp ( "fetch", buffer ) ) {X
- X if ( fscanf ( fp, "%d", &temp ) == 0 ) X
- X fprintf ( stderr, "Inproper fetch in micro code\n" );X
- X var_param[FETCH] = temp;X
- X } elseX
- X fprintf ( stderr, "Inproper command in micro code\n" );X
- XX
- X } else if ( c == '\n' ) {X
- X /* new line */X
- X if ( dataline ) X
- X entry++;X
- X p_entry = 0;X
- X dataline = 0;X
- XX
- X } else if ( number ( c, system ) == OK ) {X
- X ungetc ( c, fp ); /* put it back */X
- X dataline = 1; /* data on this line */X
- XX
- X /* scan in the number */X
- X fscanf ( fp, ( system == S_HEX ? "%x" :X
- X ( system == S_OCT ? "%o" : "%d" ) ), &temp );X
- XX
- X /* check if placement into memory is valid */X
- X if ( entry >= var_param[CPUSIZE] ) {X
- X fprintf ( stderr, "Micro code program too Large (%d %d)\n",X
- X entry, var_param[CPUSIZE] );X
- X fclose ( fp );X
- X exit ( 1 );X
- X }X
- XX
- X /* see if there is an entry */X
- X if ( p_entry < var_param[FORMATNUM] ) {X
- X cpu[entry*var_param[FORMATNUM]+p_entry] = (long) temp;X
- X } else X
- X while ( ( c = getWchar ( fp ) ) != '\n' && c != EOF ) ;X
- X p_entry++;X
- X }X
- XX
- X /* see if there is a comment */X
- X if ( c == ';' ) X
- X while ( ( c = getWchar ( fp ) ) != '\n' && c != EOF ) ;X
- X elseX
- X /* get another character */X
- X c = getWchar ( fp );X
- X }X
- XX
- X /* close the file */X
- X fclose ( fp );X
- XX
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: readMmem()X
- X * PURPOSE: read in the main memory program X
- X * ARGUMENTS: char * file - filenameX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- XreadMmem ( file )X
- X char *file;X
- X{X
- X int system;X
- X int mptr = 0;X
- X int c, temp;X
- X char buffer[80];X
- X FILE *fp, *fopen ( );X
- XX
- X if ( ( fp = fopen ( file, "r" ) ) == NULL ) {X
- X printf ( "Unable to open %s for reading\n", file );X
- X exit ( 1 );X
- X }X
- XX
- X /* numbering system set to HEX */X
- X system = S_HEX;X
- XX
- X /* read in the information */X
- X c = getWchar ( fp );X
- X while ( c != EOF ) {X
- X if ( c == '.' ) {X
- X /* format command */X
- X fscanf ( fp, "%s", buffer );X
- X if ( !strcmp ( "octal", buffer ) ) X
- X system = S_OCT;X
- X else if ( !strcmp ( "decimal", buffer ) ) X
- X system = S_DEC;X
- X elseX
- X fprintf ( stderr, "Inproper command in micro code\n" );X
- XX
- X } else if ( number ( c, system ) == OK ) {X
- X ungetc ( c, fp ); /* put it back */X
- XX
- X /* scan in the number */X
- X fscanf ( fp, ( system == S_HEX ? "%x" :X
- X ( system == S_OCT ? "%o" : "%d" ) ), &temp );X
- XX
- X if ( mptr < var_param[MAINSIZE] ) {X
- X mem[mptr++] = (long) temp & MEM_MASK;X
- X } else {X
- X fprintf ( stderr, "Program too big for main memory\n" );X
- X fclose ( fp );X
- X exit ( 1 );X
- X }X
- XX
- X } else if ( c == ';' ) X
- X /* see if there is a comment */X
- X while ( ( c = getWchar ( fp ) ) != '\n' && c != EOF ) ;X
- XX
- X /* get another character */X
- X c = getWchar ( fp );X
- XX
- X }X
- XX
- X /* close the file */X
- X fclose ( fp );X
- XX
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: getWchar()X
- X * PURPOSE: read in a character from a file and throw out whitespace X
- X * ARGUMENTS: FILE * fp - file pointerX
- X * RETURNS: read in character X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XgetWchar ( fp )X
- X FILE * fp;X
- X{X
- X int c;X
- XX
- X /* get a character until it isn't a whitespace */X
- X while ( ( c = getc ( fp ) ) == ' ' || c == '\t' ) ;X
- XX
- X return c;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: number()X
- X * PURPOSE: determine if a read in character is a valid number X
- X * ARGUMENTS: int c - read in characterX
- X * int system - number system (Octal, Decimal, Hex)X
- X * RETURNS: OK - number validX
- X * BAD - number invalid X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xnumber ( c, system )X
- X int c, system;X
- X{X
- X int retval = BAD;X
- XX
- X switch ( system ) {X
- XX
- X case S_OCT:X
- X if ( c >= '0' && c <= '7' )X
- X retval = OK;X
- X break;X
- XX
- X case S_DEC:X
- X if ( c >= '0' && c <= '9' )X
- X retval = OK;X
- X break;X
- XX
- X case S_HEX:X
- X if ( ( c >= '0' && c <= '9' ) || ( c >= 'a' && c <= 'f' ) )X
- X retval = OK;X
- X break;X
- X }X
- XX
- X return retval;X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > misc.c
- XX
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Miscellaneous routinesX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This module contains miscellaneous routines that are used throughX
- X out the program.X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include "misc.h"X
- XX
- X/* variable parameter data */X
- Xextern int var_param[];X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: findLongSize()X
- X * PURPOSE: determine the number of bits is in a type longX
- X * ARGUMENTS: noneX
- X * RETURNS: bit countX
- X * NOTES: though sizeof(long)*8 would work in most cases, this X
- X * may be easier to portX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XfindLongSize ( )X
- X{X
- X long val = 1L;X
- X int count = 1;X
- XX
- X /* the loop */X
- X while ( ( val <<= 1 ) != 0 )X
- X count++;X
- XX
- X /* return the number of bits that a long is */X
- X return count;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: createMask()X
- X * PURPOSE: given the length in bits, this routine creates a maskX
- X * ARGUMENTS: lengthX
- X * RETURNS: mask X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XlongX
- XcreateMask ( val )X
- X long val;X
- X{X
- X int i; X
- X long p = 1L;X
- XX
- X /* figure out 2 to the power of 'val' */X
- X for ( i = 1; i <= val; ++i )X
- X p *= 2;X
- XX
- X /* create the mask, given 2 to the power of 'val' minus one */X
- X p -= 1;X
- XX
- X return p;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: version()X
- X * PURPOSE: display the current version of the software X
- X * ARGUMENTS: noneX
- X * RETURNS: P_CONT - continue with operation X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xversion ( )X
- X{X
- X printf ( "YAMPC - Yet Another Micro Program Compiler\n" );X
- X printf ( "By Patrick Palmer\n" );X
- X printf ( "Version %s, %s\n\n", VERSION, V_DATE );X
- XX
- X return P_CONT;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: mpc()X
- X * PURPOSE: set and query the mpc value X
- X * ARGUMENTS: cmd - set/query commandX
- X * val - value to set mpc toX
- X * RETURNS: the value of the mpcX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- Xmpc ( cmd, val )X
- X char *cmd; /* "query", "set" */X
- X int val;X
- X{X
- X static int mpcval = 0;X
- XX
- X /* query command */X
- X if ( !strcmp ( cmd, "query" ) )X
- X return mpcval;X
- XX
- X /* set command */X
- X if ( !strcmp ( cmd, "set" ) )X
- X return ( mpcval = val );X
- XX
- X /* bad command */X
- X return -1;X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > misc.h
- XX
- XX
- X/* ----------------------------------------------------------------------- *\X
- X ***************************************************************************X
- XX
- X PROGRAM NAME: Common header.X
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This is a common header file for both YAMPC and the library.X
- X X
- X ***************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X ***************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X *************************************************************************** X
- X\* ----------------------------------------------------------------------- */X
- XX
- X/* variable list definition structure */X
- Xstruct varlist {X
- X char name[80];X
- X long bmask;X
- X int type;X
- X long val;X
- X};X
- XX
- X/* Interrupt structure */X
- Xstruct interruptlist {X
- X int period; /* interrupt every period */X
- X int next; /* interrupt when cycles hits next */X
- X};X
- XX
- X/* version of this software (string format) */X
- X#define VERSION "1.2" /* Version number */X
- X#define V_DATE "January 17, 1992" /* Version last updated */X
- XX
- X/* return values */X
- X#define OK 0X
- X#define BAD 1X
- XX
- X/* numbering systems for inputing files */X
- X#define S_HEX 0X
- X#define S_OCT 1X
- X#define S_DEC 2X
- XX
- X/* Number of breakpoints defined */X
- X#define NUMBRKPTS 10X
- XX
- X/* the global variables in an array */X
- X#define NUM_PARAM 9X
- XX
- X#define FORMATNUM 0 /* number of format entries */X
- X#define PARTSNUM 1 /* number of parts */X
- X#define VARSNUM 2 /* number of local variables */X
- X#define CPUSIZE 3 /* cpu internal memory size */X
- X#define MAINSIZE 4 /* main memory size */X
- X#define MAINBSIZE 5 /* main memory bit size */X
- X#define SUBNUM 6 /* number of subcycles */X
- X#define FETCH 7 /* mpc - start of fetch cycle */X
- X#define INTNUM 8 /* number of interrupts */X
- XX
- X/* Main Memory mask used for killing off unwanted bits */X
- X#define MEM_MASK createMask ( var_param[ 5 /* <= # is MAINBSIZE defined above */ ] )X
- XX
- X/* Types of messages for the parameters at the debug prompt */X
- X#define D_NUM 1 /* Number */X
- X#define D_STR 2 /* string */X
- X#define D_NOMORE 3 /* no more options */X
- XX
- X/* defines for debug prompt routines return codes */X
- X#define P_LEAVE 0 /* leave the program */X
- X#define P_CONT 1 /* continue in debug mode after next cmd */X
- X#define P_GOON 2 /* return and do more work */X
- XX
- X/* defines for type needed from input string */X
- X#define P_NUM 0 /* integer number */X
- X#define P_STR 1 /* string input */X
- XX
- X/* prototypes */X
- XX
- X#ifdef ANSI_CX
- X#define PROTO(x) xX
- X#elseX
- X#define PROTO(x) ()X
- X#endifX
- XX
- X/* FILE: misc.c */X
- Xint findLongSize PROTO (( void )),X
- X version PROTO (( void )),X
- X mpc PROTO (( char *, int ));X
- Xlong createMask PROTO (( long ));X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > stack.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Stack moduleX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This module deals with all access to the stack including theX
- X manipulation of variables in expressions. The computer hardware memoryX
- X program access these routines HEAVILY!X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- XX
- X#include <stdio.h>X
- X#include "main.h"X
- X#include "misc.h"X
- X#include "y.tab.h"X
- XX
- X#ifndef FALSEX
- X#define FALSE 0X
- X#define TRUE ( ! FALSE )X
- X#endifX
- XX
- X/* the variable list created by yampc */X
- Xextern struct varlist var[];X
- XX
- Xextern int var_param[];X
- Xextern int subcycles;X
- Xextern int mpcptr;X
- Xextern long *mem;X
- XX
- X/* the stack */X
- Xstatic struct s_stack {X
- X int type; /* value type on the stack */X
- X long val; /* value of the type if not a ptr */X
- X} stack[40]; /* 40 elements */X
- X X
- X/* stack pointer */X
- Xstatic int sptr = 0;X
- XX
- X/* masks needed for masking out unwanted bits */X
- X#define BIGGER_MASK ( var[ptr2->val].bmask >= var[ptr1->val].bmask ) \X
- X ? var[ptr2->val].bmask : var[ptr1->val].bmaskX
- X#define LESSER_MASK ( var[ptr2->val].bmask > var[ptr1->val].bmask ? \X
- X var[ptr1->val].bmask : var[ptr2->val].bmask )X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: push()X
- X * PURPOSE: push a value onto the stack X
- X * ARGUMENTS: type - location type of valueX
- X * value - value to place onto the stackX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xpush ( type, val )X
- X int type;X
- X long val;X
- X{X
- X switch ( type ) {X
- X case NUM:X
- X case VAR:X
- X stack[sptr].type = type;X
- X stack[sptr++].val = val;X
- X break;X
- XX
- X case MEM:X
- X stack[sptr].type = MEM;X
- X stack[sptr++].val = val & MEM_MASK;X
- X break;X
- XX
- X case SUB:X
- X push ( NUM, subcycles );X
- X break;X
- XX
- X default:X
- X fprintf ( stderr, "push: unknown operation (%d)\n", type );X
- X }X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: pop()X
- X * PURPOSE: remove the top elemnt off the stack X
- X * ARGUMENTS: noneX
- X * RETURNS: value that was removed X
- X * NOTES: if there is nothing on the stack, return zeroX
- X *X
- X ***************************************************************************/X
- XX
- XlongX
- Xpop ( ) X
- X{X
- X if ( sptr ) {X
- X if ( stack[--sptr].type == VAR ) X
- X return ( var[stack[sptr].val].val );X
- X else if ( stack[sptr].type == MEM )X
- X return ( (long) mem[stack[sptr].val] );X
- X elseX
- X return stack[sptr].val;X
- X } elseX
- X return 0L;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: do_stack()X
- X * PURPOSE: do a stack operationX
- X * ARGUMENTS: oper - operation to perform onto the stackX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xdo_stack ( oper )X
- X int oper;X
- X{X
- X struct s_stack *ptr1, *ptr2;X
- X long val1, val2;X
- X long sendmask;X
- XX
- X ptr1 = &stack[sptr-1];X
- X ptr2 = &stack[sptr-2];X
- XX
- X /* pop the used stuff */X
- X if ( oper != BNOT && oper != NOT )X
- X pop ( );X
- X pop ( );X
- X X
- X val1 = ( ptr1->type == VAR ) ? var[ptr1->val].val & X
- X var[ptr1->val].bmask : ( ptr1->type == NUM ) ? ptr1->val : mem[ptr1->val];X
- X val2 = ( ptr2->type == VAR ) ? var[ptr2->val].val & X
- X var[ptr2->val].bmask : ( ptr2->type == NUM ) ? ptr2->val : mem[ptr2->val];X
- XX
- X switch ( oper ) {X
- XX
- X case (int) '=':X
- X if ( ptr2->type == VAR ) {X
- X var[ptr2->val].val = val1 & var[ptr2->val].bmask;X
- XX
- X /* check if variable is linked */X
- X if ( var[ptr2->val].type == 1 ) {X
- X mpc ( "set", var[ptr2->val].val );X
- X mpcptr = var[ptr2->val].val;X
- X }X
- XX
- X } else if ( ptr2->type == MEM )X
- X mem[ptr2->val] = val1 & MEM_MASK;X
- X push ( NUM, val1 );X
- X break;X
- XX
- X case AND:X
- X if ( val1 > 0 ) val1 = TRUE;X
- X if ( val2 > 0 ) val2 = TRUE;X
- X /* Note: no break */X
- X case BAND:X
- X push ( NUM, val1 & val2 ); X
- X break;X
- XX
- X case OR:X
- X if ( val1 > 0 ) val1 = TRUE;X
- X if ( val2 > 0 ) val2 = TRUE;X
- X case BOR: X
- X push ( NUM, val1 | val2 ); X
- X break;X
- XX
- X case EOR:X
- X push ( NUM, val1 ^ val2 );X
- X break;X
- X X
- X case NOT:X
- X if ( val1 > 0 ) val1 = FALSE;X
- X else val1 = TRUE;X
- X push ( NUM, val1 );X
- X break;X
- XX
- X case BNOT:X
- X push ( NUM, ~ val1 );X
- X break;X
- XX
- X case SR:X
- X case SL:X
- X case (int) '+':X
- X case (int) '-':X
- X case (int) '/':X
- X case (int) '%':X
- X case (int) '*':X
- X push ( NUM, s_math ( oper, val1, val2 ) ); X
- X break;X
- XX
- X case EQ:X
- X push ( NUM, ( val1 == val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X case NE:X
- X push ( NUM, ( val1 != val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X case GT:X
- X push ( NUM, ( val1 < val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X case GE:X
- X push ( NUM, ( val1 <= val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X case LT:X
- X push ( NUM, ( val1 > val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X case LE:X
- X push ( NUM, ( val1 >= val2 ) ? TRUE : FALSE ); X
- X break;X
- XX
- X default:X
- X fprintf ( stderr, "Invalid stack operation\n" );X
- X }X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: s_math()X
- X * PURPOSE: perform a variety of operations X
- X * ARGUMENTS: oper - operation to performX
- X * val1, val2 - variables to perform operationX
- X * RETURNS: completed operation value X
- X * NOTES: noneX
- X *X
- X ***************************************************************************/X
- XX
- XlongX
- Xs_math ( oper, val1, val2 )X
- X int oper;X
- X long val1, val2;X
- X{X
- X X
- X /* for each entry, do the correct operation */X
- X switch ( oper ) {X
- X case SR: /* Shift Right */X
- X return val2 >> val1;X
- XX
- X case SL: /* Shift Left */X
- X return val2 << val1;X
- XX
- X case (int) '+': /* Addition */X
- X return val2 + val1;X
- XX
- X case (int) '/': /* Division */X
- X return val2 / val1;X
- XX
- X case (int) '%': /* Modulo */X
- X return val2 % val1;X
- XX
- X case (int) '-': /* Subtraction */X
- X return val2 - val1;X
- XX
- X case (int) '*': /* Multiplication */X
- X return val2 * val1;X
- XX
- X default: /* Fall through */X
- X return FALSE;X
- X }X
- XX
- X}X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > y_misc.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X ***************************************************************************X
- XX
- X PROGRAM NAME: Computer Hardware Compilation RoutinesX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X These are miscellaneous routines used when compiling the computerX
- X hardware description file.X
- X X
- X ***************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X ***************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X *************************************************************************** X
- X\* ----------------------------------------------------------------------- */X
- XX
- XX
- X#include <stdio.h>X
- X#include <time.h>X
- X#include "yampc.h"X
- X#include "misc.h"X
- XX
- Xextern FILE *fph; /* file pointer */X
- Xextern int var_param[]; /* variable parameters */X
- Xextern struct s_var *localvar; /* variable list */X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: start_hw()X
- X * PURPOSE: the first data placed into the compiled hardware fileX
- X * ARGUMENTS: filexe - name of the YAMPC executable on cmd lineX
- X * RETURNS: nothing X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xstart_hw ( filexe )X
- X char *filexe;X
- X{X
- X long currtime, time ( ); /* current time */X
- X char *cptr, *ctime ( );X
- XX
- X /* get the title info */X
- X currtime = time ( 0L );X
- X cptr = ctime ( &currtime );X
- X cptr[strlen ( cptr )-1] = '\0';X
- XX
- X /* print the title info */X
- X fprintf ( fph, "\n/* Created on %s by %s, version %s */\n\n", cptr,X
- X filexe, VERSION );X
- XX
- X /* the necessary defines */X
- X fprintf ( fph, "#define OK 0\n" );X
- X fprintf ( fph, "#define BAD 1\n\n" );X
- XX
- X /* function declarations */X
- X fprintf ( fph, "void push ( ), do_stack ( );\n" );X
- X fprintf ( fph, "long pop ( );\n\n" );X
- XX
- X /* set the current number of subcyles to 4 */X
- X var_param[SUBNUM] = 4;X
- XX
- X /* set the current mpc fetch */X
- X var_param[FETCH] = 8;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: end_struct()X
- X * PURPOSE: end a structure in the compiled hardware fileX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xend_struct ( )X
- X{X
- X fprintf ( fph, "\n};\n\n" );X
- X}X
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: end_func()X
- X * PURPOSE: end a routine in the compiled hardware fileX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xend_func ( )X
- X{X
- X fprintf ( fph, " return OK;\n}\n\n" );X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: put_msg()X
- X * PURPOSE: place a message into the compiled hardware file X
- X * ARGUMENTS: msg - message to place into fileX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xput_msg ( msg )X
- X char *msg; /* msg to place into hw.c */X
- X{X
- X fprintf ( fph, "%s\n", msg );X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: init_var()X
- X * PURPOSE: set up the variable list in the compiled hardware file X
- X * ARGUMENTS: noneX
- X * RETURNS: noneX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xinit_var ( )X
- X{X
- X var_param[FORMATNUM] = 0;X
- X var_param[PARTSNUM] = 0;X
- X var_param[VARSNUM] = 0;X
- X fprintf ( fph, "struct varlist {\n" );X
- X fprintf ( fph, " char name[80];\n" );X
- X fprintf ( fph, " long bmask;\n" );X
- X fprintf ( fph, " int type;\n" );X
- X fprintf ( fph, " long val;\n" );X
- X fprintf ( fph, "} var[] = {\n" );X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: add_var()X
- X * PURPOSE: add a variable to the variable listX
- X * ARGUMENTS: s - variable nameX
- X * len - check bit lengthX
- X * value - start valueX
- X * type - TRUE/FALSE on whether it is a mpc pointer variableX
- X * RETURNS: noneX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xadd_var ( s, len, value, type )X
- X char *s;X
- X int len;X
- X int value;X
- X int type;X
- X{X
- X static int count = 0;X
- X long createMask ( ); /* create a bit mask */X
- XX
- X /* add the variable to the list if not defined */X
- X if ( addLocalVar ( s, var_param[FORMATNUM] + var_param[PARTSNUM] + X
- X var_param[VARSNUM] ) == BAD )X
- X return;X
- XX
- X /* check the bit length, can't be greater than sizeof (long) */X
- X if ( len > findLongSize ( ) ) {X
- X char temp[50];X
- X sprintf ( temp, "Size of variables can't be larger than %d", X
- X ( len = findLongSize( ) ) );X
- X warning ( temp, (char *) 0 );X
- X }X
- XX
- X var_param[value]++;X
- X if ( count ) X
- X fprintf ( fph, ",\n" );X
- X elseX
- X count++;X
- XX
- X fprintf ( fph, " \"%s\", %dL, %d, 0L", s, createMask ( len ),X
- X type );X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: start_init()X
- X * PURPOSE: start compiling the initialization routineX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xstart_init ( )X
- X{X
- X int temp = 0;X
- XX
- X /* build the init function */X
- X fprintf ( fph, "int init ( var_param )\n" );X
- X fprintf ( fph, "int * var_param;\n{\n" );X
- XX
- X while ( temp++ < NUM_PARAM )X
- X fprintf ( fph, " var_param[%d] = %d;\n", temp-1, var_param[temp-1] );X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: addLocalVar()X
- X * PURPOSE: add a local variable to the variable listX
- X * ARGUMENTS: name - variable nameX
- X * value - variable valueX
- X * RETURNS: OK - variable addedX
- X * BAD - variable already existsX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XaddLocalVar ( name, value )X
- X char *name;X
- X int value;X
- X{X
- X struct s_var *temp, *temp1, *temp2;X
- X char *malloc ( );X
- XX
- X /* set up the structure */X
- X if ( ( temp = (struct s_var *) malloc ( sizeof (struct s_var) ) ) == NULL) {X
- X fprintf ( stderr, "Memory problems, Panic!\n" );X
- X exit ( 1 );X
- X }X
- X strcpy ( temp->str, name );X
- X temp->val = value;X
- X temp->next = NULL;X
- XX
- X temp1 = NULL;X
- XX
- X /* empty queue */X
- X if ( localvar == NULL ) {X
- X localvar = temp;X
- X return OK;X
- X }X
- XX
- X /* see if there exists one */X
- X do {X
- X if ( temp1 == NULL )X
- X temp1 = localvar ; X
- X else {X
- X temp2 = temp1->next;X
- X temp1 = temp2;X
- X }X
- XX
- X if ( !strcmp ( name, temp1->str ) ) {X
- X warning ( "Duplicate variable names", (char *) 0 );X
- X return BAD;X
- X }X
- X } while ( temp1->next != NULL );X
- XX
- X temp1->next = temp;X
- XX
- X return OK;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: queryLocalVar()X
- X * PURPOSE: return the current value of a local variableX
- X * ARGUMENTS: name - variable nameX
- X * RETURNS: variable value, -1 if not definedX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XqueryLocalVar ( name )X
- X char *name;X
- X{X
- X struct s_var *temp;X
- XX
- X temp = localvar;X
- XX
- X while ( temp != NULL ) {X
- X if ( ! strcmp ( name, temp->str ) ) X
- X return temp->val;X
- X temp = temp->next;X
- X }X
- XX
- X /* no entry */X
- X warning ( "Undeclared variable", name ); X
- X return -1;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: set_mem()X
- X * PURPOSE: set the memory sizes for the micro code, and mainX
- X * ARGUMENTS: cval - cpu size for microcodeX
- X * mval1 - main memory sizeX
- X * mval2 - main memory bit sizeX
- X * RETURNS: noneX
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xset_mem ( cval, mval1, mval2 )X
- X int cval, mval1, mval2;X
- X{X
- X char buffer[80];X
- XX
- X if ( mval2 > findLongSize ( ) ) {X
- X sprintf ( buffer, "Memory bit size too large, truncating to %d",X
- X findLongSize ( ) );X
- X warning ( buffer, (char *) 0 );X
- X mval2 = findLongSize ( );X
- X }X
- XX
- X var_param[CPUSIZE] = cval;X
- X var_param[MAINSIZE] = mval1;X
- X var_param[MAINBSIZE] = mval2;X
- X}X
- XX
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: set_entry()X
- X * PURPOSE: set an internal variable to a certain variableX
- X * ARGUMENTS: which - which variableX
- X * val - value to set variable toX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xset_entry ( which, val )X
- X int which, val;X
- X{X
- X var_param[which] = val;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: start_engine()X
- X * PURPOSE: start the engine routine X
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xstart_engine ( )X
- X{X
- X fprintf ( fph, "\nint engine ( subcycle )\n" );X
- X fprintf ( fph, " int subcycle;\n" );X
- X fprintf ( fph, "{\n" );X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: end_engine()X
- X * PURPOSE: end the engine routineX
- X * ARGUMENTS: noneX
- X * RETURNS: none X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- XVOIDX
- Xend_engine ( )X
- X{X
- X fprintf ( fph, " return mpc ( \"query\", 0 );\n" );X
- X fprintf ( fph, "}\n\n" );X
- X}X
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > yampc.c
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Computer Hardware Main moduleX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This is the main module when compiling the computer hardwareX
- X description file.X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- X#include <stdio.h>X
- X#include <time.h>X
- X#include "yampc.h"X
- X#include "misc.h"X
- XX
- X/* file descriptors for the files creating */X
- XFILE *fph; /* hardware_file file pointer */X
- XX
- X/* the local variables list */X
- Xstruct s_var *localvar;X
- XX
- X/* variable parameter list (global) */X
- Xint var_param[NUM_PARAM];X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: main()X
- X * PURPOSE: set up system to compile the hardware spec file X
- X * ARGUMENTS: argc - number of command line argumentsX
- X * argv - argument listX
- X * RETURNS: nothing interesting X
- X * NOTES: X
- X *X
- X ***************************************************************************/X
- XX
- Xmain ( argc, argv )X
- X int argc; /* argument counter */X
- X char *argv[]; /* arguments */X
- X{X
- X char filename[128]; /* filename for extentions */X
- X FILE *fp, *fopen ( ); /* hardware file */X
- XX
- X /* display the version of this system */X
- X version ( );X
- XX
- X /* no entries in the variable list */X
- X localvar = NULL;X
- XX
- X /* only requires 1 argument */X
- X if ( argc != 2 ) {X
- X printf ( "usage: %s <hardware file>\n", argv[0] );X
- X exit ( 1 );X
- X }X
- XX
- X /* check the file */X
- X if ( ( fp = fopen ( argv[1], "r" ) ) == NULL ) {X
- X printf ( "%s: unable to open %s\n", argv[0], argv[1] );X
- X exit ( 1 );X
- X }X
- XX
- X /* create the output file */X
- X sprintf ( filename, "%s.c", argv[1] );X
- X if ( ( fph = fopen ( filename, "w" ) ) == NULL ) {X
- X printf ( "%s: unable to open %s\n", argv[0], filename );X
- X exit ( 1 );X
- X }X
- XX
- X /* write the needed information in the filename.c */X
- X start_hw ( argv[0] );X
- XX
- X /* set the input file descriptor */X
- X setInput ( fp );X
- XX
- X /* do it */ X
- X yyparse ( );X
- XX
- X /* close the files */X
- X fclose ( fph );X
- X fclose ( fp );X
- XX
- X /* return no error */X
- X return 0;X
- X}X
- XX
- XX
- X/****************************************************************************X
- X *X
- X * FUNCTION: convStr()X
- X * PURPOSE: convert a string to a numberX
- X * ARGUMENTS: str - string containing the numberX
- X * type - type of number within the stringX
- X * RETURNS: the converted numberX
- X * NOTES: supports hex, decimal and octalX
- X *X
- X ***************************************************************************/X
- XX
- XintX
- XconvStr ( str, type )X
- X char *str; /* string to convert */X
- X int type; /* type of number */X
- X{X
- X int val; /* value to rebuild */X
- X int num = 0; /* number being converted */X
- XX
- X switch ( type ) {X
- X case DEC:X
- X val = 10;X
- X break;X
- X case OCT:X
- X val = 8;X
- X break;X
- X case HEX:X
- X val = 16;X
- X break;X
- X default:X
- X return 0;X
- X }X
- XX
- X /* do the conversion */X
- X while ( *str ) {X
- X if ( type == HEX && *str >= 'a' && *str <= 'f' ) X
- X num = ( num * val ) + ( *str++ - 'a' + 10 );X
- X else if ( type == HEX && *str >= 'A' && *str <= 'F' )X
- X num = ( num * val ) + ( *str++ - 'A' + 10 );X
- X elseX
- X num = ( num * val ) + ( *str++ - '0' );X
- X }X
- XX
- X /* return the number value in decimal */X
- X return num;X
- X}X
- XX
- XX
- Zaphod for prez
- cat << 'Zaphod for prez' | sed 's/X\(.*\)X/\1/' > yampc.h
- XX
- XX
- X/* ----------------------------------------------------------------------- *\X
- X******************************************************************************X
- XX
- X PROGRAM NAME: Computer Hardware Main module Header FileX
- XX
- X PROGRAMMER: Patrick Palmer DATE: 8/17/90 X
- X X
- X DESCRIPTION OF PROGRAM: X
- X This is the header file for the YAMPC compiler.X
- X X
- X******************************************************************************X
- XX
- X This program is free software; you can redistribute it and/orX
- X modify it under the terms of the GNU General Public LicenseX
- X (version 2) as published by the Free Software Foundation.X
- XX
- X This program is distributed in the hope that is will be useful,X
- X but WITHOUT ANY WARRANTY; without even the implied warrenty ofX
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theX
- X GNU General Public License for more details.X
- X X
- X You should have received a copy of the GNU General Public X
- X License along with this program; if not, write to the FreeX
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MAX
- X 02139, USA.X
- XX
- X YAMPC Microcode Development KitX
- X (C) 1992 by Patrick PalmerX
- XX
- X******************************************************************************X
- XX
- XX
- X PROGRAM REVISION LOGX
- X X
- X DATE DESCRIPTION OF CHANGE PROGRAMMERX
- X -------- ---------------------------------------------- ----------X
- X 08/17/90 YAMPC - Version 1.0 PAPX
- X 11/17/90 Interrupts, Bug Fixes - Version 1.1 PAPX
- X 01/11/92 Distribution version - Version 1.2 PAPX
- XX
- X*************************************************************************** X
- X\* ------------------------------------------------------------------------ */X
- XX
- Xtypedef int VOID;X
- XX
- X/* YACC stack type */X
- Xstruct ystack {X
- X int val; /* value of a number */X
- X char str[100];X
- X};X
- XX
- X/* variables structure */X
- Xstruct s_var {X
- X char str[200];X
- X int val;X
- X struct s_var *next;X
- X};X
- XX
- X/* types of numbers */X
- X#define HEX 1X
- X#define DEC 2X
- X#define OCT 3X
- XX
- XX
- X/* prototypes */X
- XX
- X#ifdef ANSI_CX
- X#define PROTO(x) xX
- X#elseX
- X#define PROTO(x) ()X
- X#endifX
- XX
- X/* FILE: lalr.y */X
- Xint yyerror PROTO (( char * )),X
- X warning PROTO (( char *, char * ));X
- XX
- X/* FILE: lex.l */X
- Xint yywrap PROTO (( void )),X
- X setInput PROTO (( FILE * ));X
- XX
- X/* FILE: yampc.c */X
- Xint main PROTO (( int, char ** )),X
- X convStr PROTO (( char *, int ));X
- XX
- X/* FILE: y_misc.c */X
- XVOID start_hw PROTO (( char * )),X
- X end_struct PROTO (( void )),X
- X end_func PROTO (( void )),X
- X put_msg PROTO (( char * )),X
- X init_var PROTO (( void )),X
- X add_var PROTO (( char *, int, int, int )),X
- X start_init PROTO (( void )),X
- X set_mem PROTO (( int, int, int )),X
- X set_entry PROTO (( int, int )),X
- X start_engine PROTO (( void )),X
- X end_engine PROTO (( void ));X
- Xint addLocalVar PROTO (( char *, int )),X
- X queryLocalVar PROTO (( char * ));X
- XX
- XX
- XX
- Zaphod for prez
- exit 0
-