Agree looks broken with a silent failure. I can resolve to issue a warning that you are using an array element and the compiler cannot resolve for you.
The core issue is as you have found. You need to take array elements through a temp variable.
So, I can resolve to issue a warning and therefore not fail silently.
Yes ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I suppose if using a variable as the array element number is not allowed when bit indexing (read array element bits).
but I thought it would be a valid use considering it works the other way around, (write array element bits)...
I copied the 4 patch files to the GreatCowBasic folder.
Inspecting messages.dat the following change...
NotABitORAConst = "%value% is not a bit or valid constant. Constant values should be 0 or 1"
Result: compiles the same with no error/warning message.
Is this error message just until the issue is fixed or is the issue not fixable.
thanks
Index = 3
A1=0
Data1 = Valu(A1) '< Variable A1 works here
Data1.Index = Valu(A1).Index ' < but not here
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Download the msg file again. I failed to upload the correct file.
What is status of fix ? You will get an error message when you try the array(element).bit.
Is this fixable ? Yes. It would take time. Got time to resolve?
The fix is relatively simple but hard to implement. We never tested this use case. An oversight - yes.
The use case.
Data1.Index = Valu(A1).Index
Needs to be evaluated as follows: This is NOT happening at the moment as the compiler does not handle array(element).bit correctly as the array pointer is being passed not the bit value, see later.
Currently, the compile is passing the array pointer ( INDF.index ). Where INDF is a pointer the array element. Both the source and destination are 'bits' but INDF.index is incorrect - hence the silent failure.
Code being processed by the compiler - the source bit is not valid. Data1.Index = INDF.Index
This is my analysis of the root cause.
Evan
Last edit: Anobium 2021-07-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just checked the release log, This is the second change to bit setting code. 984, 985 and now 993. The bit setting code is new and clearly improvements are still required. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the detail, it helps to understand.
The workaround is ok, but it could be documented somewhere for now.
My use is I have a For loop that sets each array element number & a nested loop that gets the bits of each element to place in D0 of a 32x4 RAM in a display controller. (1 bit set in 32 address)
Pretty sure it works the other way around (setting array bits using a variable to set element number), this is what I mentioned earlier.
But I will retest & confirm...
What I tested yesterday:
Data1.0= Valu(A1).Index '< not werking
Data2.0 = Valu(0).Index '< ok
Valu(A1).Index = Data1.0 '< ok
Valu(0).Index = Data1.0 '< ok
where index = 0 to 7
Considering the only difference being the element number source, (Constant or variable)
maybe as a interim fix can "trick" the compiler section to think it has a constant when the element number source is actually a variable .
(hypothetically speaking & not knowing the actual code yet...)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Its a HT1621 driver chip. its a 128 element 4 COM LCD driver & for now I am just using 1 COM hence only D0 of each 4 bit RAM location. 1 bit per RAM address.
The array is the 7seg digit values, 4 array elements per COM.
Getting bits from the array to port pin (serial out) is fast enough for this app, the slow part is the BCD convert (MOD)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You were right Evan, It does fail both ways ( a false memory or confused when testing.)
ForIndex=0to7' Bits FROM ArrayData1.Index=Arr_Val(E0).Index'< not werkingData2.Index=Arr_Val(0).Index'< ok' Bits TO ArrayArr_Val(E1).Index=Const1.Index'< not werkingArr_Val(2).Index=Const1.Index'< okNext
I copied the latest patch files but still no error or warning message
I have resolved but there are side effects and I want to discuss.
We have three cases to resolve.
1) datavar1.Index = Valu(A1).Index
This is where the source data (right hand side of the equals sign is of the format arrayname(element_number_variable).variable_as_bit_address.
' datavar1.Index = Valu(A1).Index can be expanded to' SYSARRAYELEMENTCOPY = Valu(A1)' datavar1.Index = SYSARRAYELEMENTCOPY.Index
This works ok but I have NO way of determining if .variable_as_bit_address is a constant. Processing for constants happens a lot later in the compilation process and this means that arrayname(element_number_variable).constant_as_bit_address is also expanded where this work without expansion in the past.
2) There a huge number of cases where datavar1.Index = Valu(A1).Index can have a prefix like IF, ELSEIF, WHILE etc. And, the expansion process would need address these issues.
3) There is a case of the setting the destination. Example follows:
This essentially will expand, but the same issues with IF.. WHILE will hamper this.
4) These is a fourth case of copying bits from one array to another.
'ValueA(A1).Index = ValueB(A1).Index
The expansion approach fails on this case. There is not expansion logic I can think design that works.
So, I recommend NOT implementing the expansion but leave the resolution up to the user. The compiler will issue an error, and, we can document how to resolve. This will remove the risk of expansion messing something up and it is very simple for a user.
' datavar1.Index = Valu(A1).Index can be expanded to' SYSARRAYELEMENTCOPY = Valu(A1) 'readthearrayvalue' datavar1.Index = SYSARRAYELEMENTCOPY.Index
and
'Valu(A1).Index = source (or any variable binary value 1 or 0 ) 'expands to' SYSARRAYELEMENTCOPY = Valu(A1) 'readthearrayvalue' SYSARRAYELEMENTCOPY.Index = source' Valu(A1) = SYSARRAYELEMENTCOPY
The expansion is way to complex, and, I do not like complex. I would recommend we leave it up to the user.
Your thoughts?
Last edit: Anobium 2021-07-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For the patch updates I just renamed the original 4 files with *.bak & copied over the new files & run application as normal. I do have the minimal install (I don't use microchip's monster)
My dev pc(win7p_x64) is not networked, UAC disabled.
I did have some trouble with MSE quarantining gcbasic.exe but got around it.
Best to avoid complex, unless it can be isolated.
As can be seen in the gcb test it is just 1 extra statement to mitigate , Warning message & a mention in help will be useful.
My use is to set just 1 bit in a variable from array element bits .
Please use the ZIP. Then, check the version and build. You should see build 995
0.98.<<>> 2021-07-07 (Windows 64 bit) : Build 995
Two new traps to prevent the silent compilation that does not work.
ArrayBitIndex_1.gcb (23): Error: Array(element).bit as source - compiler needs help. Please simplify 'Array(element).bit' by using a temp_variable to store the source Array(element) then use temp_variable.bit as source, or use Constant array element address.
ArrayBitIndex_1.gcb (37): Error: Array(element).bit as destination - compiler needs help. Please simplify destinationn 'Array(element).bit' by using a temp_variable to store the destination Array(element) then use temp_variable.bit as destination, or use Constant array element address.
Last edit: Anobium 2021-07-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you try the updated compiler to ensure I have sorted the error messages ( not the expansion, I have coded but I have left the expansion code disabled ).
:-(
Last edit: Anobium 2021-07-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sorry, I have to cleanup my GCB install.
With the latest release I installed to a different folder (Keeping the previous)
Looks like the old install compiler is being run?. (Compiler Version: 0.98.07 RC45 2021-03-31 (Windows 32 bit)
That's why I don't see the messages...
(After I installed latest build I no longer got a hex file output, I had to copy the old makehex.bat from the previous install.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok, all sorted now.
With a fresh install of latest & a patch dump, hex button was still compiling with old compiler 2021-03-31 gcbasic.exe & no messages
Edit makehex.bat...
REM gcbasic.exe /NP /S:use.ini %1 /F:N /P:
gcbasic64.exe /NP /S:use.ini %1 /F:N /P:
When using a variable as the array element number, I get zero value bits returned.
Replace the var A1 with a value & is ok
~~~
Valu(0) = 255
A1 = 0
For Index = 0 to 7
Data1.Index = Valu(A1).Index '< This returns only zero bits
Data2.Index = Valu(0).Index '< ok
Next
' Workaround...
Temp = Valu(A1)
Data1.Index = Temp.Index '< ok
~~~
Please confirm, thanks.
Files attached...
Last edit: ToniG 2021-07-05
Agree looks broken with a silent failure. I can resolve to issue a warning that you are using an array element and the compiler cannot resolve for you.
The core issue is as you have found. You need to take array elements through a temp variable.
So, I can resolve to issue a warning and therefore not fail silently.
Yes ?
I suppose if using a variable as the array element number is not allowed when bit indexing (read array element bits).
but I thought it would be a valid use considering it works the other way around, (write array element bits)...
Valu(A1).Index = Data1.index
Valu(0).Index = Data1.index
Both above lines work, Variable A1 does not cause a dis-function .
Correct that would work and would still work. The destination is ok - it is the source that is the issue.
Issue warning?
ok
Is it on a todoo list ? or not able to implement. (I just assumed was just a wee bug as I looked in help)
I don't mind the workaround.
I must sort the silent failure with an error message. :=)
Give me a few more mins.
Using the 0.098.07 (latest release!)
Take the files from https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/GCB%40Syn/GreatCowBASIC/ There are four files. Rename the exe to meet your needs.
This will resolve the issue with an error message.
I copied the 4 patch files to the GreatCowBasic folder.
Inspecting messages.dat the following change...
NotABitORAConst = "%value% is not a bit or valid constant. Constant values should be 0 or 1"
Result: compiles the same with no error/warning message.
Is this error message just until the issue is fixed or is the issue not fixable.
thanks
@ToniG
Download the msg file again. I failed to upload the correct file.
What is status of fix ? You will get an error message when you try the array(element).bit.
Is this fixable ? Yes. It would take time. Got time to resolve?
The fix is relatively simple but hard to implement. We never tested this use case. An oversight - yes.
The use case.
Needs to be evaluated as follows: This is NOT happening at the moment as the compiler does not handle array(element).bit correctly as the array pointer is being passed not the bit value, see later.
Currently, the compile is passing the array pointer ( INDF.index ). Where INDF is a pointer the array element. Both the source and destination are 'bits' but INDF.index is incorrect - hence the silent failure.
Code being processed by the compiler - the source bit is not valid.
Data1.Index = INDF.Index
This is my analysis of the root cause.
Evan
Last edit: Anobium 2021-07-06
@ToniG. I have uploaded a ZIP today. Please please on top of the released code. See https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/
I just checked the release log, This is the second change to bit setting code. 984, 985 and now 993. The bit setting code is new and clearly improvements are still required. :-)
@ToniG.
A thought... I am guessing that assigning an array(element).bit also fails, and, it fails silently.
I am out for a day or two - can you test the code shown above?
Thanks for the detail, it helps to understand.
The workaround is ok, but it could be documented somewhere for now.
My use is I have a For loop that sets each array element number & a nested loop that gets the bits of each element to place in D0 of a 32x4 RAM in a display controller. (1 bit set in 32 address)
Pretty sure it works the other way around (setting array bits using a variable to set element number), this is what I mentioned earlier.
But I will retest & confirm...
What I tested yesterday:
where index = 0 to 7
Considering the only difference being the element number source, (Constant or variable)
maybe as a interim fix can "trick" the compiler section to think it has a constant when the element number source is actually a variable .
(hypothetically speaking & not knowing the actual code yet...)
ToniG. Not sure what display this is.. but, this method is slow.
I am not saying we should not resolve this silent failure.
But, use rotate with a constant will be much, much faster.
Which/type of display is this? I can point you to some faster code.
Its a HT1621 driver chip. its a 128 element 4 COM LCD driver & for now I am just using 1 COM hence only D0 of each 4 bit RAM location. 1 bit per RAM address.
The array is the 7seg digit values, 4 array elements per COM.
Getting bits from the array to port pin (serial out) is fast enough for this app, the slow part is the BCD convert (MOD)
You were right Evan, It does fail both ways ( a false memory or confused when testing.)
I copied the latest patch files but still no error or warning message
Test code attached
I have resolved. The compiler will now expand the array(element).bit addressing to handle.
ToniG - I will post a new compiler later. 0.98.07 2021-07-07 (Windows 64 bit) : Build 995
If you do not get the build 995 then re-examine your installation method of the patches.
@ToniG
I have resolved but there are side effects and I want to discuss.
We have three cases to resolve.
1) datavar1.Index = Valu(A1).Index
This is where the source data (right hand side of the equals sign is of the format arrayname(element_number_variable).variable_as_bit_address.
This works ok but I have NO way of determining if .variable_as_bit_address is a constant. Processing for constants happens a lot later in the compilation process and this means that arrayname(element_number_variable).constant_as_bit_address is also expanded where this work without expansion in the past.
2) There a huge number of cases where datavar1.Index = Valu(A1).Index can have a prefix like IF, ELSEIF, WHILE etc. And, the expansion process would need address these issues.
3) There is a case of the setting the destination. Example follows:
This essentially will expand, but the same issues with IF.. WHILE will hamper this.
4) These is a fourth case of copying bits from one array to another.
The expansion approach fails on this case. There is not expansion logic I can think design that works.
So, I recommend NOT implementing the expansion but leave the resolution up to the user. The compiler will issue an error, and, we can document how to resolve. This will remove the risk of expansion messing something up and it is very simple for a user.
and
The expansion is way to complex, and, I do not like complex. I would recommend we leave it up to the user.
Your thoughts?
Last edit: Anobium 2021-07-07
For the patch updates I just renamed the original 4 files with *.bak & copied over the new files & run application as normal. I do have the minimal install (I don't use microchip's monster)
My dev pc(win7p_x64) is not networked, UAC disabled.
I did have some trouble with MSE quarantining gcbasic.exe but got around it.
Best to avoid complex, unless it can be isolated.
As can be seen in the gcb test it is just 1 extra statement to mitigate , Warning message & a mention in help will be useful.
My use is to set just 1 bit in a variable from array element bits .
OK. I will upload in my morning.London time.
Uploaded https://sourceforge.net/projects/gcbasic/files/Release%20Candidates/Patches/
Please use the ZIP. Then, check the version and build. You should see build 995
0.98.<<>> 2021-07-07 (Windows 64 bit) : Build 995
Two new traps to prevent the silent compilation that does not work.
ArrayBitIndex_1.gcb (23): Error: Array(element).bit as source - compiler needs help. Please simplify 'Array(element).bit' by using a temp_variable to store the source Array(element) then use temp_variable.bit as source, or use Constant array element address.
ArrayBitIndex_1.gcb (37): Error: Array(element).bit as destination - compiler needs help. Please simplify destinationn 'Array(element).bit' by using a temp_variable to store the destination Array(element) then use temp_variable.bit as destination, or use Constant array element address.
Last edit: Anobium 2021-07-08
Below is my use of the array bit indexing, the temp var sits quite well in the code.
The 16 array elements are a memory map of the HT1621 32x4 mem.
Very nice.
Can you try the updated compiler to ensure I have sorted the error messages ( not the expansion, I have coded but I have left the expansion code disabled ).
:-(
Last edit: Anobium 2021-07-08
sorry, I have to cleanup my GCB install.
With the latest release I installed to a different folder (Keeping the previous)
Looks like the old install compiler is being run?. (Compiler Version: 0.98.07 RC45 2021-03-31 (Windows 32 bit)
That's why I don't see the messages...
(After I installed latest build I no longer got a hex file output, I had to copy the old makehex.bat from the previous install.)
I would do a temp install and then dump the patches on top.
Thank you
ok, all sorted now.
With a fresh install of latest & a patch dump, hex button was still compiling with old compiler 2021-03-31 gcbasic.exe & no messages
Edit makehex.bat...
REM gcbasic.exe /NP /S:use.ini %1 /F:N /P:
gcbasic64.exe /NP /S:use.ini %1 /F:N /P:
That's better, now I get in errors .txt with