Package: z80asm
Version: 1.5-1
Severity: normal
Tags: patch

Hi

The following assembler program causes "a.asm:7: error: relative jump
out of range (65537)":

        nop
label:
        nop
        ds 64*1024-4,0
        ;jr label       ;works
        ;jr 1           ;works
        jr $+3          ;error
        ;jr label2      ;works

label2: equ     1

This "jr" instruction is valid because the program counter wraps around
when jump is executed (this program fills the entire Z80 address space).
The error is only reported when "$" is used in the argument to "jr".
With other jump instructions, which should produce equivalent code, the
program assembles correctly.

I believe the patch below fixes the problem (but it could be it just
fixes symptoms of a bug deeper down in the expression evaluation code).

Best regards
Tomaz

diff -ru z80asm-1.5/z80asm.c z80asm-1.5-new/z80asm.c
--- z80asm-1.5/z80asm.c 2007-06-14 12:26:47.000000000 +0200
+++ z80asm-1.5-new/z80asm.c     2007-06-28 23:39:31.000000000 +0200
@@ -1397,6 +1397,8 @@
       return;
     case TYPE_RELB:
       val -= count;
+      if (val >= 0x10000)
+        val -= 0x10000;
       if (val < -128 || val > 127)
        {
          printerr (1, "relative jump out of range (%d)\n", val);

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.18-4-k7 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages z80asm depends on:
ii  libc6                         2.5-9+b1   GNU C Library: Shared libraries

z80asm recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to