Compiler size calculation error

I have found that there is an error in the control basic compilation with regard to the calculated size of the program. I have a ‘large’ program and with the following code, the size of the code block is 1667 bytes


1085 u1clsetp = u1setp + (u1dedbnd)/2
1090 u1htsetp = u1setp - (u1dedbnd)/2

However with the following change, the size is reported as being larger 2000 bytes.

1080 hfdedbnd = (u1dedbnd)/2
1085 u1clsetp = u1setp + hfdedbnd
1090 u1htsetp = u1setp - hfdedbnd

The issue is not limited to this specific change. I use it only for reference. I can add one line of code to other parts of the code block and the size jumps from approximately 1650 bytes to more than 2000 bytes. It would extremely helpful if the compiler reported the size even if it was oversize for the purposes of partitioning the code.

1 Like

I just did a simple test and the code size calculation is indeed correct. If the system says the code is larger than 2000 bytes, then you can trust that it is over 2k bytes.

It is recommended that you split the code as much as possible, possibly moving some of the control logic to other programs. Keep in mind that only one program should act on one variable or output.

In addition, the REM statements take up space, each char is one byte.

1 Like

Hi Fandu,

We are already splitting the code into the small blocks using 13 of the 16 but the loss of another 20% with this current issue means we have even less space than we expected.

Can you explain then why the size jump occurs in the program from 1667 bytes to 2000 bytes with the addition of only one line of code? This just seems strange. We have tried multiple programs and each time the size jumps near the 80% limit. It seems like a boundary condition.

Again, it would be very useful if the program indicated the size even if it is in excess of the 2000 byte limit.

Thank,

Jason

Fandu did some testing and his test showed that the program size calculation is accurate. If you could send on your program by email he will see if he can repeat what you saw there.

If the program you are doing fills up all the available space the only work around for now would be to add another CPU to the application, it can be as simple as one of the T3-nano’s which are around $60USD.

When the new ESP32 based cpu’s are into production we can bump up the program space, should be only a month or two for that and you are welcome to swap hardware with us when it comes out.

1 Like

Here is a sample code entry to demonstrate that something is amiss:

1000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1950 if var1 = 1 then var2 = 2, var3 = 3

This code has a length of 496 bytes. By repeating the code 3 times, we get code of byte length 1488 which makes sense as 496 x 3.

1000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1950 if var1 = 1 then var2 = 2, var3 = 3
2000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2950 if var1 = 1 then var2 = 2, var3 = 3
3000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3950 if var1 = 1 then var2 = 2, var3 = 3

However, if the block is repeated 4 times, which should yield a size of 1984, the code is reported as too large.

1000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1950 if var1 = 1 then var2 = 2, var3 = 3
2000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2950 if var1 = 1 then var2 = 2, var3 = 3
3000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3950 if var1 = 1 then var2 = 2, var3 = 3
4000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4950 if var1 = 1 then var2 = 2, var3 = 3

We must then remove the last 3 lines to get to a size that fits which only reports as 1856 bytes:

1000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
1950 if var1 = 1 then var2 = 2, var3 = 3
2000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
2950 if var1 = 1 then var2 = 2, var3 = 3
3000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
3950 if var1 = 1 then var2 = 2, var3 = 3
4000 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4100 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4200 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4300 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4400 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4500 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4600 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4700 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4

However, the removed lines only total 128 bytes so should fit because 1856 + 128 = 1984

4800 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4900 if var1 = 1 then var2 = 2, var3 = 3, var4 = 4
4950 if var1 = 1 then var2 = 2, var3 = 3

Depending on the actual code that is built, I have seen as much as 360 unavailable bytes that suddenly add to the total with a single line of code. This can reduce the already limited space from 2000 bytes down to around 1600 which eliminates 20% of the available space in these small slots.

K, the team will spend more time on this on Monday.

For compilation purposes, we set aside 100 bytes to store the time table, variables, and remote points that may be used.
So, your conclusion is correct. The total available is still 2000 bytes, but 100 bytes are used by the compiler, but not editable. Thank you for your feedback. Thank you!

1 Like

Hi Fandu,

As mentioned, this is only one example to demonstrate and we are seeing as much as 350 bytes lost in other code examples. We can add one line and jump from 1650 bytes to being oversized so something else is going on as well

Something else to keep in mind is that the 100 bytes or whatever else is required should be shown at all times so that person knows when they are reaching the limit. It is much harder to guess at the limit nd partition the code when the these additional values are not included as a part of the calculation that is displayed.

Jason

I haven’t tested the extra 300-plus bytes you described yet. I will optimize the prompt so that users know more precisely how many bytes are left to use when they are programming
Thanks!

1 Like

As an update, I now have code that jumps from 1557 bytes to > 2000 bytes with the addition of only one character in a rem comment, so that is 443 bytes unaccounted for.

If you can send me 1557 bytes of the program, or send the entire prog file, it will be easier for me to find the cause.
I haven’t had a problem losing hundreds of bytes. As I said earlier, we have 100 bytes reserved to store the time table, variable table, and remote points, and their size is determined by the specific programming content.

Hi Fandu,

I have sent the code text and the program to the info@temco… email.

Thanks,

Jason

We found the root cause, the firmware and T3000 software are missing the local_table and time table when calculating the length. We will release this bug in the next release. Thank you!

1 Like

Hi Fandu,

I am glad you found it. That should make it easier to chop up the code. Can you please remove the image of our code from the forums. I didn’t want to share it with all your customers.

Also, would it be possible to show the size of the local table, time table and code individually in the popup window to better enable understanding of how they contribute to the total? Based on your previous comments, my understanding was that they were only 100 bytes or so. If they are 450 bytes, they represent a large fraction of the available coding space at 2kB.

Thanks,

Jason

1 Like

In this modification, all local tables, time tables and so on are included in all sizes. Users do not need to care about the size of these tables individually, but only pay attention to the total size.
Thanks!Jason.

I look forward to the updated release to see if we have more space per block or if those tables are in fact consuming up to a quarter of the available space.

The program space is not changed or improved. Only the calculation of the size of the program is fixed. Now you will know (more accurately) how much space is left.

Any estimated time frame for when the program updates will be released? Or was it supposed to be in the July 21st release?

This was released last week. Generally when we say something has been done that means it has also been released in the update system.

We have encountered additional issues with the compiler size calculation that are causing complexity during development:

  1. The size of the program reported in different windows and at different times is not the same:
    a. The result from compilation
    image
    b. The size shown in the editor window after compilation
    image
    c. The size shown in the list of programs


    d. The size shown in the editor window when the program is reloaded
    image

  2. When the program is sent to the thermostat immediately after being loaded from the thermostat, the compiler indicates that the program is oversized even though the program could be written successfully in the first place:
    image

  3. When the names of variables in the program are changed, from pid1 to pid3 for example to run two parts of the control in separate programs, the compiler indicates that the program is oversized even though nothing else in the program is changed.

All of this would be much less of a problem if the program size was larger. Unfortunately, now when we want to make changes, we have to get the same code working and test the size with different variable names. It would also be much easier if the compiler reported the actual program size even if it is oversized.