Hello,
I wrote a program for a 89C51ED2 (using C instructions, not assembler, it's easier for me...); the compilator is OK, but when I use the simulator, I get the error 65 with the return of a sub program to the main one; in the disassembly window, I can see that there is no instruction (just "NOP") at the adress after the RET instruction. I tried to modify some instructions, I get some results, but still the error 65 appears, at different locations of the program.
Some other times, the simulator goes to some used part of the program, but jumping instructions that should precede.
As I do not control the compliling process, I just don't know what to do, and what is hapening.
Does someone understand what is happening, and where I am wrong??
Thanks.
your symptoms sound indeed like, as Per stated, an out-of-bounds error. check you array indexes. did you try to comment your forth case (and possibly, all of your cases)? what happens then? try to isolate the problem.
OK: I send the bit of code. But first, related to the code optimization: I did not set anything; I found something in Project\Options for Target "XXX"\C51\Code Optimisation\Level: 8:Reuse Common Entry Code. Is this a code optimization? As I don't need it, how can I remove code optimization?
The bit of code:
void Scan(void) { for(j = 1; j<=4; j++){ Registre_BP = P0; //reads P0 port// Registre_GPI = P1; //reads P1 port// switch (j) {
case 1: Octet_BP[j][i] = Registre_BP; Octet_GPI[i] = Registre_GPI; break;
case 2: Octet_BP[j][i] = Registre_BP; Octet_RCOD = Registre_GPI; break;
case 3: Octet_BP[j][i] = Registre_BP; break;
case 4: Octet_BP[j][i] = Registre_BP; break;
}; //End switch (j)//
}; //End for(j = 1; j<=4; j++)// }
This sub is called in the Main by:
for (i=1; i<=3; i++) Scan();
Get a C programming book!
In C, an array always starts with index 0, i.e. a 4x4 array as index 0,0 .. 3,3.
Your loop uses j = 1 .. 4. That is a big no-no!
By the way: since I did warn you about possible overwrites of the array, you really, really should have posted the declaration of the array - right now, I can only assume that your array is declared as name[4][4] or something like that.
Yes, it works with the correct indexes.
I'll get a C book...
I should have ask earlier, I would not be that tired now...Anyway, thank you very much to both of you.