Setting output bits in Pasm
AV_Tech
Posts: 24
in Propeller 1
Hello readers of the forum.
I have a question about setting output bits in Pasm. When i set or reset 1 bit I use the example in Part_1 of my code snippet below. But when I want to set more bit's, but stil not touch other bit's, I use the code snippet of Part_2. Are I am right, is this the right way or is there an other way to set/reset for example a nibble to the output pin's in Pasm.
Greeting Abraham
I have a question about setting output bits in Pasm. When i set or reset 1 bit I use the example in Part_1 of my code snippet below. But when I want to set more bit's, but stil not touch other bit's, I use the code snippet of Part_2. Are I am right, is this the right way or is there an other way to set/reset for example a nibble to the output pin's in Pasm.
Greeting Abraham
dat 'example data = %00000000_00000000_00001010_00000000 or %00000000_00000000_00001101_00000000 Start mov dira, Pin_out ' Set the output's Part_1 or outa, Clk_2 ' Set a bit andn outa, Clk_2 ' Reset a bit Part_2 andn outa, mask_nibb ' Clear a nibble or outa, data ' Set data nibble Pin_out long %00000000_00011111_11111111_00000000 Clk_2 long %00000000_00010000_00000000_00000000 mask_nibb long %00000000_00000000_00001111_00000000
Comments
You can also use "or" and "andn" to modify dira if you need to change pin directions at runtime, but a "mov dira, whatever" is fine for setup.
-Phil
Phil.
Thanks for this suggestion. I go use it.
Abraham.
Thanks for pointing out the glitching problem with the original Part_2 code. That pointed out a fastspin bug; the optimizer wasn't special casing OUTA or DIRA, and so the code generated did look like that original one. I've added a special case for OUTA[a..b] and DIRA[a..b] to use the second form, so it's fixed in fastspin 3.1.2.
Eric