home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zslsrc36.lbr / COMPLW.ZZ0 / COMPLW.Z80
Encoding:
Text File  |  1992-03-09  |  1.4 KB  |  46 lines

  1. ; Library:    ZSLIB
  2. ; Version:    3.6
  3. ; Module:    COMPLW
  4. ; Version:    1.0
  5. ; Author:    Gene Pizzetta
  6. ; Date:        March 9, 1992
  7. ; Comment:    Modified from work by Leventhal and Saville.
  8. ;
  9. ; COMPLW -- compares two 4-byte (32-bit) binary numbers.
  10. ;
  11. ; Entry: HL = address of 32-bit integer (4-bytes, low-byte first)
  12. ;     DE = address of 32-bit integer (4-bytes, low-byte first)
  13. ; Exit:     Zero flag set (Z) if values are equal (HL = DE)
  14. ;     Carry flag set (C) if value<-HL is less than value<-DE number (HL < DE)
  15. ;     Carry flag reset (NC) if value<-HL is greater than value<-DE (HL > DE)
  16. ; Uses:     AF
  17. ; Notes: Both integers are unaffected by this routine.
  18. ;
  19.     PUBLIC    COMPLW
  20. ;
  21. COMPLW:    push    bc        ; save registers
  22.     push    de
  23.     push    hl
  24.     ld    bc,4        ; put number of bytes in BC
  25.     add    hl,bc
  26.     ex    de,hl        ; DE points to end of HL integer
  27.     add    hl,bc        ; HL points to end of DE integer
  28.     ld    b,c        ; copy number of bytes to B
  29.     or    a        ; clear carry before entering loop
  30. ;
  31. ; LWLoop -- Subtract bytes, starting with most significant
  32. ;
  33. LWLoop:    dec    hl        ; point to next less significant byte
  34.     dec    de
  35.     ld    a,(de)        ; get next byte of HL integer
  36.     sbc    a,(hl)        ; subtract byte of DE integer
  37.     jr    nz,LWExit    ; not equal, return with flags set accordingly
  38.     djnz    LWLoop        ; continue until all bytes compared
  39. ;
  40. LWExit:    pop    hl        ; restore registers
  41.     pop    de
  42.     pop    bc
  43.     ret
  44. ;
  45.     end
  46.