compiler error

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 32-bit PIC MCUs
Post Reply
Author
Message
kenneth43
Posts: 7
Joined: 16 Jul 2017 16:22

compiler error

#1 Post by kenneth43 » 10 May 2019 18:15

In the following code: CaliWSum : int64, AD_START_UP, Work_Limit : LongInt
Optimization level 3, SSA enabled. MCU P32MX564F128H, compiled for ICD Debug.
MikroPascal 4.0.0
CaliWSum is in R2,R3 at this time
;ComProcessor.mpas, 529 :: If (CaliWSum - Sys^.AD_START_UP) > Work_Limit then
0x9D00E900 0x8C24ADDC LW R4, Offset(_Sys+0)(GP)
0x9D00E904 0x2484007C ADDIU R4, R4, 124
0x9D00E908 0x8C840000 LW R4, 0(R4)
0x9D00E90C 0x0080200A MOVZ R4, R4, R0 /---------------------------/what is this good for?
0x9D00E910 0x00042FC3 SRA R5, R4, 31 /---------------------------/now AD_START_UP expanded to int64 in R4,R5
0x9D00E914 0x0044F02B SLTU R30, R2, R4
0x9D00E918 0x00443023 SUBU R6, R2, R4
0x9D00E91C 0x00653823 SUBU R7, R3, R5
0x9D00E920 0x00FE3823 SUBU R7, R7, R30 /--------------------------/now difference in R6,R7
0x9D00E924 0x8C24A5BC LW R4, Offset(_Work_Limit+0)(GP) /----/now Work_Limit to R4, not expanded to R5
0x9D00E928 0x00A7102A SLT R2, R5, R7 /---------------------------/R5 has data from AD_START_UP, not from Work_Limit
0x9D00E92C 0x14400006 BNE R2, R0, L__main814 /----------------/this jump always goes further to L__main815
0x9D00E930 0x70000000 NOP
0x9D00E934 0x00A71026 XOR R2, R5, R7
0x9D00E938 0x2C420001 SLTIU R2, R2, 1
0x9D00E93C 0x10400002 BEQ R2, R0, L__main814 /----------------/this jump always goes further to L__main281
0x9D00E940 0x70000000 NOP
0x9D00E944 0x0086102B SLTU R2, R4, R6
L__main814:
0x9D00E948 0x10400004 BEQ R2, R0, L__main281 /----------------/ so why this at all?
0x9D00E94C 0x70000000 NOP
L__main815:
;ComProcessor.mpas, 530 :: Tara_Test := cTara_Over /-------/ here I land if Work_Limit has opposite sign of AD_START_UP
0x9D00E950 0x34020003 ORI R2, R0, 3
0x9D00E954 0x0B403A71 J L__main282
0x9D00E958 0xA022AEC5 SB R2, Offset(_Tara_Test+0)(GP)
;ComProcessor.mpas, 531 :: else
L__main281:

As I know that the value of CaliWSum comming into this code fits in an LongInt,
templong := CaliWSum;
If (templong - Sys^.AD_START_UP) > Work_Limit then
fixes the issue with the bonus of less rows in the listing.
However, there is a compiler error.
b.r.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: compiler error

#2 Post by filip » 16 May 2019 08:07

Hi,

Can you please send me a minimal code that represents this issue ?

Regards,
Filip.

kenneth43
Posts: 7
Joined: 16 Jul 2017 16:22

Re: compiler error

#3 Post by kenneth43 » 16 May 2019 21:29

To fool the opimizer to forget the constants there is some strange code before coming to the
;Test.mpas, 39 :: If (CaliWSum - Sys^.AD_START_UP) > Work_Limit then
0x9D0003B8 0x8C228110 LW R2, Offset(_Sys+0)(GP)
0x9D0003BC 0x24420004 ADDIU R2, R2, 4
0x9D0003C0 0x8C420000 LW R2, 0(R2)
0x9D0003C4 0x0040200A MOVZ R4, R2, R0
0x9D0003C8 0x00042FC3 SRA R5, R4, 31
0x9D0003CC 0x8C23811C LW R3, Offset(_CaliWSum+4)(GP)
0x9D0003D0 0x8C228118 LW R2, Offset(_CaliWSum+0)(GP)
0x9D0003D4 0x0044F02B SLTU R30, R2, R4
0x9D0003D8 0x00443023 SUBU R6, R2, R4
0x9D0003DC 0x00653823 SUBU R7, R3, R5
0x9D0003E0 0x00FE3823 SUBU R7, R7, R30
0x9D0003E4 0x8C24800C LW R4, Offset(_Work_Limit+0)(GP) //is not expanded to 64 bits
0x9D0003E8 0x00A7102A SLT R2, R5, R7 //here R5 is used as it was the high word of Work_Limit

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: compiler error

#4 Post by filip » 17 May 2019 08:57

Hi,

Please, is it possible for you to attach here a minimal code that represents this issue ?

Regards,
Filip.

kenneth43
Posts: 7
Joined: 16 Jul 2017 16:22

Re: compiler error

#5 Post by kenneth43 » 17 May 2019 10:53

yet another try to submit files.
After "Add the file" and a popup window indicating the transfer,
a visit to the user control panel shows "You have posted no files."
whats wrong?
Here is the code:
program MyProject;

Type

SysData_T = Record
RAM_Chk_Sum : dWord;
AD_START_UP : LongInt;
B2 : Byte;
B3 : Byte;
end;



Const
cHIGH : LongInt = -900100;
cLOW : LongInt = -900000;
capacity : LongInt = 5000;
cTara_Over : byte = 3;
cTara_Under : byte = 2;
cTara_OK : byte = 0;
Var
CaliWSum : int64;
Work_Limit, a, b, c : LongInt;
Sys : ^SysData_T;
Tara_Test : Byte;

procedure setit(var parm1, parm2, parm3 : Longint);
begin
Work_Limit := parm1 * 0.2;
Sys^.AD_START_UP := parm2;
CaliWSum := parm3;
end;

begin
a := cHIGH;
b := cLOW;
c := capacity;
setit(c, a, b);
If (CaliWSum - Sys^.AD_START_UP) > Work_Limit then
Tara_Test := cTara_Over
else
If (Sys^.AD_START_UP - CaliWSum) > Work_Limit then
Tara_Test := cTara_Under
else
Tara_Test := cTara_OK;


end.

Post Reply

Return to “PIC32 PRO Compilers”