Page 1 of 1

Invalid Opcode[SOLVED]

Posted: Mon Nov 22, 2010 2:52 am
by Chandra
It's been a long time since I last posted. Everything was fine after then. Now, I've encounterd the 'invalid opcode' fault. This happens only when I install the mouse handler. Sometimes, the mouse handler works fine and then suddenly generates the 'invalid opcode' fault in the middle after the mouse cursor is moved for some time.
To my surprise, this happens only when I run my OS under the AMD processor on real hardware(I've tested it under AMD duron and AMD Turion processor and both on my laptops). Amazingly, there is no problem at all when I run my OS under Bochs, Qemu, Virtual PC or under Intel Processor on real hardware. So far I've been able to figure out that the problem is the handler code(adapted from sanik's mouse driver) and as soon as I remove the mouse handler code, there's no Invalid Opcode Fault.
I'm currently trying to debug the code to see if there's some problem in the binary generated code but I'm facing difficulty to figure out the problem because of the huge bunch of the handler code.
If someone knows the workaround for this, please help!
Looking forward for help.

Re: Invalid Opcode

Posted: Mon Nov 22, 2010 3:24 am
by Combuster
As far as my crystal ball goes: Invalid opcode is almost always caused by a bad instruction pointer, which in turn is usually caused by stack corruption so check your ISR and see if it overwrites anything. With the lack of information provided guesswork is the best we can do.

Re: Invalid Opcode

Posted: Mon Nov 22, 2010 9:55 am
by Chandra
Thank you very much. Yes, the problem was with the stack. Now I've reserved 8 kb of stack space and the code is working fine. Thank you very much once again.
Oh! One more question. How did it previously work fine with the Intel processor and the emulators while it didn't work with AMD processors. Please let me know.

Best Regards,
Chandra

Re: Invalid Opcode

Posted: Mon Nov 22, 2010 10:05 am
by Owen
My guess: Unallocated address space generally reads as FFh. On Intel processors, this is an undocumented NOP (to placate some BIOS manufacturers who, years ago, had issues with puting their BIOS ROMs at the top of the address space; this would cause the boot process to quickly wrap to 0h. AMD don't implement this hack (they have never needed to)

Re: Invalid Opcode

Posted: Tue Nov 23, 2010 6:24 am
by Chandra
Owen wrote:My guess: Unallocated address space generally reads as FFh. On Intel processors, this is an undocumented NOP (to placate some BIOS manufacturers who, years ago, had issues with puting their BIOS ROMs at the top of the address space; this would cause the boot process to quickly wrap to 0h. AMD don't implement this hack (they have never needed to)
Oh yes, this seems to be useful. Possibly this is the case with the emulators too, not only with the intel processors; if I am not wrong. Anyway, thanks.