home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / OTL-MC6.DMS / in.adf / libsrc.lha / LIBSRC / string_find.asm < prev    next >
Encoding:
Assembly Source File  |  1994-04-16  |  988 b   |  64 lines

  1.  
  2. *    Maxon C++ Library:
  3. *    Modul "string_find"
  4. *    Jens Gelhar 11.09.91, 16.04.94
  5.  
  6.     xdef    _strchr,strchr__PCci
  7.     xdef    _strrchr,strrchr__PCci
  8.     xdef    _strstr,strstr__PCcPCc
  9.  
  10. _strchr:
  11. strchr__PCci:
  12.     move.l    4(a7),a0
  13.     move.l    8(a7),d0
  14. .loop    cmp.b    (a0),d0
  15.     beq.b    .found
  16.     tst.b    (a0)+
  17.     bne.b    .loop
  18.     moveq    #0,d0
  19.     rts
  20. .found    move.l    a0,d0
  21.     rts
  22.  
  23. _strrchr:
  24. strrchr__PCci:
  25.     moveq    #0,d0
  26.     move.l    4(a7),a0
  27.     move.l    8(a7),d1
  28. .loop    cmp.b    (a0),d1
  29.     bne.b    .uneq
  30.     move.l    a0,d0
  31. .uneq    tst.b    (a0)+
  32.     bne.b    .loop
  33.     rts
  34.  
  35. _strstr:
  36. strstr__PCcPCc:
  37.     movem.l    4(a7),a0/a1    ; a1 in a0 suchen!
  38.     tst.b    (a1)
  39.     beq.b    .end        ; a1 == ""
  40.     move.b    (a1),d0
  41. .loop    ; erstmal erstes Zeichen suchen
  42.     cmp.b    (a0),d0
  43.     beq.b    .comp1
  44. .cont1    tst.b    (a0)+
  45.     bne.b    .loop
  46.     ; nicht gefunden:
  47.     moveq    #0,d0
  48.     bra.b    .ret
  49. .comp1    ; Strings vergleichen:
  50.     move.l    a0,d0        ; a0 in d0 merken
  51. .4    move.b    (a1)+,d1
  52.     beq.b    .ret        ; Erfolgreich!
  53.     cmp.b    (a0)+,d1
  54.     beq.b    .4
  55.     ; weitersuchen:
  56.     move.l    d0,a0
  57.     move.l    8(a7),a1
  58.     move.b    (a1),d0
  59.     bra.b    .cont1
  60. .end    move.l    a0,d0
  61. .ret    rts
  62.  
  63.     end
  64.