-
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathstrcat.src
More file actions
46 lines (36 loc) · 653 Bytes
/
strcat.src
File metadata and controls
46 lines (36 loc) · 653 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
36
37
38
39
40
41
42
43
44
45
46
.assume adl=1
.section .text
.global _strcat
.type _strcat, @function
.ifdef PREFER_CE_LIBC
.set _strcat, 0x0000C0
.else
_strcat:
pop iy
pop de
ex (sp), hl ; src
push de ; dst
; move to the end of src
xor a, a
ld bc, 0
push hl ; src
cpir
sbc hl, hl
sbc hl, bc ; carry is set
ex (sp), hl
ex de, hl
; move to the end of dst
; not needed unless the strlen(dst) + strlen(src) > 16777215 bytes,
; which would imply that the resulting string would not fit into memory
; ld bc, 0
cpir
dec hl
pop bc
ex de, hl
; DE = dst + strlen(dst)
; HL = src
; BC = strlen(src) + 1
ldir
ex (sp), hl ; return value
jp (iy)
.endif