home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / modem / ccredir.zip / FINDSIG.ASM < prev   
Assembly Source File  |  1992-04-03  |  968b  |  33 lines

  1. ;put into the public domain by Russell Nelson, nelson@clutx.clarkson.edu
  2.  
  3. find_signature:
  4. ;find a signature somewhere in memory.
  5. ;enter with ds:si -> our signature, al = first letter of signature.
  6. ;exit with es:di -> their signature, zr if we found ourselves.
  7.     mov    [si],al            ;set the proper first char.
  8.     mov    ax,60h            ;can't possibly be lower than this.
  9. find_signature_1:
  10.     mov    es,ax            ;go to the current paragraph.
  11.     mov    di,si
  12.     and    di,0fh
  13. find_signature_3:
  14.     push    si            ;see if this is the signature string.
  15.     push    di
  16.     push    cx
  17.     repe    cmpsb
  18.     pop    cx
  19.     pop    di
  20.     pop    si
  21.     je    find_signature_2    ;we found it!
  22.     add    di,10h            ;move up a paragraph.
  23.     cmp    di,0fffh        ;have we searched far enough?
  24.     jb    find_signature_3    ;not yet.
  25.     add    ax,100h
  26.     jmp    find_signature_1    ;we'll eventually find our own.
  27. find_signature_2:
  28.     not    byte ptr [si]        ;invert the first letter.
  29.     mov    al,[si]            ;if the signature still matches,
  30.     cmp    al,es:[di]        ;return zr if we found ours.
  31.     ret
  32.  
  33.