From 9daca8967b015be04d90a608c7eebb9f3b1dd723 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sat, 18 Dec 2021 19:28:47 -0500 Subject: [PATCH] Added function names to DEBUG, cleaned prslit() calls --- doc/{ => include}/args.txt | 0 doc/{ => include}/bitlib.txt | 0 doc/{ => include}/block.txt | 0 doc/{ => include}/color.txt | 0 doc/{ => include}/ctype.txt | 0 doc/{ => include}/direct.txt | 0 doc/{ => include}/dirent.txt | 0 doc/{ => include}/fileio.txt | 0 doc/{ => include}/func-idx.txt | 0 doc/{ => include}/header.txt | 0 doc/{ => include}/intlib.txt | 0 doc/{ => include}/joystk.txt | 0 doc/{ => include}/keydef.txt | 0 doc/{ => include}/lgtpen.txt | 0 doc/{ => include}/memio.txt | 0 doc/{ => include}/memory.txt | 0 doc/{ => include}/mouse.txt | 0 doc/{ => include}/paddle.txt | 0 doc/{ => include}/pointer.txt | 0 doc/{ => include}/screen.txt | 0 doc/{ => include}/stack.txt | 0 doc/{ => include}/stackx.txt | 0 doc/{ => include}/stddef.txt | 0 doc/{ => include}/stdio.txt | 0 doc/{ => include}/stdiox.txt | 0 doc/{ => include}/stdlib.txt | 0 doc/{ => include}/string.txt | 0 doc/{ => include}/stringl.txt | 0 doc/{ => include}/stringm.txt | 0 doc/{ => include}/stringx.txt | 0 doc/{ => include}/syntax.bnf | 0 doc/{ => include}/test.txt | 0 doc/{ => include}/util.txt | 0 doc/{ => include}/xmemory.txt | 0 src/cond.c | 24 +++++++++++------------ src/dclrtn.c | 26 ++++++++++++------------ src/files.c | 20 +++++++++---------- src/include.c | 36 +++++++++++++++++----------------- src/stmnt.c | 7 +++++-- src/stmnt.h | 1 + src/vars.c | 28 ++++++++++++++------------ 41 files changed, 74 insertions(+), 68 deletions(-) rename doc/{ => include}/args.txt (100%) rename doc/{ => include}/bitlib.txt (100%) rename doc/{ => include}/block.txt (100%) rename doc/{ => include}/color.txt (100%) rename doc/{ => include}/ctype.txt (100%) rename doc/{ => include}/direct.txt (100%) rename doc/{ => include}/dirent.txt (100%) rename doc/{ => include}/fileio.txt (100%) rename doc/{ => include}/func-idx.txt (100%) rename doc/{ => include}/header.txt (100%) rename doc/{ => include}/intlib.txt (100%) rename doc/{ => include}/joystk.txt (100%) rename doc/{ => include}/keydef.txt (100%) rename doc/{ => include}/lgtpen.txt (100%) rename doc/{ => include}/memio.txt (100%) rename doc/{ => include}/memory.txt (100%) rename doc/{ => include}/mouse.txt (100%) rename doc/{ => include}/paddle.txt (100%) rename doc/{ => include}/pointer.txt (100%) rename doc/{ => include}/screen.txt (100%) rename doc/{ => include}/stack.txt (100%) rename doc/{ => include}/stackx.txt (100%) rename doc/{ => include}/stddef.txt (100%) rename doc/{ => include}/stdio.txt (100%) rename doc/{ => include}/stdiox.txt (100%) rename doc/{ => include}/stdlib.txt (100%) rename doc/{ => include}/string.txt (100%) rename doc/{ => include}/stringl.txt (100%) rename doc/{ => include}/stringm.txt (100%) rename doc/{ => include}/stringx.txt (100%) rename doc/{ => include}/syntax.bnf (100%) rename doc/{ => include}/test.txt (100%) rename doc/{ => include}/util.txt (100%) rename doc/{ => include}/xmemory.txt (100%) diff --git a/doc/args.txt b/doc/include/args.txt similarity index 100% rename from doc/args.txt rename to doc/include/args.txt diff --git a/doc/bitlib.txt b/doc/include/bitlib.txt similarity index 100% rename from doc/bitlib.txt rename to doc/include/bitlib.txt diff --git a/doc/block.txt b/doc/include/block.txt similarity index 100% rename from doc/block.txt rename to doc/include/block.txt diff --git a/doc/color.txt b/doc/include/color.txt similarity index 100% rename from doc/color.txt rename to doc/include/color.txt diff --git a/doc/ctype.txt b/doc/include/ctype.txt similarity index 100% rename from doc/ctype.txt rename to doc/include/ctype.txt diff --git a/doc/direct.txt b/doc/include/direct.txt similarity index 100% rename from doc/direct.txt rename to doc/include/direct.txt diff --git a/doc/dirent.txt b/doc/include/dirent.txt similarity index 100% rename from doc/dirent.txt rename to doc/include/dirent.txt diff --git a/doc/fileio.txt b/doc/include/fileio.txt similarity index 100% rename from doc/fileio.txt rename to doc/include/fileio.txt diff --git a/doc/func-idx.txt b/doc/include/func-idx.txt similarity index 100% rename from doc/func-idx.txt rename to doc/include/func-idx.txt diff --git a/doc/header.txt b/doc/include/header.txt similarity index 100% rename from doc/header.txt rename to doc/include/header.txt diff --git a/doc/intlib.txt b/doc/include/intlib.txt similarity index 100% rename from doc/intlib.txt rename to doc/include/intlib.txt diff --git a/doc/joystk.txt b/doc/include/joystk.txt similarity index 100% rename from doc/joystk.txt rename to doc/include/joystk.txt diff --git a/doc/keydef.txt b/doc/include/keydef.txt similarity index 100% rename from doc/keydef.txt rename to doc/include/keydef.txt diff --git a/doc/lgtpen.txt b/doc/include/lgtpen.txt similarity index 100% rename from doc/lgtpen.txt rename to doc/include/lgtpen.txt diff --git a/doc/memio.txt b/doc/include/memio.txt similarity index 100% rename from doc/memio.txt rename to doc/include/memio.txt diff --git a/doc/memory.txt b/doc/include/memory.txt similarity index 100% rename from doc/memory.txt rename to doc/include/memory.txt diff --git a/doc/mouse.txt b/doc/include/mouse.txt similarity index 100% rename from doc/mouse.txt rename to doc/include/mouse.txt diff --git a/doc/paddle.txt b/doc/include/paddle.txt similarity index 100% rename from doc/paddle.txt rename to doc/include/paddle.txt diff --git a/doc/pointer.txt b/doc/include/pointer.txt similarity index 100% rename from doc/pointer.txt rename to doc/include/pointer.txt diff --git a/doc/screen.txt b/doc/include/screen.txt similarity index 100% rename from doc/screen.txt rename to doc/include/screen.txt diff --git a/doc/stack.txt b/doc/include/stack.txt similarity index 100% rename from doc/stack.txt rename to doc/include/stack.txt diff --git a/doc/stackx.txt b/doc/include/stackx.txt similarity index 100% rename from doc/stackx.txt rename to doc/include/stackx.txt diff --git a/doc/stddef.txt b/doc/include/stddef.txt similarity index 100% rename from doc/stddef.txt rename to doc/include/stddef.txt diff --git a/doc/stdio.txt b/doc/include/stdio.txt similarity index 100% rename from doc/stdio.txt rename to doc/include/stdio.txt diff --git a/doc/stdiox.txt b/doc/include/stdiox.txt similarity index 100% rename from doc/stdiox.txt rename to doc/include/stdiox.txt diff --git a/doc/stdlib.txt b/doc/include/stdlib.txt similarity index 100% rename from doc/stdlib.txt rename to doc/include/stdlib.txt diff --git a/doc/string.txt b/doc/include/string.txt similarity index 100% rename from doc/string.txt rename to doc/include/string.txt diff --git a/doc/stringl.txt b/doc/include/stringl.txt similarity index 100% rename from doc/stringl.txt rename to doc/include/stringl.txt diff --git a/doc/stringm.txt b/doc/include/stringm.txt similarity index 100% rename from doc/stringm.txt rename to doc/include/stringm.txt diff --git a/doc/stringx.txt b/doc/include/stringx.txt similarity index 100% rename from doc/stringx.txt rename to doc/include/stringx.txt diff --git a/doc/syntax.bnf b/doc/include/syntax.bnf similarity index 100% rename from doc/syntax.bnf rename to doc/include/syntax.bnf diff --git a/doc/test.txt b/doc/include/test.txt similarity index 100% rename from doc/test.txt rename to doc/include/test.txt diff --git a/doc/util.txt b/doc/include/util.txt similarity index 100% rename from doc/util.txt rename to doc/include/util.txt diff --git a/doc/xmemory.txt b/doc/include/xmemory.txt similarity index 100% rename from doc/xmemory.txt rename to doc/include/xmemory.txt diff --git a/src/cond.c b/src/cond.c index 7a831b5..c5e4754 100644 --- a/src/cond.c +++ b/src/cond.c @@ -22,7 +22,7 @@ int cmpenc; //Encoded Comparator Character * Returns: Comparison Operator Bit Mask */ int enccmp(char c) { int e; - DEBUG("Encoding Comparison Character '%c'", c) + DEBUG("cond.enccm: Encoding Comparison Character '%c'", c) switch(c) { case '=': e = 1; break; case '<': e = 2; break; @@ -39,7 +39,7 @@ int enccmp(char c) { * Uses: term - Term Being Compared Against * * label - Branch Target if Comparison is FALSE */ void prccmp(void) { - DEBUG("Processing comparator %d", cmprtr) DETAIL(" with REVCMP=%d\n", revcmp) + DEBUG("cond.prccmp: Processing comparator %d", cmprtr) DETAIL(" with REVCMP=%d\n", revcmp) if (cmprtr > 7) { //Process Flag cmprtr = (cmprtr ^ revcmp) & 1; //Apply Reversal if (cmprtr) asmlin("BPL", cmplbl); @@ -81,12 +81,12 @@ void prscmp(int revrse) { skpspc(); if (cmprtr) prstrm(FALSE, TRUE); //prccmp(); - Do after check for logical operator - DEBUG("Parsed comparator %d\n", cmprtr) + DEBUG("cond.prscmp: Parsed comparator %d\n", cmprtr) } /* Parse Flag Operator */ void prsflg(int revrse) { - DEBUG("Parsing Flag Operator '%c'\n", nxtchr) + DEBUG("cond.prsflg: Parsing Flag Operator '%c'\n", nxtchr) if (match('+')) cmprtr = 8; //Bit 0 = 0 else if (match('-')) cmprtr = 9; //Bit 1 = 1 else expctd("Flag operator"); @@ -96,40 +96,40 @@ void prsflg(int revrse) { /* Parse Logical Operator * * Sets: logops */ void prslop(void) { - DEBUG("Checking for Logical Operator\n", 0) + DEBUG("cond.prslop: Checking for Logical Operator\n", 0) logopr = LOPNONE; skpspc(); if (isalph()) { getwrd(); //Get Logical Operator - DEBUG("Parsing Logical Operator %s\n", word) + DEBUG("cond.prslop: Parsing Logical Operator %s\n", word) if (wordis("AND")) logopr = LOPAND; else if (wordis("OR")) logopr = LOPOR; else ERROR("Encountered invalid token \"%s\"\n", word, EXIT_FAILURE) } - DEBUG("Set LOGOPR to %d\n", logopr) + DEBUG("cond.prslop: Set LOGOPR to %d\n", logopr) } /* Parse and Compile Conditional Expression * * Condition = */ void prscnd(char trmntr, int revrse) { - DEBUG("Parsing condition with REVRSE=%d\n", revrse) + DEBUG("cond.prscnd: Parsing condition with REVRSE=%d\n", revrse) tmplbl[0] = 0; do { - strcpy(cmplbl, cndlbl); DEBUG("Set CMPLBL to \"%s\"\n", cmplbl); + strcpy(cmplbl, cndlbl); DEBUG("cond.prscnd: Set CMPLBL to \"%s\"\n", cmplbl); revcmp = revrse; if (look('!')) revcmp = (revcmp) ? FALSE: TRUE; - DEBUG("Set REVCMP to %d\n", revcmp) + DEBUG("cond.prscnd: Set REVCMP to %d\n", revcmp) if (!look('.')) prsxpr(0); if (look(':')) prsflg(revcmp); //Parse Flag Operator else prscmp(revcmp); //Parse Comparison Operator prslop(); //Parse Logical Operator if (logopr == LOPOR) { revcmp = (revcmp) ? FALSE: TRUE; - DEBUG("Set REVCMP to %d\n", revcmp) + DEBUG("cond.prscnd: Set REVCMP to %d\n", revcmp) } if (logopr && revcmp) { if (!tmplbl[0]) newlbl(tmplbl); - strcpy(cmplbl, tmplbl); DEBUG("Set CMPLBL to \"%s\"\n", cmplbl); + strcpy(cmplbl, tmplbl); DEBUG("cond.prscnd: Set CMPLBL to \"%s\"\n", cmplbl); } prccmp(); //Process Comparison/Flag Operator } while (logopr); diff --git a/src/dclrtn.c b/src/dclrtn.c index 5b54d83..d90a3a5 100644 --- a/src/dclrtn.c +++ b/src/dclrtn.c @@ -51,7 +51,7 @@ void addfnc(void) { expect(')'); if (look(';')) return; //Forward Definition infunc = TRUE; //Set Inside Function Definition Flag - DEBUG("Set infunc to %d\n", infunc) + DEBUG("dclrtn.addfnc: Set infunc to %d\n", infunc) setlbl(fncnam); //Set Function Entry Point asmlin(LOCOP, ""); //Set Local Variables Boundary if (prmtra[0]) asmlin("STA", prmtra); //Store First Parameter @@ -72,7 +72,7 @@ void addcon(int numval) { if (alcvar) setlbl(defnam); //Set label Assembler Line conval[concnt++] = numval; //Get Value if (alcvar) asmlin(EQUOP, value); //Write Definition - DEBUG("Defined constant '%s'", defnam) + DEBUG("dclrtn.addcon: Defined constant '%s'", defnam) DETAIL(" as '%s'\n", value) if (!alcvar) SCMNT(""); //Clear Comment } @@ -81,17 +81,17 @@ void addcon(int numval) { */ void penum(int m, int bitmsk) { int enmval = (bitmsk) ? 1 : 0; - DEBUG("Processing Enum Declarations with BITMSK %d\n", bitmsk) + DEBUG("dclrtn.enum: Processing Enum Declarations with BITMSK %d\n", bitmsk) if (m != MTNONE) ERROR("Illegal Modifier %d in Enum Definition", m, EXIT_FAILURE) expect('{'); do { if (enmval > 0xFF) ERROR("Maximum ENUM or BITMASK value exceeded\n", 0, EXIT_FAILURE) if (look('.')) - DEBUG("Skipping sequence %d\n", enmval) + DEBUG("dclrtn.penum: Skipping sequence %d\n", enmval) else { getwrd(); //get defined identifier - DEBUG("Enumerating '%s'", word) - DEBUG(" as %d\n", enmval); + DEBUG("dclrtn.penum: Enumerating '%s'", word) + DEBUG("dclrtn.penum: as %d\n", enmval); strncpy(defnam, word, VARLEN); sprintf(value, "%d", enmval); addcon(enmval); @@ -101,12 +101,12 @@ void penum(int m, int bitmsk) { } while (look(',')); expect('}'); expect(';'); - DEBUG("Enum Declaration Completed\n", 0) + DEBUG("dclrtn.penum: Enum Declaration Completed\n", 0) } /* Parse Enum Declaration*/ void pstrct(int m) { - DEBUG("Processing Struct Declarations\n", 0) + DEBUG("dclrtn.pstrct: Processing Struct Declarations\n", 0) getwrd(); //Parse Structure Name if (look('{')) defstc(); //Parse Struct Definition else addstc(); //Parse and Compile Struct Declaration @@ -115,18 +115,18 @@ void pstrct(int m) { /* Parse Variable/Function Declaration*/ void pdecl(int m, int t) { - DEBUG("Processing declaration(s) of type %d\n", t) + DEBUG("dclrtn.pdegl: Processing declaration(s) of type %d\n", t) do { getwrd(); if (match('(')) { - if (m > MTNONE) ERROR("Illegal Modifier %d in Function Definition\n", m, EXIT_FAILURE) + if (m > MTNONE) ERROR("dclrtn.pdegl: Illegal Modifier %d in Function Definition\n", m, EXIT_FAILURE) addfnc(); //Add Function Call return; } addvar(m, t); } while (look(',')); expect(';'); - DEBUG("Declaration completed\n", 0) + DEBUG("dclrtn.pdegl: Declaration completed\n", 0) cmtlin(); //Write out declaration comment } @@ -162,13 +162,13 @@ int ptype(int m) { int pmtype(int m) { getwrd(); if (m == MTALGN && wordis("CONST")) {m = m | MTCONST; getwrd();} - DEBUG("Parsing type %s\n", word) + DEBUG("dclrtn.pmtype: Parsing type %s\n", word) return ptype(m); } /* Check for and Parse Modifier */ int pmodfr(void) { - DEBUG("Parsing modifier '%s'\n", word) + DEBUG("dclrtn.pmodfr: Parsing modifier '%s'\n", word) int result = TRUE; if (wordis("ALIAS")) { pmtype(MTALS); } else if (wordis("ALIGNED")) { pmtype(MTALGN); } diff --git a/src/files.c b/src/files.c index 76c57d9..3ad9dcb 100644 --- a/src/files.c +++ b/src/files.c @@ -22,9 +22,9 @@ void extsys(char *s) { * Uses: srcnam - Source File Name * * Sets: srcfil - Source File Handle */ void opnsrc(void) { - DEBUG("Processing Source File Name '%s'\n", srcnam) + DEBUG("files.opnsrc: Processing Source File Name '%s'\n", srcnam) if (strrchr(srcnam, '.') == NULL) strcat(srcnam, ".c02"); //if no extension. add ".c02" - DEBUG("opening Source File '%s'\n", srcnam) + DEBUG("files.opnsrc: Opening Source File '%s'\n", srcnam) srcfil = fopen(srcnam, "r"); //open file if (srcfil == NULL) extsys(srcnam); } @@ -36,16 +36,16 @@ void clssrc(void) { fclose(srcfil); } * Uses: outnam - Output File Name * * Sets: outfil - Output File Handle */ void opnout(void) { - DEBUG("Processing Output File Name '%s'\n", outnam) + DEBUG("files.opnout: Processing Output File Name '%s'\n", outnam) if (strlen(outnam) == 0) //if Output File not specified { strcpy(outnam, srcnam); //copy Source Name to Ouput Name char *dot = strrchr(outnam, '.'); //find extension if (dot != NULL) *dot = 0; //and remove it - DEBUG("Set Output File Name to '%s'\n", outnam) + DEBUG("files.opnout: Set Output File Name to '%s'\n", outnam) } if (strrchr(outnam, '.') == NULL) strcat(outnam, ".asm"); //if no extension, add ".asm" - DEBUG("Opening Output File '%s'\n", outnam) + DEBUG("files.opnout: Opening Output File '%s'\n", outnam) outfil = fopen(outnam, "w"); //open file if (outfil == NULL) extsys(outnam); } @@ -64,7 +64,7 @@ void opnlog(void) { char *dot = strrchr(lognam, '.'); //find file extension if (dot != NULL) *dot = 0; //and remove it strcat(lognam, ".log"); //add extension ".log" - DEBUG("Opening Log File '%s'\n", lognam) + DEBUG("files.opnlog: Opening Log File '%s'\n", lognam) logfil = fopen(lognam, "w"); if (logfil == NULL) extsys(lognam); } @@ -81,18 +81,18 @@ void opninc(int chksub) { if (chksub) { for (subidx=0; subidx -1) { @@ -160,7 +160,7 @@ int pidxof(void) { * Returns: variable size (as integer */ int psizof(void) { expect('@'); //Check for and Skip SizeOf Operator - DEBUG("vars.pdizof: Parsing SizeOf operator", 0); + DEBUG("vars.psizof: Parsing SizeOf operator\n", 0); mbridx = -1; //Set Member Index to None reqvar(FALSE); //Parse Variable Name to get Size Of if (mbridx > -1) { @@ -310,7 +310,8 @@ void addvar(int m, int t) { skpchr(); if (alcvar) { DEBUG("vars.addvar: Parsing array size\n", 0) - sprintf(value, "%d", prsnum(0xFF) + 1); + prslit(); + sprintf(value, "%d", litval + 1); } expect(']'); } @@ -400,12 +401,12 @@ void addstc(void) { /* Parse Struct Definition * * Uses: word - Struct Name */ void defstc(void) { - DEBUG("Parsing struct definition\n", 0) + DEBUG("vars.defstc: Parsing struct definition\n", 0) if (fndstc(word)) ERROR("Duplicate Declaration of Struct '%s\n", word,EXIT_FAILURE) int type; int prnidx = stcidx; strncpy(strct.name, word, STCLEN); - DEBUG("Set struct name to '%s'\n", word); + DEBUG("vars.defstc: Set struct name to '%s'\n", word); strct.size = 0; //Initialize Struct Length while (look('/')) skpcmt(FALSE); //Skip Comments do { @@ -434,10 +435,10 @@ void defstc(void) { default: ERROR("Invalid Type %s in Struct Definition\n", word, EXIT_FAILURE) } - DEBUG("Parsing members of type %s\n", word) + DEBUG("vars.defstc: Parsing members of type %s\n", word) do { getwrd(); //Get Member Name - DEBUG("Parsing member %s\n", word) + DEBUG("vars.defstc: Parsing member %s\n", word) if (fndmbr(stccnt, word)) ERROR("Duplicate Declaration of Struct Member '%s\n", word,EXIT_FAILURE) if (strlen(word) > STMLEN) ERROR("Member Name %s too long\n", word, EXIT_FAILURE) strcpy(membr.name, word); //Set Member Name @@ -447,18 +448,19 @@ void defstc(void) { membr.offset = strct.size; //Set Offset into Struct membr.size = mbrsiz; //Set Member Size if (membr.vartyp == VTCHAR) { - DEBUG("Checking member for array definition\n", 0) + DEBUG("vars.defstc: Checking member for array definition\n", 0) if (match('[')) { CCMNT('['); skpchr(); membr.vartyp = VTARRAY; - DEBUG("Parsing member array size\n", 0) - membr.size = prsnum(0xFF) + 1; + DEBUG("vars.defstc: Parsing member array size\n", 0) + prslit(); + membr.size = litval + 1; expect(']'); } } - DEBUG("Set member type to %d", membr.vartyp) DETAIL(" and size to %d\n", membr.size); - DEBUG("Adding member at index %d\n", mbrcnt); + DEBUG("vars.defstc: Set member type to %d", membr.vartyp) DETAIL(" and size to %d\n", membr.size); + DEBUG("vars.defstc: Adding member at index %d\n", mbrcnt); membrs[mbrcnt++] = membr; strct.size += membr.size; } while (look(',')); @@ -467,7 +469,7 @@ void defstc(void) { } while (!look('}')); expect(';'); if (strct.size > 256) ERROR("Structure Size %d Exceeds Limit of 256 bytes.\n", strct.size, EXIT_FAILURE); - DEBUG("Adding struct with size %d", strct.size) DETAIL("at index %d\n", stccnt); + DEBUG("vars.defstc: Adding struct with size %d", strct.size) DETAIL("at index %d\n", stccnt); strcts[stccnt++] = strct; }