-
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathmemcpy.src
More file actions
35 lines (29 loc) · 704 Bytes
/
memcpy.src
File metadata and controls
35 lines (29 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.assume adl=1
.section .text
.global _memcpy
.type _memcpy, @function
; Note: TiOS memcpy works fine, but our implementation is faster
; .set _memcpy, 0x0000A4
_memcpy:
; size > 0 : 25F + 15R + 1 + LDIR
; size >= 65536 : 32F + 16R + 3 + LDIR (only when the low 16 bits are zero)
; size == 0 : 26F + 13R + 2
ld iy, 0
add iy, sp
ld bc, (iy + 9) ; Load count
ld a, c
or a, b
ld de, (iy + 3) ; Load destination
jr z, .L.maybe_zero
.L.not_zero:
ld hl, (iy + 6) ; Load source
ldir
ld hl, (iy + 3) ; Return the destination pointer
ret
.L.maybe_zero:
; low 16 bits are zero
or a, (iy + 11) ; test upper 8 bits
jr nz, .L.not_zero ; size >= 65536
; size == 0
ex de, hl
ret