diff --git a/libsrc/common/stpcpy.c b/libsrc/common/stpcpy.c deleted file mode 100644 index 12af47f2f3..0000000000 --- a/libsrc/common/stpcpy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -char * __fastcall__ stpcpy (char * dst, const char * src) -{ - strcpy (dst, src); - return dst + strlen (src); -} diff --git a/libsrc/common/stpcpy.s b/libsrc/common/stpcpy.s new file mode 100644 index 0000000000..1f10fca094 --- /dev/null +++ b/libsrc/common/stpcpy.s @@ -0,0 +1,22 @@ +; +; Colin Leroy-Mira, 4 Sept. 2024 +; +; char* stpcpy (char* dest, const char* src); +; + + .export _stpcpy + .import _strcpy + + .importzp tmp1, ptr2 + +_stpcpy: + jsr _strcpy + + ldx ptr2+1 ; Load dest pointer's last high byte + sty tmp1 ; Store low byte's offset + + clc + adc tmp1 ; Add to low byte value + bcc :+ + inx +: rts diff --git a/libsrc/common/strcpy.s b/libsrc/common/strcpy.s index 77b39fe761..b64f4fc907 100644 --- a/libsrc/common/strcpy.s +++ b/libsrc/common/strcpy.s @@ -25,6 +25,5 @@ L1: lda (ptr1),y inc ptr2+1 bne L1 -L9: lda ptr2 ; X still contains high byte +L9: lda ptr2 ; X still contains dest's original high byte rts -