]> git.sur5r.net Git - cc65/commitdiff
The longbranch macros did not work with numeric addresses
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 11 Oct 2001 20:06:01 +0000 (20:06 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 11 Oct 2001 20:06:01 +0000 (20:06 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1039 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/macpack.c

index 317cf390cc59a0e46f36ed189b2bb7ae578bc7d6..db5c7531f5fe16d317ff2d0066ded82aa53054fd 100644 (file)
@@ -35,7 +35,7 @@
 
 /* common */
 #include "check.h"
-                 
+
 /* ca65 */
 #include "error.h"
 #include "scanner.h"
@@ -72,7 +72,10 @@ static const char MacGeneric [] =    /* Generic macros */
 
 static const char MacLongBranch [] =   /* Long branch macros */
     ".macro  jeq     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bne     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        beq     Target\n"
     "        .else\n"
     "        bne     *+5\n"
@@ -80,7 +83,10 @@ static const char MacLongBranch [] = /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jne     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        beq     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bne     Target\n"
     "        .else\n"
     "        beq     *+5\n"
@@ -88,7 +94,10 @@ static const char MacLongBranch [] = /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jmi     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bpl     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bmi     Target\n"
     "        .else\n"
     "        bpl     *+5\n"
@@ -96,7 +105,10 @@ static const char MacLongBranch [] =        /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jpl     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bmi     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bpl     Target\n"
     "        .else\n"
     "        bmi     *+5\n"
@@ -104,7 +116,10 @@ static const char MacLongBranch [] =       /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jcs     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bcc     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bcs     Target\n"
     "        .else\n"
     "        bcc     *+5\n"
@@ -112,7 +127,10 @@ static const char MacLongBranch [] =       /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jcc     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bcs     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bcc     Target\n"
     "        .else\n"
     "        bcs     *+5\n"
@@ -120,7 +138,10 @@ static const char MacLongBranch [] =       /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jvs     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bvc     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bvs     Target\n"
     "        .else\n"
     "        bvc     *+5\n"
@@ -128,7 +149,10 @@ static const char MacLongBranch [] =       /* Long branch macros */
     "        .endif\n"
     ".endmacro\n"
     ".macro  jvc     Target\n"
-    "        .if     .def(Target) .and ((*+2)-(Target) <= 127)\n"
+    "        .if     .match(Target, 0)\n"
+    "        bvs     *+5\n"
+    "        jmp     Target\n"
+    "        .elseif .def(Target) .and ((*+2)-(Target) <= 127)\n"
     "        bvc     Target\n"
     "        .else\n"
     "        bvs     *+5\n"