Hello everyone,
I have a program with the If syntax , and it' seem when setting for multiple conditions AND an OR it's
not working.
Does GCStudio will implement this in any future.
Tanks to all.
#option explicit
#chip tiny10, 8
dir portb.0 in
dir portb.1 out
dir portb.2 out
dir portb.3 in
dim Count as word
dim Latch as Bit
Latch = 0
do
if portb.0 = 0 then ;off
Latch = 0
portb.2 = 0
end if
;if portb.0 = 1 then ; **working**
if portb.0 = 1 and Latch = 0 then ; **not working**
portb.2 = 1
Latch = 1
end if
loop
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
These chips are very short on resources. So, consider using a used register.bit rather then use RAM. I use ADMUX.0 and ADMUX.1 as my bits, but, I am not using the ADC there maybe other registers that you are not using that your can use.
So, change to #DEFINE LATCH ADMUX.0. Saves RAM!
And, you really should install Atmel Toolchain. Using the Atmel Toolchain to verify the ASM generated is the best approach.
#option explicit
#chip tiny10, 8
dir portb.0 in
dir portb.1 out
dir portb.2 out
dir portb.3 in
dim Count as word
#DEFINE LATCH ADMUX.0
LATCH = 0
do
if portb.0 = 0 then ;off
LATCH = 0
portb.2 = 0
end if
;if portb.0 = 1 then ; **working**
if portb.0 = 1 then
If LATCH = 0 then
portb.2 = 1
LATCH = 1
end if
end if
loop
Gives the following using Atmel toolchain. No RAM used.
THIS IS AN EDITED POST. MY INITIAL POST WAS SO WRONG.
@AVR - very good. Good advice. Use the workaround.
We are looking at two issues here. Both, latent issues and not reported or noticed. You get the same error across all AVRs when you have a two BIT test statement.
The error in the ASM and therefore the fail in AVR2ASM. I have just looked at the Change log for the compiler. Hugh added the BIT test code un Oct 2018 change[805] and he made an error in the ASM. I have correct that error. And, now the AVR2ASM compiles correctly.
The error with the logic is more complex. The workaround resolves, but, it took me a while to figure out. The compiler is doing exactly as asked.
Last edit: Anobium 2024-03-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I have resolved to make in work with the Tiny10.
Ping me a Personal Message. I will let you have a new compiler. Build #1377
The root cause of the issue was incorrect generation of ASM and a typo deep inside the compiler.
The typo was relatively simple to fix. I found the type in a few minutes. The typo was introduced in Oct 2018 by Hugh. But, this was not picked up by GCASM. Using AVR2ASM did pick this up.
The generation of the correct ASM took all day. To resolve.
These comments are only for AVR/LGT ( not applicable to PIC).
A single BIT conditional test worked. The implementation of a single bit test is relatively simple, test the bit and jump.
Multiple BIT conditional tests is vey different and handled by a different part of the compiler. The compiler CLeaRed a register and then tested the first bit state, cached the bit, tested the second bit and then 'and' the two together for result testing. However, this was wrong ( this analysis took many hours as I totally trust Hugh's coding ). The compiled should SET the register when testing then when the 'and' for result testing.
This is fixed in build #1377.
Here is a video of the testing:
The attachment is the document I use to enable me to understand the issue.
Hello,
this is a very good news saw the OSHONSOFT IDE video very impressive demonstration.
I'm not at all on this level yet.
is this will work only for Bit or other like Byte, Word
let me know how to get #1377, I'll do some testing with tiny10 and let you know.
Thanks again for your great work.
Last edit: JB 2024-03-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I thought about leaving the ',' for a millisecond. But, it would only lead to confusion.
Many years ago when Hugh initially developed GCBASIC there was a UI that would control all aspects of the program. It also applied many rules. Those rules are what I constantly embed with Syntax and other Error handlers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
I have a program with the If syntax , and it' seem when setting for multiple conditions AND an OR it's
not working.
Does GCStudio will implement this in any future.
Tanks to all.
You have hit the constraints on these little chips.
Try this, does this work ? This code operates the same and is faster.
These chips are very short on resources. So, consider using a used register.bit rather then use RAM. I use ADMUX.0 and ADMUX.1 as my bits, but, I am not using the ADC there maybe other registers that you are not using that your can use.
So, change to #DEFINE LATCH ADMUX.0. Saves RAM!
And, you really should install Atmel Toolchain. Using the Atmel Toolchain to verify the ASM generated is the best approach.
Gives the following using Atmel toolchain. No RAM used.
Using GCASM. is 0.013 seconds faster but no validation of the ASM.
Your original program... gives these errors.
Nice little chip. A pain to use.
THIS IS AN EDITED POST. MY INITIAL POST WAS SO WRONG.
@AVR - very good. Good advice. Use the workaround.
We are looking at two issues here. Both, latent issues and not reported or noticed. You get the same error across all AVRs when you have a two BIT test statement.
The error in the ASM and therefore the fail in AVR2ASM. I have just looked at the Change log for the compiler. Hugh added the BIT test code un Oct 2018 change[805] and he made an error in the ASM. I have correct that error. And, now the AVR2ASM compiles correctly.
The error with the logic is more complex. The workaround resolves, but, it took me a while to figure out. The compiler is doing exactly as asked.
Last edit: Anobium 2024-03-24
THIS IS A NEW POST. MY INITIAL POST WAS SO WRONG. I have edited the previous post.
@AVR - very good. Good advice. Use the workaround.
Many thanks , AVR, Anobium
Last edit: JB 2024-03-24
I think I have resolved to make in work with the Tiny10.
Ping me a Personal Message. I will let you have a new compiler. Build #1377
The root cause of the issue was incorrect generation of ASM and a typo deep inside the compiler.
These comments are only for AVR/LGT ( not applicable to PIC).
A single BIT conditional test worked. The implementation of a single bit test is relatively simple, test the bit and jump.
Multiple BIT conditional tests is vey different and handled by a different part of the compiler. The compiler CLeaRed a register and then tested the first bit state, cached the bit, tested the second bit and then 'and' the two together for result testing. However, this was wrong ( this analysis took many hours as I totally trust Hugh's coding ). The compiled should SET the register when testing then when the 'and' for result testing.
This is fixed in build #1377.
Here is a video of the testing:
The attachment is the document I use to enable me to understand the issue.
Hopefully, resolved.
Enjoy
Hello,
this is a very good news saw the OSHONSOFT IDE video very impressive demonstration.
I'm not at all on this level yet.
is this will work only for Bit or other like Byte, Word
let me know how to get #1377, I'll do some testing with tiny10 and let you know.
Thanks again for your great work.
Last edit: JB 2024-03-25
The bit test is only for the BITS, or BITS of a BYTE or WORD ( like BYTE_VAR.0 ). So, this fix is specific to multiple BIT test conditions.
To get the release. GCBASIC.EXE and MESSAGE.DAT from here - replace your local one version. https://gcbasic.com/reps/goldbuild/masterbuild/GCB%40Syn/GreatCowBASIC/ We are mid the floats testing and download loading directly will work for you.
Many thanks,
Maybe I'm doing something wrong, when I click on the files I get error 404.
Right hand context menu, 'save link as ... " then save to local download.
I did right click on the file, when trying to save
I've got "File wasn't available on site"
Not sure of issue. It is not really meant to be downloaded from... it was a quick way for you.
Try this. You will have to accept all the warning etc. when you download
http://gcbasic.sourceforge.net/newfiles/1377.zip?latest=1
Work !
Compiler Version: 2024.3.24 (Windows 64 bit) : Build 1377) Program Memory: 126/1024 bytes (12.3%) RAM: 1/32 bytes (3.12%) OSC: 8Mhz Chip: TINY10
Work !
Compiler Version: 2024.3.24 (Windows 64 bit) : Build 1377) Program Memory: 126/1024 bytes (12.3%) RAM: 1/32 bytes (3.12%) OSC: 8Mhz Chip: TINY10
Does it work as a compiler? or, does the program logic work? or, both?
Both the compiler and the logic circuit.
Great news.
Also you fix my sloppy code for DIR ( dir portb.1,2,3 out)
Error: Invalid DIRection command. Command cannot contain ',' 1
Thanks again
I thought about leaving the ',' for a millisecond. But, it would only lead to confusion.
Many years ago when Hugh initially developed GCBASIC there was a UI that would control all aspects of the program. It also applied many rules. Those rules are what I constantly embed with Syntax and other Error handlers.
Good work, really appreciate