z80: use signed char for relative offset

Alan Modra amodra@gmail.com
Sun Mar 8 22:30:51 GMT 2026


A char is signed on some hosts, unsigned on others.

	* z80-dis.c (prt_e): Don't use plain char for offset.

diff --git a/opcodes/z80-dis.c b/opcodes/z80-dis.c
index 0c0c19092a2..d5b4c4210d0 100644
--- a/opcodes/z80-dis.c
+++ b/opcodes/z80-dis.c
@@ -111,13 +111,10 @@ prt (struct buffer *buf, disassemble_info * info, const char *txt)
 static int
 prt_e (struct buffer *buf, disassemble_info * info, const char *txt)
 {
-  char e;
-  int target_addr;
-
   if (fetch_data (buf, info, 1))
     {
-      e = buf->data[1];
-      target_addr = (buf->base + 2 + e) & 0xffff;
+      signed char e = buf->data[1];
+      int target_addr = (buf->base + 2 + e) & 0xffff;
       buf->n_used = buf->n_fetch;
       info->fprintf_func (info->stream, "%s0x%04x", txt, target_addr);
     }

-- 
Alan Modra


More information about the Binutils mailing list