(Using Astrobe 7.2 on an LPC1769-Cortex ARM3)
Under certain conditions, the INC and DEC have stopped working when applied to a BYTE inside a RECORD.
It is easiest explained with some sample programs;
1.) When a RECORD is used and passed on a VAR to a PROCEDURE, INC or DEC on BYTEs in that record lead to a Bus Fault:
Code: Select all
MODULE faulttest1;
IMPORT Main, Out;
TYPE
BRec=RECORD
B0, B1, B2, B3:BYTE;
END;
VAR gB:BRec;
PROCEDURE DoTest2(VAR B:BRec); (*This FAILS!!!*)
BEGIN
Out.Writeln("VAR INCing");
B.B0:=100; B.B1:=100; B.B2:=100; B.B3:=100;
Out.Int(B.B2,0); Out.Ln;
INC(B.B2);
Out.Int(B.B2,0); Out.Ln;
INC(B.B2);
Out.Int(B.B2,0); Out.Ln;
END DoTest2;
PROCEDURE DoTest1(VAR B:BRec); (*This works*)
BEGIN
Out.Writeln("Adding");
B.B0:=100; B.B1:=100; B.B2:=100; B.B3:=100;
Out.Int(B.B2,0); Out.Ln;
B.B2:=B.B2+1;
Out.Int(B.B2,0); Out.Ln;
B.B2:=B.B2+1;
Out.Int(B.B2,0); Out.Ln;
END DoTest1;
BEGIN
Out.Writeln("Start");
DoTest1(gB);
DoTest2(gB);
END faulttest1.
Code: Select all
MODULE faulttest2;
IMPORT Main, Out;
TYPE BPtr=POINTER TO BRec;
BRec=RECORD
B0, B1, B2, B3:BYTE;
END;
VAR gB:BPtr;
PROCEDURE DoTest3(B:BPtr);(*This Fails!!!*)
BEGIN
Out.Writeln("INCing");
B^.B0:=100; B^.B1:=100; B^.B2:=100; B^.B3:=100;
Out.Int(B^.B2,0); Out.Ln;
INC(B^.B2);
Out.Int(B^.B2,0); Out.Ln;
INC(B^.B2);
Out.Int(B^.B2,0); Out.Ln;
END DoTest3;
PROCEDURE DoTest2(VAR B:BPtr); (*This works, but the VAR should not be needed*)
BEGIN
Out.Writeln("VAR INCing");
B^.B0:=100; B^.B1:=100; B^.B2:=100; B^.B3:=100;
Out.Int(B^.B2,0); Out.Ln;
INC(B^.B2);
Out.Int(B^.B2,0); Out.Ln;
INC(B^.B2);
Out.Int(B^.B2,0); Out.Ln;
END DoTest2;
PROCEDURE DoTest1(B:BPtr); (*This works*)
BEGIN
Out.Writeln("Adding");
B^.B0:=100; B^.B1:=100; B^.B2:=100; B^.B3:=100;
Out.Int(B^.B2,0); Out.Ln;
B^.B2:=B^.B2+1;
Out.Int(B^.B2,0); Out.Ln;
B^.B2:=B^.B2+1;
Out.Int(B^.B2,0); Out.Ln;
END DoTest1;
BEGIN
Out.Writeln("Start");
NEW(gB);
DoTest1(gB);
DoTest2(gB);
DoTest3(gB);
DISPOSE(gB);
END faulttest2.
Code: Select all
PROCEDURE ByteINC(VAR B:BYTE)
BEGIN
B:=B+1
END ByteINC;
unfortunately, we have many INC's and DEC's of BYTE's in the code.....
I hope this feedback is useful.