Mercurial > hg > index.cgi
diff lwasm/instab.c @ 519:724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
It seemed useful to have the ability to build up a variable containing
arbitrary text and then to be able to include that in the assembly process
like an include file. So add, undocumented for now, the following:
SETTSTR varname="string"
INCLUDESTSR "string"
"string" must be enclosed in double quotes and may contain most of the usual
escape sequences (\t, \r, etc.) as well as %(varname) to interpolate a
variable value.
To use it to create assembleable source code, you need to make sure it
creates lines (ended by either \r or \n) with appropriate whitespace in
appropriate places.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 19 Dec 2021 17:01:42 -0700 |
parents | 1260b4eec5a5 |
children | a584b9ddffc4 |
line wrap: on
line diff
--- a/lwasm/instab.c Tue Apr 13 15:41:23 2021 -0600 +++ b/lwasm/instab.c Sun Dec 19 17:01:42 2021 -0700 @@ -320,6 +320,10 @@ #define pseudo_resolve_includebin NULL EMITFUNC(pseudo_emit_includebin); +PARSEFUNC(pseudo_parse_includestr); +#define pseudo_resolve_includestr NULL +#define pseudo_emit_includestr NULL + PARSEFUNC(pseudo_parse_include); #define pseudo_resolve_include NULL #define pseudo_emit_include NULL @@ -340,6 +344,10 @@ #define pseudo_resolve_endstruct NULL #define pseudo_emit_endstruct NULL +PARSEFUNC(pseudo_parse_setstr); +#define pseudo_resolve_setstr NULL +#define pseudo_emit_setstr NULL + // convenience ops PARSEFUNC(insn_parse_conv); #define insn_resolve_conv NULL @@ -669,6 +677,7 @@ { "end", { -1, -1, -1, -1 }, pseudo_parse_end, pseudo_resolve_end, pseudo_emit_end, lwasm_insn_normal}, { "includebin", { -1, -1, -1, -1}, pseudo_parse_includebin,pseudo_resolve_includebin, pseudo_emit_includebin, lwasm_insn_normal}, + { "includestr", { -1, -1, -1, -1}, pseudo_parse_includestr,pseudo_resolve_includestr, pseudo_emit_includestr, lwasm_insn_normal}, { "include", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, { "incl", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, { "use", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, @@ -707,6 +716,7 @@ { "endm", { -1, -1, -1, -1}, pseudo_parse_endm, pseudo_resolve_endm, pseudo_emit_endm, lwasm_insn_cond | lwasm_insn_setsym | lwasm_insn_endm}, { "setdp", { -1, -1, -1, -1}, pseudo_parse_setdp, pseudo_resolve_setdp, pseudo_emit_setdp, lwasm_insn_normal}, + { "setstr", { -1, -1, -1, -1}, pseudo_parse_setstr, pseudo_resolve_setstr, pseudo_emit_setstr, lwasm_insn_normal}, { "set", { -1, -1, -1, -1}, pseudo_parse_set, pseudo_resolve_set, pseudo_emit_set, lwasm_insn_setsym},