From 8ecec344af85960967b7ccb8bcf0a3e4107364c2 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 26 Feb 2024 13:49:41 +0100 Subject: [PATCH] Added header for disas files --- src/uldas.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/uldas.c b/src/uldas.c index cecb44b..c615432 100644 --- a/src/uldas.c +++ b/src/uldas.c @@ -1,11 +1,20 @@ #include "uldas.h" + void ulas_dasm_print_addr(FILE *dst) { if (ulascfg.print_addrs) { fprintf(dst, "%08x ", ulas.address); } } +void ulas_dasm_print_header(FILE *dst) { + if (ulas.pass != ULAS_PASS_FINAL) { + return; + } + ulas_dasm_print_addr(dst); + fprintf(dst, ".org 0x%x\n", ulas.address); +} + // this function assumes the bounds checks // for buf have already been done and will not check anymore! void ulas_dasm_instr_fout(FILE *src, FILE *dst, const struct ulas_instr *instr, @@ -34,7 +43,7 @@ void ulas_dasm_instr_fout(FILE *src, FILE *dst, const struct ulas_instr *instr, val = (short)buf[bi] | (short)(buf[bi + 1] << 8); } bi += 2; - fprintf(dst, "0x%x", val); + fprintf(dst, "0x%x", val & 0xFFFF); break; } default: { @@ -160,6 +169,8 @@ int ulas_dasm(FILE *src, FILE *dst) { // pass 1: run and collect labels // pass 2: run and output to file + ulas_dasm_print_header(dst); + int rc = 0; while ((rc = ulas_dasm_next(src, dst)) > 0) { if (rc == -1) { -- 2.30.2