mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-25 06:31:25 +00:00
Added function names to DEBUG statements in c02.c and vars.c
This commit is contained in:
parent
658bb18b57
commit
8203daed7d
32
src/c02.c
32
src/c02.c
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
/* Initilize Compiler Variables */
|
/* Initilize Compiler Variables */
|
||||||
void init(void) {
|
void init(void) {
|
||||||
DEBUG("Initializing Compiler Variables\n",0)
|
DEBUG("c02.init: Initializing Compiler Variables\n",0)
|
||||||
concnt = 0; //Number of Constants Defined
|
concnt = 0; //Number of Constants Defined
|
||||||
varcnt = 0; //Number of Variables in Table
|
varcnt = 0; //Number of Variables in Table
|
||||||
lblcnt = 0; //Number of Labels in stack
|
lblcnt = 0; //Number of Labels in stack
|
||||||
@ -66,7 +66,7 @@ void ppntr(void) {
|
|||||||
void pword(void) {
|
void pword(void) {
|
||||||
lsrtrn = FALSE; //Clear RETURN flag
|
lsrtrn = FALSE; //Clear RETURN flag
|
||||||
getwrd();
|
getwrd();
|
||||||
DEBUG("Parsing Word '%s'\n", word)
|
DEBUG("c02.pword: Parsing Word '%s'\n", word)
|
||||||
if (xstmnt[0]) {
|
if (xstmnt[0]) {
|
||||||
if (wordis(xstmnt)) xstmnt[0] = 0; //Clear xstmnt
|
if (wordis(xstmnt)) xstmnt[0] = 0; //Clear xstmnt
|
||||||
else ERROR("Expected '%s' statement\n", xstmnt, EXIT_FAILURE)
|
else ERROR("Expected '%s' statement\n", xstmnt, EXIT_FAILURE)
|
||||||
@ -79,7 +79,7 @@ void pdrctv(void) {
|
|||||||
skpchr(); //skip '#'
|
skpchr(); //skip '#'
|
||||||
CCMNT('#');
|
CCMNT('#');
|
||||||
getwrd(); //read directive into word
|
getwrd(); //read directive into word
|
||||||
DEBUG("Processing directive '%s'\n", word)
|
DEBUG("c02.pdrctv: Processing directive '%s'\n", word)
|
||||||
if (wordis("DEFINE")) pdefin(); //Parse Define
|
if (wordis("DEFINE")) pdefin(); //Parse Define
|
||||||
else if (wordis("INCLUDE")) pincfl(); //Parse Include File
|
else if (wordis("INCLUDE")) pincfl(); //Parse Include File
|
||||||
else if (wordis("ERROR")) ERROR("Error \n", 0, EXIT_FAILURE)
|
else if (wordis("ERROR")) ERROR("Error \n", 0, EXIT_FAILURE)
|
||||||
@ -88,7 +88,7 @@ void pdrctv(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void prolog(void) {
|
void prolog(void) {
|
||||||
DEBUG("Writing Assembly Prolog\n", 0)
|
DEBUG("c02.prolog: Writing Assembly Prolog\n", 0)
|
||||||
asmlin(CPUOP,cputyp);
|
asmlin(CPUOP,cputyp);
|
||||||
setcmt("Program ");
|
setcmt("Program ");
|
||||||
addcmt(srcnam);
|
addcmt(srcnam);
|
||||||
@ -106,11 +106,11 @@ void epilog(void) {
|
|||||||
|
|
||||||
/* Compile Source Code*/
|
/* Compile Source Code*/
|
||||||
void compile(void) {
|
void compile(void) {
|
||||||
DEBUG("Starting Compilation\n", 0)
|
DEBUG("c02.compile: Starting Compilation\n", 0)
|
||||||
prolog();
|
prolog();
|
||||||
phdrfl(); //Process Header File specified on Command Line
|
phdrfl(); //Process Header File specified on Command Line
|
||||||
skpchr();
|
skpchr();
|
||||||
DEBUG("Parsing Code\n", 0)
|
DEBUG("c02.compile: Parsing Code\n", 0)
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
skpspc();
|
skpspc();
|
||||||
if (match(EOF)) break; //Stop Parsing (End of File)
|
if (match(EOF)) break; //Stop Parsing (End of File)
|
||||||
@ -142,24 +142,24 @@ int popt(int arg, int argc, char *argv[]) {
|
|||||||
if (++arg >= argc) ERROR("Option -%c requires an argument\n", opt, EXIT_FAILURE)
|
if (++arg >= argc) ERROR("Option -%c requires an argument\n", opt, EXIT_FAILURE)
|
||||||
strncpy(optarg, argv[arg], 31);
|
strncpy(optarg, argv[arg], 31);
|
||||||
}
|
}
|
||||||
DEBUG("Processing Command Line Option -%c\n", argstr[1])
|
DEBUG("c02.popt: Processing Command Line Option -%c\n", argstr[1])
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'D':
|
case 'D':
|
||||||
debug = TRUE;
|
debug = TRUE;
|
||||||
DEBUG("Debug output enable\n", 0)
|
DEBUG("c02.popt: Debug output enable\n", 0)
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
strcpy(cputyp, optarg);
|
strcpy(cputyp, optarg);
|
||||||
DEBUG("CPU Type set to '%s'\n", cputyp)
|
DEBUG("c02.popt: CPU Type set to '%s'\n", cputyp)
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
strcpy(hdrnam, optarg);
|
strcpy(hdrnam, optarg);
|
||||||
DEBUG("Header Name set to '%s'\n", hdrnam)
|
DEBUG("c02.popt: Header Name set to '%s'\n", hdrnam)
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
strcpy(subdir[subcnt], optarg);
|
strcpy(subdir[subcnt], optarg);
|
||||||
DEBUG("subdir[%d] ", subcnt)
|
DEBUG("c02.popt: subdir[%d] ", subcnt)
|
||||||
DEBUG("set to '%s'\n", subdir[subcnt])
|
DETAIL("set to '%s'\n", subdir[subcnt])
|
||||||
subcnt++;
|
subcnt++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -175,18 +175,18 @@ void pargs(int argc, char *argv[]) {
|
|||||||
int arg;
|
int arg;
|
||||||
srcnam[0] = 0;
|
srcnam[0] = 0;
|
||||||
outnam[0] = 0;
|
outnam[0] = 0;
|
||||||
DEBUG("Parsing %d arguments\n", argc)
|
DEBUG("c02.pargs: Parsing %d arguments\n", argc)
|
||||||
if (argc == 0) usage(); //at least one argument is required
|
if (argc == 0) usage(); //at least one argument is required
|
||||||
for (arg = 1; arg<argc; arg++) {
|
for (arg = 1; arg<argc; arg++) {
|
||||||
DEBUG("Parsing argument %d\n", arg);
|
DEBUG("c02.pargs: Parsing argument %d\n", arg);
|
||||||
if (argv[arg][0] == '-') arg = popt(arg, argc, argv); //Process Command Line Option
|
if (argv[arg][0] == '-') arg = popt(arg, argc, argv); //Process Command Line Option
|
||||||
else if (srcnam[0] == 0) strcpy(srcnam, argv[arg]); //set Source File Name to first arg
|
else if (srcnam[0] == 0) strcpy(srcnam, argv[arg]); //set Source File Name to first arg
|
||||||
else if (outnam[0] == 0) strcpy(outnam, argv[arg]); //set Out File Name to second arg
|
else if (outnam[0] == 0) strcpy(outnam, argv[arg]); //set Out File Name to second arg
|
||||||
else ERROR("Unexpected argument '%s'\n", argv[arg], EXIT_FAILURE)
|
else ERROR("Unexpected argument '%s'\n", argv[arg], EXIT_FAILURE)
|
||||||
}
|
}
|
||||||
if (srcnam[0]) DEBUG("srcnam set to '%s'\n", srcnam)
|
if (srcnam[0]) DEBUG("c02.pargs: srcnam set to '%s'\n", srcnam)
|
||||||
else ERROR("Error: Source file not specified\n", 0, EXIT_FAILURE)
|
else ERROR("Error: Source file not specified\n", 0, EXIT_FAILURE)
|
||||||
if (outnam[0]) DEBUG("outnam set to '%s'\n", outnam)
|
if (outnam[0]) DEBUG("c02.pargs: outnam set to '%s'\n", outnam)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate CPU Type *
|
/* Validate CPU Type *
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* varcnt if not found *
|
* varcnt if not found *
|
||||||
* Returns: TRUE if found, otherwise FALSE */
|
* Returns: TRUE if found, otherwise FALSE */
|
||||||
int fndvar(char *name) {
|
int fndvar(char *name) {
|
||||||
DEBUG("vars,fndvar: Looking up variable '%s'\n", name)
|
DEBUG("vars.fndvar: Looking up variable '%s'\n", name)
|
||||||
for (varidx=0; varidx<varcnt; varidx++) {
|
for (varidx=0; varidx<varcnt; varidx++) {
|
||||||
if (strcmp(vartbl[varidx].name, name) == 0) {
|
if (strcmp(vartbl[varidx].name, name) == 0) {
|
||||||
memcpy(&varble, &vartbl[varidx], sizeof(varble));
|
memcpy(&varble, &vartbl[varidx], sizeof(varble));
|
||||||
@ -66,6 +66,7 @@ int fndmbr(int idx, char *name) {
|
|||||||
* alwcon - allow const variable *
|
* alwcon - allow const variable *
|
||||||
* name - variable name */
|
* name - variable name */
|
||||||
void chksym(int alwreg, int alwcon, char *name) {
|
void chksym(int alwreg, int alwcon, char *name) {
|
||||||
|
DEBUG("Checking symbol %s ", name)
|
||||||
if (strlen(name) == 1 && strchr("AXY", name[0])) {
|
if (strlen(name) == 1 && strchr("AXY", name[0])) {
|
||||||
if (alwreg && valtyp != ARRAY) {
|
if (alwreg && valtyp != ARRAY) {
|
||||||
valtyp = REGISTER;
|
valtyp = REGISTER;
|
||||||
|
Loading…
Reference in New Issue
Block a user