From e131b6e43286a0a0e4f1639236aa68c51962bf8d Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 4 Dec 2000 20:38:45 +0000 Subject: [PATCH] 65C02 optimizations git-svn-id: svn://svn.cc65.org/cc65/trunk@548 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/optimize.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cc65/optimize.c b/src/cc65/optimize.c index 4421a9bb6..8889e4fb8 100644 --- a/src/cc65/optimize.c +++ b/src/cc65/optimize.c @@ -4106,10 +4106,18 @@ static Line* OptOneBlock (Line* L) Delete = 1; } else if (LineMatch (L, "\tlda\t(")) { if (IsXAddrMode (L)) { - /* lda (zp,x) - if Y and X are both zero, replace by - * load indirect y and save one cycle in some cases. + /* lda (zp,x). */ + /* If X is zero and we have a 65C02 cpu, replace it by + * an indirect load. */ - if (X == 0 && Y == 0) { + if (X == 0 && CPU == CPU_65C02) { + unsigned Len = strlen (L->Line); + L->Line [Len-3] = ')'; + L->Line [Len-2] = '\0'; + /* If Y and X are both zero, replace by load indirect + * y and save one cycle in some cases. + */ + } else if (X == 0 && Y == 0) { char Buf [256]; const char* S = L->Line + 6; char* T = Buf + 6; @@ -4123,6 +4131,15 @@ static Line* OptOneBlock (Line* L) *T = '\0'; L = ReplaceLine (L, Buf); } + } else if (IsYAddrMode (L)) { + /* lda (zp),y. If Y is zero and we have a 65C02 CPU, + * replace it by an indirect load. + */ + if (Y == 0 && CPU == CPU_65C02) { + unsigned Len = strlen (L->Line); + L->Line [Len-3] = ')'; + L->Line [Len-2] = '\0'; + } } /* In any case invalidate A */ A = -1; -- 2.39.5