From 96393257a43ac52f2b911594d106741245dec5f0 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 4 Dec 2020 15:20:28 -0500 Subject: - Started work on writing the new version of the assembler. - Did alot of stuff in the emulator. - Did alot of stuff in the SuB Suite. --- lexer/symbol.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lexer/symbol.c (limited to 'lexer/symbol.c') diff --git a/lexer/symbol.c b/lexer/symbol.c new file mode 100644 index 0000000..7a8001f --- /dev/null +++ b/lexer/symbol.c @@ -0,0 +1,42 @@ +/* Name: make_local_label() + * Desc: Constructs a local label of the form: + * " " + global_name + " " + local_name + * Args: + * global: Global label name. + * global_len: Length of Global label name. + * local: Local label name. + * local_len: Length of Local label name. + * Return value: Returns the constructed local label. + */ + +char make_local_label(char *global, int global_len, char *local, int local_len) { + char *name; + char *p; + + if (!global_len) { + /* Use last defined global. */ + global = last_global; + global_len = strlen(last_global); + } + name = malloc(local_len+global_len+3); + p = name; + *p++ = ' '; + if (global_len) { + memcpy(p, global, global_len); + p += global_len; + } + *p++ = ' '; + memcpy(p, local, local_len); + p[local_len] = '\0'; + return name; +} + +/* Name: + * Desc: + * Args: + * + * + * + * + * Return value: + */ -- cgit v1.2.3-13-gbd6f