invalid opcode

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
shahzad

invalid opcode

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:invalid opcode

Post 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?
shahzad

Re:invalid opcode

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:invalid opcode

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

Re:invalid opcode

Post by BoomSukka »

static <what?> a;

You need to give the compiler a proper declaration.

e.g. static int a;

Boom-
shahzad

Re:invalid opcode

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

Re:invalid opcode

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