From e56ff7ea8ea1bffdcf4fee43ec8a125453a6ad8d Mon Sep 17 00:00:00 2001 From: spth Date: Fri, 3 Apr 2009 10:41:30 +0000 Subject: [PATCH] Minor improvements, code cleanup and license clarification git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5423 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ device/lib/z80/memmove.s | 28 ++++++++++++++++++++++++++++ device/lib/z80/mul.s | 17 ++++++++--------- device/lib/z80/strlen.s | 38 ++++++++++++++++++++++++++++++++------ 4 files changed, 75 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9805da8f..94693ba9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-04-03 Philipp Klaus Krause + + * device/lib/z80/mul.s, + device/lib/z80/memmove.s, + device/lib/z80/strlen.s: + Minor improvements, code cleanup and license clarification. + 2009-04-01 Philipp Klaus Krause * device/lib/z80/mul.s: diff --git a/device/lib/z80/memmove.s b/device/lib/z80/memmove.s index 76d21a2c..273a1eb5 100644 --- a/device/lib/z80/memmove.s +++ b/device/lib/z80/memmove.s @@ -1,3 +1,31 @@ +; Copyright (C) 2008-2009 +; Philipp Klaus Krause + +; This file is part of the sdcc Library. This library is free +; software; you can redistribute it and/or modify it under the +; terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) +; any later version. + +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. + +; You should have received a copy of the GNU General Public License along +; with this library; see the file COPYING. If not, write to the Free +; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +; USA. + +; As a special exception, you may use this file as part of a free software +; library without restriction. Specifically, if other files instantiate +; templates or use macros or inline functions from this file, or you compile +; this file and link it with other files to produce an executable, this +; file does not by itself cause the resulting executable to be covered by +; the GNU General Public License. This exception does not however +; invalidate any other reasons why the executable file might be covered by +; the GNU General Public License. + .area _CODE .globl _memmove diff --git a/device/lib/z80/mul.s b/device/lib/z80/mul.s index cba10dfe..61ff5cf3 100644 --- a/device/lib/z80/mul.s +++ b/device/lib/z80/mul.s @@ -18,30 +18,29 @@ __mulint_rrx_s:: __muluchar_rrx_hds:: __mulint_rrx_hds:: ;; Parameters: - ;; HL, DE (left, right irrelevant) + ;; hl, de (left, right irrelevant) ld b,h ld c,l ;; 16-bit multiplication ;; ;; Entry conditions - ;; BC = multiplicand - ;; DE = multiplier + ;; bc = multiplicand + ;; de = multiplier ;; ;; Exit conditions - ;; DE = less significant word of product + ;; hl = less significant word of product ;; ;; Register used: AF,BC,DE,HL __mul16:: - ld l,#0 - ld a,b - ld b,#16 + xor a,a + ld l,a + or a,b + ld b,#16 ;; Optimise for the case when this side has 8 bits of data or ;; less. This is often the case with support address calls. - or a jr NZ,2$ - ld b,#8 ld a,c 1$: diff --git a/device/lib/z80/strlen.s b/device/lib/z80/strlen.s index 2eccf70d..583a27ad 100644 --- a/device/lib/z80/strlen.s +++ b/device/lib/z80/strlen.s @@ -1,3 +1,31 @@ +; Copyright (C) 2008-2009 +; Philipp Klaus Krause + +; This file is part of the sdcc Library. This library is free +; software; you can redistribute it and/or modify it under the +; terms of the GNU General Public License as published by the +; Free Software Foundation; either version 2, or (at your option) +; any later version. + +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. + +; You should have received a copy of the GNU General Public License along +; with this library; see the file COPYING. If not, write to the Free +; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +; USA. + +; As a special exception, you may use this file as part of a free software +; library without restriction. Specifically, if other files instantiate +; templates or use macros or inline functions from this file, or you compile +; this file and link it with other files to produce an executable, this +; file does not by itself cause the resulting executable to be covered by +; the GNU General Public License. This exception does not however +; invalidate any other reasons why the executable file might be covered by +; the GNU General Public License. + .area _CODE .globl _strlen @@ -5,17 +33,15 @@ ; The Z80 has the cpir instruction, which is perfect for implementing strlen(). _strlen: - push ix - ld ix, #0 - add ix, sp - ld l, 4(ix) - ld h, 5(ix) + pop bc + pop hl + push hl + push bc xor a, a ld b, a ld c, a cpir ld hl, #-1 sbc hl, bc ; C flag still cleared from xor above. - pop ix ret -- 2.30.2