* as/z80/z80mch.c: fixed bug #1704376: missing as-z80 errors
[fw/sdcc] / as / z80 / z80mch.c
index 785087487c0b21cfa275db623febbf065a9a28d3..d9609938b46d64a929deef2f4677a141dc7a661d 100644 (file)
@@ -1,13 +1,20 @@
-/* z80mch.c */
+/* z80mch.c
 
-/*
- * (C) Copyright 1989-1995
- * All Rights Reserved
- *
- * Alan R. Baldwin
- * 721 Berkeley St.
- * Kent, Ohio  44240
- */
+   Copyright (C) 1989-1995 Alan R. Baldwin
+   721 Berkeley St., Kent, Ohio 44240
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 /*
  * Extensions: P. Felber
@@ -30,7 +37,7 @@ VOID
 machine(mp)
 struct mne *mp;
 {
-       register op, t1, t2;
+       register int op, t1, t2;
        struct expr e1, e2;
        int rf, v1, v2;
 
@@ -542,10 +549,16 @@ struct mne *mp;
        case S_DJNZ:
        case S_JR:
                if ((v1 = admode(CND)) != 0 && rf != S_DJNZ) {
-#else GAMEBOY
+                       if ((v1 &= 0xFF) <= 0x18 && v1 != PO && v1 != PE && v1 != P && v1 != M) {
+                               op += (v1+1)<<3;
+                       } else {
+                               aerr();
+                       }
+                       comma();
+               }
+#else /* GAMEBOY */
        case S_JR:
                if ((v1 = admode(CND)) != 0) {
-#endif /* GAMEBOY */
                        if ((v1 &= 0xFF) <= 0x18) {
                                op += (v1+1)<<3;
                        } else {
@@ -553,11 +566,12 @@ struct mne *mp;
                        }
                        comma();
                }
+#endif /* GAMEBOY */
                expr(&e2, 0);
                outab(op);
                if (e2.e_base.e_ap == NULL || e2.e_base.e_ap == dot.s_area) {
                        v2 = e2.e_addr - dot.s_addr - 1;
-                       if ((v2 < -128) || (v2 > 127))
+                       if (pass == 2 && ((v2 < -128) || (v2 > 127)))
                                aerr();
                        outab(v2);
                } else {