home *** CD-ROM | disk | FTP | other *** search
- ; Library: ZSLIB
- ; Version: 3.6
- ; Module: COMPLW
- ; Version: 1.0
- ; Author: Gene Pizzetta
- ; Date: March 9, 1992
- ; Comment: Modified from work by Leventhal and Saville.
- ;
- ; COMPLW -- compares two 4-byte (32-bit) binary numbers.
- ;
- ; Entry: HL = address of 32-bit integer (4-bytes, low-byte first)
- ; DE = address of 32-bit integer (4-bytes, low-byte first)
- ; Exit: Zero flag set (Z) if values are equal (HL = DE)
- ; Carry flag set (C) if value<-HL is less than value<-DE number (HL < DE)
- ; Carry flag reset (NC) if value<-HL is greater than value<-DE (HL > DE)
- ; Uses: AF
- ; Notes: Both integers are unaffected by this routine.
- ;
- PUBLIC COMPLW
- ;
- COMPLW: push bc ; save registers
- push de
- push hl
- ld bc,4 ; put number of bytes in BC
- add hl,bc
- ex de,hl ; DE points to end of HL integer
- add hl,bc ; HL points to end of DE integer
- ld b,c ; copy number of bytes to B
- or a ; clear carry before entering loop
- ;
- ; LWLoop -- Subtract bytes, starting with most significant
- ;
- LWLoop: dec hl ; point to next less significant byte
- dec de
- ld a,(de) ; get next byte of HL integer
- sbc a,(hl) ; subtract byte of DE integer
- jr nz,LWExit ; not equal, return with flags set accordingly
- djnz LWLoop ; continue until all bytes compared
- ;
- LWExit: pop hl ; restore registers
- pop de
- pop bc
- ret
- ;
- end