Mercurial > hg > index.cgi
comparison 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 |
comparison
equal
deleted
inserted
replaced
534:558ee362437e | 535:a584b9ddffc4 |
---|---|
30 | 30 |
31 #include <lw_alloc.h> | 31 #include <lw_alloc.h> |
32 #include <lw_expr.h> | 32 #include <lw_expr.h> |
33 | 33 |
34 #include "lwasm.h" | 34 #include "lwasm.h" |
35 #include "instab.h" | |
35 | 36 |
36 void write_code_raw(asmstate_t *as, FILE *of); | 37 void write_code_raw(asmstate_t *as, FILE *of); |
37 void write_code_decb(asmstate_t *as, FILE *of); | 38 void write_code_decb(asmstate_t *as, FILE *of); |
38 void write_code_BASIC(asmstate_t *as, FILE *of); | 39 void write_code_BASIC(asmstate_t *as, FILE *of); |
39 void write_code_rawrel(asmstate_t *as, FILE *of); | 40 void write_code_rawrel(asmstate_t *as, FILE *of); |
243 | 244 |
244 /* | 245 /* |
245 raw merely writes all the bytes directly to the file as is. ORG is just a | 246 raw merely writes all the bytes directly to the file as is. ORG is just a |
246 reference for the assembler to handle absolute references. Multiple ORG | 247 reference for the assembler to handle absolute references. Multiple ORG |
247 statements will produce mostly useless results | 248 statements will produce mostly useless results |
249 | |
250 However, if a run of RMBs exists at the start that is ended by an ORG | |
251 statement, that run of RMBs will not be output as a zero fill. | |
248 */ | 252 */ |
249 void write_code_raw(asmstate_t *as, FILE *of) | 253 void write_code_raw(asmstate_t *as, FILE *of) |
250 { | 254 { |
251 line_t *cl; | 255 line_t *cl; |
252 | 256 line_t *sl; |
253 for (cl = as -> line_head; cl; cl = cl -> next) | 257 |
258 sl = as -> line_head; | |
259 for (cl = sl; cl; cl = cl -> next) | |
260 { | |
261 if (cl -> outputl > 0) | |
262 break; | |
263 if (instab[cl -> insn].flags & lwasm_insn_org) | |
264 sl = cl; | |
265 } | |
266 for (cl = sl; cl; cl = cl -> next) | |
254 { | 267 { |
255 if (cl -> len > 0 && cl -> outputl < 0) | 268 if (cl -> len > 0 && cl -> outputl < 0) |
256 { | 269 { |
257 int i; | 270 int i; |
258 for (i = 0; i < cl -> len; i++) | 271 for (i = 0; i < cl -> len; i++) |