* device/include/string.h: added size_t typedef, changed
[fw/sdcc] / device / lib / z80 / asm_strings.s
index a6527fb97f5adb1575db4194b69055aa5d0c5d87..1796b4a57017f580289701ea007a989c4517baae 100644 (file)
@@ -51,29 +51,21 @@ __memcpy_rrx_s::
         ;; LDIR:        do; *DE = *HL; HL++; BC--; while BC != 0
         
         ;; All registers are already saved.
-        ld      hl,#2
-        add     hl,sp
-        ld      e,(hl)
-        inc     hl
-        ld      d,(hl)
-        inc     hl
-        ld      a,(hl)
-        inc     hl
-        ld      b,(hl)
-        inc     hl
-        ld      c,(hl)
-        inc     hl
-        ld      h,(hl)
-        ld      l,a
-        ld      a,h
-        ld      h,b
-        ld      b,a
-
-        ;; Pending: could optimise this check to occur earlier.
-        or      c
-        ret     z
-
-        ldir
+       pop     iy      ; iy = return address
+       pop     de      ; de = destination pointer
+       pop     hl      ; hl = source pointer
+       pop     bc      ; bc = count
+       push    bc
+       push    hl
+       push    de
+       ld      a,b
+       or      c
+       jr      z,1$
+       ldir
+1$:
+       pop     hl      ; return hl = original destination pointer
+       push    hl
+       jp      (iy)
         ret
 
 ; int strcmp(const char *s1, const char *s2)