Do not display or generate output on errors.

This commit is contained in:
waltje
2023-06-17 20:32:45 -04:00
parent e4a00dffe2
commit a6d3f704cd
8 changed files with 42 additions and 31 deletions

View File

@@ -120,3 +120,5 @@
+ Add -C option to allow for case-insensitivity of symbol names.
- add symbol-table listing in numeric order.
+ cleaned up parser, added listing output for directives.
+ Do not display or generate output on errors.
+ Implemented the "{*,$,.} = value" constructs to set origin.

View File

@@ -8,7 +8,7 @@
*
* General expression handler.
*
* Version: @(#)expr.c 1.0.9 2023/06/16
* Version: @(#)expr.c 1.0.10 2023/06/17
*
* Authors: Fred N. van Kempen, <waltje@varcem.com>
* Bernd B”ckmann, <https://codeberg.org/boeckmann/asm6502>
@@ -209,7 +209,7 @@ primary(char **p, int label)
skip_white(p);
#ifdef _DEBUG
if (opt_d)
if (opt_d > 1)
printf("> PRIMARY(%s)\n", dumpline(*p));
#endif
pt = *p;
@@ -378,7 +378,7 @@ product(char **p)
char op, op2;
#ifdef _DEBUG
if (opt_d)
if (opt_d > 1)
printf("PRODUCT(%s)\n", dumpline(*p));
#endif
res = primary(p, 1);
@@ -473,7 +473,7 @@ term(char **p)
skip_white(p);
#ifdef _DEBUG
if (opt_d)
if (opt_d > 1)
printf("TERM(%s)\n", dumpline(*p));
#endif
if (**p == '-') { // indicate negative value
@@ -555,7 +555,7 @@ compare(char **p)
char op, op2;
#ifdef _DEBUG
if (opt_d)
if (opt_d > 1)
printf("COMPARE(%s)\n", dumpline(*p));
#endif
res = term(p);
@@ -678,7 +678,7 @@ expr(char **p)
skip_white(p);
#ifdef _DEBUG
if (opt_d)
if (opt_d > 1)
printf("EXPR(%s)\n", dumpline(*p));
#endif

View File

@@ -8,7 +8,7 @@
*
* Definitions for the entire application.
*
* Version: @(#)global.h 1.0.10 2023/06/15
* Version: @(#)global.h 1.0.11 2023/06/17
*
* Author: Fred N. van Kempen, <waltje@varcem.com>
*
@@ -240,7 +240,7 @@ extern void list_set_head(const char *);
extern void list_set_head_sub(const char *);
extern void list_set_syms(int);
extern int list_init(const char *);
extern void list_close(void);
extern void list_close(int);
extern void list_line(const char *);
extern void list_page(const char *, const char *);
extern void list_save(uint32_t);

View File

@@ -8,7 +8,7 @@
*
* Handle the listfile output.
*
* Version: @(#)list.c 1.0.9 2023/06/16
* Version: @(#)list.c 1.0.10 2023/06/17
*
* Author: Fred N. van Kempen, <waltje@varcem.com>
*
@@ -72,8 +72,9 @@ static uint32_t list_pc,
list_oc;
static char *list_title;
static char *list_subttl;
static FILE *list_file = NULL;
static int list_syms = 0;
static FILE *list_file = NULL;
static char list_path[1024];
void
@@ -350,7 +351,7 @@ list_save(uint32_t pc)
void
list_close(void)
list_close(int remov)
{
if (list_file != NULL) {
/* Reset printer to normal mode if needed. */
@@ -358,8 +359,10 @@ list_close(void)
fprintf(list_file, LIST_CHAR_DC2);
(void)fclose(list_file);
list_file = NULL;
if (remov)
remove(list_path);
}
}
@@ -367,27 +370,26 @@ list_close(void)
int
list_init(const char *fn)
{
char name[1024];
char *p;
/* Copy the filename and see if we need to add a filename extension. */
strncpy(name, fn, sizeof(name) - 1);
p = strrchr(name, '/');
strncpy(list_path, fn, sizeof(list_path) - 1);
p = strrchr(list_path, '/');
#ifdef _WIN32
if (p == NULL)
p = strrchr(name, '\\');
p = strrchr(list_path, '\\');
#endif
if (p == NULL)
p = name;
p = list_path;
p = strrchr(p, '.');
if (p != NULL)
p++;
if (p == NULL) {
/* No filename extension - use .lst as a default! */
strcat(name, ".lst");
strcat(list_path, ".lst");
}
list_file = fopen(name, "w");
list_file = fopen(list_path, "w");
if (list_file == NULL)
return 0;

View File

@@ -10,7 +10,7 @@
*
* Usage: vasm [-dCFqsTvPV] [-p processor] [-l fn] [-o fn] [-Dsym[=val]] file ...
*
* Version: @(#)main.c 1.0.10 2023/06/15
* Version: @(#)main.c 1.0.11 2023/06/17
*
* Authors: Fred N. van Kempen, <waltje@varcem.com>
* Bernd B”ckmann, <https://codeberg.org/boeckmann/asm6502>
@@ -308,7 +308,7 @@ main(int argc, char *argv[])
ttext = text;
errors = pass(&ttext, 1);
if (errors)
goto ret1;
goto ret2;
/* Perform Pass 2. */
ttext = text;
@@ -320,7 +320,7 @@ main(int argc, char *argv[])
list_symbols();
ret2:
list_close();
list_close(errors);
ret1:
// if (text != NULL)
@@ -329,11 +329,12 @@ ret1:
sym_free(NULL);
ret0:
if ((c = output_close(errors)) <= 0) {
fprintf(stderr, "error writing output file %s\n", out_name);
if ((c = output_close(errors)) < 0) {
if (! errors)
fprintf(stderr, "error writing output file %s\n", out_name);
errors = 1;
} else {
if (! opt_q)
if (!opt_q && !errors)
printf("Generated %i bytes of output.\n", c);
}

View File

@@ -34,7 +34,7 @@
* into one, and have the backends select the proper mode for
* them at runtime.
*
* Version: @(#)output.c 1.0.6 2023/06/16
* Version: @(#)output.c 1.0.6 2023/06/17
*
* Author: Fred N. van Kempen, <waltje@varcem.com>
*
@@ -297,7 +297,7 @@ int
output_close(int remov)
{
if (out_file == NULL)
return 0;
return -1;
/* Flush any buffered data. */
out_flush(1);

View File

@@ -8,7 +8,7 @@
*
* Parse the source input, process it, and generate output.
*
* Version: @(#)parse.c 1.0.10 2023/06/15
* Version: @(#)parse.c 1.0.11 2023/06/17
*
* Authors: Fred N. van Kempen, <waltje@varcem.com>
* Bernd B”ckmann, <https://codeberg.org/boeckmann/asm6502>
@@ -242,6 +242,11 @@ statement(char **p, int pass)
char id[ID_LEN], id2[ID_LEN], *pt;
int label = 0, local = 0;
#ifdef _DEBUG
if (opt_d)
printf("<< '%s'\n", dumpline(*p));
#endif
skip_white_and_comment(p);
if (IS_END(**p))
return NULL;
@@ -400,7 +405,7 @@ statement(char **p, int pass)
pt = *p;
nident_upcase(p, id);
if ((psop = is_pseudo(id, 0)) != NULL) {
/* All good, we're a directive. */
/* All good, we are. */
skip_white(p);
return pseudo(psop, p, pass);
}

View File

@@ -8,7 +8,7 @@
*
* Handle directives and pseudo-ops.
*
* Version: @(#)pseudo.c 1.0.8 2023/06/16
* Version: @(#)pseudo.c 1.0.9 2023/06/17
*
* Authors: Fred N. van Kempen, <waltje@varcem.com>
* Bernd B”ckmann, <https://codeberg.org/boeckmann/asm6502>
@@ -1194,7 +1194,8 @@ do_warn(char **p, int pass)
}
} while (next);
printf("%s\n", buff);
if (opt_v || pass == 2)
printf("%s\n", buff);
return NULL;
}