1
0
mirror of https://github.com/cc65/cc65.git synced 2025-09-23 07:25:11 +00:00

Fixed a bug

git-svn-id: svn://svn.cc65.org/cc65/trunk@89 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2000-06-20 06:53:01 +00:00
parent ea2f5c1309
commit dff9bae70a

View File

@@ -1845,8 +1845,8 @@ static int OptPtrOps1 (Line** Start)
/* Cannot get lines */ /* Cannot get lines */
return 0; return 0;
} }
if (LineFullMatch (L2[3], "\tclc") && if (LineFullMatch (L2[3], "\tclc") &&
LineMatch (L2[4], "\tadc\t#$") && LineMatch (L2[4], "\tadc\t#$") &&
LineFullMatch (L2[5], "\tbcc\t*+3") && LineFullMatch (L2[5], "\tbcc\t*+3") &&
LineFullMatch (L2[6], "\tinx")) { LineFullMatch (L2[6], "\tinx")) {
/* Inlined increment */ /* Inlined increment */
@@ -1860,9 +1860,9 @@ static int OptPtrOps1 (Line** Start)
} }
/* Check for the remainder */ /* Check for the remainder */
if (!LineMatch (L3[0], "\tsta\t") || if (!LineMatch (L3[0], "\tsta\t") ||
strcmp (L3[0]->Line+5, L->Line+5) != 0 || strcmp (L3[0]->Line+5, L->Line+5) != 0 ||
!LineMatch (L3[1], "\tstx\t") || !LineMatch (L3[1], "\tstx\t") ||
strcmp (L3[1]->Line+5, L2[0]->Line+5) != 0 || strcmp (L3[1]->Line+5, L2[0]->Line+5) != 0 ||
!LineFullMatch (L3[2], "\tlda\tregsave") || !LineFullMatch (L3[2], "\tlda\tregsave") ||
!LineFullMatch (L3[3], "\tldx\tregsave+1")) { !LineFullMatch (L3[3], "\tldx\tregsave+1")) {
@@ -1872,18 +1872,14 @@ static int OptPtrOps1 (Line** Start)
} }
/* Check if AX is actually used following the code above. If not, /* Check if AX is actually used following the code above. If not,
* we don't need to load A/X from regsave. Since X will never by * we don't need to load A/X from regsave. Since X will never be
* used without A, check just for A. * used without A, check just for A.
*/ */
NeedLoad = 1; NeedLoad = RegAUsed (L3[3]);
if (!RegAUsed (L3[3])) {
/* We don't need to load regsave */
NeedLoad = 0;
}
/* Special code for register variables */ /* Special code for register variables */
Done = 0; Done = 0;
if (LineMatch (L, "\tlda\tregbank+") && if (LineMatch (L, "\tlda\tregbank+") &&
GetNextCodeLines (L3[3], &L3[4], 1) && GetNextCodeLines (L3[3], &L3[4], 1) &&
Inc == 1) { Inc == 1) {
@@ -2042,8 +2038,8 @@ static int OptPtrOps1 (Line** Start)
/* If we need to load a/x, add the code */ /* If we need to load a/x, add the code */
if (NeedLoad) { if (NeedLoad) {
L = NewLineAfter (L, "\ttax");
L = NewLineAfter (L, "\tlda\tptr1"); L = NewLineAfter (L, "\tlda\tptr1");
L = NewLineAfter (L, "\tldx\tptr1+1");
} }
} }
@@ -2157,11 +2153,7 @@ static int OptPtrOps2 (Line** Start)
* we don't need to load A/X from regsave. Since X will never by * we don't need to load A/X from regsave. Since X will never by
* used without A, check just for A. * used without A, check just for A.
*/ */
NeedLoad = 1; NeedLoad = RegAUsed (L3[0]);
if (!RegAUsed (L3[0])) {
/* We don't need to load regsave */
NeedLoad = 0;
}
/* Replace the ldy instruction, offset must point to the low byte */ /* Replace the ldy instruction, offset must point to the low byte */
sprintf (L->Line+7, "%02X", Offs); sprintf (L->Line+7, "%02X", Offs);
@@ -2251,8 +2243,8 @@ static int OptPtrOps2 (Line** Start)
/* If we need to load a/x, add the code */ /* If we need to load a/x, add the code */
if (NeedLoad) { if (NeedLoad) {
L = NewLineAfter (L, "\ttax");
L = NewLineAfter (L, "\tlda\tptr1"); L = NewLineAfter (L, "\tlda\tptr1");
L = NewLineAfter (L, "\tldx\tptr1+1");
} }
/* Remove the code that is no longer needed */ /* Remove the code that is no longer needed */
@@ -2273,7 +2265,7 @@ static void OptPtrOps (void)
Line* L = FirstCode; Line* L = FirstCode;
while (L) { while (L) {
if (OptPtrOps1 (&L)) { if (OptPtrOps1 (&L)) {
continue; continue;
} else if (OptPtrOps2 (&L)) { } else if (OptPtrOps2 (&L)) {
continue; continue;