File tree 2 files changed +22
-23
lines changed
2 files changed +22
-23
lines changed Original file line number Diff line number Diff line change 1
1
assume adl=1
2
2
3
3
section .text
4
+
4
5
public _memcpy
5
6
6
7
if PREFER_OS_LIBC
@@ -10,19 +11,17 @@ _memcpy := $0000A4
10
11
else
11
12
12
13
_memcpy:
13
- ld iy,0
14
- add iy,sp
15
- ld bc,(iy + 9 ) ; Load count
16
- sbc hl,hl
17
- sbc hl,bc
18
- jr z, .zero
19
- ld de,(iy + 3 ) ; Load destination
20
- ld hl,(iy + 6 ) ; Load source
14
+ ld iy, -1
15
+ add iy, sp
16
+ ld bc, (iy + 10 ) ; Load count
17
+ sbc hl, hl
18
+ add hl, bc
19
+ jr nc, .zero
20
+ ld de, (iy + 4 ) ; Load destination
21
+ ld hl, (iy + 7 ) ; Load source
21
22
ldir
22
23
.zero:
23
- ld hl,(iy + 3 ) ; Return the destination pointer
24
+ ld hl, (iy + 4 ) ; Return the destination pointer
24
25
ret
25
26
26
27
end if
27
-
28
-
Original file line number Diff line number Diff line change 8
8
9
9
; faster when count is zero
10
10
_mempcpy:
11
- ld iy, 0
11
+ ld iy, -1
12
12
add iy, sp
13
- ld bc, (iy + 9 ) ; Load count
13
+ ld bc, (iy + 10 ) ; Load count
14
14
sbc hl, hl
15
- sbc hl, bc
16
- ld hl, (iy + 3 ) ; Load destination
17
- ret z ; zero bytes to copy
18
- ld de, (iy + 6 ) ; Load source
15
+ add hl, bc
16
+ ld hl, (iy + 4 ) ; Load destination
17
+ ret nc ; zero bytes to copy
18
+ ld de, (iy + 7 ) ; Load source
19
19
ex de, hl
20
20
ldir
21
21
ex de, hl
25
25
26
26
; faster in full execution case by 0F + 1 clock cycles
27
27
_mempcpy:
28
- ld iy, 0
28
+ ld iy, -1
29
29
add iy, sp
30
- ld bc, (iy + 9 ) ; Load count
30
+ ld bc, (iy + 10 ) ; Load count
31
31
sbc hl, hl
32
- sbc hl, bc
33
- ld de, (iy + 3 ) ; Load destination
34
- jr z , .zero_byte_copy ; zero bytes to copy
35
- ld hl, (iy + 6 ) ; Load source
32
+ add hl, bc
33
+ ld de, (iy + 4 ) ; Load destination
34
+ jr nc , .zero_byte_copy ; zero bytes to copy
35
+ ld hl, (iy + 7 ) ; Load source
36
36
ldir
37
37
.zero_byte_copy:
38
38
ex de, hl
You can’t perform that action at this time.
0 commit comments