From 46209118b1a77d2e57f28026b1e5916c2c074778 Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 11 Oct 2001 20:06:01 +0000 Subject: [PATCH] The longbranch macros did not work with numeric addresses git-svn-id: svn://svn.cc65.org/cc65/trunk@1039 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/macpack.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/ca65/macpack.c b/src/ca65/macpack.c index 317cf390c..db5c7531f 100644 --- a/src/ca65/macpack.c +++ b/src/ca65/macpack.c @@ -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"