home *** CD-ROM | disk | FTP | other *** search
- ;
- ; SYSLIB Module Name: SCANN
- ; Author: Richard Conn
- ; SYSLIB Version Number: 2.0
- ; Module Version Number: 1.0
- ; Module Entry Points:
- ; SCANNER
- ; Module External References:
- ; None
- ;
-
- ;
- ; SSCANNER --
- ; SCANNER scans the vector of bytes pointed to by HL for
- ; the vector of bytes pointed to by DE. The HL-byte vector is B bytes
- ; long, and the DE-byte vector is C bytes long.
- ; On return, if found, HL points to the beginning location within
- ; the original HL vector of the located vector and Zero Flag is set.
- ; If not found, Zero Flag is not set and HL is unaffected. DE and BC
- ; are not affected by this routine.
- ;
-
- SCANNER::
- PUSH B ; SAVE REGISTERS
- PUSH H
-
- ; MAIN LOOP
- SCAN:
-
- ; CHECK FOR DONE
- MOV A,B ; DONE IF B<C
- CMP C ; DONE?
- JC NOT$FOUND
-
- ; SCAN HL FOR DE FOR C BYTES
- PUSH B ; SAVE BC
- PUSH H ; SAVE PTRS
- PUSH D
- SCANL:
- LDAX D ; GET DE BYTE
- CMP M ; MATCH?
- JNZ NEXT
- INX D ; PT TO NEXT
- INX H
- DCR C ; COUNT DOWN
- JNZ SCANL
-
- ; MATCH!
- POP D ; RESTORE PTRS
- POP H
- POP B ; OLD BC
- POP B ; ORIGINAL HL -- DISCARD
- POP B ; ORIGINAL BC
- RET ; ZERO FLAG IS SET
-
- ; NOT FOUND YET
- NEXT:
- POP D ; RESTORE PTRS
- POP H
- POP B ; GET COUNT
- INX H ; PT TO NEXT IN SCANNED VECTOR
- DCR B ; COUNT DOWN
- JNZ SCAN ; CONTINUE SCANNING
-
- ; NO MATCH!
- NOT$FOUND:
- POP H ; ORIGINAL HL
- POP B ; ORIGINAL BC
- MVI A,0FFH ; NOT FOUND
- ORA A ; SET NOT ZERO
- RET
-
- END
-