After few months of searching, finally I got the BUG !!!
Was discovered today 29 May 2008 at 23.25 local time.
It's talk about inc(x) instruction where x is word or integer , at P18 MCU , when x is located (split ed) in 2 banks of memory !!!!
I can't take into account where compiler put my variables in memory ...
Chance for happened this is very small , but this problem give unpredictable result ... specially in big programs with a lot of variables.
Example :
Code: Select all
program test;
var my_important_data : byte; absolute $100;
data_wu : word; absolute $1FF;
begin
my_important_data := 0;
data_wu := 0;
while true do
begin
inc(data_wu);
end;
end.
Take a look in asm :
Code: Select all
;TEST.ppas,11 :: inc(data_wu);
$0012 $0101 MOVLB 1
$0014 $4BFF INFSNZ _data_wu, 1, 1
$0016 $0102 MOVLB 2
$0018 $2B00 INCF _data_wu+1, 1, 1
Work around :
Code: Select all
procedure inc_w(var data_w : word);
begin
FSR2Ptr := @data_w;
asm
INFSNZ POSTINC2,f
INCF INDF2,f
end;
end;
Code: Select all
var
bug_a : byte; absolute $060;
bug_b : byte; absolute $100;
bug_c : byte; absolute $200;
bug_d : byte; absolute $300;
bug_e : byte; absolute $400;
bug_f : byte; absolute $500;
etc ...
Code: Select all
bug_a := bug_a;
bug_b := bug_b;
bug_c := bug_c;
bug_d := bug_d;
bug_e := bug_e;
bug_e := bug_e;