Page 1 of 1

invalid opcode

Posted: Wed Dec 24, 2003 6:48 pm
by shahzad
i'm getting invalid opcode exception.
what might be the possibilities of this exception and how should i look to remove this exception.

Re:invalid opcode

Posted: Thu Dec 25, 2003 4:10 am
by Candy
shahzad wrote: i'm getting invalid opcode exception.
what might be the possibilities of this exception and how should i look to remove this exception.
Obvious answers first, an invalid opcode exception occurs because you execute - an invalid opcode. The possibilities are that you have something the cpu doesn't know or you use something that doesn't exist (or is illegal, such as 0F C7 [C0-FF]), the solution is to remove those opcodes.

The less obvious answer, is the point where the crash occurs even code? if it isn't, how did you get there? If it is, is it a part of the code or a misaligned access of sorts?

Re:invalid opcode

Posted: Thu Dec 25, 2003 6:04 am
by shahzad
actually i used a variable

Code: Select all

static a=0;
this line was causing the invalid op code exception .

but this type of declaration does not cause any error in TC,then why its causing exception when i compiled code in gcc and ran the code as a kernel.

Re:invalid opcode

Posted: Thu Dec 25, 2003 8:25 am
by Candy
shahzad wrote: actually i used a variable

Code: Select all

static a=0;
this line was causing the invalid op code exception .

but this type of declaration does cause any error in TC,then why its causing exception when i compiled code in gcc and ran the code as a kernel.
because you probably don't have a real big makefile system up now, all static data is put at the start of the file. This static data is initialized, so it's put in the file, but it's no code, yet you try to execute it as code (guessing here). Well, 00 is a valid code (add with modrm byte) but some of those after it are not.

Use a proper linking script to avoid.

Re:invalid opcode

Posted: Thu Dec 25, 2003 10:28 pm
by BoomSukka
static <what?> a;

You need to give the compiler a proper declaration.

e.g. static int a;

Boom-

Re:invalid opcode

Posted: Fri Dec 26, 2003 1:17 am
by shahzad
then it should be a compiler error ,but gcc didn't complaint about it.

rather processor reported that it's an error.

is it a bug in gcc?

Re:invalid opcode

Posted: Tue Dec 30, 2003 7:12 am
by Tim
If it's a bug, then it's a bug in the C standard -- "static a" is an old way of saying "static int a".