1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2025-04-21 09:38:12 +00:00

Replaced variables def??? with con???

This commit is contained in:
Curtis F Kaylor 2018-03-07 12:32:08 -05:00
parent 1c4c2b4696
commit df34d89252
7 changed files with 26 additions and 26 deletions

View File

@ -28,7 +28,7 @@
/* Initilize Compiler Variables */
void init(void) {
DEBUG("Initializing Compiler Variables\n",0)
defcnt = 0;
concnt = 0;
varcnt = 0;
lblcnt = 0;
curcol = 0;
@ -172,7 +172,7 @@ int main(int argc, char *argv[]) {
compile();
logdef();
logcon();
clssrc(); //Close Source File
clsout(); //Close Output File

View File

@ -4,8 +4,8 @@
#define FNAMLEN 255 //Maximum File Name Length
#define LINELEN 255 //Maximum Input/Output Line Length
#define DEFLEN 6 //Maximum Definition Text Length
#define MAXDEF 255 //Maximum Number of Definitions
#define CONLEN 6 //Maximum Definition Text Length
#define MAXCON 255 //Maximum Number of Definitions
#define VARLEN 6 //Maximum Variable Length
#define MAXVAR 255 //Maximum Number of Variables
#define MAXFNS 16 //Maximum Functions in Stack

View File

@ -58,10 +58,10 @@ void pconst(int m) {
expect('#'); //Require # prefix
getwrd(); //Get constant name
DEBUG("Defining constant '%s',", word)
strncpy(defnam[defcnt], word, VARLEN);
strncpy(connam[concnt], word, VARLEN);
setlbl(word); //Set label Assembler Line
expect('=');
defval[defcnt++] = prsbyt(); //Get Value
conval[concnt++] = prsbyt(); //Get Value
ACMNT(word); //comment value
asmlin(EQUOP, value); //Write Definition
DETAIL(" defined as '%s'\n", value)
@ -79,9 +79,9 @@ void penum(int m) {
do {
getwrd(); //get defined identifier
DEBUG("Enumerating '%s'\n", word)
strncpy(defnam[defcnt], word, VARLEN);
strncpy(connam[concnt], word, VARLEN);
setlbl(word); //Set label Assembler Line
defval[defcnt++] = enmval; //Set Value
conval[concnt++] = enmval; //Set Value
sprintf(value, "%d", enmval);
asmlin(EQUOP, value); //Write Definition
DEBUG("Defined as '%s'\n", value)

View File

@ -227,12 +227,12 @@ void pincfl(void) {
}
}
/* Print Definition Table to Log File */
void logdef(void) {
/* Print Constant Table to Log File */
void logcon(void) {
int i;
fprintf(logfil, "\n%-31s %5s\n", "Definition", "Value");
for (i=0; i<defcnt; i++)
for (i=0; i<concnt; i++)
{
fprintf(logfil, "%-31s %5d\n", defnam[i], defval[i]);
fprintf(logfil, "%-31s %5d\n", connam[i], conval[i]);
}
}

View File

@ -4,7 +4,7 @@
char line[255]; /*Entire line parsed from include file*/
void logdef(); //Print Definition Table to Log File
void logcon(); //Print Constant Table to Log File
void pdefin(); //Process define directive
void pdefin(); //Process define directive
void penumd(); //Process enum directive

View File

@ -282,19 +282,19 @@ int prsbyt(void) {return prsnum(0xFF);}
/* Find Defined Constant */
void fnddef(char *name) {
DEBUG("Looking up defined constant '%s'\n", word)
for (defidx=0; defidx<defcnt; defidx++)
if (strcmp(defnam[defidx], name) == 0) return;
defidx = -1;
for (conidx=0; conidx<concnt; conidx++)
if (strcmp(connam[conidx], name) == 0) return;
conidx = -1;
}
/* Parse Definition */
int prsdef(void) {
/* Parse Constant */
int prscon(void) {
expect('#');
getwrd(); //Get Constant Name
fnddef(word);
if (defidx < 0) ERROR("Undefined constant '%s'\n", word, EXIT_FAILURE)
if (conidx < 0) ERROR("Undefined constant '%s'\n", word, EXIT_FAILURE)
strcpy(value, word);
return defval[defidx];
return conval[conidx];
}
/* Parse numeric literal *
@ -308,8 +308,8 @@ int prsdef(void) {
* character arguments instead of 'c' */
void prslit(void) {
skpspc();
if (ishash()) litval = prsdef();
else litval = prsbyt();
if (ishash()) litval = prscon(); //Parse Constant
else litval = prsbyt(); //Parse Byte Value
valtyp = LITERAL;
strcpy(word, value); //Patch for DASM
strcpy(value, "#");

View File

@ -14,10 +14,10 @@ int valtyp; //Value Type
char oper; //Arithmetic or Bitwise Operator
int litval; //Value of Parsed Literal
char defnam[MAXDEF+1][VARLEN+1]; //Definition Name Table
int defval[MAXDEF+1]; //Definition Value Table
int defcnt; //Number of Definitions Defined
int defidx; //Index into Definition Tables
char connam[MAXCON+1][CONLEN+1]; //Definition Name Table
int conval[MAXCON+1]; //Definition Value Table
int concnt; //Number of Definitions Defined
int conidx; //Index into Definition Tables
int invasc; //Invert ASCII Flag
int mskasc; //Set High Bit Flag