title fixing toolshed/hdbdos/*.rom with lwtools-4.22 user strick ip 38.101.220.234 vol 1 hdbtools has 13 bytes of RMBs in the middle of the ROM, at offset $1930 after ORG $C000, which is $D930 in the listing. They are not really to be reserved in the ROM, and they have a different ORG than the rest of the ROM. This diff fixes the ROM output by omitting out-of-order line addresses. /box( /b /tt DIFF -y lwasm/output.c /pre( void write_code_raw(asmstate_t *as, FILE *of) void write_code_raw(asmstate_t *as, FILE *of) { { line_t *cl; line_t *cl; line_t *sl; line_t *sl; > int next_addr = -1; // -1 for Unknown. sl = as -> line_head; sl = as -> line_head; for (cl = sl; cl; cl = cl -> next) for (cl = sl; cl; cl = cl -> next) { { if (cl -> outputl > 0) if (cl -> outputl > 0) break; break; if (instab[cl -> insn].flags & lwasm_insn_org) if (instab[cl -> insn].flags & lwasm_insn_org) sl = cl; sl = cl; } } for (cl = sl; cl; cl = cl -> next) for (cl = sl; cl; cl = cl -> next) { { > // Check that lines are correct sequential address, or drop them. > if (next_addr > -1) { > if (cl -> addr -> value != next_addr) { > continue; > } > } else { > next_addr = cl -> addr -> value; > } > if (cl -> len > 0 && cl -> outputl < 0) if (cl -> len > 0 && cl -> outputl < 0) { { int i; int i; for (i = 0; i < cl -> len; i++) for (i = 0; i < cl -> len; i++) writebytes("\0", 1, 1, of); writebytes("\0", 1, 1, of); > next_addr += cl -> len; continue; continue; } } else if (cl -> outputl > 0) | else if (cl -> outputl > 0) { writebytes(cl -> output, cl -> outputl, 1, of); writebytes(cl -> output, cl -> outputl, 1, of); > next_addr += cl -> outputl; > } > } } } } /pre) box)