2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 31.05.1998
|
2017-03-05 01:09:12 +00:00
|
|
|
; Christian Krueger: 2013-Jul-24, minor optimizations
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; char* strcat (char* dest, const char* src);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _strcat
|
|
|
|
.import popax
|
|
|
|
.importzp ptr1, ptr2, tmp3
|
2017-03-05 10:38:55 +00:00
|
|
|
.macpack cpu
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_strcat:
|
2017-02-26 21:36:19 +00:00
|
|
|
sta ptr1 ; Save src
|
|
|
|
stx ptr1+1
|
|
|
|
jsr popax ; Get dest
|
|
|
|
sta tmp3 ; Remember for function return
|
|
|
|
tay
|
2017-03-05 01:09:12 +00:00
|
|
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
|
|
|
stz ptr2
|
|
|
|
.else
|
2017-02-26 21:36:19 +00:00
|
|
|
lda #0
|
|
|
|
sta ptr2 ; access from page start, y contains low byte
|
2017-03-05 01:09:12 +00:00
|
|
|
.endif
|
2017-02-26 21:36:19 +00:00
|
|
|
stx ptr2+1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2017-02-25 19:19:34 +00:00
|
|
|
findEndOfDest:
|
2017-02-26 21:36:19 +00:00
|
|
|
lda (ptr2),y
|
|
|
|
beq endOfDestFound
|
2013-05-09 11:56:54 +00:00
|
|
|
iny
|
2017-02-26 21:36:19 +00:00
|
|
|
bne findEndOfDest
|
|
|
|
inc ptr2+1
|
|
|
|
bne findEndOfDest
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2017-02-25 19:19:34 +00:00
|
|
|
endOfDestFound:
|
2017-02-26 21:36:19 +00:00
|
|
|
sty ptr2 ; advance pointer to last y position
|
|
|
|
ldy #0 ; reset new y-offset
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2017-02-25 19:19:34 +00:00
|
|
|
copyByte:
|
2017-02-26 21:36:19 +00:00
|
|
|
lda (ptr1),y
|
|
|
|
sta (ptr2),y
|
|
|
|
beq done
|
2013-05-09 11:56:54 +00:00
|
|
|
iny
|
2017-02-26 21:36:19 +00:00
|
|
|
bne copyByte
|
|
|
|
inc ptr1+1
|
|
|
|
inc ptr2+1
|
|
|
|
bne copyByte ; like bra here
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2017-02-25 19:19:34 +00:00
|
|
|
; return pointer to dest
|
2017-02-26 21:36:19 +00:00
|
|
|
done: lda tmp3 ; X does still contain high byte
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|