The problem was caused by a very stupid error I made: I made a string too smal in my testcases, and this caused to overwrite a buffer holding pointers to procedures. Of course everything went wrong once the program tried to call these errorneous non existing routines...
Thanks Janni, for finding the cause of the problem, and Marko, Janni and Zoran for your neverlasting effort to find the cause.
Anyway, the good news is: it was my own stupid fault, and the compiler performed well!!
p.s. I knew this was one of the pitfalls (see http://users.edpnet.be/rosseel01/DRO/PIC/Pitfalls.htm) point 4, and still...
------- original description: ----------------
Hi, I discovered that manipulating INTCON stops my program. I can not find the line where INTCON is read in the listfile, but the code generated is different anyway. I use the P18F2620.
I wonder if the different assembled code can be the reason why my program stops working (I am not familiar with assembly...). The issue seems to be "boolean" related.
p.s. "RtosRunning" is a boolean.
p.s2: the line "INTCON := INTCON;" is of course a silly statement, it is only used here in this sample code to illustrate the issue.
1. NOT working code
Pascal:
Code: Select all
while RtosRunning do
begin
INTCON := INTCON; // <--- cause of the problem
I := 0;
...
Code: Select all
;Rtos.mpas,111 :: while RtosRunning do
L__Rtos_Start10:
0x0878 0x0100 MOVLB 0
0x087A 0x53BD MOVF Rtos_RtosRunning, 1, 1
0x087C 0xB4D8 BTFSC STATUS, 2
0x087E 0xD355 BRA L__Rtos_Start11
;Rtos.mpas,122 :: I := 0;
0x0880 0x0101 MOVLB 1
0x0882 0x6B35 CLRF Rtos_Start_I, 1
Pascal:
Code: Select all
while RtosRunning do
begin
//INTCON := INTCON; // <--- cause of the problem
I := 0;
...
Code: Select all
;Rtos.mpas,111 :: while RtosRunning do
L__Rtos_Start10:
0x0872 0x527F MOVF Rtos_RtosRunning, 1
0x0874 0xB4D8 BTFSC STATUS, 2
0x0876 0xD356 BRA L__Rtos_Start11
;Rtos.mpas,122 :: I := 0;
0x0878 0x0101 MOVLB 1
0x087A 0x6B35 CLRF Rtos_Start_I, 1
1. Line present (problem)
Pascal
Code: Select all
RtosRunning := false;
Code: Select all
;Rtos.mpas,77 :: RtosRunning := false;
0x059A 0x0100 MOVLB 0
0x059C 0x6BBD CLRF Rtos_RtosRunning, 1
Code: Select all
RtosRunning := true;
Code: Select all
;Rtos.mpas,108 :: RtosRunning := true;
0x084A 0x0EFF MOVLW 255
0x084C 0x0100 MOVLB 0
0x084E 0x6FBD MOVWF Rtos_RtosRunning, 1
Pascal
Code: Select all
RtosRunning := false;
Code: Select all
;Rtos.mpas,77 :: RtosRunning := false;
0x059A 0x6A7F CLRF Rtos_RtosRunning
Code: Select all
RtosRunning := true;
Code: Select all
;Rtos.mpas,108 :: RtosRunning := true;
0x0846 0x0EFF MOVLW 255
0x0848 0x6E7F MOVWF Rtos_RtosRunning