I'd like to know how to check for an FPU using ASM. Thanks.
Posted on 2001-05-31 23:23:00 by dig
.data myword dw 1234h ;anything nonzero ... .code ... fninit ;initialize copro if any fnstsw myword ;if copro present, this will put 0 to mem mov ecx,myword jcxz HasCopro
Posted on 2001-05-31 23:49:00 by Larry Hammick
Wouldn't the code you suggested above cause a problem to a CPU that doesn't have an FPU?
Posted on 2001-06-01 03:07:00 by dig
It should cause no trouble. I got it from Intel documentation some years back.
Posted on 2001-06-01 04:12:00 by Larry Hammick
I thought the FPU was built in all pentium and aove processor anyway? If a floating point unit is not present, but is being emulated, then the above code will return incorrect results. A much better way (to make sure the FPU CHIP is present), on a pentium or later is to use the CPUID instruction.

mov eax,1   ;CPUID code to use
cpuid       ;Execute instruction
test edx,1  ;Test if bit 1 in EDX is set
jz NoFPU    ;If not, there is no FPU
With the above, there may be a problem with a non-intel processor, as the flags returned in EDX may or may not be different. Im trying to find the docs now.
Posted on 2001-06-03 17:39:00 by George
CPUID is an invalid opcode on early machines. Dettman & Wyatt "DOS Programmer's Reference" is a good source on identifying cpu's, copros, and video capacity on the earlier machines. (Edit) Oops, that should be "Dettmann" This message was edited by Larry Hammick, on 6/4/2001 2:11:23 PM
Posted on 2001-06-04 06:52:00 by Larry Hammick