Edit (2018-11-13) Solved in a new release v.0.98.03 (added #asmraw directive)
Hi, I am trying to include ASM code online in programs written for AVR microcontrollers, and I found problems in instructions (mnemonics) that have the same name as BASIC instructions. For example:
'Set chip model
#chip tiny13,4.8
mymainloop:
and r16,r17
andi r16,10
com r16
rjmp mymainloop
Compile... "and r16,r17": Error: Syntax Error
The same happens when using the assemble OR mnemonic. ¿?
I tried to use the old ASM compiler directive:
asm and r16,r17
Compile without errors, but generate the code:
;asm and r16,r17
& R16,R17
and results Error: & R16,R17 is not a valid symbol in Assemble time.
Thank you for your help and congratulations for your work with this great compiler.
Last edit: Agustin Hernandez 2018-11-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'''A demonstration program for GCGB and GCB.
'''--------------------------------------------------------------------------------------------------------------------------------
'''This program
'''
'''
'''@author
'''@licence GPL
'''@version
'''@date
'''********************************************************************************
; ----- Configuration
'Set chip model
#chip tiny13,4.8
#option Explicit
dim variable1 as Byte
dim variable2 as Byte
DO forever
variable1 = variable1 AND variable2
variable1 = variable1 AND 0x10
variable1 = NOT variable1
loop
There are other, far more skilled than I, who can really help if you want to use ASM. I would not - I would use the power of the compiler.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your answer Anobium.
For ordinary processes I use the compiler, but I was testing the possibility of inserting ASM code in critical processes or when small microcontrollers do not have program space.
Would there be possible to create a directive in the compiler to indicate blocks of programming in ASM to avoid these conflicts with the BASIC compiler? I think it would be very important to optimize critical processes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't use ASM much, but it can be useful. I think the answer might be somewhere inbetween. Using variables like Anobium suggests or strict register calls like Agustin can be worked around with minimal? overhead. Here is one way from the pwh.h include for AVR:
'AVR prescale applied to timers
If PWMPrescale = 1 Then
#IFDEF AVRTC0
If AVRTimer = 0 Then
lds SysValueCopy,TCCR0B
andi SysValueCopy, 0xf8
inc SysValueCopy
sts TCCR0B, SysValueCopy
End If
#ENDIF
...
...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi kent_twt4, I think it's a very good idea to propose using the variable SysValueCopy instead of using the microcontroller register that can cause runtime error because the compiler does not know the registers used in the inserted ASM blocks.
I believe that not to be able to use AND and OR instructions in the AVR assembler blocks is a mistake. I think a very simple solution would be to tell the compiler by means of some directive that a line of code or a block is written in assembler. It would be interesting that it was thought about this proposal that would facilitate the insertion of code ASM.
Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see now, "andi", "com", and "ori" AVR asm instructions are correctly handled; and that, "and" and "or" are not, so I agree this should be fixed. I would raise a ticket.
That code works perfectly well with or without the ASM prefix.
Augustin has pointed out that using AVR ASM instructions "and Rd,Rr" or "or Rd,Rf" do not compile correctly. See errors by trying to compile previous code of :
and SysValCopy,var1
or SysValCopy,var2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium, ASM for a line seems to be already implemented, although I do not know if it works correctly (with the instructions AND and OR it does not work), but to help the compiler recognize blocks of ASM code, which seems to use compilation directives:
Shown below is the reference code. We have the prefix ASM for asm blocks. We have to resolve the treatment in the compiler with respect to AND and OR.
#chip tiny13,4.8
#option Explicit
dim variable1 as Byte
dim variable2 as Byte
ASM lds SysValueCopy,TCCR0B
ASM andi SysValueCopy, 0xf8
ASM inc SysValueCopy
ASM sts TCCR0B, SysValueCopy
;error with AND and OR
;ASM and SysValCopy,var1
& SYSVALCOPY,VAR1
;ASM or SysValCopy,var2
| SYSVALCOPY,VAR2
ASM and SysValCopy,var1
ASM or SysValCopy,var2
Anobium
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
541 Fix Compiler Improvement: added #asmraw directive. Anything following this will be inserted into assembly with no changes other than trimming spaces - no replacement of constants.[769]
Thanks!
... but it is not mentioned in the compiler's help. Is it a "secret directive"?
😄
1
Last edit: Agustin Hernandez 2018-11-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For those that track these things... the number as the start of the line is the change log reference and the number between the [] is the SVN commit number.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edit (2018-11-13) Solved in a new release v.0.98.03 (added #asmraw directive)
Hi, I am trying to include ASM code online in programs written for AVR microcontrollers, and I found problems in instructions (mnemonics) that have the same name as BASIC instructions. For example:
Compile... "and r16,r17": Error: Syntax Error
The same happens when using the assemble OR mnemonic. ¿?
I tried to use the old ASM compiler directive:
Compile without errors, but generate the code:
and results Error: & R16,R17 is not a valid symbol in Assemble time.
Thank you for your help and congratulations for your work with this great compiler.
Last edit: Agustin Hernandez 2018-11-13
You do not really need to struggle with ASM.
There are other, far more skilled than I, who can really help if you want to use ASM. I would not - I would use the power of the compiler.
Thanks for your answer Anobium.
For ordinary processes I use the compiler, but I was testing the possibility of inserting ASM code in critical processes or when small microcontrollers do not have program space.
Would there be possible to create a directive in the compiler to indicate blocks of programming in ASM to avoid these conflicts with the BASIC compiler? I think it would be very important to optimize critical processes.
Don't use ASM much, but it can be useful. I think the answer might be somewhere inbetween. Using variables like Anobium suggests or strict register calls like Agustin can be worked around with minimal? overhead. Here is one way from the pwh.h include for AVR:
Hi kent_twt4, I think it's a very good idea to propose using the variable SysValueCopy instead of using the microcontroller register that can cause runtime error because the compiler does not know the registers used in the inserted ASM blocks.
I believe that not to be able to use AND and OR instructions in the AVR assembler blocks is a mistake. I think a very simple solution would be to tell the compiler by means of some directive that a line of code or a block is written in assembler. It would be interesting that it was thought about this proposal that would facilitate the insertion of code ASM.
Thank you.
I see now, "andi", "com", and "ori" AVR asm instructions are correctly handled; and that, "and" and "or" are not, so I agree this should be fixed. I would raise a ticket.
That does not look quite right... but, does this. :-)
~~~
ASM lds SysValueCopy,TCCR0B
ASM andi SysValueCopy, 0xf8
ASM inc SysValueCopy
ASM sts TCCR0B, SysValueCopy
~~~
Use ASM as the prefix.
That code works perfectly well with or without the ASM prefix.
Augustin has pointed out that using AVR ASM instructions "and Rd,Rr" or "or Rd,Rf" do not compile correctly. See errors by trying to compile previous code of :
OK. On the list of issues now. :=)
kent_twt4, I use 0.98.02 2018-05-10 compiler.
The code:
ERROR time compiler:
Code:
No error Time Compiler but the ASM isn't correct:
And, of course, it causes assembly error to generate the HEX file:
The problem is that the compiler does not recognize the instructions OR and AND with assembler mnemonics, but rather as BASIC instructions.
Last edit: Agustin Hernandez 2018-07-09
OK. On the list of issues now. :=)
Anobium, ASM for a line seems to be already implemented, although I do not know if it works correctly (with the instructions AND and OR it does not work), but to help the compiler recognize blocks of ASM code, which seems to use compilation directives:
@Agustin.
Thank you.
Shown below is the reference code. We have the prefix ASM for asm blocks. We have to resolve the treatment in the compiler with respect to AND and OR.
Anobium
@Agustin.
Please send me a personal message. We have a fix for you regarding this issue. I would like you to test.
Thank you. Personal message sent.
:) #ASMRaw implemented in a new release v.0.98.03
541 Fix Compiler Improvement: added #asmraw directive. Anything following this will be inserted into assembly with no changes other than trimming spaces - no replacement of constants.[769]
Thanks!
... but it is not mentioned in the compiler's help. Is it a "secret directive"?
Last edit: Agustin Hernandez 2018-11-13
Seriously pleased that you read the release note!
Pleasure.
For those that track these things... the number as the start of the line is the change log reference and the number between the [] is the SVN commit number.
Secret directive.. no. I forgot.
Documented now.
See https://github.com/Anobium/Great-Cow-BASIC-Help/blob/master/source/asmraw.adoc for help.
There is a set of LXL files, CHM and helper files for those that really need. I will include in the next release.