home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol090 / sscanner.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  1.3 KB  |  74 lines

  1. ;
  2. ; SYSLIB Module Name:  SCANN
  3. ; Author:  Richard Conn
  4. ; SYSLIB Version Number:  2.0
  5. ; Module Version Number:  1.0
  6. ; Module Entry Points:
  7. ;    SCANNER
  8. ; Module External References:
  9. ;    None
  10. ;
  11.  
  12. ;
  13. ;  SSCANNER --
  14. ;    SCANNER scans the vector of bytes pointed to by HL for
  15. ; the vector of bytes pointed to by DE.  The HL-byte vector is B bytes
  16. ; long, and the DE-byte vector is C bytes long.
  17. ;    On return, if found, HL points to the beginning location within
  18. ; the original HL vector of the located vector and Zero Flag is set.
  19. ; If not found, Zero Flag is not set and HL is unaffected.  DE and BC
  20. ; are not affected by this routine.
  21. ;
  22.  
  23. SCANNER::
  24.     PUSH    B    ; SAVE REGISTERS
  25.     PUSH    H
  26.  
  27. ; MAIN LOOP
  28. SCAN:
  29.  
  30. ; CHECK FOR DONE
  31.     MOV    A,B    ; DONE IF B<C
  32.     CMP    C    ; DONE?
  33.     JC    NOT$FOUND
  34.  
  35. ; SCAN HL FOR DE FOR C BYTES
  36.     PUSH    B    ; SAVE BC
  37.     PUSH    H    ; SAVE PTRS
  38.     PUSH    D
  39. SCANL:
  40.     LDAX    D    ; GET DE BYTE
  41.     CMP    M    ; MATCH?
  42.     JNZ    NEXT
  43.     INX    D    ; PT TO NEXT
  44.     INX    H
  45.     DCR    C    ; COUNT DOWN
  46.     JNZ    SCANL
  47.  
  48. ;  MATCH!
  49.     POP    D    ; RESTORE PTRS
  50.     POP    H
  51.     POP    B    ; OLD BC
  52.     POP    B    ; ORIGINAL HL -- DISCARD
  53.     POP    B    ; ORIGINAL BC
  54.     RET        ; ZERO FLAG IS SET
  55.  
  56. ;  NOT FOUND YET
  57. NEXT:
  58.     POP    D    ; RESTORE PTRS
  59.     POP    H
  60.     POP    B    ; GET COUNT
  61.     INX    H    ; PT TO NEXT IN SCANNED VECTOR
  62.     DCR    B    ; COUNT DOWN
  63.     JNZ    SCAN    ; CONTINUE SCANNING
  64.  
  65. ;  NO MATCH!
  66. NOT$FOUND:
  67.     POP    H    ; ORIGINAL HL
  68.     POP    B    ; ORIGINAL BC
  69.     MVI    A,0FFH    ; NOT FOUND
  70.     ORA    A    ; SET NOT ZERO
  71.     RET
  72.  
  73.     END
  74.