From 9e2e3f0fc5a542a4fcf1b43cec83fe0054395bd0 Mon Sep 17 00:00:00 2001 From: spth Date: Fri, 26 Dec 2008 10:23:35 +0000 Subject: [PATCH] Implemented RFE #1914256 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5300 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ device/lib/Makefile.in | 2 +- device/lib/z80/Makefile.in | 2 +- device/lib/z80/memmove.s | 44 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 device/lib/z80/memmove.s diff --git a/ChangeLog b/ChangeLog index ece91a9b..d53ff388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-12-26 Philipp Klaus Krause + * device/lib/z80/Makefile.in, + device/lib/Makefile.in, + device/lib/z80/memmove.s: Implemented RFE #1914256 + 2008-12-26 Philipp Klaus Krause * src/z80/peeph-z80.def: fixed a bug in peephole 0zf diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index fa743b6d..94d3214f 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -124,7 +124,7 @@ Z80SOURCES = \ _strcspn.c _strlen.c _strncat.c _strncmp.c \ _strncpy.c _strpbrk.c _strrchr.c _strspn.c \ _strstr.c _strtok.c \ - _memcmp.c _memcpy.c _memmove.c _memset.c \ + _memcmp.c _memcpy.c _memset.c \ _calloc.c _malloc.c _realloc.c _free.c \ printf_large.c sprintf.c vprintf.c puts.c gets.c \ assert.c time.c \ diff --git a/device/lib/z80/Makefile.in b/device/lib/z80/Makefile.in index 31b5c64f..45d8a86d 100644 --- a/device/lib/z80/Makefile.in +++ b/device/lib/z80/Makefile.in @@ -8,7 +8,7 @@ TOPDIR = ../../.. SCC = $(TOPDIR)/bin/sdcc -mz80 SAS = $(TOPDIR)/bin/as-z80 -OBJ = div.o mul.o putchar.o shift.o stubs.o crt0_rle.o heap.o fstubs.o +OBJ = div.o mul.o putchar.o shift.o stubs.o crt0_rle.o heap.o fstubs.o memmove.o LIB = z80.lib CC = $(SCC) diff --git a/device/lib/z80/memmove.s b/device/lib/z80/memmove.s new file mode 100644 index 00000000..55462ef8 --- /dev/null +++ b/device/lib/z80/memmove.s @@ -0,0 +1,44 @@ + .area _CODE + + .globl _memmove + +; The Z80 has the ldir and lddr instructions, which are perfect for implementing memmove(). + +_memmove: + push ix + ld ix,#0 + add ix,sp + ld c, 8(ix) + ld b, 9(ix) + ld a, c + or a, b + jr Z, memmove_end + ld e, 4(ix) + ld d, 5(ix) + ld l, 6(ix) + ld h, 7(ix) + ld a, l + sbc hl, de ; or above cleared carry. + ld l, a + ld h, 7(ix) + jr NC, memmove_up +memmove_down: + add hl, bc + dec hl + ld a, e + add a, c + ld e, a + ld a, d + adc a, b + ld d, a + dec de + lddr + jr memmove_end +memmove_up: + ldir +memmove_end: + ld l, 4(ix) + ld h, 5(ix) + pop ix + ret + -- 2.30.2