1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 06:29:32 +00:00

Added -s command line option to compiler

This commit is contained in:
Curtis F Kaylor 2018-09-09 16:10:21 -04:00
parent 9683509797
commit 330ed1285a
7 changed files with 46 additions and 13 deletions

View File

@ -51,6 +51,7 @@ void init(void) {
wrtofs[0] = 0; //Write Offset
xsnvar[0] = 0; //Assigned X Variable Name
ysnvar[0] = 0; //Assigned Y Variable Name
subdir[0] = 0; //Include Subdirectory
strcpy(incdir, "../include/");
}
@ -129,7 +130,7 @@ int popt(int arg, int argc, char *argv[]) {
strncpy (argstr, argv[arg], 31);
if (strlen(argstr) != 2) ERROR("malformed option %s\n", argstr, EXIT_FAILURE)
opt = toupper(argstr[1]);
if (strchr("H", opt)) {
if (strchr("HS", opt)) {
if (++arg >= argc) ERROR("Option -%c requires an argument\n", opt, EXIT_FAILURE)
strncpy(optarg, argv[arg], 31);
}
@ -139,6 +140,10 @@ int popt(int arg, int argc, char *argv[]) {
strcpy(hdrnam, optarg);
DEBUG("Header Name set to '%s'\n", hdrnam)
break;
case 'S':
strcpy(subdir, optarg);
DEBUG("Header Name set to '%s'\n", hdrnam)
break;
default:
ERROR("Illegal option -%c\n", opt, EXIT_FAILURE)
}

View File

@ -66,6 +66,7 @@ char cmtasm[LINELEN]; //Assembly Language Comment Text
char hdrnam[FNAMLEN]; //Header File Name
char incdir[FNAMLEN]; //Include File Directory
char inpnam[FNAMLEN]; //Input File Name
char subdir[FNAMLEN]; //Include File SubDirectory
int alcvar; //Allocate Variables Flag
int inblck; //Multiline Block Flag

View File

@ -96,18 +96,18 @@ void pstrct(int m) {
/* Parse Variable/Function Declaration*/
void pdecl(int m, int t) {
DEBUG("Processing variable declarations(s) of type %d\n", t)
DEBUG("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("Illegal Modifier %d in Function Definition\n", m, EXIT_FAILURE)
addfnc(); //Add Function Call
return;
}
}
addvar(m, t);
} while (look(','));
expect(';');
DEBUG("Variable Declaration Completed\n", 0)
DEBUG("Declaration completed\n", 0)
cmtlin(); //Write out declaration comment
}

View File

@ -69,15 +69,28 @@ void opnlog(void) {
if (logfil == NULL) extsys(lognam);
}
/* Close Log File *
* Uses: logfil - Log File Handle */
/* Close Log File *
* Uses: logfil - Log File Handle */
void clslog(void) { fclose(logfil); }
/* Open Include file *
* Uses: incnam - Include File Name *
* Sets: incfil - Include File Handle */
/* Open Include file *
* Uses: incnam - Include File Name *
* subnam - Include File Name (Subdirectory) *
* Sets: incfil - Include File Handle */
void opninc(void)
{
if (subnam[0]) {
DEBUG("Attempting to open include file '%s'\n", subnam)
incfil = fopen(subnam, "r");
if (incfil == NULL) DEBUG("Open failed\n", 0)
else {
strcpy(incnam, subnam);
DEBUG("INCNAM set to '%s'\n", incnam);
subnam[0] = 0;
return;
}
}
DEBUG("Opening include file '%s'\n", incnam)
incfil = fopen(incnam, "r");
if (incfil == NULL) extsys(incnam);

View File

@ -12,6 +12,7 @@ char srcnam[FNAMLEN]; //Source File Name
char outnam[FNAMLEN]; //Assembler File Name
char lognam[FNAMLEN]; //Log File Name
char incnam[FNAMLEN]; //Include File Name
char subnam[FNAMLEN]; //Include File Name (Subdirectory)
void opnsrc(); //Open Source File
void clssrc(); //Close Source File

View File

@ -23,11 +23,18 @@
void pincnm(void) {
char dlmtr;
int inclen = 0;
int sublen = 0;
skpspc();
dlmtr = getnxt();
if (dlmtr == '<') {
strcpy(incnam, incdir);
inclen = strlen(incnam);
if (subdir[0]) {
strcpy(subnam, incdir);
strcat(subnam, subdir);
sublen = strlen(subnam);
subnam[sublen++] = '/';
}
dlmtr = '>';
}
else if (dlmtr != '"')
@ -35,10 +42,14 @@ void pincnm(void) {
while (!match(dlmtr))
{
incnam[inclen++] = nxtchr;
if (sublen) subnam[sublen++] = nxtchr;
skpchr();
}
skpchr(); //skip end dlmtr
incnam[inclen] = 0;
subnam[sublen] = 0;
DEBUG("Set INCNAM to '%s'\n", incnam);
DEBUG("Set SUBNAM to '%s'\n", subnam);
}
/* Process assembly language include file */
@ -250,7 +261,9 @@ void pincfl(void) {
incasm();
else if (strcmp(dot, ".h02") == 0) {
inchdr(); //Process Header File
dot = strrchr(incnam, '.'); //find extension
strcpy(dot, ".a02");
DEBUG("INCNAM set to '%s'\n", incnam)
incasm(); //Process Assembly File with Same Name
}
else {

View File

@ -50,9 +50,9 @@ enum dtypes {DTBYTE, DTSTR, DTARRY}; //Variable Data Types
/*Variable Modifier Types (Bit Mask) */
#define MTNONE 0 //No Modifier
#define MTCONST 1 //Constant
#define MTZP 2 //Zero Page
#define MTALS 4 //Alias
#define MTALS 1 //Alias
#define MTCONST 2 //Constant
#define MTZP 4 //Zero Page
#define MTALGN 128 //Aligned
int symdef(char *name); //Is Variable defined (TRUE or FALSE)