I am trying to convert some programs that I had written in MikroBasic to GCBasic to be able to use new processors not supported by the old MikroBasic.
Until some time ago it was not possible because of floating point calculations, now that the good Evan has greatly improved the compiler this problem no longer exists.
So I have some questions:
I have to dimension an array of singles and I have to store three values in it.
I did this:
Dim EXTRA_BASS_COEFF_A (2) As Single
EXTRA_BASS_COEFF_A (0) = 1.0
EXTRA_BASS_COEFF_A (1) = -1.561
EXTRA_BASS_COEFF_A (2) = 0.6414
I know that the compiler uses the index 0 to store the size of the array, so is it feasible?
Then, This instruction gives me an error, it says it can't store the negative value:
EXTRA_BASS_COEFF_A = 1.0, -1.561, 0.6414
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looks to me like the array load function does not work. Well.. I never test because I never implemented that load function and I did not write a function to prevent use. Actually, I never even thought about this load function.
EXTRA_BASS_COEFF_A = 1.0, -1.561, 0.6414 will not work.
The use of array element zero. I can only use empirical testing to assess this element.
The following program shows that element 0 is not maintained therefore single array permit usage of element 0. However, therefore element 0 does not return the number array element.
I have run some tests with your program with some modifications and picsimlab.
The value of the array at address 0 can be used to read and write data.
The values are displayed correctly albeit with some rounding.
However, I noticed a problem, I do not know if it is due to the compiler or the simulator.
On the first line of printing on the serial (HSerPrint "0:") on the terminal a dot "." is displayed before the data to be printed.
I attach an image with the result.
List:
#Chip 16f886
#Option Explicit
Dim ArrayAddress As Byte
Dim EXTRA_BASS_COEFF_A (3) As Single
EXTRA_BASS_COEFF_A (0) = 201.034
EXTRA_BASS_COEFF_A (1) = 1.01234
EXTRA_BASS_COEFF_A (2) = -1.561
EXTRA_BASS_COEFF_A (3) = 0.6414
The rounding is the outcome of conversation to string. Check the hex values, by using StringToHex() and then use an online IEEE converter. All should look OK.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to convert some programs that I had written in MikroBasic to GCBasic to be able to use new processors not supported by the old MikroBasic.
Until some time ago it was not possible because of floating point calculations, now that the good Evan has greatly improved the compiler this problem no longer exists.
So I have some questions:
I have to dimension an array of singles and I have to store three values in it.
I did this:
Dim EXTRA_BASS_COEFF_A (2) As Single
EXTRA_BASS_COEFF_A (0) = 1.0
EXTRA_BASS_COEFF_A (1) = -1.561
EXTRA_BASS_COEFF_A (2) = 0.6414
I know that the compiler uses the index 0 to store the size of the array, so is it feasible?
Then, This instruction gives me an error, it says it can't store the negative value:
EXTRA_BASS_COEFF_A = 1.0, -1.561, 0.6414
Looks to me like the array load function does not work. Well.. I never test because I never implemented that load function and I did not write a function to prevent use. Actually, I never even thought about this load function.
EXTRA_BASS_COEFF_A = 1.0, -1.561, 0.6414
will not work.The use of array element zero. I can only use empirical testing to assess this element.
The following program shows that element 0 is not maintained therefore single array permit usage of element 0. However, therefore element 0 does not return the number array element.
Please do test and evaluate. Share your insights.
Evan
I have run some tests with your program with some modifications and picsimlab.
The value of the array at address 0 can be used to read and write data.
The values are displayed correctly albeit with some rounding.
However, I noticed a problem, I do not know if it is due to the compiler or the simulator.
On the first line of printing on the serial (HSerPrint "0:") on the terminal a dot "." is displayed before the data to be printed.
I attach an image with the result.
List:
// EXTRA_BASS_COEFF_A = 1.0, -1.561, 0.6414
Last edit: jackjames 2025-05-06
Great.
The '.' I will ignore.
The rounding is the outcome of conversation to string. Check the hex values, by using StringToHex() and then use an online IEEE converter. All should look OK.
🚀 GCBASIC Compiler Update: Fixing Array Assignment Issue
Non-BYTE arrays were failing on shorthand assignments—@Jackjames spotted it, and I fixed it!
🛠️ A quick check now ensures proper error handling, making GCBASIC more stable and reliable. ✅
Curious how I found the issue? Read the full post—it took 2.5 hours to track down, 5 seconds to fix! ⏳😅
Read the full KO-FI post here