home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
intel8051.tar.gz
/
intel8051.tar
/
i51strf.asm
< prev
next >
Wrap
Assembly Source File
|
1996-06-30
|
897b
|
53 lines
; concantenate string pointed by stack to string pointed by dptr
strcat: pop 7 ; hi ret
pop 6 ; lo ret
sc4: movx a,@dptr ; find end of string
jz sc3 ; got it
inc dptr ; next char
sjmp sc4
sc3: mov r0,dpl ; r0 = lo destination
mov dpl,r6 ; dpl = lo source
mov r6,dph ; r6 = hi destination
mov dph,r7 ; dph = hi source
sc1: mov p2,r6
movx a,@dptr
inc dptr
jz sc2 ; all done
movx @r0,a
inc r0
mov a,r0
jnz sc1
inc r6 ; next page
sjmp sc1
sc2: movx @r0,a ; terminate string
push dpl ; lo ret
push dph ; hi ret
mov dpl,r0
mov dph,r6
ret
;
; find length of string, return A
strlen: mov r2,#0
len2: movx a,@dptr
jz len1
inc dptr
inc r2
sjmp len2
len1: mov a,r2
ret
;
; find char B in string DPTR return index A
strstr: mov r2,#0
sstr1: movx a,@dptr
jz sstr3
inc r2
cjne a,b,sstr2
sjmp sstr4
sstr2: inc dptr
sjmp sstr1
sstr3: mov r2,a
sstr4: mov a,r2
ret