File tree Expand file tree Collapse file tree 2 files changed +22
-23
lines changed Expand file tree Collapse file tree 2 files changed +22
-23
lines changed Original file line number Diff line number Diff line change 11 assume adl=1
22
33 section .text
4+
45 public _memcpy
56
67if PREFER_OS_LIBC
@@ -10,19 +11,17 @@ _memcpy := $0000A4
1011else
1112
1213_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
2122 ldir
2223.zero:
23- ld hl,(iy + 3 ) ; Return the destination pointer
24+ ld hl, (iy + 4 ) ; Return the destination pointer
2425 ret
2526
2627end if
27-
28-
Original file line number Diff line number Diff line change 88
99; faster when count is zero
1010_mempcpy:
11- ld iy, 0
11+ ld iy, -1
1212 add iy, sp
13- ld bc, (iy + 9 ) ; Load count
13+ ld bc, (iy + 10 ) ; Load count
1414 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
1919 ex de, hl
2020 ldir
2121 ex de, hl
2525
2626; faster in full execution case by 0F + 1 clock cycles
2727_mempcpy:
28- ld iy, 0
28+ ld iy, -1
2929 add iy, sp
30- ld bc, (iy + 9 ) ; Load count
30+ ld bc, (iy + 10 ) ; Load count
3131 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
3636 ldir
3737.zero_byte_copy:
3838 ex de, hl
You can’t perform that action at this time.
0 commit comments