ba237a9d91
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
112 lines
3.2 KiB
NASM
Executable File
112 lines
3.2 KiB
NASM
Executable File
; int _AddUnsArrToUnsArr(src1,src2,dst,n)
|
|
;
|
|
; ARGUMENT
|
|
; unsigned *src1, *src2, *dst;
|
|
; unsigned n; /* number of ints to add */
|
|
;
|
|
; DESCRIPTION
|
|
;
|
|
; Adds src1 to scr2 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
|
|
; Andy Anderson 16-jul-87 80-bit
|
|
;
|
|
;
|
|
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 add
|
|
;
|
|
cproc _AddUnsArrToUnsArr,,agmn
|
|
|
|
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 add
|
|
else
|
|
mov si,parm1_
|
|
mov di,parm2_
|
|
mov cx,parm4_
|
|
mov dx,parm3_ ; offset to dst
|
|
endif
|
|
|
|
xor bx,bx ; clear flags and offset
|
|
addlp:
|
|
if _LDATA
|
|
mov ax,[si+bx] ; get a digit
|
|
adc ax,es:[di+bx]
|
|
push ds ; have to exchange for large model
|
|
push si
|
|
lds si,parm5_ ; destination seg:offset
|
|
mov [si+bx],ax ; mov partial product
|
|
pop si ; restore ptr to src1
|
|
pop ds
|
|
pushf ; save overflow flag
|
|
inc bx
|
|
inc bx ; move to next unsigned
|
|
loop addlp
|
|
else
|
|
mov ax,[si+bx] ; get a digit
|
|
adc ax,[di+bx]
|
|
xchg dx,si
|
|
mov [bx+si],ax
|
|
xchg si,dx
|
|
pushf ; save overflow flag
|
|
inc bx
|
|
inc bx ; move to next unsigned
|
|
loop addlp
|
|
endif
|
|
pop bx ; get back last undisturbed flags
|
|
test bx,0800h ; mask the overflow bit
|
|
jnz overf
|
|
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
|