From 4ee5e895e55eaac0e1b5f82894f36b173c22d215 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 1 Mar 2025 19:29:50 +0100 Subject: [PATCH] symbols: Added new symbol format option --- man/ulas.1 | 2 +- src/main.c | 4 +++- src/ulas.c | 24 +++++++++++++++++++++++- src/ulas.h | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/man/ulas.1 b/man/ulas.1 index 4614691..35e477f 100644 --- a/man/ulas.1 +++ b/man/ulas.1 @@ -6,7 +6,7 @@ .SH NAME ulas .SH SYNOPSIS - ulas [-hvVpdA] [-o=path] [-I=path] [-l=path] [-a=initial-address] [-S=ulas|mlb] [input] + ulas [-hvVpdA] [-o=path] [-I=path] [-l=path] [-a=initial-address] [-S=ulas|mlb|sym] [input] .SH DESCRIPTION ulas diff --git a/src/main.c b/src/main.c index 8acf6a1..6e48637 100644 --- a/src/main.c +++ b/src/main.c @@ -69,7 +69,9 @@ void ulas_getopt(int argc, char **argv, struct ulas_config *cfg) { cfg->sym_fmt = ULAS_SYM_FMT_DEFAULT; } else if (strcmp("mlb", optarg) == 0) { cfg->sym_fmt = ULAS_SYM_FMT_MLB; - } else { + } else if (strcmp("sym", optarg) == 0) { + cfg->sym_fmt = ULAS_SYM_FMT_SYM; + }else { printf("Invalid symbol format: %s\n", optarg); exit(-1); } diff --git a/src/ulas.c b/src/ulas.c index 6c39253..98588f3 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -24,7 +24,7 @@ unsigned long defslen = 0; void ulas_help(void) { printf("%s\n", ULAS_NAME); printf("Usage %s [-%s] [-o=path] [-I=path] [-l=path] [-a=initial-address] " - "[-S=ulas|mlb] " + "[-S=ulas|mlb|sym] " "[input]\n\n", ULAS_NAME, ULAS_OPTS); ULAS_HELP("h", "display this help and exit"); @@ -440,6 +440,28 @@ int ulas_symbolout(FILE *dst, struct ulas_sym *s) { } fprintf(dst, "\n"); break; + case ULAS_SYM_FMT_SYM: + fprintf(dst, "00:"); + + switch (s->tok.type) { + case ULAS_INT: + fprintf(dst, "%x", ulas_valint(&s->tok, &rc)); + break; + case ULAS_STR: + fprintf(dst, "%s", ulas_valstr(&s->tok, &rc)); + break; + default: + fprintf(dst, ""); + break; + } + + if (!s->name || s->name[0] == '\0') { + fprintf(dst, ""); + } else { + fprintf(dst, " %s", s->name); + } + fprintf(dst, "\n"); + break; case ULAS_SYM_FMT_MLB: switch (s->tok.type) { case ULAS_INT: { diff --git a/src/ulas.h b/src/ulas.h index 43deaa7..9f62e74 100644 --- a/src/ulas.h +++ b/src/ulas.h @@ -142,7 +142,7 @@ struct ulas_tok; enum ulas_warm { ULAS_WARN_OVERFLOW = 1, ULAS_WARN_ALL = 0x7FFFFFFF }; -enum ulas_symfmt { ULAS_SYM_FMT_DEFAULT, ULAS_SYM_FMT_MLB }; +enum ulas_symfmt { ULAS_SYM_FMT_DEFAULT, ULAS_SYM_FMT_SYM, ULAS_SYM_FMT_MLB }; struct ulas_config { // argv represents file names -- 2.30.2