Another FPU solution, I think probably slow, with min and max as separate procedures, and since this was for graphics I guessed REAL4 instead of REAL8.
;==============================================================================
include \masm32\include\masm32rt.inc
.686
;==============================================================================
;-------------------------------------
; These from VC Toolkit 2003 float.h:
;-------------------------------------
FLT_MAX equ 3.402823466e+38
DBL_MAX equ 1.7976931348623158e+308
;==============================================================================
.data
array real4 -8.8, -3.9, 111.5, 0.5, 3.6, 1.2, 4.9, 9.9, -98.2, 0.0
r8 real8 ?
.code
;==============================================================================
fltmax proc p:dword, n:dword
local _max:real4
mov ecx, n
mov edx, p
fld4 -FLT_MAX
fstp _max
L0:
fld real4 ptr [edx+ecx*4]
fld _max
fcomip st, st(1)
ja L1
fst _max
L1:
fstp st
sub ecx, 1
jns L0
fld _max
ret
fltmax endp
;==============================================================================
fltmin proc p:dword, n:dword
local _min:real4
mov ecx, n
mov edx, p
fld4 FLT_MAX
fstp _min
L0:
fld real4 ptr [edx+ecx*4]
fld _min
fcomip st, st(1)
jb L1
fst _min
L1:
fstp st
sub ecx, 1
jns L0
fld _min
ret
fltmin endp
;==============================================================================
start:
;==============================================================================
invoke fltmin, addr array, lengthof array
fstp r8
printf("%.1f\n",r8)
invoke fltmax, addr array, lengthof array
fstp r8
printf("%.1f\n",r8)
inkey
exit
;==============================================================================
end start