Created
April 5, 2020 21:48
-
-
Save kmck/127d851a4e7c61cc464ed8a37aae46a0 to your computer and use it in GitHub Desktop.
Suppress IGNORENL'ed output in .mlb files and treat ENUM'ed labels as RAM aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/asm6f.c b/asm6f.c | |
index 0507082..ac35efe 100644 | |
--- a/asm6f.c | |
+++ b/asm6f.c | |
@@ -82,6 +82,7 @@ typedef struct { | |
int pass; //when label was last defined | |
int scope; //where visible (0=global, nonzero=local) | |
int ignorenl; //[freem addition] output this label in .nl files? (0=yes, nonzero=no) | |
+ int insideenum; //[kmck addition] output this label? (0=yes, nonzero=no) | |
void *link; //labels that share the same name (local labels) are chained together | |
} label; | |
@@ -95,6 +96,7 @@ label firstlabel={ //'$' label | |
0,//pass | |
0,//scope | |
0,//[freem addition] ignorenl | |
+ 0,//[kmck addition] insideenum | |
0,//link | |
}; | |
@@ -1291,12 +1293,16 @@ void export_mesenlabels() { | |
for(i = labelstart; i<=labelend; i++) { | |
l = labellist[i]; | |
+ // [kmck addition]: handle IGNORENL'd labels | |
+ if((*l).ignorenl) | |
+ continue; | |
+ | |
if(l->value >= 0x10000 || l->name[0] == '+' || l->name[0] == '-' || l->value < 0) { | |
//Ignore CHR & anonymous code labels | |
continue; | |
} | |
- if(l->type == LABEL) { | |
+ if(l->type == LABEL && !(*l).insideenum) { | |
//Labels in the actual code | |
if(l->pos < 16) { | |
//Ignore file header | |
@@ -1336,7 +1342,7 @@ void export_mesenlabels() { | |
fwrite((const void *)commenttext, 1, strlen(commenttext), outfile); | |
} | |
fwrite("\n", 1, 1, outfile); | |
- } else if(l->type == VALUE || l->type == EQUATE) { | |
+ } else if(l->type == VALUE || l->type == EQUATE || l->type == LABEL) { | |
//These are potentially aliases for variables in RAM, or read/write registers, etc. | |
if(l->value < 0x2000) { | |
//Assume nes internal RAM below $2000 (2kb) | |
@@ -1384,6 +1390,9 @@ void addlabel(char *word, int local) { | |
// [freem addition] | |
(*labelhere).ignorenl=nonl; | |
+ // [kmck addition] | |
+ (*labelhere).insideenum=nooutput; | |
+ | |
if(c==LOCALCHAR || local) { //local | |
(*labelhere).scope=scope; | |
} else { //global | |
@@ -2886,4 +2895,4 @@ void nes2chrbram(label *id, char **next) { | |
errmsg=OutOfRange; | |
ines_include++; use_nes2 = 1; | |
-} | |
\ No newline at end of file | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment