From 387a113c525527a9b43b7c1c20cfc7a36ccd19b3 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Sat, 11 Oct 2025 17:28:44 +0100 Subject: [PATCH] More MASM compatibility and bug fixes --- intel.c | 23 +++++++++++++++++------ kwd.c | 3 ++- process.c | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/intel.c b/intel.c index 12fa84c..abfdb9d 100644 --- a/intel.c +++ b/intel.c @@ -2185,14 +2185,13 @@ static struct pseudo_op_entry pseudo_op_table[] = { void machine_dependent_init (void) { + struct template *template = template_table; struct hashtab_name *key; struct reg_entry *reg_entry; struct templates *templates; - struct template *template = template_table; struct model_entry *model_entry; - int ch; templates = xmalloc (sizeof (*templates)); @@ -2421,7 +2420,19 @@ void machine_dependent_handle_segment (char *start, char **pp, char *name) { break; } - if (xstrcasecmp (arg, "use16") == 0) { + if (xstrcasecmp (arg, "byte") == 0) { + + /* TODO: Figure out what needs to be done. */ + + } else if (xstrcasecmp (arg, "word") == 0) { + + /* TODO: Figure out what needs to be done. */ + + } else if (xstrcasecmp (arg, "public") == 0) { + + /* TODO: Figure out what needs to be done. */ + + } else if (xstrcasecmp (arg, "use16") == 0) { machine_dependent_set_march ("i8086+8087"); bits = 16; @@ -2431,11 +2442,11 @@ void machine_dependent_handle_segment (char *start, char **pp, char *name) { machine_dependent_set_march ("i386+387"); bits = 32; - } else if (xstrcasecmp (arg, "code")) { + } else if (xstrcasecmp (arg, "code") == 0) { section_set_by_name (".text"); - } else if (xstrcasecmp (arg, "data")) { + } else if (xstrcasecmp (arg, "data") == 0) { section_set_by_name (".data"); - } else if (xstrcasecmp (arg, "bss")) { + } else if (xstrcasecmp (arg, "bss") == 0) { section_set_by_name (".bss"); } else { diff --git a/kwd.c b/kwd.c index 125a158..55fd366 100644 --- a/kwd.c +++ b/kwd.c @@ -2,6 +2,7 @@ * @file kwd.c *****************************************************************************/ #include +#include #include #include @@ -198,7 +199,7 @@ static void align_bytes (char *start, char **pp, int first_arg_is_bytes) { void machine_dependent_number_to_chars (unsigned char *p, uint64_t number, unsigned int size); -unsigned long array_to_integer (unsigned char *arr, int size) { +static unsigned long array_to_integer (unsigned char *arr, int size) { unsigned long value = 0; int i; diff --git a/process.c b/process.c index bb1f4a5..0303a6a 100644 --- a/process.c +++ b/process.c @@ -141,6 +141,13 @@ static char *preprocess_line (char *src, int in_macro) { } + if (xstrcasecmp (sname, "DGROUP") == 0 && *caret == ':') { + + caret++; + continue; + + } + cstr_cat (&cstr, start, caret - start); continue; @@ -922,6 +929,7 @@ static void handle_org (char *start, char **pp) { } extern void machine_dependent_assemble_line (char *start, char *line); +extern void machine_dependent_handle_label (char *start, char **line); extern void machine_dependent_handle_proc (char *start, char **pp, char *name); extern void machine_dependent_handle_endp (char *start, char *name); @@ -1111,6 +1119,18 @@ static void process_line (char *line, char *line_end) { } + if (xstrcasecmp (directive, "label") == 0) { + + symbol = symbol_label (start, caret, arg); + symbol->scope = SYMBOL_SCOPE_LOCAL; + + free (directive); + + ignore_rest_of_line (&line); + goto check; + + } + if (xstrcasecmp (directive, "proc") == 0) { machine_dependent_handle_proc (start, &line, arg); -- 2.34.1