4
.b8b
5
.model flat
6
7
.code
8
9
_floatMin PROC
10
11
push ebp
; save caller frame pointer
12
mov ebp, esp
; establish current frame pointer
13
14
15
mov ebx, [ebp+8]
; store address of first array element into ebx
16
mov ecx, [ebp+12]
; store the size of array into ecx
17
xor edx, edx
; initialize loop counter edx to zero
18
19
fld dword ptr[ebx]; load first array element arrary onto st(0)
20
inc edx
; increment loop counter in edx
21
22
LoopMin:
23
24
fld dword ptr[ebx+edx*4]
; load next array element onto st(1)
25
fcom st(1)
; compare st(0) with st(1)
26
27
fstsw ax
; copy the Status Word containing the result to AX
28
fwait
; insure the previous instruction is completed
29
sahf
; transfer the condition codes to the CPU's flag register
30
31
32
jb lookNext
;if st(0) < st(1) jump to lookNext to continue with next array element
fcomp
33
34
35
LookNext:
36
inc edx
; increment counter in edx
37
cmp ecx, edx
; compare array size in ecx with loop counter in edx
38
jl loopMin
39
40
pop ebp
; restore caller frame pointer
41
ret
; return contents of st(0)
42
43
44
45
_floatMin ENDP
46
47
END
48