git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5436
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2009-04-19 Philipp Klaus Krause <pkk AT spth.de>
+ * device/lib/z80/shift.s,
+ device/lib/z80/memmove.s,
+ device/lib/z80/mul.s,
+ device/lib/z80/mulchar.s,
+ device/lib/z80/div.s,
+ device/lib/z80/mod.s:
+ Applied patch #2762516 from Marco Bodrato containing minor
+ improvementsof many Z80 asm routines.
+
2009-04-19 Philipp Klaus Krause <pkk AT spth.de>
* support/regression/tests/strtok.c,
2009-04-19 Philipp Klaus Krause <pkk AT spth.de>
* support/regression/tests/strtok.c,
__divuschar_rrx_s::
ld hl,#2+1
__divuschar_rrx_s::
ld hl,#2+1
ld e,c ; DE = quotient, HL = remainder
ex de,hl ; HL = quotient, DE = remainder
ret
ld e,c ; DE = quotient, HL = remainder
ex de,hl ; HL = quotient, DE = remainder
ret
; Copyright (C) 2008-2009
; Copyright (C) 2008-2009
+; Philipp Klaus Krause, Marco Bodrato
; This file is part of the sdcc Library. This library is free
; software; you can redistribute it and/or modify it under the
; This file is part of the sdcc Library. This library is free
; software; you can redistribute it and/or modify it under the
; The Z80 has the ldir and lddr instructions, which are perfect for implementing memmove().
_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)
+ pop af
+ pop hl
+ pop de
+ pop bc
+ push bc
+ push de
+ push hl
+ push af
- 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
+ ret Z
+ push hl
+ sbc hl, de ; or above cleared carry.
+ add hl, de ; same carry as the line before
+ jr C, memmove_up
- dec hl
- ld a, e
- add a, c
- ld e, a
- ld a, d
- adc a, b
- ld d, a
- dec de
+ ex de, hl
+ add hl, bc
+ inc bc
-memmove_end:
- ld l, 4(ix)
- ld h, 5(ix)
- pop ix
+ pop af
+ pop hl
+ pop de
+ push de
+ push hl
+ push af
- ld d,(hl)
- dec hl
- ld e,(hl)
- dec hl
- ld a,(hl)
- dec hl
- ld l,(hl)
- ld h,a
__moduint_rrx_hds::
call __divu16
__moduint_rrx_hds::
call __divu16
__moduschar_rrx_s::
ld hl,#2+1
__moduschar_rrx_s::
ld hl,#2+1
.area _CODE
__mulint_rrx_s::
.area _CODE
__mulint_rrx_s::
- ld hl,#2
- add hl,sp
-
- ld e,(hl)
- inc hl
- ld d,(hl)
- inc hl
- ld a,(hl)
- inc hl
- ld h,(hl)
- ld l,a
+ pop af
+ pop hl
+ pop de
+ push de
+ push hl
+ push af
; still called from some asm files in this directory.
__muluchar_rrx_s::
ld hl, #2+1
; still called from some asm files in this directory.
__muluchar_rrx_s::
ld hl, #2+1
add hl, sp
ld e, (hl)
dec hl
ld h, (hl)
add hl, sp
ld e, (hl)
dec hl
ld h, (hl)
ld b, #8
muluchar_rrx_s_loop:
add hl, hl
ld b, #8
muluchar_rrx_s_loop:
add hl, hl
__mulsuchar_rrx_s::
ld hl,#2+1
__mulsuchar_rrx_s::
ld hl,#2+1
add hl,sp
ld e,(hl)
dec hl
ld c,(hl)
add hl,sp
ld e,(hl)
dec hl
ld c,(hl)
jr signexte
__muluschar_rrx_s::
jr signexte
__muluschar_rrx_s::
- ld c,(hl)
- ld b, #0
- dec hl
jr signexte
;; Originally from GBDK by Pascal Felber.
jr signexte
;; Originally from GBDK by Pascal Felber.
- ld c,(hl)
- dec hl
- ld d,(hl)
- dec hl
- ld e,(hl)
- dec hl
- dec hl
- ld l,(hl)
- ld h,a
-
- ld a,c
-1$:
+ pop bc
+ pop hl
+ pop de
+ push de
+ push hl
+ push bc
+ ld b,a
+ ld a,e
+1$:
+ srl d
+ rra
+ rr h
__rrslong_rrx_s::
ld hl,#2+4
add hl,sp
__rrslong_rrx_s::
ld hl,#2+4
add hl,sp
- ld c,(hl)
- dec hl
- ld d,(hl)
- dec hl
- ld e,(hl)
- dec hl
- dec hl
- ld l,(hl)
- ld h,a
-
- ld a,c
-1$:
+ pop bc
+ pop hl
+ pop de
+ push de
+ push hl
+ push bc
__rlslong_rrx_s::
__rlulong_rrx_s::
ld hl,#2+4
add hl,sp
__rlslong_rrx_s::
__rlulong_rrx_s::
ld hl,#2+4
add hl,sp
- ld c,(hl)
- dec hl
- ld d,(hl)
- dec hl
- ld e,(hl)
- dec hl
- dec hl
- ld l,(hl)
- ld h,a
-
- ld a,c
-1$:
+ pop bc
+ pop hl
+ pop de
+ push de
+ push hl
+ push bc
+ ld b,a
+ ld a,e
+3$:
+ add hl,hl
+ rla
+ rl d
- rl l
- rl h
- rl e
- rl d
-
- dec a
- jp 1$