home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / intel8051 / i51strf.asm < prev    next >
Assembly Source File  |  2020-01-01  |  897b  |  53 lines

  1.  
  2. ; concantenate string pointed by stack to string pointed by dptr
  3. strcat:    pop    7        ; hi ret
  4.     pop    6        ; lo ret
  5. sc4:    movx    a,@dptr        ; find end of string
  6.     jz    sc3        ; got it
  7.     inc    dptr        ; next char
  8.     sjmp    sc4
  9. sc3:    mov    r0,dpl        ; r0  = lo destination
  10.     mov    dpl,r6        ; dpl = lo source
  11.     mov    r6,dph        ; r6  = hi destination
  12.     mov    dph,r7        ; dph = hi source
  13. sc1:    mov    p2,r6
  14.     movx    a,@dptr
  15.     inc    dptr
  16.     jz    sc2        ; all done
  17.     movx    @r0,a
  18.     inc    r0
  19.     mov    a,r0
  20.     jnz    sc1
  21.     inc    r6        ; next page
  22.     sjmp    sc1
  23. sc2:    movx    @r0,a        ; terminate string
  24.     push    dpl        ; lo ret
  25.     push    dph        ; hi ret
  26.     mov    dpl,r0
  27.     mov    dph,r6
  28.     ret
  29. ;
  30. ; find length of string, return A
  31. strlen:    mov    r2,#0
  32. len2:    movx    a,@dptr
  33.     jz    len1
  34.     inc    dptr
  35.     inc    r2
  36.     sjmp    len2
  37. len1:    mov    a,r2
  38.     ret
  39. ;
  40. ; find char B in string DPTR return index A
  41. strstr:    mov    r2,#0
  42. sstr1:    movx    a,@dptr
  43.     jz    sstr3
  44.     inc    r2
  45.     cjne    a,b,sstr2
  46.     sjmp    sstr4
  47. sstr2:    inc    dptr
  48.     sjmp    sstr1
  49. sstr3:    mov    r2,a
  50. sstr4:    mov    a,r2
  51.     ret
  52.  
  53.