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.
Problem with stac overflow? Watchdog? Uninitialized pointer? Pointer/array access outside bounds? Nested interrupts?
The compiler just creates a program based on valid C instructions. It is up to you to make sure that those instructions forms a valid program. If they don't then the simulator (or the real hardware) will fail to run your application.
The compiler is not magic?
From all your suggestions, I would rather think of a stack overflow; but I am not sure, as I don't know how to overflow a stack! Do you know how I can verify if the stack is overflow or not, and when? I can see a "SP" and a "SP_max" in the project Work window of µvision, but I don't undestand it
Anyway, it seems like I need to learn more deeply how a MCU works, not just the peripherals and their registers. That's what I understand from your answer. Thank you for it.
Can you just also suggest some links to informations on this subject (not a MCU and its peripherals, but instead its PC, stack, ALU, DPTR, and so on...).
Thank you very much.