comparison 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
comparison
equal deleted inserted replaced
518:b530ff19f7c0 519:724bcc4508bc
318 318
319 PARSEFUNC(pseudo_parse_includebin); 319 PARSEFUNC(pseudo_parse_includebin);
320 #define pseudo_resolve_includebin NULL 320 #define pseudo_resolve_includebin NULL
321 EMITFUNC(pseudo_emit_includebin); 321 EMITFUNC(pseudo_emit_includebin);
322 322
323 PARSEFUNC(pseudo_parse_includestr);
324 #define pseudo_resolve_includestr NULL
325 #define pseudo_emit_includestr NULL
326
323 PARSEFUNC(pseudo_parse_include); 327 PARSEFUNC(pseudo_parse_include);
324 #define pseudo_resolve_include NULL 328 #define pseudo_resolve_include NULL
325 #define pseudo_emit_include NULL 329 #define pseudo_emit_include NULL
326 330
327 PARSEFUNC(pseudo_parse_align); 331 PARSEFUNC(pseudo_parse_align);
337 #define pseudo_emit_struct NULL 341 #define pseudo_emit_struct NULL
338 342
339 PARSEFUNC(pseudo_parse_endstruct); 343 PARSEFUNC(pseudo_parse_endstruct);
340 #define pseudo_resolve_endstruct NULL 344 #define pseudo_resolve_endstruct NULL
341 #define pseudo_emit_endstruct NULL 345 #define pseudo_emit_endstruct NULL
346
347 PARSEFUNC(pseudo_parse_setstr);
348 #define pseudo_resolve_setstr NULL
349 #define pseudo_emit_setstr NULL
342 350
343 // convenience ops 351 // convenience ops
344 PARSEFUNC(insn_parse_conv); 352 PARSEFUNC(insn_parse_conv);
345 #define insn_resolve_conv NULL 353 #define insn_resolve_conv NULL
346 EMITFUNC(insn_emit_conv); 354 EMITFUNC(insn_emit_conv);
667 { "fdbs", { -1, -1, -1, -1 }, pseudo_parse_fdbs, pseudo_resolve_fdbs, pseudo_emit_fdbs, lwasm_insn_normal}, 675 { "fdbs", { -1, -1, -1, -1 }, pseudo_parse_fdbs, pseudo_resolve_fdbs, pseudo_emit_fdbs, lwasm_insn_normal},
668 { "fqb", { -1, -1, -1, -1 }, pseudo_parse_fqb, pseudo_resolve_fqb, pseudo_emit_fqb, lwasm_insn_normal}, 676 { "fqb", { -1, -1, -1, -1 }, pseudo_parse_fqb, pseudo_resolve_fqb, pseudo_emit_fqb, lwasm_insn_normal},
669 { "end", { -1, -1, -1, -1 }, pseudo_parse_end, pseudo_resolve_end, pseudo_emit_end, lwasm_insn_normal}, 677 { "end", { -1, -1, -1, -1 }, pseudo_parse_end, pseudo_resolve_end, pseudo_emit_end, lwasm_insn_normal},
670 678
671 { "includebin", { -1, -1, -1, -1}, pseudo_parse_includebin,pseudo_resolve_includebin, pseudo_emit_includebin, lwasm_insn_normal}, 679 { "includebin", { -1, -1, -1, -1}, pseudo_parse_includebin,pseudo_resolve_includebin, pseudo_emit_includebin, lwasm_insn_normal},
680 { "includestr", { -1, -1, -1, -1}, pseudo_parse_includestr,pseudo_resolve_includestr, pseudo_emit_includestr, lwasm_insn_normal},
672 { "include", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, 681 { "include", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal},
673 { "incl", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, 682 { "incl", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal},
674 { "use", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal}, 683 { "use", { -1, -1, -1, -1 }, pseudo_parse_include, pseudo_resolve_include, pseudo_emit_include, lwasm_insn_normal},
675 684
676 { "align", { -1, -1, -1, -1 }, pseudo_parse_align, pseudo_resolve_align, pseudo_emit_align, lwasm_insn_normal}, 685 { "align", { -1, -1, -1, -1 }, pseudo_parse_align, pseudo_resolve_align, pseudo_emit_align, lwasm_insn_normal},
705 { "macro", { -1, -1, -1, -1}, pseudo_parse_macro, pseudo_resolve_macro, pseudo_emit_macro, lwasm_insn_cond | lwasm_insn_setsym}, 714 { "macro", { -1, -1, -1, -1}, pseudo_parse_macro, pseudo_resolve_macro, pseudo_emit_macro, lwasm_insn_cond | lwasm_insn_setsym},
706 { "macr", { -1, -1, -1, -1}, pseudo_parse_macro, pseudo_resolve_macro, pseudo_emit_macro, lwasm_insn_cond | lwasm_insn_setsym}, 715 { "macr", { -1, -1, -1, -1}, pseudo_parse_macro, pseudo_resolve_macro, pseudo_emit_macro, lwasm_insn_cond | lwasm_insn_setsym},
707 { "endm", { -1, -1, -1, -1}, pseudo_parse_endm, pseudo_resolve_endm, pseudo_emit_endm, lwasm_insn_cond | lwasm_insn_setsym | lwasm_insn_endm}, 716 { "endm", { -1, -1, -1, -1}, pseudo_parse_endm, pseudo_resolve_endm, pseudo_emit_endm, lwasm_insn_cond | lwasm_insn_setsym | lwasm_insn_endm},
708 717
709 { "setdp", { -1, -1, -1, -1}, pseudo_parse_setdp, pseudo_resolve_setdp, pseudo_emit_setdp, lwasm_insn_normal}, 718 { "setdp", { -1, -1, -1, -1}, pseudo_parse_setdp, pseudo_resolve_setdp, pseudo_emit_setdp, lwasm_insn_normal},
719 { "setstr", { -1, -1, -1, -1}, pseudo_parse_setstr, pseudo_resolve_setstr, pseudo_emit_setstr, lwasm_insn_normal},
710 { "set", { -1, -1, -1, -1}, pseudo_parse_set, pseudo_resolve_set, pseudo_emit_set, lwasm_insn_setsym}, 720 { "set", { -1, -1, -1, -1}, pseudo_parse_set, pseudo_resolve_set, pseudo_emit_set, lwasm_insn_setsym},
711 721
712 722
713 { "section", { -1, -1, -1, -1}, pseudo_parse_section, pseudo_resolve_section, pseudo_emit_section, lwasm_insn_normal}, 723 { "section", { -1, -1, -1, -1}, pseudo_parse_section, pseudo_resolve_section, pseudo_emit_section, lwasm_insn_normal},
714 { "sect", { -1, -1, -1, -1}, pseudo_parse_section, pseudo_resolve_section, pseudo_emit_section, lwasm_insn_normal}, 724 { "sect", { -1, -1, -1, -1}, pseudo_parse_section, pseudo_resolve_section, pseudo_emit_section, lwasm_insn_normal},