Invalid Opcode handling

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pini

Invalid Opcode handling

Post 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 ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Invalid Opcode handling

Post 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).
pini

Re:Invalid Opcode handling

Post by pini »

Thank you for your answer. That's perfect to me !
Tim

Re:Invalid Opcode handling

Post by Tim »

Does anyone still own a CPU that lacks an FPU? i.e. a 486SX or worse?
Therx

Re:Invalid Opcode handling

Post 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
Tim

Re:Invalid Opcode handling

Post by Tim »

OK, but that's still recent enough to have an FPU built in. 486SX = CPU. 487 = FPU. 486DX = 486SX + 487.
Therx

Re:Invalid Opcode handling

Post by Therx »

Maybe its a SX then because some OSes and Win98 don't run on it (win95 does)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Invalid Opcode handling

Post 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.
Post Reply