Page 1 of 1

Invalid Opcode handling

Posted: Thu Jan 29, 2004 8:07 am
by pini
I have a working exception handler for Invalid Opcode (I tried it on bochs' level 3 cpu and works good on handling error caused by the use of "rdtsc").

I wanted to catch invalid opcode exceptions brought up by the use of FPU instruction when no FPU is currently present. This way, I (successfully) compiled bochs without support of the FPU, but when it comes to execute this :

Code: Select all

wait
fninit
Bochs prints out the following

Code: Select all

[tick=(00001205525)][eip=(001019ab)][type=(i)][dev=[CPU  ] FWAIT: requred FPU, use --enable-fpu
[tick=(00001205526)][eip=(001019ad)][type=(i)][dev=[CPU  ] FNINIT: required FPU, configure --enable-fpu
and doesn't call neither the invalid opcode exception handler nor the fpu error exception handler.

My question is the following : what will happen on a real computer with no FPU at all ?
Will it hang on the invalid opcode exception handler or will it go further ?

Re:Invalid Opcode handling

Posted: Thu Jan 29, 2004 1:02 pm
by Pype.Clicker
"invalid opcode" is not the right way to deal with this. Instead, you should set CR0.EM to 1 to tell the processor you want to emulate the x87 instruction set. Then, everytime a FPU instruction is attempted, you'll receive EXC 7 (no coprocessor).

Re:Invalid Opcode handling

Posted: Fri Jan 30, 2004 9:06 am
by pini
Thank you for your answer. That's perfect to me !

Re:Invalid Opcode handling

Posted: Fri Jan 30, 2004 12:57 pm
by Tim
Does anyone still own a CPU that lacks an FPU? i.e. a 486SX or worse?

Re:Invalid Opcode handling

Posted: Sat Jan 31, 2004 2:11 am
by Therx
Yeh I've got a 486DX 55MHz. It can run linux and I've used it as a DNS, web and mail server. However trying to make it run mySQL and php was a bit to much ;D

Pete

Re:Invalid Opcode handling

Posted: Sat Jan 31, 2004 2:17 am
by Tim
OK, but that's still recent enough to have an FPU built in. 486SX = CPU. 487 = FPU. 486DX = 486SX + 487.

Re:Invalid Opcode handling

Posted: Sat Jan 31, 2004 4:29 am
by Therx
Maybe its a SX then because some OSes and Win98 don't run on it (win95 does)

Re:Invalid Opcode handling

Posted: Mon Feb 02, 2004 10:46 am
by Candy
Pete wrote: Maybe its a SX then because some OSes and Win98 don't run on it (win95 does)
SXes never came above 25 or 33 mhz (afaik), and anyway, win98 doesn't need an FPU? At least, last time I checked it didn't.