Mercurial > hg-old > index.cgi
changeset 390:027d7fbcdcfc
Basic symbol table output; needs work for non-constant symbols
author | lost@l-w.ca |
---|---|
date | Wed, 14 Jul 2010 22:46:56 -0600 |
parents | fbb7bfed8076 |
children | c1d83336e1d1 |
files | lwasm/list.c lwasm/lwasm.h lwasm/main.c lwasm/symbol.c |
diffstat | 4 files changed, 41 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/list.c Wed Jul 14 22:33:55 2010 -0600 +++ b/lwasm/list.c Wed Jul 14 22:46:56 2010 -0600 @@ -30,6 +30,8 @@ #include "lwasm.h" #include "instab.h" +void list_symbols(asmstate_t *as, FILE *of); + /* Do listing */ @@ -132,4 +134,7 @@ fprintf(of, "\n"); } } + + if (as -> flags & FLAG_SYMBOLS) + list_symbols(as, of); }
--- a/lwasm/lwasm.h Wed Jul 14 22:33:55 2010 -0600 +++ b/lwasm/lwasm.h Wed Jul 14 22:46:56 2010 -0600 @@ -62,9 +62,10 @@ enum lwasm_flags_e { - FLAG_NONE = 0, FLAG_LIST = 0x0001, - FLAG_DEPEND = 0x0002 + FLAG_DEPEND = 0x0002, + FLAG_SYMBOLS = 0x004, + FLAG_NONE = 0 }; enum lwasm_pragmas_e
--- a/lwasm/main.c Wed Jul 14 22:33:55 2010 -0600 +++ b/lwasm/main.c Wed Jul 14 22:46:56 2010 -0600 @@ -46,6 +46,7 @@ { "debug", 'd', "LEVEL", OPTION_ARG_OPTIONAL, "Set debug mode"}, { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, { "list", 'l', "FILE", OPTION_ARG_OPTIONAL, "Generate list [to FILE]"}, + { "symbols", 's', 0, OPTION_ARG_OPTIONAL, "Generate symbol list in listing, no effect without --list"}, { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, @@ -90,6 +91,10 @@ as -> list_file = lw_strdup(arg); as -> flags |= FLAG_LIST; break; + + case 's': + as -> flags |= FLAG_SYMBOLS; + break; case 'b': as -> output_format = OUTPUT_DECB;
--- a/lwasm/symbol.c Wed Jul 14 22:33:55 2010 -0600 +++ b/lwasm/symbol.c Wed Jul 14 22:46:56 2010 -0600 @@ -21,6 +21,7 @@ #include <config.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -166,3 +167,30 @@ return s; } + +void list_symbols(asmstate_t *as, FILE *of) +{ + struct symtabe *s; + + fprintf(of, "\nSymbol Table:\n"); + + for (s = as -> symtab.head; s; s = s -> next) + { + fputc('[', of); + if (s -> flags & symbol_flag_set) + fputc('S', of); + else + fputc(' ', of); + if (lw_expr_istype(s -> value, lw_expr_type_int)) + fputc('G', of); + else + fputc(' ', of); + fputc(']', of); + fputc(' ', of); + fprintf(of, "%-32s ", s -> symbol); + if (lw_expr_istype(s -> value, lw_expr_type_int)) + fprintf(of, "%04X\n", lw_expr_intval(s -> value)); + else + fprintf(of, "%s\n", lw_expr_print(s -> value)); + } +}