From 8874a80ddd8b544336eba7941a97169b2c8bcbc8 Mon Sep 17 00:00:00 2001 From: cuz Date: Sat, 9 Oct 2004 19:09:35 +0000 Subject: [PATCH] Fixed a bug in inlined memcpy git-svn-id: svn://svn.cc65.org/cc65/trunk@3236 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/stdfunc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 26b224ba1..906634fd1 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -339,9 +339,9 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - if (Offs == 0 || AllowOneIndex) { + if (Offs == 0) { AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs)); @@ -413,13 +413,13 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) Label = GetLocalLabel (); /* Generate memcpy code */ - if (Arg3.Expr.IVal <= 127) { + if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) { - if (Offs == 0 || AllowOneIndex) { - AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1)); + if (Offs == 0) { + AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1)); g_defcodelabel (Label); AddCodeLine ("lda (sp),y"); - AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs)); + AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0)); AddCodeLine ("dey"); AddCodeLine ("bpl %s", LocalLabelName (Label)); } else { -- 2.39.5