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.
ANDN exists also in the P2 instructions. Why do you think it's not there?
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.
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 result
Note, too, that the RX pin is directly sampled into C using testp -- again, no mask required for IO access.
The little bit I know about programming the propellor has been learned using PASM. Basically I know just enough spin to launch PASM code in a cog on the P1. When I started to look at Spin2 I couldn't find an andn equivalent and wondered if I had missed it somehow.
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.
I'm prefer Spin but use a bit of PASM for speed when required. While the new PASM2 instruction set is much larger (by about 5x), much of it seems easier. As discussed earlier, bit manipulation is a lot easier in the P2 than in the P1.
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
end
The reason I started using PASM on the P1 was the requirement to calculate or, worse, estimate the amount of stack space required when launching spin code into a new cog. Calculating... isn't that what computers are good at?
The reason I started using PASM on the P1 was the requirement to calculate or, worse, estimate the amount of stack space required when launching spin code into a new cog. Calculating... isn't that what computers are good at?
Sandy
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.
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
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. Note, 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:
Sandy
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.