1 /*-------------------------------------------------------------------------
4 Copyright (C) 2003, Kevin Vigor
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
31 // FIXME: can optimize even further on '400 with auto-increment/auto-toggle.
33 void __xdata
* memcpyx (
39 /* Shut compiler up about unused parameters. */
43 ; Destination is in DPTR
. Save it on stack so we can
return it at end
.
49 mov dps
, #0x1 ; Alternate DPTR.
51 ; count is in _memcpyx_PARM_3
52 mov dptr
, #_memcpyx_PARM_3
59 ; src is in _memcpyx_PARM_2
60 mov dptr
, #_memcpyx_PARM_2
72 mov dps
, #0x21 ; Current DPTR is alt DPTR, toggle after each op.
74 ; src is in alt DPTR
, dst is in normal DPTR
, count is in r2
/r3
.
76 ; If we have zero bytes to copy
, quick out
.
81 ; increment r3
if r2
!= 0 (makes djnz end
-of
-loop sequence possible
).
83 cjne r2
, #0x0, _memcpyx_loopTop
93 djnz r2
, _memcpyx_loopTop
94 djnz r3
, _memcpyx_loopTop