constant arithmetic (and, or) in inline assembler
pik33
Posts: 2,388
While in Spin I can do
wrpin ##(P_ASYNC_TX | P_OE), #pi_tx_2
This generates an error in FlexBasic. FlexBasic uses "or" instead of "|", so I tried this:
wrpin ##(P_ASYNC_TX or P_OE), #pi_tx_2
which also gives the compilation error:
error: syntax error, unexpected asm instruction, expecting ')'
The workaround was to define the global constant
const asm_tx=P_ASYNC_TX or P_OE
and use this in the asm.
Is there any better way do do constants arithmetic in FlexBasic's inline assembler?
Comments
I always use
+
instead of|
As long as there are no overlapping bits in the constants, this is the same.And FlexBasic is also happy with it.
Andy
Yeah, this one is an unfortunate case where Spin's syntax for inline assembly and BASIC's conflict. I'm unsure of the best solution. Probably adding | and & as operators to BASIC might make sense, although there would still be a problem with xor (^), which already has a meaning in BASIC as exponentiation.
Maybe the solution is to recognize |, & and ^ as or, and, xor only in asm blocks. Exponentiation is much less needed (did someone used it already?) in asm blocks than xor