From 1eb3f57437062efaee684fe7b91d9899f9359044 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 4 Mar 2025 18:18:25 -0500 Subject: listamsb: list_*() functions. --- listamsb.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/listamsb.c b/listamsb.c index 463e12d..06b8277 100644 --- a/listamsb.c +++ b/listamsb.c @@ -89,6 +89,7 @@ int warnings = 0; int proglen = 0; int linecount = 0; int header_read = 0; +int printing = 0; FILE *infile; FILE *outfile; @@ -255,10 +256,28 @@ void read_header(void) { } void unknown_token(unsigned char byte, int ext) { + if(!printing) return; fprintf(outfile, "", (ext ? "$ff ": ""), byte); } +void list_char(unsigned char c) { + if(printing) fputc(c, outfile); +} + +void list_token(unsigned char c) { + if(printing) fputs(std_tokens[byte - MIN_STD_TOK], outfile); +} + +void list_ext_token(unsigned char c) { + if(printing) fputs(ext_tokens[byte - MIN_EXT_TOK], outfile); +} + +void list_lineno(int l) { + /* note that AMSB always puts a space after the line number in LIST */ + if(printing) fprintf(outfile, "%d ", lineno); +} + /* meat and potatoes. does the actual detokenizing. gets called once per line of code. returns false when it hits the last line, or true if there are more lines. */ @@ -266,7 +285,6 @@ int next_line(void) { static int last_lineno = -1; static int last_ptr = -1; int ptr, lineno, was_ff, was_colon, in_string, in_comment, offset, len; - int printing; unsigned char byte; offset = bytes_read; @@ -310,7 +328,6 @@ int next_line(void) { last_lineno = lineno; - /* note that AMSB always puts a space after the line number in LIST */ if(printing) fprintf(outfile, "%d ", lineno); was_ff = 0; @@ -368,7 +385,7 @@ int next_line(void) { if(printing) fputs(ext_tokens[byte - MIN_EXT_TOK], outfile); } else { if(printing) unknown_token(byte, 1); - warnings++; + warn("unknown extended token $ff $%02x at line %d", byte, lineno); } was_ff = 0; } else if(byte == 0xff) { @@ -382,7 +399,7 @@ int next_line(void) { } else if(byte >= 0x80) { /* invalid token */ if(printing) unknown_token(byte, 0); - warnings++; + warn("unknown token $%02x at line %d", byte, lineno); } else { /* null byte means the line of code is done */ if(!byte) break; -- cgit v1.2.3