2 ; Ullrich von Bassewitz, 2003-08-20
4 ; void* __fastcall__ memcpy (void* dest, const void* src, size_t n);
6 ; NOTE: This function contains entry points for memmove, which will ressort
7 ; to memcpy for an upwards copy. Don't change this module without looking
11 .export _memcpy, memcpy_upwards, memcpy_getparams
13 .importzp ptr1, ptr2, ptr3, tmp1
15 ; ----------------------------------------------------------------------
21 ldx ptr3 ; Get low counter byte
25 @L1: inx ; Bump low counter byte
26 beq @L3 ; Jump on overflow
31 inc ptr1+1 ; Bump pointers
33 bne @L1 ; Branch always
34 @L3: inc ptr3+1 ; Bump high counter byte
37 ; Done. The low byte of dest is still in ptr2
40 ldx tmp1 ; get function result (dest)
43 ; ----------------------------------------------------------------------
44 ; Get the parameters from stack as follows:
51 ; dest is returned in a/x.
58 sta ptr3+1 ; Save -(size-1)
66 stx ptr2+1 ; Save work copy
67 stx tmp1 ; Save for function result