From 105995c6cd3b07688d916f8fd311cbe2833c4f70 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Mon, 8 Oct 2018 23:11:43 +0300 Subject: Fix for labels in symbols generations --- README.md | 2 +- source/command.c | 1 + source/defs.h | 1 + source/main.c | 2 +- source/symbol.c | 20 +++++++------------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 74c4a92..8462d96 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# nesasm CE v3.0b - a 6502 assembler with specific NES support +# nesasm CE v3.1 - a 6502 assembler with specific NES support Just another modification of nesasm. Based on modification by Tim Hentenaar which is based on modification by Bob Rost which is based on modification of nesasm 2.51 from MagicKit. diff --git a/source/command.c b/source/command.c index ba83ad7..226b334 100644 --- a/source/command.c +++ b/source/command.c @@ -349,6 +349,7 @@ do_equ(int *ip) return; /* assign value to the label */ + lablptr->equ = 1; labldef(value, 0); /* output line */ diff --git a/source/defs.h b/source/defs.h index d789f88..b55d9b0 100644 --- a/source/defs.h +++ b/source/defs.h @@ -182,6 +182,7 @@ typedef struct t_symbol { int pal; int refcnt; int reserved; + int equ; int data_type; int data_size; char name[SBOLSZ]; diff --git a/source/main.c b/source/main.c index 34457ca..ebdf9cd 100644 --- a/source/main.c +++ b/source/main.c @@ -25,7 +25,7 @@ * */ -#define VERSION "v3.0b" +#define VERSION "v3.1" #define DESCRIPTION "a 6502 assembler with specific NES support" #define GITHUB_URL "https://github.com/ClusterM/nesasm/" diff --git a/source/symbol.c b/source/symbol.c index 0e284b1..d1a7090 100644 --- a/source/symbol.c +++ b/source/symbol.c @@ -78,8 +78,6 @@ colsym(int *ip) /* error */ if (err) { fatal_error("Reserved symbol!"); -// symbol[0] = 0; -// symbol[1] = '\0'; return (0); } @@ -119,29 +117,24 @@ void stlist(char *file, int bank_offset) if (!sym) continue; do { - /* predefined symbols */ - if (strcmp(sym->name+1, "_bss_end") == 0) continue; - if (strcmp(sym->name+1, "_bank_base") == 0) continue; - if (strcmp(sym->name+1, "_nb_bank") == 0) continue; - if (strcmp(sym->name+1, "_call_bank") == 0) continue; + /* skipping reserved symbols and constants */ + if (sym->reserved || sym->equ) continue; bank = sym->value < 0x8000 ? -1 : sym->bank/2 + bank_offset; fnum = bank >= 0 ? bank : (sizeof(files) / sizeof(FILE*) - 1); files[fnum] = stlist_file(files[fnum], file, bank); - if (sym->data_size > 0) - fprintf(files[fnum], "$%04X#%s#\n", sym->value, sym->name+1); + fprintf(files[fnum], "$%04X#%s# %d %d\n", sym->value, sym->name+1, sym->reserved, sym->equ); for (j = 1; j < sym->data_size; j++) - fprintf(files[fnum], "$%04X#%s+%d#\n", sym->value+j, sym->name+1, j); + fprintf(files[fnum], "$%04X#%s+%d# %d %d\n", sym->value+j, sym->name+1, j, sym->reserved, sym->equ); local = sym->local; while (local) { bank = local->value < 0x8000 ? -1 : local->bank/2 + bank_offset; fnum = bank >= 0 ? bank : (sizeof(files) / sizeof(FILE*) - 1); files[fnum] = stlist_file(files[fnum], file, bank); - if (local->data_size > 0) - fprintf(files[fnum], "$%04X#%s (%s)#\n", local->value, local->name+1, sym->name+1); + fprintf(files[fnum], "$%04X#%s (%s)# %d %d\n", local->value, local->name+1, sym->name+1, local->reserved, local->equ); for (j = 1; j < sym->data_size; j++) - fprintf(files[fnum], "$%04X#%s+%d (%s)#\n", local->value+j, local->name+1, j, sym->name+1); + fprintf(files[fnum], "$%04X#%s+%d (%s)# %d %d\n", local->value+j, local->name+1, j, sym->name+1, local->reserved, local->equ); local = local->next; } } while ((sym = sym->next) != NULL); @@ -251,6 +244,7 @@ struct t_symbol *stinstall(int hash, int type) sym->pal = -1; sym->refcnt = 0; sym->reserved = 0; + sym->equ = 0; sym->data_type = -1; sym->data_size = 0; strcpy(sym->name, symbol); -- cgit v1.2.3