116 lines
3.1 KiB
NASM
116 lines
3.1 KiB
NASM
|
; int _SubUnsArrFromUnsArr(&src1,&src2,&dst,n)
|
||
|
;
|
||
|
; ARGUMENT
|
||
|
; unsigned *src1, *src2, *dst;
|
||
|
; unsigned n; /* number of ints to subtract */
|
||
|
;
|
||
|
; DESCRIPTION
|
||
|
;
|
||
|
; Subtracts src2 from scr1 giving dst. src1 and scr2 are unchanged.
|
||
|
; src1, src2 and dst point to unsigned arrays.
|
||
|
;
|
||
|
; SIDE EFFECTS
|
||
|
; dst is indeterminate on overflow. Note that although we are using
|
||
|
; unsigned, we return an overflow status from here if the high-order bit
|
||
|
; goes set. Caller can then determine if that is an error in his case.
|
||
|
;
|
||
|
; RETURNS
|
||
|
; Returns GM_SUCCESS if no overflow, otherwise GM_FAILURE.
|
||
|
;
|
||
|
; AUTHOR
|
||
|
; Andy Anderson 13-JAN-1987 13:30
|
||
|
; Copyright (C) 1987-90 Greenleaf Software Inc. All Rights Reserved.
|
||
|
;
|
||
|
; MODIFICATIONS
|
||
|
; aa 16-JUL-87 80-bit
|
||
|
;
|
||
|
;
|
||
|
.SFCOND
|
||
|
|
||
|
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_ = destination segment ptr
|
||
|
; parm6_ = destination offset ptr
|
||
|
; parm7_ = number of unsigned's to add
|
||
|
;
|
||
|
; for if small model then
|
||
|
; parm1_ = ptr to source1
|
||
|
; parm2_ = ptr to source2
|
||
|
; parm3_ = ptr to destination
|
||
|
; parm4_ = number of unsigned's to subtract
|
||
|
;
|
||
|
cproc _SubUnsArrFromUnsArr,,_sgmn
|
||
|
|
||
|
if _LDATA
|
||
|
push ds
|
||
|
push es
|
||
|
lds si,parm1_ ; ptr to a
|
||
|
les di,parm3_ ; ptr to b
|
||
|
mov cx,parm7_ ; number of uns's to subtract
|
||
|
else
|
||
|
mov si,parm1_
|
||
|
mov di,parm2_
|
||
|
mov cx,parm4_
|
||
|
mov dx,parm3_ ; offset to dst
|
||
|
endif
|
||
|
|
||
|
xor bx,bx ; clear flags and offset
|
||
|
sublp:
|
||
|
if _LDATA
|
||
|
mov ax,[si+bx] ; get a digit
|
||
|
sbb ax,es:[di+bx]
|
||
|
push ds ; have to exchange for large model
|
||
|
push si
|
||
|
lds si,parm5_ ; destination seg:offset
|
||
|
mov [bx+si],ax ; mov partial product
|
||
|
pop si
|
||
|
pop ds
|
||
|
pushf
|
||
|
inc bx
|
||
|
inc bx ; move to next unsigned
|
||
|
loop sublp
|
||
|
else
|
||
|
mov ax,[si+bx] ; get a digit
|
||
|
sbb ax,[di+bx]
|
||
|
xchg dx,si
|
||
|
mov [bx+si],ax
|
||
|
xchg si,dx
|
||
|
pushf
|
||
|
inc bx
|
||
|
inc bx ; move to next unsigned
|
||
|
loop sublp
|
||
|
endif
|
||
|
pop bx
|
||
|
test bx,0800h ; OF must be set
|
||
|
jnz overf ; sense OF from last subtract
|
||
|
|
||
|
mov ax,GM_SUCCESS ; set SUCCESS return for caller
|
||
|
exit:
|
||
|
if _LDATA
|
||
|
mov cx,parm7_
|
||
|
else
|
||
|
mov cx,parm4_
|
||
|
endif
|
||
|
dec cx ; since we've already poped one off
|
||
|
sal cx,1 ; the stack, make byte offset -2
|
||
|
add sp,cx ; clean up stack from pushf's
|
||
|
if _LDATA
|
||
|
pop es
|
||
|
pop ds
|
||
|
endif
|
||
|
cproce
|
||
|
overf:
|
||
|
mov ax,GM_FAILURE
|
||
|
jmp short exit
|
||
|
endps
|
||
|
END
|