Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			107 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			NASM
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			NASM
		
	
	
		
			Executable File
		
	
	
	
	
 ; int  _CompareUnsArr(src1,src2,n)
 | 
						|
 ;
 | 
						|
 ; ARGUMENT
 | 
						|
 ;      src1, src2 point to unsigned arrays of length 'n'
 | 
						|
 ;
 | 
						|
 ; DESCRIPTION
 | 
						|
 ;
 | 
						|
 ;      Compares src1 to scr2. Src1 and Src2 remain unchanged.
 | 
						|
 ;
 | 
						|
 ; SIDE EFFECTS
 | 
						|
 ;      None.
 | 
						|
 ;
 | 
						|
 ; RETURNS
 | 
						|
 ;      Returns zero if src1=src2, 1 if src1>src2, -1 if src2>src1.
 | 
						|
 ;
 | 
						|
 ; AUTHOR
 | 
						|
 ;  Andy Anderson   14-JAN-1987  14:45
 | 
						|
 ;   Copyright (C) 1987-90 Greenleaf Software Inc.  All Rights Reserved.
 | 
						|
 ;
 | 
						|
 ; MODIFICATIONS
 | 
						|
 ;
 | 
						|
 ;
 | 
						|
 ;
 | 
						|
        include model.h
 | 
						|
        include prologue.h
 | 
						|
        include gm.equ
 | 
						|
 | 
						|
 | 
						|
        pseg    gmath
 | 
						|
;
 | 
						|
;  if large memory model then:
 | 
						|
;
 | 
						|
;       parm1_ = ptr to source 1
 | 
						|
;       parm3_ = ptr to source 2;
 | 
						|
;       parm5_ = number of unsigned's to compare
 | 
						|
;
 | 
						|
;  for if small model then
 | 
						|
;       parm1_ = ptr to source1
 | 
						|
;       parm2_ = ptr to source2
 | 
						|
;       parm3_ = number of unsigned's to compare
 | 
						|
;
 | 
						|
        cproc   _CompareUnsArr,,_gcmp
 | 
						|
if      _LDATA
 | 
						|
        push    ds
 | 
						|
        push    es
 | 
						|
        lds     si,parm1_       ; ptr to a
 | 
						|
        les     di,parm3_       ; ptr to b
 | 
						|
        mov     cx,parm5_       ; number of ints to compare
 | 
						|
else
 | 
						|
        mov     si,parm1_
 | 
						|
        mov     di,parm2_
 | 
						|
        mov     cx,parm3_
 | 
						|
endif
 | 
						|
;
 | 
						|
;       then do the compare, starting at the most significant bits
 | 
						|
;  which are considered signed, others are unsigned
 | 
						|
;
 | 
						|
        mov     bx,cx           ; make number of unsigned's an
 | 
						|
        sal     bx,1            ;  offset into array
 | 
						|
        sub     bx,2            ;  now yy+bx pts to last int
 | 
						|
        mov     ax,[bx+si]      ; src1 msb
 | 
						|
if      _LDATA
 | 
						|
        cmp     ax,Word Ptr es:[bx+di]
 | 
						|
else
 | 
						|
        cmp     ax,Word Ptr [bx+di]
 | 
						|
endif
 | 
						|
        ja      g1              ; src1>src2 unsigned!
 | 
						|
        jb      l1              ; src1<src2 unsigned!
 | 
						|
        sub     cx,1            ; find out if done before loop
 | 
						|
        jz      done            ; they were equal and we're done
 | 
						|
        sub     bx,2            ; move back one word in array
 | 
						|
cmplp:
 | 
						|
if      _LDATA
 | 
						|
        mov     ax,[bx+si]      ; get next src1 word
 | 
						|
        cmp     ax,Word Ptr es:[bx+di]
 | 
						|
        ja      g1              ; src1>src2 unsigned
 | 
						|
        jb      l1              ; src1<src2 unsigned!
 | 
						|
        sub     bx,2            ; decrement offset
 | 
						|
        loop    cmplp           ; not done
 | 
						|
else
 | 
						|
        mov     ax,[bx+si]      ; get next src1 word
 | 
						|
        cmp     ax,Word Ptr [bx+di]
 | 
						|
        ja      g1              ; src1>src2 unsigned
 | 
						|
        jb      l1              ; src1<src2 unsigned!
 | 
						|
        sub     bx,2            ; decrement offset
 | 
						|
        loop    cmplp           ; not done
 | 
						|
endif
 | 
						|
;
 | 
						|
;       If we fall through, then both are equal
 | 
						|
;
 | 
						|
done:
 | 
						|
        mov     ax,0000h        ; zero means both are equal
 | 
						|
        jmp short exit
 | 
						|
l1:
 | 
						|
        mov     ax,0ffffh       ; -1 means first is smaller
 | 
						|
        jmp short exit
 | 
						|
g1:
 | 
						|
        mov     ax,0001h        ; otherwise first is larger
 | 
						|
exit:
 | 
						|
if      _LDATA
 | 
						|
        pop     es
 | 
						|
        pop     ds
 | 
						|
endif
 | 
						|
        cproce
 | 
						|
        endps
 | 
						|
        END
 |