+2009-04-03 Philipp Klaus Krause <pkk AT spth.de>
+
+ * 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 <pkk AT spth.de>
* device/lib/z80/mul.s:
+; 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
__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$:
+; 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
; 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