2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 31.05.1998
|
|
|
|
;
|
|
|
|
; char* strcat (char* dest, const char* src);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _strcat
|
|
|
|
.import popax
|
|
|
|
.importzp ptr1, ptr2, tmp3
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_strcat:
|
2013-05-09 11:56:54 +00:00
|
|
|
sta ptr1 ; Save src
|
|
|
|
stx ptr1+1
|
|
|
|
jsr popax ; Get dest
|
|
|
|
sta ptr2
|
|
|
|
stx ptr2+1
|
|
|
|
sta tmp3 ; Remember for function return
|
|
|
|
ldy #0
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; find end of dest
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
sc1: lda (ptr2),y
|
|
|
|
beq sc2
|
|
|
|
iny
|
|
|
|
bne sc1
|
|
|
|
inc ptr2+1
|
|
|
|
bne sc1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; end found, get offset in y into pointer
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
sc2: tya
|
|
|
|
clc
|
|
|
|
adc ptr2
|
|
|
|
sta ptr2
|
|
|
|
bcc sc3
|
|
|
|
inc ptr2+1
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; copy src
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
sc3: ldy #0
|
|
|
|
sc4: lda (ptr1),y
|
|
|
|
sta (ptr2),y
|
|
|
|
beq sc5
|
|
|
|
iny
|
|
|
|
bne sc4
|
|
|
|
inc ptr1+1
|
|
|
|
inc ptr2+1
|
|
|
|
bne sc4
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; done, return pointer to dest
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
sc5: lda tmp3 ; X does still contain high byte
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|