Applied patch #2762516
[fw/sdcc] / as / z80 / z80mch.c
index 7ee7c746fecdc1b90b35c20afeeb3664b2e42487..fe999011244ac4ac99d4a8f3dc0b74b030095297 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
@@ -126,6 +133,7 @@ struct mne *mp;
                        if ((t2 != S_R8) || (e2.e_addr != A))
                                ++t1;
                        comma();
+                       clrexpr(&e2);
                        t2 = addr(&e2);
                }
                if (genop(0xCB, op, &e2, 0) || t1)
@@ -140,6 +148,7 @@ struct mne *mp;
                        if ((t2 != S_R8) || (e2.e_addr != A))
                                ++t1;
                        comma();
+                       clrexpr(&e2);
                        t2 = addr(&e2);
                }
                if (genop(0, op, &e2, 1) || t1)
@@ -542,10 +551,16 @@ struct mne *mp;
        case S_DJNZ:
        case S_JR:
                if ((v1 = admode(CND)) != 0 && rf != S_DJNZ) {
+                       if ((v1 &= 0xFF) <= 0x03) {
+                               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,6 +568,7 @@ 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) {