Hey,

I have been having a strange problem for the last couple of days. I create code with a native code compiler (the code should be valid checked it a couple of times) and then I want to execute that Code. I am using a PowerPC microcontroller with some kind of linux OS. So I am running a C program where I have a Byte array containing the native Code. Then I do the usual trick where I create a function pointer to that array and call that function. When I debug/start this program I have the following behaviour:

1. Debug with Breakpoint at native code call and single stepping:
I start at the function call and step through my native Code operatior for operation. My crated native code is executed perfectly everything is fine.

2. Debug without Breakpoint
Program halts at the first instruction (depending on native code, sometimes a later instructions but always another instruction i.e. not alway LD or ST or whatever) with the error SIGILL (Illegal Instruction)

3. Executing of binary file
Program terminates with SIGILL

I am using GDBServer for remote debugging. Additionally at the second case, I checked the instruction I checked the registers and I checked the memory everything seems to be ok. I can not figure out why my program works with single stepping but not when I execute it normally...

Also here is part of my code, I know it is not much but that is basically what I do. I have a prepared NC array which represents a C function (the code works when I execute it as Assembler instructions).

Code:
LZSBYTE (*NC_fct)(LZSDWORD, LZSDWORD, LZSDWORD);
LZSBYTE *AnfNS;

...

NC_fct = (LZSBYTE(*)()) AnfNS;
bRetCode = (*NC_fct)((LZSDWORD) pSegTab_l, (LZSDWORD) pAdrDS, (LZSWORD) hChildInst_p);
Here is the input NC Array, which basically translates to i = 1; i = i + 1;

Code:
li r0, 1
andi. r0, r0, 65535
sth r0, 8(r4)
lhz r0, 8(r4)
li r10, 1
andi. r10, r10, 65535
extsh r0, r0
extsh r10, r10
addo. r0, r0, r10
andi. r0, r0, 65535
sth r0, 8(r4)
li r3, 0
blr
Help would be very much appreciated =D