Using the example at x86 assembler: floating point compare, I wrote the following NASM code, which compares two doubles and selects the smaller of the two:
fld qword[a]
fld qword[b]
fcomip
fstp qword [float_temp_var] ; to clear stack
jge minmax1_next
movsd xmm0,[b]
movsd [minval],xmm0
jmp minmax1_out
minmax1_next:
movsd xmm0,[a]
movsd [minval],xmm0
minmax1_out:
The only problem is that the results are not consistent. Sometimes it identifies the smaller value correctly and sometimes it does not. According to the post at the url above, I don't need to store or pop the flags register, so I don't know what I've done wrong. Research hasn't revealed the problem.