diff lwasm/output.c @ 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 a812bb4d3a51
children 33a59e232a5b
line wrap: on
line diff
--- 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)
 		{