From c356ab8bcad89fe7c989ccdd82a3c58d0ea05d0e Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 26 Feb 2024 17:10:13 +0100 Subject: [PATCH] Disas now produces code that will compile back to unit test binary. TODO: add this to tests --- src/uldas.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uldas.c b/src/uldas.c index 7e222ff..d526dc5 100644 --- a/src/uldas.c +++ b/src/uldas.c @@ -32,15 +32,15 @@ void ulas_dasm_instr_fout(FILE *src, FILE *dst, const struct ulas_instr *instr, switch (dat) { case ULAS_E8: case ULAS_A8: - fprintf(dst, "0x%x", buf[bi++]); + fprintf(dst, "0x%x", buf[bi++] & 0xFF); break; case ULAS_A16: case ULAS_E16: { unsigned short val = 0; if (ulas.arch.endianess == ULAS_BE) { - val = (short)buf[bi + 1] | (short)(buf[bi] << 8); + val = (unsigned short)(buf[bi + 1] & 0xFF) | (unsigned short)((buf[bi] & 0xFF) << 8); } else { - val = (short)buf[bi] | (short)(buf[bi + 1] << 8); + val = (unsigned short)(buf[bi] & 0xFF) | (unsigned short)((buf[bi + 1] & 0xFF) << 8); } bi += 2; fprintf(dst, "0x%x", val & 0xFFFF); -- 2.30.2