home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / sigmv089.ark / SCOMP.MAC < prev    next >
Encoding:
Text File  |  1984-04-29  |  1.1 KB  |  57 lines

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