Remove non-OPT options from Options struct

This commit is contained in:
ISSOtm
2020-04-13 17:15:00 +02:00
parent cdb4c5f553
commit 5fe3a0adb6
6 changed files with 29 additions and 26 deletions

View File

@@ -18,12 +18,7 @@
struct sOptions { struct sOptions {
char binary[2]; char binary[2];
char gbgfx[4]; char gbgfx[4];
bool exportall;
int32_t fillchar; int32_t fillchar;
bool haltnop;
bool optimizeloads;
bool verbose;
bool warnings; /* True to enable warnings, false to disable them. */
}; };
extern char *tzNewMacro; extern char *tzNewMacro;
@@ -35,6 +30,10 @@ extern uint32_t curOffset; /* Offset into the current section */
extern struct sOptions DefaultOptions; extern struct sOptions DefaultOptions;
extern struct sOptions CurrentOptions; extern struct sOptions CurrentOptions;
extern bool haltnop;
extern bool optimizeloads;
extern bool verbose;
extern bool warnings; /* True to enable warnings, false to disable them. */
extern FILE *dependfile; extern FILE *dependfile;
extern char *tzTargetFileName; extern char *tzTargetFileName;

View File

@@ -1618,7 +1618,7 @@ z80_ei : T_Z80_EI { out_AbsByte(0xFB); }
z80_halt : T_Z80_HALT { z80_halt : T_Z80_HALT {
out_AbsByte(0x76); out_AbsByte(0x76);
if (CurrentOptions.haltnop) if (haltnop)
out_AbsByte(0x00); out_AbsByte(0x00);
} }
; ;
@@ -1718,8 +1718,8 @@ z80_ld_mem : T_Z80_LD op_mem_ind ',' T_MODE_SP {
out_RelWord(&$2); out_RelWord(&$2);
} }
| T_Z80_LD op_mem_ind ',' T_MODE_A { | T_Z80_LD op_mem_ind ',' T_MODE_A {
if (CurrentOptions.optimizeloads && if (optimizeloads && rpn_isKnown(&$2)
(rpn_isKnown(&$2)) && ($2.nVal >= 0xFF00)) { && $2.nVal >= 0xFF00) {
out_AbsByte(0xE0); out_AbsByte(0xE0);
out_AbsByte($2.nVal & 0xFF); out_AbsByte($2.nVal & 0xFF);
rpn_Free(&$2); rpn_Free(&$2);
@@ -1766,8 +1766,8 @@ z80_ld_a : T_Z80_LD reg_r ',' T_MODE_C_IND {
} }
| T_Z80_LD reg_r ',' op_mem_ind { | T_Z80_LD reg_r ',' op_mem_ind {
if ($2 == REG_A) { if ($2 == REG_A) {
if (CurrentOptions.optimizeloads && if (optimizeloads && rpn_isKnown(&$4)
(rpn_isKnown(&$4)) && ($4.nVal >= 0xFF00)) { && $4.nVal >= 0xFF00) {
out_AbsByte(0xF0); out_AbsByte(0xF0);
out_AbsByte($4.nVal & 0xFF); out_AbsByte($4.nVal & 0xFF);
rpn_Free(&$4); rpn_Free(&$4);

View File

@@ -434,7 +434,7 @@ void fstk_RunInclude(char *tzFileName)
nCurrentStatus = STAT_isInclude; nCurrentStatus = STAT_isInclude;
snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s", snprintf(tzCurrentFileName, sizeof(tzCurrentFileName), "%s%s",
incPathUsed, tzFileName); incPathUsed, tzFileName);
if (CurrentOptions.verbose) if (verbose)
printf("Assembling %s\n", tzCurrentFileName); printf("Assembling %s\n", tzCurrentFileName);
pCurrentFile = f; pCurrentFile = f;
CurrentFlexHandle = yy_create_buffer(pCurrentFile); CurrentFlexHandle = yy_create_buffer(pCurrentFile);

View File

@@ -63,6 +63,10 @@ char *tzTargetFileName;
struct sOptions DefaultOptions; struct sOptions DefaultOptions;
struct sOptions CurrentOptions; struct sOptions CurrentOptions;
bool haltnop;
bool optimizeloads;
bool verbose;
bool warnings; /* True to enable warnings, false to disable them. */
struct sOptionStackEntry { struct sOptionStackEntry {
struct sOptions Options; struct sOptions Options;
@@ -360,12 +364,12 @@ int main(int argc, char *argv[])
DefaultOptions.gbgfx[3] = '3'; DefaultOptions.gbgfx[3] = '3';
DefaultOptions.binary[0] = '0'; DefaultOptions.binary[0] = '0';
DefaultOptions.binary[1] = '1'; DefaultOptions.binary[1] = '1';
DefaultOptions.exportall = false;
DefaultOptions.fillchar = 0; DefaultOptions.fillchar = 0;
DefaultOptions.optimizeloads = true; optimizeloads = true;
DefaultOptions.haltnop = true; haltnop = true;
DefaultOptions.verbose = false; verbose = false;
DefaultOptions.warnings = true; warnings = true;
bool exportall = false;
opt_SetCurrentOptions(&DefaultOptions); opt_SetCurrentOptions(&DefaultOptions);
@@ -386,7 +390,7 @@ int main(int argc, char *argv[])
opt_AddDefine(optarg); opt_AddDefine(optarg);
break; break;
case 'E': case 'E':
newopt.exportall = true; exportall = true;
break; break;
case 'g': case 'g':
if (strlen(optarg) == 4) { if (strlen(optarg) == 4) {
@@ -399,13 +403,13 @@ int main(int argc, char *argv[])
} }
break; break;
case 'h': case 'h':
newopt.haltnop = false; haltnop = false;
break; break;
case 'i': case 'i':
fstk_AddIncludePath(optarg); fstk_AddIncludePath(optarg);
break; break;
case 'L': case 'L':
newopt.optimizeloads = false; optimizeloads = false;
break; break;
case 'M': case 'M':
if (!strcmp("-", optarg)) if (!strcmp("-", optarg))
@@ -439,13 +443,13 @@ int main(int argc, char *argv[])
printf("rgbasm %s\n", get_package_version_string()); printf("rgbasm %s\n", get_package_version_string());
exit(0); exit(0);
case 'v': case 'v':
newopt.verbose = true; verbose = true;
break; break;
case 'W': case 'W':
processWarningFlag(optarg); processWarningFlag(optarg);
break; break;
case 'w': case 'w':
newopt.warnings = false; warnings = false;
break; break;
/* Long-only options */ /* Long-only options */
@@ -510,7 +514,7 @@ int main(int argc, char *argv[])
setup_lexer(); setup_lexer();
if (CurrentOptions.verbose) if (verbose)
printf("Assembling %s\n", tzMainfile); printf("Assembling %s\n", tzMainfile);
if (dependfile) { if (dependfile) {
@@ -528,7 +532,7 @@ int main(int argc, char *argv[])
skipElif = true; skipElif = true;
nUnionDepth = 0; nUnionDepth = 0;
sym_Init(); sym_Init();
sym_SetExportAll(CurrentOptions.exportall); sym_SetExportAll(exportall);
fstk_Init(tzMainfile); fstk_Init(tzMainfile);
opt_ParseDefines(); opt_ParseDefines();
charmap_InitMain(); charmap_InitMain();
@@ -554,7 +558,7 @@ int main(int argc, char *argv[])
nEndClock = clock(); nEndClock = clock();
timespent = ((double)(nEndClock - nStartClock)) timespent = ((double)(nEndClock - nStartClock))
/ (double)CLOCKS_PER_SEC; / (double)CLOCKS_PER_SEC;
if (CurrentOptions.verbose) { if (verbose) {
printf("Success! %u lines in %d.%02d seconds ", nTotalLines, printf("Success! %u lines in %d.%02d seconds ", nTotalLines,
(int)timespent, ((int)(timespent * 100.0)) % 100); (int)timespent, ((int)(timespent * 100.0)) % 100);
if (timespent < FLT_MIN_EXP) if (timespent < FLT_MIN_EXP)

View File

@@ -416,6 +416,6 @@ void out_WriteObject(void)
void out_SetFileName(char *s) void out_SetFileName(char *s)
{ {
tzObjectname = s; tzObjectname = s;
if (CurrentOptions.verbose) if (verbose)
printf("Output filename %s\n", s); printf("Output filename %s\n", s);
} }

View File

@@ -48,7 +48,7 @@ static bool warningsAreErrors; /* Set if `-Werror` was specified */
static enum WarningState warningState(enum WarningID id) static enum WarningState warningState(enum WarningID id)
{ {
/* Check if warnings are globally disabled */ /* Check if warnings are globally disabled */
if (!CurrentOptions.warnings) if (!warnings)
return WARNING_DISABLED; return WARNING_DISABLED;
/* Get the actual state */ /* Get the actual state */