home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ZSYS / SIMTEL20 / SYSLIB / SLIB1.LBR / SCOMP.Z80 < prev    next >
Text File  |  2000-06-30  |  1KB  |  53 lines

  1. ;
  2. ; SYSLIB Module Name:  SCOMP
  3. ; Author:  Richard Conn
  4. ; SYSLIB Version Number:  3.6
  5. ; Module Version Number:  1.1
  6.  
  7.     public    compb,compbc
  8.  
  9. ;
  10. ;  SCOMP --
  11. ;    Vector Compare Routine.  Compare vector pointed to by HL with that
  12. ; pointed to by DE.  Vector is B bytes long for COMPB and BC bytes long for
  13. ; COMPBC.  On exit, Zero Flag Set indicates match, Carry Flag Set indicates
  14. ; that vector pointed to by HL is binarily less than vector pointed to by DE.
  15. ;    PSW is affected.  HL, DE, BC are not affected.
  16. ;
  17. COMPB:
  18.     PUSH    BC    ; SAVE BC
  19.     LD    C,B    ; SET COUNT IN C
  20.     LD    B,0
  21.     CALL    COMPBC    ; USE BC FOR COUNT
  22.     POP    BC    ; RESTORE BC
  23.     RET
  24.  
  25. COMPBC:
  26.     PUSH    HL    ; SAVE REGISTERS
  27.     PUSH    DE
  28.     PUSH    BC
  29.  
  30. ;  COMPARE LOOP
  31. COMP:
  32.     LD    A,(DE)    ; GET BYTE PTED TO BY DE
  33.     CP    (HL)    ; COMPARE TO BYTE PTED TO BY HL
  34.     JP    NZ,COMPDN    ; DONE IF NO MATCH
  35.     INC    HL    ; PT TO NEXT
  36.     INC    DE
  37.     DEC    BC    ; COUNT DOWN
  38.     LD    A,B    ; DONE?
  39.     OR    C
  40.     JP    NZ,COMP
  41.  
  42. ;  DONE WITH COMPARE; Z=>MATCH, C=>(HL)>(DE)
  43. COMPDN:
  44.     JP    Z,CMPDN    ; DON'T COMPLEMENT CARRY IF ZERO SET
  45.     CCF        ; C=>(HL)<(DE)
  46. CMPDN:
  47.     POP    BC    ; RESTORE REGISTERS
  48.     POP    DE
  49.     POP    HL
  50.     RET
  51.  
  52.     END
  53.