Is there an ANDN equivalent in Spin2?
Alexander (Sandy) Hapgood
Posts: 360
in Propeller 2
In PASM, the ANDN instruction is quite handy for clearing individual bit(s) in a register. I can't find a similar function in Spin2. I'm thinking about how you would change the output of an individual pin from 1 to 0.
Sandy
Sandy

Comments
But for individual pins there are much better instructions now:
OUTH, OUTL sets the output High or Low
DIRH, DIRL sets the direction of the pin
DRVL, DRVH sets the direction and output with one instruction.
The parameter is direct the pin number, this works for all 64 pins, not only for Port A or B.
Andy
BITL D,{#}S {WCZ} BITH D,{#}S {WCZ} BITC D,{#}S {WCZ} BITNC D,{#}S {WCZ} BITZ D,{#}S {WCZ} BITNZ D,{#}S {WCZ} BITRND D,{#}S {WCZ} BITNOT D,{#}S {WCZ}Here's a simple bit-bang RX UART that takes in the bits LSB first -- using bitc (C has the new bit) and putting it where it belongs means no mask is needed, and no byte clean-up is required after.
mov t1, bittix ' wait for middle of start bit shr t1, #1 addct1 bittimer, t1 waitct1 mov t3, #0 ' clear workspace rx_byte rep #5, #8 ' 5 (inst) x 8 bits addct1 bittimer, bittix ' update bit timer waitct1 ' let bit timer expire testp rxd wc ' sample rx shr t3, #1 ' prep for new bit bitc t3, #7 ' add to resultNote, too, that the RX pin is directly sampled into C using testp -- again, no mask required for IO access.Things like Pinhigh()
But maybe &NOT would work in Spin2?
As I become familiar with the P2 I'm learning that launching PASM code is not particularly hard so I can return to my usual methods.
Thanks for your input.
Sandy
With an org and end block.
Makes using assembly in Spin2 easy.
Inline PASM2 is my favorite thing about the P2. As Ray points out, it makes using small sections (that don't need to run in a cog) very easy. It also facilitates learning PASM2. I use this method for testing PASM2 instructions and code snippets:
pub test_pasm2(dvalue, svalue, flagsin) : result, flagsout org testb flagsin, #1 wc ' set flags testb flagsin, #0 wz rol dvalue, svalue wcz ' instruction to test mov result, dvalue ' return modified value bitc flagsout, #1 ' return modified flags bitz flagsout, #0 endSandy
Thing is, you will rarely if ever need more than 128 longs. Less than 64 for most things you're going to launch into another cog. Starting with that and adjusting up and down depending on need is barely an issue.