changeset 535:a584b9ddffc4

Update raw output to work with RMB only definitions at the start It seems useful to be able to define a number of symbols at the start of the source file without generating a run of NUL output. This update adjusts the output to ignore any number of statements that generate no output as long as there is a subsequent ORG statement. If there is no ORG statement after them, the NUL sequence should still appear.
author William Astle <lost@l-w.ca>
date Sat, 14 May 2022 21:30:59 -0600
parents 558ee362437e
children 33a59e232a5b
files lwasm/instab.c lwasm/instab.h lwasm/output.c
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Sat May 14 13:05:43 2022 -0600
+++ b/lwasm/instab.c	Sat May 14 21:30:59 2022 -0600
@@ -643,7 +643,7 @@
 	{ "tstf",		{	0x115d,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
 	{ "tstw",		{	0x105d,	-1,		-1,		-1	},	insn_parse_inh,			insn_resolve_inh,				insn_emit_inh,				lwasm_insn_is6309},
 
-	{ "org",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_org,		pseudo_resolve_org,				pseudo_emit_org,			lwasm_insn_normal},
+	{ "org",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_org,		pseudo_resolve_org,				pseudo_emit_org,			lwasm_insn_org},
 	{ "reorg",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_reorg,		pseudo_resolve_reorg,			pseudo_emit_reorg,			lwasm_insn_normal},
 	{ "equ",		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_equ,		pseudo_resolve_equ,				pseudo_emit_equ,			lwasm_insn_setsym},
 	{ "=",			{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_equ,		pseudo_resolve_equ,				pseudo_emit_equ,			lwasm_insn_setsym},
--- a/lwasm/instab.h	Sat May 14 13:05:43 2022 -0600
+++ b/lwasm/instab.h	Sat May 14 21:30:59 2022 -0600
@@ -49,6 +49,7 @@
 	lwasm_insn_is6809conv	= 1 << 8,	/* insn is 6809 convenience only */
 	lwasm_insn_is6309conv	= 1 << 9,	/* insn is 6309 convenience only */
 	lwasm_insn_isemuext		= 1 << 10,	/* insn is an emulator extension */
+	lwasm_insn_org                  = 1 << 11,      /* insn sets assembly address */
 	lwasm_insn_normal		= 0
 };
 
--- a/lwasm/output.c	Sat May 14 13:05:43 2022 -0600
+++ b/lwasm/output.c	Sat May 14 21:30:59 2022 -0600
@@ -32,6 +32,7 @@
 #include <lw_expr.h>
 
 #include "lwasm.h"
+#include "instab.h"
 
 void write_code_raw(asmstate_t *as, FILE *of);
 void write_code_decb(asmstate_t *as, FILE *of);
@@ -245,12 +246,24 @@
 raw merely writes all the bytes directly to the file as is. ORG is just a
 reference for the assembler to handle absolute references. Multiple ORG
 statements will produce mostly useless results
+
+However, if a run of RMBs exists at the start that is ended by an ORG
+statement, that run of RMBs will not be output as a zero fill.
 */
 void write_code_raw(asmstate_t *as, FILE *of)
 {
 	line_t *cl;
+	line_t *sl;
 	
-	for (cl = as -> line_head; cl; cl = cl -> next)
+	sl = as -> line_head;
+	for (cl = sl; cl; cl = cl -> next)
+	{
+		if (cl -> outputl > 0)
+			break;
+		if (instab[cl -> insn].flags & lwasm_insn_org)
+			sl = cl;
+	}
+	for (cl = sl; cl; cl = cl -> next)
 	{
 		if (cl -> len > 0 && cl -> outputl < 0)
 		{