Shop OBEX P1 Docs P2 Docs Learn Events
constant arithmetic (and, or) in inline assembler — Parallax Forums

constant arithmetic (and, or) in inline assembler

pik33pik33 Posts: 2,388
edited 2022-01-13 11:25 in BASIC (for Propeller)

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

  • AribaAriba Posts: 2,690

    I always use + instead of | As long as there are no overlapping bits in the constants, this is the same.

                wrpin     ##(P_ASYNC_TX + P_OE), #pi_tx_2
    

    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.

  • pik33pik33 Posts: 2,388

    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

Sign In or Register to comment.