From: cuz Date: Sat, 9 Oct 2004 19:09:35 +0000 (+0000) Subject: Fixed a bug in inlined memcpy X-Git-Tag: V2.12.0~599 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8874a80ddd8b544336eba7941a97169b2c8bcbc8;p=cc65 Fixed a bug in inlined memcpy git-svn-id: svn://svn.cc65.org/cc65/trunk@3236 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- 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 {